@secondlayer/cli 1.5.1 → 1.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/dist/cli.js CHANGED
@@ -5,25 +5,43 @@ var __getProtoOf = Object.getPrototypeOf;
5
5
  var __defProp = Object.defineProperty;
6
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ function __accessProp(key) {
9
+ return this[key];
10
+ }
11
+ var __toESMCache_node;
12
+ var __toESMCache_esm;
8
13
  var __toESM = (mod, isNodeMode, target) => {
14
+ var canCache = mod != null && typeof mod === "object";
15
+ if (canCache) {
16
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
17
+ var cached = cache.get(mod);
18
+ if (cached)
19
+ return cached;
20
+ }
9
21
  target = mod != null ? __create(__getProtoOf(mod)) : {};
10
22
  const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
11
23
  for (let key of __getOwnPropNames(mod))
12
24
  if (!__hasOwnProp.call(to, key))
13
25
  __defProp(to, key, {
14
- get: () => mod[key],
26
+ get: __accessProp.bind(mod, key),
15
27
  enumerable: true
16
28
  });
29
+ if (canCache)
30
+ cache.set(mod, to);
17
31
  return to;
18
32
  };
19
33
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
34
+ var __returnValue = (v) => v;
35
+ function __exportSetter(name, newValue) {
36
+ this[name] = __returnValue.bind(null, newValue);
37
+ }
20
38
  var __export = (target, all) => {
21
39
  for (var name in all)
22
40
  __defProp(target, name, {
23
41
  get: all[name],
24
42
  enumerable: true,
25
43
  configurable: true,
26
- set: (newValue) => all[name] = () => newValue
44
+ set: __exportSetter.bind(all, name)
27
45
  });
28
46
  };
29
47
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
@@ -2211,8 +2229,8 @@ function migrateConfig(raw) {
2211
2229
  if (typeof old.dataDir === "string") {
2212
2230
  migrated.dataDir = old.dataDir;
2213
2231
  }
2214
- if (typeof old.defaultWebhookUrl === "string") {
2215
- migrated.defaultWebhookUrl = old.defaultWebhookUrl;
2232
+ if (typeof old.defaultEndpointUrl === "string") {
2233
+ migrated.defaultEndpointUrl = old.defaultEndpointUrl;
2216
2234
  }
2217
2235
  if (typeof old.nodeInstallPath === "string" || typeof old.nodeNetwork === "string") {
2218
2236
  migrated.node = {
@@ -2252,8 +2270,8 @@ async function loadConfig() {
2252
2270
  }
2253
2271
  }
2254
2272
  config = applyEnvOverrides(config);
2255
- if (!config.defaultWebhookUrl && config.network === "local") {
2256
- config.defaultWebhookUrl = LOCAL_WEBHOOK_URL;
2273
+ if (!config.defaultEndpointUrl && config.network === "local") {
2274
+ config.defaultEndpointUrl = LOCAL_ENDPOINT_URL;
2257
2275
  }
2258
2276
  return config;
2259
2277
  }
@@ -2283,12 +2301,15 @@ function applyEnvOverrides(config) {
2283
2301
  result.ports = { ...result.ports, indexer: port };
2284
2302
  }
2285
2303
  }
2286
- if (process.env.SL_WEBHOOK_PORT) {
2287
- const port = parseInt(process.env.SL_WEBHOOK_PORT, 10);
2304
+ if (process.env.SL_RECEIVER_PORT) {
2305
+ const port = parseInt(process.env.SL_RECEIVER_PORT, 10);
2288
2306
  if (!isNaN(port) && port > 0 && port <= 65535) {
2289
- result.ports = { ...result.ports, webhook: port };
2307
+ result.ports = { ...result.ports, receiver: port };
2290
2308
  }
2291
2309
  }
2310
+ if (process.env.STACKS_NODE_RPC_URL) {
2311
+ result.nodeRpcUrl = process.env.STACKS_NODE_RPC_URL;
2312
+ }
2292
2313
  if (process.env.DATABASE_URL) {
2293
2314
  result.database = { type: "external", url: process.env.DATABASE_URL };
2294
2315
  }
@@ -2377,13 +2398,13 @@ function isDefaultValue(config, key) {
2377
2398
  const defaultValue = getConfigValue(DEFAULT_CONFIG, key);
2378
2399
  return JSON.stringify(currentValue) === JSON.stringify(defaultValue);
2379
2400
  }
2380
- var PortsSchema, NodeSchema, DatabaseSchema, NetworkSchema, API_URLS, ConfigSchema, CONFIG_DIR, CONFIG_PATH, LOCAL_WEBHOOK_URL = "http://localhost:3900/webhook", DEFAULT_CONFIG;
2401
+ var PortsSchema, NodeSchema, DatabaseSchema, NetworkSchema, API_URLS, ConfigSchema, CONFIG_DIR, CONFIG_PATH, LOCAL_ENDPOINT_URL = "http://localhost:3900/receiver", DEFAULT_CONFIG;
2381
2402
  var init_config = __esm(() => {
2382
2403
  init_fs();
2383
2404
  PortsSchema = z.object({
2384
2405
  api: z.number().int().min(1).max(65535).default(3800),
2385
2406
  indexer: z.number().int().min(1).max(65535).default(3700),
2386
- webhook: z.number().int().min(1).max(65535).default(3900)
2407
+ receiver: z.number().int().min(1).max(65535).default(3900)
2387
2408
  });
2388
2409
  NodeSchema = z.object({
2389
2410
  installPath: z.string().min(1),
@@ -2403,8 +2424,9 @@ var init_config = __esm(() => {
2403
2424
  network: NetworkSchema.default("mainnet"),
2404
2425
  apiUrl: z.string().url().optional(),
2405
2426
  apiKey: z.string().optional(),
2427
+ nodeRpcUrl: z.string().url().optional(),
2406
2428
  dataDir: z.string().default("~/.secondlayer/data"),
2407
- defaultWebhookUrl: z.string().url().optional(),
2429
+ defaultEndpointUrl: z.string().url().optional(),
2408
2430
  node: NodeSchema.optional(),
2409
2431
  ports: PortsSchema.default({}),
2410
2432
  database: DatabaseSchema.default({})
@@ -2414,7 +2436,7 @@ var init_config = __esm(() => {
2414
2436
  DEFAULT_CONFIG = {
2415
2437
  network: "mainnet",
2416
2438
  dataDir: "~/.secondlayer/data",
2417
- ports: { api: 3800, indexer: 3700, webhook: 3900 },
2439
+ ports: { api: 3800, indexer: 3700, receiver: 3900 },
2418
2440
  database: { type: "docker" }
2419
2441
  };
2420
2442
  });
@@ -4529,20 +4551,20 @@ __export(exports_api_client, {
4529
4551
  rotateSecret: () => rotateSecret,
4530
4552
  resumeAllStreams: () => resumeAllStreams,
4531
4553
  resolveStreamId: () => resolveStreamId,
4532
- reindexViewApi: () => reindexViewApi,
4533
- queryViewTableCount: () => queryViewTableCount,
4534
- queryViewTable: () => queryViewTable,
4554
+ reindexSubgraphApi: () => reindexSubgraphApi,
4555
+ querySubgraphTableCount: () => querySubgraphTableCount,
4556
+ querySubgraphTable: () => querySubgraphTable,
4535
4557
  pauseAllStreams: () => pauseAllStreams,
4536
- listViewsApi: () => listViewsApi,
4558
+ listSubgraphsApi: () => listSubgraphsApi,
4537
4559
  listStreams: () => listStreams,
4538
4560
  handleApiError: () => handleApiError,
4539
- getViewApi: () => getViewApi,
4561
+ getSubgraphApi: () => getSubgraphApi,
4540
4562
  getStream: () => getStream,
4541
4563
  getQueueStats: () => getQueueStats,
4542
4564
  enableStream: () => enableStream,
4543
4565
  disableStream: () => disableStream,
4544
- deployViewApi: () => deployViewApi,
4545
- deleteViewApi: () => deleteViewApi,
4566
+ deploySubgraphApi: () => deploySubgraphApi,
4567
+ deleteSubgraphApi: () => deleteSubgraphApi,
4546
4568
  deleteStream: () => deleteStream,
4547
4569
  createStream: () => createStream,
4548
4570
  authHeaders: () => authHeaders,
@@ -4620,26 +4642,26 @@ async function resumeAllStreams() {
4620
4642
  async function getQueueStats() {
4621
4643
  return (await getClient()).getQueueStats();
4622
4644
  }
4623
- async function listViewsApi() {
4624
- return (await getClient()).views.list();
4645
+ async function listSubgraphsApi() {
4646
+ return (await getClient()).subgraphs.list();
4625
4647
  }
4626
- async function getViewApi(name) {
4627
- return (await getClient()).views.get(name);
4648
+ async function getSubgraphApi(name) {
4649
+ return (await getClient()).subgraphs.get(name);
4628
4650
  }
4629
- async function reindexViewApi(name, options) {
4630
- return (await getClient()).views.reindex(name, options);
4651
+ async function reindexSubgraphApi(name, options) {
4652
+ return (await getClient()).subgraphs.reindex(name, options);
4631
4653
  }
4632
- async function deleteViewApi(name) {
4633
- return (await getClient()).views.delete(name);
4654
+ async function deleteSubgraphApi(name) {
4655
+ return (await getClient()).subgraphs.delete(name);
4634
4656
  }
4635
- async function deployViewApi(data) {
4636
- return (await getClient()).views.deploy(data);
4657
+ async function deploySubgraphApi(data) {
4658
+ return (await getClient()).subgraphs.deploy(data);
4637
4659
  }
4638
- async function queryViewTable(name, table, params = {}) {
4639
- return (await getClient()).views.queryTable(name, table, params);
4660
+ async function querySubgraphTable(name, table, params = {}) {
4661
+ return (await getClient()).subgraphs.queryTable(name, table, params);
4640
4662
  }
4641
- async function queryViewTableCount(name, table, params = {}) {
4642
- return (await getClient()).views.queryTableCount(name, table, params);
4663
+ async function querySubgraphTableCount(name, table, params = {}) {
4664
+ return (await getClient()).subgraphs.queryTableCount(name, table, params);
4643
4665
  }
4644
4666
  var init_api_client = __esm(() => {
4645
4667
  init_config();
@@ -6374,7 +6396,7 @@ var init_responselike = __esm(() => {
6374
6396
 
6375
6397
  // ../../node_modules/json-buffer/index.js
6376
6398
  var require_json_buffer = __commonJS((exports) => {
6377
- exports.stringify = function stringify(o) {
6399
+ exports.stringify = function stringify2(o) {
6378
6400
  if (typeof o == "undefined")
6379
6401
  return o;
6380
6402
  if (o && Buffer.isBuffer(o))
@@ -6396,9 +6418,9 @@ var require_json_buffer = __commonJS((exports) => {
6396
6418
  if (o[k] == undefined)
6397
6419
  s += "null";
6398
6420
  else
6399
- s += stringify(o[k]);
6421
+ s += stringify2(o[k]);
6400
6422
  } else if (o[k] !== undefined) {
6401
- s += stringify(k) + ":" + stringify(o[k]);
6423
+ s += stringify2(k) + ":" + stringify2(o[k]);
6402
6424
  }
6403
6425
  }
6404
6426
  }
@@ -7342,7 +7364,7 @@ var init_FormDataEncoder = __esm(() => {
7342
7364
  }
7343
7365
  }
7344
7366
  }
7345
- [(_FormDataEncoder_CRLF = new WeakMap, _FormDataEncoder_CRLF_BYTES = new WeakMap, _FormDataEncoder_CRLF_BYTES_LENGTH = new WeakMap, _FormDataEncoder_DASHES = new WeakMap, _FormDataEncoder_encoder = new WeakMap, _FormDataEncoder_footer = new WeakMap, _FormDataEncoder_form = new WeakMap, _FormDataEncoder_options = new WeakMap, _FormDataEncoder_instances = new WeakSet, _FormDataEncoder_getFieldHeader = function _FormDataEncoder_getFieldHeader(name, value) {
7367
+ [(_FormDataEncoder_CRLF = new WeakMap, _FormDataEncoder_CRLF_BYTES = new WeakMap, _FormDataEncoder_CRLF_BYTES_LENGTH = new WeakMap, _FormDataEncoder_DASHES = new WeakMap, _FormDataEncoder_encoder = new WeakMap, _FormDataEncoder_footer = new WeakMap, _FormDataEncoder_form = new WeakMap, _FormDataEncoder_options = new WeakMap, _FormDataEncoder_instances = new WeakSet, _FormDataEncoder_getFieldHeader = function _FormDataEncoder_getFieldHeader2(name, value) {
7346
7368
  let header = "";
7347
7369
  header += `${__classPrivateFieldGet(this, _FormDataEncoder_DASHES, "f")}${this.boundary}${__classPrivateFieldGet(this, _FormDataEncoder_CRLF, "f")}`;
7348
7370
  header += `Content-Disposition: form-data; name="${escapeName(name)}"`;
@@ -7355,7 +7377,7 @@ var init_FormDataEncoder = __esm(() => {
7355
7377
  header += `${__classPrivateFieldGet(this, _FormDataEncoder_CRLF, "f")}Content-Length: ${isFile(value) ? value.size : value.byteLength}`;
7356
7378
  }
7357
7379
  return __classPrivateFieldGet(this, _FormDataEncoder_encoder, "f").encode(`${header}${__classPrivateFieldGet(this, _FormDataEncoder_CRLF, "f").repeat(2)}`);
7358
- }, _FormDataEncoder_getContentLength = function _FormDataEncoder_getContentLength() {
7380
+ }, _FormDataEncoder_getContentLength = function _FormDataEncoder_getContentLength2() {
7359
7381
  let length = 0;
7360
7382
  for (const [name, raw] of __classPrivateFieldGet(this, _FormDataEncoder_form, "f")) {
7361
7383
  const value = isFile(raw) ? raw : __classPrivateFieldGet(this, _FormDataEncoder_encoder, "f").encode(normalizeValue(raw));
@@ -12414,13 +12436,16 @@ class StacksApiClient {
12414
12436
  static hasWarnedAboutApiKey = false;
12415
12437
  baseUrl;
12416
12438
  headers;
12439
+ usingHiro;
12417
12440
  constructor(network = "mainnet", apiKey, apiUrl) {
12418
- this.baseUrl = apiUrl || API_URLS2[network];
12441
+ const nodeRpcUrl = process.env.STACKS_NODE_RPC_URL;
12442
+ this.baseUrl = apiUrl || nodeRpcUrl || HIRO_URLS[network];
12443
+ this.usingHiro = !apiUrl && !nodeRpcUrl;
12419
12444
  this.headers = apiKey ? { "x-api-key": apiKey } : {};
12420
- if (!apiKey && !StacksApiClient.hasWarnedAboutApiKey) {
12421
- console.warn(`⚠️ No API key provided. You may be rate-limited.
12422
- ` + ` Set HIRO_API_KEY env var or use --api-key flag.
12423
- ` + " Get a free key at: https://platform.hiro.so/");
12445
+ if (this.usingHiro && !apiKey && !StacksApiClient.hasWarnedAboutApiKey) {
12446
+ console.warn(`⚠️ Using Hiro public API (no STACKS_NODE_RPC_URL set). You may be rate-limited.
12447
+ ` + ` Set STACKS_NODE_RPC_URL to use your own node, or set HIRO_API_KEY for Hiro.
12448
+ ` + " Get a free Hiro key at: https://platform.hiro.so/");
12424
12449
  StacksApiClient.hasWarnedAboutApiKey = true;
12425
12450
  }
12426
12451
  }
@@ -12453,7 +12478,7 @@ class StacksApiClient {
12453
12478
  return data.source;
12454
12479
  }
12455
12480
  }
12456
- var gotWithRetry, API_URLS2;
12481
+ var gotWithRetry, HIRO_URLS;
12457
12482
  var init_api = __esm(() => {
12458
12483
  init_source3();
12459
12484
  gotWithRetry = source_default2.extend({
@@ -12465,7 +12490,7 @@ var init_api = __esm(() => {
12465
12490
  calculateDelay: ({ attemptCount }) => attemptCount * 1000
12466
12491
  }
12467
12492
  });
12468
- API_URLS2 = {
12493
+ HIRO_URLS = {
12469
12494
  mainnet: "https://api.hiro.so",
12470
12495
  testnet: "https://api.testnet.hiro.so",
12471
12496
  devnet: "http://localhost:3999"
@@ -13171,9 +13196,9 @@ var init_api2 = __esm(() => {
13171
13196
  init_manager();
13172
13197
  });
13173
13198
 
13174
- // src/services/webhook-server.ts
13199
+ // src/services/receiver-server.ts
13175
13200
  import { verifySignatureHeader } from "@secondlayer/shared/crypto";
13176
- function startWebhookServer(options2 = {}) {
13201
+ function startReceiverServer(options2 = {}) {
13177
13202
  const port = options2.port ?? 3900;
13178
13203
  const responseCode = options2.responseCode ?? 200;
13179
13204
  server = Bun.serve({
@@ -13212,27 +13237,27 @@ function startWebhookServer(options2 = {}) {
13212
13237
  body,
13213
13238
  signatureValid
13214
13239
  };
13215
- if (options2.onWebhook) {
13216
- options2.onWebhook(event);
13240
+ if (options2.onDelivery) {
13241
+ options2.onDelivery(event);
13217
13242
  } else {
13218
- logWebhook(event);
13243
+ logDelivery(event);
13219
13244
  }
13220
13245
  return new Response("OK", { status: responseCode });
13221
13246
  }
13222
13247
  });
13223
13248
  return port;
13224
13249
  }
13225
- function stopWebhookServer() {
13250
+ function stopReceiverServer() {
13226
13251
  if (server) {
13227
13252
  server.stop();
13228
13253
  server = null;
13229
13254
  }
13230
13255
  }
13231
- function logWebhook(event) {
13256
+ function logDelivery(event) {
13232
13257
  const time = event.timestamp.toISOString();
13233
13258
  console.log("");
13234
13259
  console.log(blue("━".repeat(60)));
13235
- console.log(green("⚡ Webhook received"));
13260
+ console.log(green("⚡ Delivery received"));
13236
13261
  console.log(dim(` ${time}`));
13237
13262
  console.log(dim(` ${event.method} ${event.path}`));
13238
13263
  if (event.signatureValid === true) {
@@ -13254,25 +13279,25 @@ function logWebhook(event) {
13254
13279
  console.log(blue("━".repeat(60)));
13255
13280
  }
13256
13281
  var server = null;
13257
- var init_webhook_server = __esm(() => {
13282
+ var init_receiver_server = __esm(() => {
13258
13283
  init_output();
13259
13284
  });
13260
13285
 
13261
- // src/services/view-processor.ts
13286
+ // src/services/subgraph-processor.ts
13262
13287
  import { resolve as resolve5, dirname as dirname4 } from "node:path";
13263
- async function startViewProcessor(options2) {
13288
+ async function startSubgraphProcessor(options2) {
13264
13289
  const rootDir = dirname4(dirname4(dirname4(dirname4(import.meta.dir))));
13265
- const servicePath = resolve5(rootDir, "packages/views/src/service.ts");
13290
+ const servicePath = resolve5(rootDir, "packages/subgraphs/src/service.ts");
13266
13291
  await serviceManager.start(SERVICE_NAME4, ["bun", "run", "--watch", servicePath], {
13267
13292
  env: {
13268
- VIEW_CONCURRENCY: String(options2.concurrency ?? 5)
13293
+ SUBGRAPH_CONCURRENCY: String(options2.concurrency ?? 5)
13269
13294
  },
13270
13295
  onStdout: options2.onLog,
13271
13296
  onStderr: options2.onLog
13272
13297
  });
13273
13298
  }
13274
- var SERVICE_NAME4 = "view-processor";
13275
- var init_view_processor = __esm(() => {
13299
+ var SERVICE_NAME4 = "subgraph-processor";
13300
+ var init_subgraph_processor = __esm(() => {
13276
13301
  init_manager();
13277
13302
  });
13278
13303
 
@@ -13282,8 +13307,8 @@ var init_services = __esm(() => {
13282
13307
  init_indexer();
13283
13308
  init_worker();
13284
13309
  init_api2();
13285
- init_webhook_server();
13286
- init_view_processor();
13310
+ init_receiver_server();
13311
+ init_subgraph_processor();
13287
13312
  });
13288
13313
 
13289
13314
  // src/commands/dev-impl.ts
@@ -13326,7 +13351,7 @@ async function runBackground(options2) {
13326
13351
  const dataDir = getDataDir(config);
13327
13352
  const indexerPort = options2.stacksNode ? 3701 : parseInt(options2.indexerPort) || config.ports.indexer;
13328
13353
  const apiPort = parseInt(options2.apiPort) || config.ports.api;
13329
- const webhookPort = parseInt(options2.webhookPort) || config.ports.webhook;
13354
+ const receiverPort = parseInt(options2.receiverPort) || config.ports.receiver;
13330
13355
  if (options2.stacksNode && config.node) {
13331
13356
  const validation = await validateNetworkConsistency(config);
13332
13357
  if (!validation.valid) {
@@ -13422,38 +13447,38 @@ async function runBackground(options2) {
13422
13447
  console.log(green(" ✓ Worker"), dim("processing jobs"));
13423
13448
  }
13424
13449
  {
13425
- const viewsLogFile = getLogFile("views");
13426
- const viewsProc = Bun.spawn(["bun", "run", resolve6(packagesDir, "packages/views/src/service.ts")], {
13450
+ const subgraphsLogFile = getLogFile("subgraphs");
13451
+ const subgraphsProc = Bun.spawn(["bun", "run", resolve6(packagesDir, "packages/subgraphs/src/service.ts")], {
13427
13452
  env: { ...process.env, ...env },
13428
- stdout: Bun.file(viewsLogFile),
13429
- stderr: Bun.file(viewsLogFile)
13453
+ stdout: Bun.file(subgraphsLogFile),
13454
+ stderr: Bun.file(subgraphsLogFile)
13430
13455
  });
13431
- state.services.views = {
13432
- pid: viewsProc.pid,
13456
+ state.services.subgraphs = {
13457
+ pid: subgraphsProc.pid,
13433
13458
  port: null,
13434
13459
  startedAt: new Date().toISOString(),
13435
- logFile: viewsLogFile
13460
+ logFile: subgraphsLogFile
13436
13461
  };
13437
- console.log(green(" ✓ View processor"), dim("processing views"));
13462
+ console.log(green(" ✓ Subgraph processor"), dim("processing subgraphs"));
13438
13463
  }
13439
- if (options2.webhook) {
13440
- const webhookLogFile = getLogFile("webhook");
13441
- const webhookArgs = ["bun", "run", resolve6(packagesDir, "packages/cli/src/services/webhook-standalone.ts")];
13442
- const webhookEnv = { ...process.env, PORT: String(webhookPort) };
13464
+ if (options2.receiver) {
13465
+ const receiverLogFile = getLogFile("receiver");
13466
+ const receiverArgs = ["bun", "run", resolve6(packagesDir, "packages/cli/src/services/receiver-standalone.ts")];
13467
+ const receiverEnv = { ...process.env, PORT: String(receiverPort) };
13443
13468
  if (options2.secret)
13444
- webhookEnv.WEBHOOK_SECRET = options2.secret;
13445
- const webhookProc = Bun.spawn(webhookArgs, {
13446
- env: webhookEnv,
13447
- stdout: Bun.file(webhookLogFile),
13448
- stderr: Bun.file(webhookLogFile)
13469
+ receiverEnv.SIGNING_SECRET = options2.secret;
13470
+ const receiverProc = Bun.spawn(receiverArgs, {
13471
+ env: receiverEnv,
13472
+ stdout: Bun.file(receiverLogFile),
13473
+ stderr: Bun.file(receiverLogFile)
13449
13474
  });
13450
- state.services.webhook = {
13451
- pid: webhookProc.pid,
13452
- port: webhookPort,
13475
+ state.services.receiver = {
13476
+ pid: receiverProc.pid,
13477
+ port: receiverPort,
13453
13478
  startedAt: new Date().toISOString(),
13454
- logFile: webhookLogFile
13479
+ logFile: receiverLogFile
13455
13480
  };
13456
- console.log(green(" ✓ Webhook server"), dim(`http://localhost:${webhookPort}`));
13481
+ console.log(green(" ✓ Receiver server"), dim(`http://localhost:${receiverPort}`));
13457
13482
  }
13458
13483
  await Bun.sleep(500);
13459
13484
  for (const [name, service] of Object.entries(state.services)) {
@@ -13463,7 +13488,7 @@ async function runBackground(options2) {
13463
13488
  }
13464
13489
  await saveDevState(state);
13465
13490
  console.log("");
13466
- printUrls(indexerPort, apiPort, webhookPort, options2.webhook);
13491
+ printUrls(indexerPort, apiPort, receiverPort, options2.receiver);
13467
13492
  console.log("");
13468
13493
  success("Dev environment started in background");
13469
13494
  console.log("");
@@ -13501,14 +13526,14 @@ async function runForeground(options2) {
13501
13526
  const dataDir = getDataDir(config);
13502
13527
  const indexerPort = options2.stacksNode ? 3701 : parseInt(options2.indexerPort) || config.ports.indexer;
13503
13528
  const apiPort = parseInt(options2.apiPort) || config.ports.api;
13504
- const webhookPort = parseInt(options2.webhookPort) || config.ports.webhook;
13529
+ const receiverPort = parseInt(options2.receiverPort) || config.ports.receiver;
13505
13530
  let devPostgresStarted = false;
13506
13531
  const shutdown = async () => {
13507
13532
  console.log(`
13508
13533
  `);
13509
13534
  info("Shutting down services...");
13510
- if (options2.webhook) {
13511
- stopWebhookServer();
13535
+ if (options2.receiver) {
13536
+ stopReceiverServer();
13512
13537
  }
13513
13538
  await serviceManager.stopAll();
13514
13539
  if (devPostgresStarted) {
@@ -13555,9 +13580,9 @@ async function runForeground(options2) {
13555
13580
  console.log("");
13556
13581
  }
13557
13582
  process.env.DEV_MODE = "true";
13558
- if (options2.webhook) {
13559
- startWebhookServer({ port: webhookPort, secret: options2.secret });
13560
- console.log(green(" ✓ Webhook server"), dim(`http://localhost:${webhookPort}`));
13583
+ if (options2.receiver) {
13584
+ startReceiverServer({ port: receiverPort, secret: options2.secret });
13585
+ console.log(green(" ✓ Receiver server"), dim(`http://localhost:${receiverPort}`));
13561
13586
  }
13562
13587
  await startApi({ port: apiPort, onLog: (line) => logService("api", line) });
13563
13588
  console.log(green(" ✓ API"), dim(`http://localhost:${apiPort}`));
@@ -13567,10 +13592,10 @@ async function runForeground(options2) {
13567
13592
  await startWorker({ onLog: (line) => logService("worker", line) });
13568
13593
  console.log(green(" ✓ Worker"), dim("processing jobs"));
13569
13594
  }
13570
- await startViewProcessor({ onLog: (line) => logService("views", line) });
13571
- console.log(green(" ✓ View processor"), dim("processing views"));
13595
+ await startSubgraphProcessor({ onLog: (line) => logService("subgraphs", line) });
13596
+ console.log(green(" ✓ Subgraph processor"), dim("processing subgraphs"));
13572
13597
  console.log("");
13573
- printUrls(indexerPort, apiPort, webhookPort, options2.webhook);
13598
+ printUrls(indexerPort, apiPort, receiverPort, options2.receiver);
13574
13599
  console.log("");
13575
13600
  info("Press Ctrl+C to stop all services");
13576
13601
  console.log("");
@@ -13578,8 +13603,8 @@ async function runForeground(options2) {
13578
13603
  } catch (err) {
13579
13604
  error(`Failed to start services: ${err}`);
13580
13605
  await serviceManager.stopAll();
13581
- if (options2.webhook) {
13582
- stopWebhookServer();
13606
+ if (options2.receiver) {
13607
+ stopReceiverServer();
13583
13608
  }
13584
13609
  process.exit(1);
13585
13610
  }
@@ -13610,10 +13635,10 @@ async function showLogs(options2) {
13610
13635
  await showStaticLogs(serviceEntries, lines, verbose);
13611
13636
  }
13612
13637
  }
13613
- function formatWebhookSummary(jsonStr) {
13638
+ function formatDeliverySummary(jsonStr) {
13614
13639
  try {
13615
13640
  const data = JSON.parse(jsonStr);
13616
- if (data.type !== "webhook" || !data.body)
13641
+ if (data.type !== "delivery" || !data.body)
13617
13642
  return null;
13618
13643
  const { body, method, path, timestamp } = data;
13619
13644
  const streamName = body.streamName ?? body.streamId?.slice(0, 8) ?? "unknown";
@@ -13643,8 +13668,8 @@ function formatLogLine2(service, line, verbose) {
13643
13668
  return `${prefix} ${dimTimestamp} ${dim(level + ":")} ${dim(message)}`;
13644
13669
  }
13645
13670
  }
13646
- if (service === "webhook" && !verbose) {
13647
- const summary = formatWebhookSummary(line);
13671
+ if (service === "receiver" && !verbose) {
13672
+ const summary = formatDeliverySummary(line);
13648
13673
  if (summary)
13649
13674
  return `${prefix} ${summary}`;
13650
13675
  }
@@ -13820,36 +13845,36 @@ async function restartDev() {
13820
13845
  };
13821
13846
  console.log(green(" ✓ Worker"), dim("processing jobs"));
13822
13847
  }
13823
- if (state.services.webhook) {
13824
- const webhookPort = config.ports.webhook;
13825
- const webhookLogFile = getLogFile("webhook");
13826
- const webhookProc = Bun.spawn(["bun", "run", resolve6(packagesDir, "packages/cli/src/services/webhook-standalone.ts")], {
13827
- env: { ...process.env, PORT: String(webhookPort) },
13828
- stdout: Bun.file(webhookLogFile),
13829
- stderr: Bun.file(webhookLogFile)
13848
+ if (state.services.receiver) {
13849
+ const receiverPort = config.ports.receiver;
13850
+ const receiverLogFile = getLogFile("receiver");
13851
+ const receiverProc = Bun.spawn(["bun", "run", resolve6(packagesDir, "packages/cli/src/services/receiver-standalone.ts")], {
13852
+ env: { ...process.env, PORT: String(receiverPort) },
13853
+ stdout: Bun.file(receiverLogFile),
13854
+ stderr: Bun.file(receiverLogFile)
13830
13855
  });
13831
- newState.services.webhook = {
13832
- pid: webhookProc.pid,
13833
- port: webhookPort,
13856
+ newState.services.receiver = {
13857
+ pid: receiverProc.pid,
13858
+ port: receiverPort,
13834
13859
  startedAt: new Date().toISOString(),
13835
- logFile: webhookLogFile
13860
+ logFile: receiverLogFile
13836
13861
  };
13837
- console.log(green(" ✓ Webhook server"), dim(`http://localhost:${webhookPort}`));
13862
+ console.log(green(" ✓ Receiver server"), dim(`http://localhost:${receiverPort}`));
13838
13863
  }
13839
- if (state.services.views) {
13840
- const viewsLogFile = getLogFile("views");
13841
- const viewsProc = Bun.spawn(["bun", "run", resolve6(packagesDir, "packages/views/src/service.ts")], {
13864
+ if (state.services.subgraphs) {
13865
+ const subgraphsLogFile = getLogFile("subgraphs");
13866
+ const subgraphsProc = Bun.spawn(["bun", "run", resolve6(packagesDir, "packages/subgraphs/src/service.ts")], {
13842
13867
  env: { ...process.env, ...env },
13843
- stdout: Bun.file(viewsLogFile),
13844
- stderr: Bun.file(viewsLogFile)
13868
+ stdout: Bun.file(subgraphsLogFile),
13869
+ stderr: Bun.file(subgraphsLogFile)
13845
13870
  });
13846
- newState.services.views = {
13847
- pid: viewsProc.pid,
13871
+ newState.services.subgraphs = {
13872
+ pid: subgraphsProc.pid,
13848
13873
  port: null,
13849
13874
  startedAt: new Date().toISOString(),
13850
- logFile: viewsLogFile
13875
+ logFile: subgraphsLogFile
13851
13876
  };
13852
- console.log(green(" ✓ View processor"), dim("processing views"));
13877
+ console.log(green(" ✓ Subgraph processor"), dim("processing subgraphs"));
13853
13878
  }
13854
13879
  await Bun.sleep(500);
13855
13880
  for (const [name, service] of Object.entries(newState.services)) {
@@ -13910,7 +13935,7 @@ function printBanner2() {
13910
13935
  console.log(dim(" Starting services..."));
13911
13936
  console.log("");
13912
13937
  }
13913
- function printUrls(indexerPort, apiPort, webhookPort, webhookEnabled) {
13938
+ function printUrls(indexerPort, apiPort, receiverPort, receiverEnabled) {
13914
13939
  console.log(dim(" ─────────────────────────────────────────"));
13915
13940
  console.log("");
13916
13941
  console.log(" " + blue("API:"));
@@ -13921,9 +13946,9 @@ function printUrls(indexerPort, apiPort, webhookPort, webhookEnabled) {
13921
13946
  console.log(` Health check: curl http://localhost:${indexerPort}/health`);
13922
13947
  console.log(` Send block: curl -X POST http://localhost:${indexerPort}/new_block -d @block.json`);
13923
13948
  console.log("");
13924
- if (webhookEnabled) {
13925
- console.log(" " + blue("Test Webhook:"));
13926
- console.log(` Receives webhooks at http://localhost:${webhookPort}/`);
13949
+ if (receiverEnabled) {
13950
+ console.log(" " + blue("Test Receiver:"));
13951
+ console.log(` Receives deliveries at http://localhost:${receiverPort}/`);
13927
13952
  console.log(` Use this URL when creating streams for testing`);
13928
13953
  console.log("");
13929
13954
  }
@@ -13999,8 +14024,8 @@ var init_dev_impl = __esm(() => {
13999
14024
  api: blue,
14000
14025
  indexer: cyan,
14001
14026
  worker: yellow,
14002
- views: magenta,
14003
- webhook: green
14027
+ subgraphs: magenta,
14028
+ receiver: green
14004
14029
  };
14005
14030
  });
14006
14031
 
@@ -21131,23 +21156,23 @@ var require_ansis = __commonJS((exports, module) => {
21131
21156
  }, s2 = t2, c2 = l2;
21132
21157
  return e2 && (s2 = e2.o + t2, c2 = l2 + e2.c), n(o2, r), o2.p = { open: t2, close: l2, o: s2, c: c2, p: e2 }, o2.open = s2, o2.close = c2, o2;
21133
21158
  };
21134
- var w = new function e(t2 = f) {
21135
- let s2 = { Ansis: e, level: t2, isSupported: () => a2, strip: (e2) => e2.replace(/[›][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, i), extend(e2) {
21136
- for (let t3 in e2) {
21137
- let r2 = e2[t3], l2 = (typeof r2)[0];
21159
+ var w = new function e2(t2 = f) {
21160
+ let s2 = { Ansis: e2, level: t2, isSupported: () => a2, strip: (e3) => e3.replace(/[›][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, i), extend(e3) {
21161
+ for (let t3 in e3) {
21162
+ let r2 = e3[t3], l2 = (typeof r2)[0];
21138
21163
  l2 === "s" ? (c2(t3, T(...p(r2))), c2(_(t3), v(...p(r2)))) : c2(t3, r2, l2 === "f");
21139
21164
  }
21140
21165
  return r = o({}, O), n(s2, r), s2;
21141
- } }, c2 = (e2, t3, r2) => {
21142
- O[e2] = { get() {
21143
- let n2 = r2 ? (...e3) => m(this, t3(...e3)) : m(this, t3);
21144
- return l(this, e2, { value: n2 }), n2;
21166
+ } }, c2 = (e3, t3, r2) => {
21167
+ O[e3] = { get() {
21168
+ let n2 = r2 ? (...e4) => m(this, t3(...e4)) : m(this, t3);
21169
+ return l(this, e3, { value: n2 }), n2;
21145
21170
  } };
21146
- }, a2 = t2 > 0, w2 = (e2, t3) => a2 ? { open: `\x1B[${e2}m`, close: `\x1B[${t3}m` } : g, y = (e2) => (t3) => e2(...p(t3)), R = (e2, t3) => (r2, l2, n2) => w2(`${e2}8;2;${r2};${l2};${n2}`, t3), $ = (e2, t3) => (r2, l2, n2) => w2(((e3, t4, r3) => d(u(e3, t4, r3)))(r2, l2, n2) + e2, t3), x = (e2) => (t3, r2, l2) => e2(u(t3, r2, l2)), T = R(3, h), v = R(4, b2), C = (e2) => w2("38;5;" + e2, h), E = (e2) => w2("48;5;" + e2, b2);
21147
- t2 === 2 ? (T = x(C), v = x(E)) : t2 === 1 && (T = $(0, h), v = $(10, b2), C = (e2) => w2(d(e2), h), E = (e2) => w2(d(e2) + 10, b2));
21148
- let M, I = { fg: C, bg: E, rgb: T, bgRgb: v, hex: y(T), bgHex: y(v), visible: g, reset: w2(0, 0), bold: w2(1, 22), dim: w2(2, 22), italic: w2(3, 23), underline: w2(4, 24), inverse: w2(7, 27), hidden: w2(8, 28), strikethrough: w2(9, 29) }, _ = (e2) => "bg" + e2[0].toUpperCase() + e2.slice(1), k = "Bright";
21149
- return "black,red,green,yellow,blue,magenta,cyan,white,gray".split(",").map((e2, t3) => {
21150
- M = _(e2), 8 > t3 ? (I[e2 + k] = w2(90 + t3, h), I[M + k] = w2(100 + t3, b2)) : t3 = 60, I[e2] = w2(30 + t3, h), I[M] = w2(40 + t3, b2);
21171
+ }, a2 = t2 > 0, w2 = (e3, t3) => a2 ? { open: `\x1B[${e3}m`, close: `\x1B[${t3}m` } : g, y = (e3) => (t3) => e3(...p(t3)), R = (e3, t3) => (r2, l2, n2) => w2(`${e3}8;2;${r2};${l2};${n2}`, t3), $ = (e3, t3) => (r2, l2, n2) => w2(((e4, t4, r3) => d(u(e4, t4, r3)))(r2, l2, n2) + e3, t3), x = (e3) => (t3, r2, l2) => e3(u(t3, r2, l2)), T = R(3, h), v = R(4, b2), C = (e3) => w2("38;5;" + e3, h), E = (e3) => w2("48;5;" + e3, b2);
21172
+ t2 === 2 ? (T = x(C), v = x(E)) : t2 === 1 && (T = $(0, h), v = $(10, b2), C = (e3) => w2(d(e3), h), E = (e3) => w2(d(e3) + 10, b2));
21173
+ let M, I = { fg: C, bg: E, rgb: T, bgRgb: v, hex: y(T), bgHex: y(v), visible: g, reset: w2(0, 0), bold: w2(1, 22), dim: w2(2, 22), italic: w2(3, 23), underline: w2(4, 24), inverse: w2(7, 27), hidden: w2(8, 28), strikethrough: w2(9, 29) }, _ = (e3) => "bg" + e3[0].toUpperCase() + e3.slice(1), k = "Bright";
21174
+ return "black,red,green,yellow,blue,magenta,cyan,white,gray".split(",").map((e3, t3) => {
21175
+ M = _(e3), 8 > t3 ? (I[e3 + k] = w2(90 + t3, h), I[M + k] = w2(100 + t3, b2)) : t3 = 60, I[e3] = w2(30 + t3, h), I[M] = w2(40 + t3, b2);
21151
21176
  }), s2.extend(I);
21152
21177
  };
21153
21178
  module.exports = w, w.default = w;
@@ -21159,302 +21184,11 @@ var init_ansis = __esm(() => {
21159
21184
  import__2 = __toESM(require_ansis(), 1);
21160
21185
  });
21161
21186
 
21162
- // ../../node_modules/@antfu/ni/node_modules/package-manager-detector/dist/commands.mjs
21163
- function dashDashArg(agent, agentCommand) {
21164
- return (args) => {
21165
- if (args.length > 1) {
21166
- return [agent, agentCommand, args[0], "--", ...args.slice(1)];
21167
- } else {
21168
- return [agent, agentCommand, args[0]];
21169
- }
21170
- };
21171
- }
21172
- function denoExecute() {
21173
- return (args) => {
21174
- return ["deno", "run", `npm:${args[0]}`, ...args.slice(1)];
21175
- };
21176
- }
21177
- var npm, yarn, yarnBerry, pnpm, bun, deno, COMMANDS;
21178
- var init_commands = __esm(() => {
21179
- npm = {
21180
- agent: ["npm", 0],
21181
- run: dashDashArg("npm", "run"),
21182
- install: ["npm", "i", 0],
21183
- frozen: ["npm", "ci", 0],
21184
- global: ["npm", "i", "-g", 0],
21185
- add: ["npm", "i", 0],
21186
- upgrade: ["npm", "update", 0],
21187
- "upgrade-interactive": null,
21188
- dedupe: ["npm", "dedupe", 0],
21189
- execute: ["npx", 0],
21190
- "execute-local": ["npx", 0],
21191
- uninstall: ["npm", "uninstall", 0],
21192
- global_uninstall: ["npm", "uninstall", "-g", 0]
21193
- };
21194
- yarn = {
21195
- agent: ["yarn", 0],
21196
- run: ["yarn", "run", 0],
21197
- install: ["yarn", "install", 0],
21198
- frozen: ["yarn", "install", "--frozen-lockfile", 0],
21199
- global: ["yarn", "global", "add", 0],
21200
- add: ["yarn", "add", 0],
21201
- upgrade: ["yarn", "upgrade", 0],
21202
- "upgrade-interactive": ["yarn", "upgrade-interactive", 0],
21203
- dedupe: null,
21204
- execute: ["npx", 0],
21205
- "execute-local": dashDashArg("yarn", "exec"),
21206
- uninstall: ["yarn", "remove", 0],
21207
- global_uninstall: ["yarn", "global", "remove", 0]
21208
- };
21209
- yarnBerry = {
21210
- ...yarn,
21211
- frozen: ["yarn", "install", "--immutable", 0],
21212
- upgrade: ["yarn", "up", 0],
21213
- "upgrade-interactive": ["yarn", "up", "-i", 0],
21214
- dedupe: ["yarn", "dedupe", 0],
21215
- execute: ["yarn", "dlx", 0],
21216
- "execute-local": ["yarn", "exec", 0],
21217
- global: ["npm", "i", "-g", 0],
21218
- global_uninstall: ["npm", "uninstall", "-g", 0]
21219
- };
21220
- pnpm = {
21221
- agent: ["pnpm", 0],
21222
- run: ["pnpm", "run", 0],
21223
- install: ["pnpm", "i", 0],
21224
- frozen: ["pnpm", "i", "--frozen-lockfile", 0],
21225
- global: ["pnpm", "add", "-g", 0],
21226
- add: ["pnpm", "add", 0],
21227
- upgrade: ["pnpm", "update", 0],
21228
- "upgrade-interactive": ["pnpm", "update", "-i", 0],
21229
- dedupe: ["pnpm", "dedupe", 0],
21230
- execute: ["pnpm", "dlx", 0],
21231
- "execute-local": ["pnpm", "exec", 0],
21232
- uninstall: ["pnpm", "remove", 0],
21233
- global_uninstall: ["pnpm", "remove", "--global", 0]
21234
- };
21235
- bun = {
21236
- agent: ["bun", 0],
21237
- run: ["bun", "run", 0],
21238
- install: ["bun", "install", 0],
21239
- frozen: ["bun", "install", "--frozen-lockfile", 0],
21240
- global: ["bun", "add", "-g", 0],
21241
- add: ["bun", "add", 0],
21242
- upgrade: ["bun", "update", 0],
21243
- "upgrade-interactive": ["bun", "update", "-i", 0],
21244
- dedupe: null,
21245
- execute: ["bun", "x", 0],
21246
- "execute-local": ["bun", "x", 0],
21247
- uninstall: ["bun", "remove", 0],
21248
- global_uninstall: ["bun", "remove", "-g", 0]
21249
- };
21250
- deno = {
21251
- agent: ["deno", 0],
21252
- run: ["deno", "task", 0],
21253
- install: ["deno", "install", 0],
21254
- frozen: ["deno", "install", "--frozen", 0],
21255
- global: ["deno", "install", "-g", 0],
21256
- add: ["deno", "add", 0],
21257
- upgrade: ["deno", "outdated", "--update", 0],
21258
- "upgrade-interactive": ["deno", "outdated", "--update", 0],
21259
- dedupe: null,
21260
- execute: denoExecute(),
21261
- "execute-local": ["deno", "task", "--eval", 0],
21262
- uninstall: ["deno", "remove", 0],
21263
- global_uninstall: ["deno", "uninstall", "-g", 0]
21264
- };
21265
- COMMANDS = {
21266
- npm,
21267
- yarn,
21268
- "yarn@berry": yarnBerry,
21269
- pnpm,
21270
- "pnpm@6": {
21271
- ...pnpm,
21272
- run: dashDashArg("pnpm", "run")
21273
- },
21274
- bun,
21275
- deno
21276
- };
21277
- });
21278
-
21279
- // ../../node_modules/@antfu/ni/node_modules/package-manager-detector/dist/constants.mjs
21280
- var AGENTS, LOCKS, INSTALL_METADATA, INSTALL_PAGE;
21281
- var init_constants = __esm(() => {
21282
- AGENTS = [
21283
- "npm",
21284
- "yarn",
21285
- "yarn@berry",
21286
- "pnpm",
21287
- "pnpm@6",
21288
- "bun",
21289
- "deno"
21290
- ];
21291
- LOCKS = {
21292
- "bun.lock": "bun",
21293
- "bun.lockb": "bun",
21294
- "deno.lock": "deno",
21295
- "pnpm-lock.yaml": "pnpm",
21296
- "pnpm-workspace.yaml": "pnpm",
21297
- "yarn.lock": "yarn",
21298
- "package-lock.json": "npm",
21299
- "npm-shrinkwrap.json": "npm"
21300
- };
21301
- INSTALL_METADATA = {
21302
- "node_modules/.deno/": "deno",
21303
- "node_modules/.pnpm/": "pnpm",
21304
- "node_modules/.yarn-state.yml": "yarn",
21305
- "node_modules/.yarn_integrity": "yarn",
21306
- "node_modules/.package-lock.json": "npm",
21307
- ".pnp.cjs": "yarn",
21308
- ".pnp.js": "yarn",
21309
- "bun.lock": "bun",
21310
- "bun.lockb": "bun"
21311
- };
21312
- INSTALL_PAGE = {
21313
- bun: "https://bun.sh",
21314
- deno: "https://deno.com",
21315
- pnpm: "https://pnpm.io/installation",
21316
- "pnpm@6": "https://pnpm.io/6.x/installation",
21317
- yarn: "https://classic.yarnpkg.com/en/docs/install",
21318
- "yarn@berry": "https://yarnpkg.com/getting-started/install",
21319
- npm: "https://docs.npmjs.com/cli/configuring-npm/install"
21320
- };
21321
- });
21322
-
21323
- // ../../node_modules/@antfu/ni/node_modules/package-manager-detector/dist/detect.mjs
21324
- import fs5 from "node:fs/promises";
21325
- import path3 from "node:path";
21326
- import process5 from "node:process";
21327
- async function pathExists(path22, type) {
21328
- try {
21329
- const stat2 = await fs5.stat(path22);
21330
- return type === "file" ? stat2.isFile() : stat2.isDirectory();
21331
- } catch {
21332
- return false;
21333
- }
21334
- }
21335
- function* lookup(cwd = process5.cwd()) {
21336
- let directory = path3.resolve(cwd);
21337
- const { root } = path3.parse(directory);
21338
- while (directory && directory !== root) {
21339
- yield directory;
21340
- directory = path3.dirname(directory);
21341
- }
21342
- }
21343
- async function parsePackageJson(filepath, options2) {
21344
- if (!filepath || !await pathExists(filepath, "file"))
21345
- return null;
21346
- return await handlePackageManager(filepath, options2);
21347
- }
21348
- async function detect(options2 = {}) {
21349
- const {
21350
- cwd,
21351
- strategies = ["lockfile", "packageManager-field", "devEngines-field"]
21352
- } = options2;
21353
- let stopDir;
21354
- if (typeof options2.stopDir === "string") {
21355
- const resolved = path3.resolve(options2.stopDir);
21356
- stopDir = (dir) => dir === resolved;
21357
- } else {
21358
- stopDir = options2.stopDir;
21359
- }
21360
- for (const directory of lookup(cwd)) {
21361
- for (const strategy of strategies) {
21362
- switch (strategy) {
21363
- case "lockfile": {
21364
- for (const lock of Object.keys(LOCKS)) {
21365
- if (await pathExists(path3.join(directory, lock), "file")) {
21366
- const name = LOCKS[lock];
21367
- const result = await parsePackageJson(path3.join(directory, "package.json"), options2);
21368
- if (result)
21369
- return result;
21370
- else
21371
- return { name, agent: name };
21372
- }
21373
- }
21374
- break;
21375
- }
21376
- case "packageManager-field":
21377
- case "devEngines-field": {
21378
- const result = await parsePackageJson(path3.join(directory, "package.json"), options2);
21379
- if (result)
21380
- return result;
21381
- break;
21382
- }
21383
- case "install-metadata": {
21384
- for (const metadata of Object.keys(INSTALL_METADATA)) {
21385
- const fileOrDir = metadata.endsWith("/") ? "dir" : "file";
21386
- if (await pathExists(path3.join(directory, metadata), fileOrDir)) {
21387
- const name = INSTALL_METADATA[metadata];
21388
- const agent = name === "yarn" ? isMetadataYarnClassic(metadata) ? "yarn" : "yarn@berry" : name;
21389
- return { name, agent };
21390
- }
21391
- }
21392
- break;
21393
- }
21394
- }
21395
- }
21396
- if (stopDir?.(directory))
21397
- break;
21398
- }
21399
- return null;
21400
- }
21401
- function getNameAndVer(pkg) {
21402
- const handelVer = (version) => version?.match(/\d+(\.\d+){0,2}/)?.[0] ?? version;
21403
- if (typeof pkg.packageManager === "string") {
21404
- const [name, ver] = pkg.packageManager.replace(/^\^/, "").split("@");
21405
- return { name, ver: handelVer(ver) };
21406
- }
21407
- if (typeof pkg.devEngines?.packageManager?.name === "string") {
21408
- return {
21409
- name: pkg.devEngines.packageManager.name,
21410
- ver: handelVer(pkg.devEngines.packageManager.version)
21411
- };
21412
- }
21413
- return;
21414
- }
21415
- async function handlePackageManager(filepath, options2) {
21416
- try {
21417
- const content = await fs5.readFile(filepath, "utf8");
21418
- const pkg = options2.packageJsonParser ? await options2.packageJsonParser(content, filepath) : JSON.parse(content);
21419
- let agent;
21420
- const nameAndVer = getNameAndVer(pkg);
21421
- if (nameAndVer) {
21422
- const name = nameAndVer.name;
21423
- const ver = nameAndVer.ver;
21424
- let version = ver;
21425
- if (name === "yarn" && ver && Number.parseInt(ver) > 1) {
21426
- agent = "yarn@berry";
21427
- version = "berry";
21428
- return { name, agent, version };
21429
- } else if (name === "pnpm" && ver && Number.parseInt(ver) < 7) {
21430
- agent = "pnpm@6";
21431
- return { name, agent, version };
21432
- } else if (AGENTS.includes(name)) {
21433
- agent = name;
21434
- return { name, agent, version };
21435
- } else {
21436
- return options2.onUnknown?.(pkg.packageManager) ?? null;
21437
- }
21438
- }
21439
- } catch {}
21440
- return null;
21441
- }
21442
- function isMetadataYarnClassic(metadataPath) {
21443
- return metadataPath.endsWith(".yarn_integrity");
21444
- }
21445
- var init_detect = __esm(() => {
21446
- init_constants();
21447
- });
21448
-
21449
21187
  // ../../node_modules/@antfu/ni/node_modules/package-manager-detector/dist/index.mjs
21450
21188
  import"node:fs/promises";
21451
21189
  import"node:path";
21452
21190
  import"node:process";
21453
- var init_dist3 = __esm(() => {
21454
- init_commands();
21455
- init_constants();
21456
- init_detect();
21457
- });
21191
+ var init_dist3 = () => {};
21458
21192
 
21459
21193
  // ../../node_modules/tinyexec/dist/main.js
21460
21194
  import { createRequire as e } from "module";
@@ -22149,12 +21883,143 @@ var init_main = __esm(() => {
22149
21883
  q = K;
22150
21884
  });
22151
21885
 
21886
+ // ../../node_modules/@antfu/ni/node_modules/package-manager-detector/dist/constants.mjs
21887
+ var INSTALL_PAGE2;
21888
+ var init_constants = __esm(() => {
21889
+ INSTALL_PAGE2 = {
21890
+ bun: "https://bun.sh",
21891
+ deno: "https://deno.com",
21892
+ pnpm: "https://pnpm.io/installation",
21893
+ "pnpm@6": "https://pnpm.io/6.x/installation",
21894
+ yarn: "https://classic.yarnpkg.com/en/docs/install",
21895
+ "yarn@berry": "https://yarnpkg.com/getting-started/install",
21896
+ npm: "https://docs.npmjs.com/cli/configuring-npm/install"
21897
+ };
21898
+ });
21899
+
21900
+ // ../../node_modules/@antfu/ni/node_modules/package-manager-detector/dist/commands.mjs
21901
+ function dashDashArg(agent, agentCommand) {
21902
+ return (args) => {
21903
+ if (args.length > 1) {
21904
+ return [agent, agentCommand, args[0], "--", ...args.slice(1)];
21905
+ } else {
21906
+ return [agent, agentCommand, args[0]];
21907
+ }
21908
+ };
21909
+ }
21910
+ function denoExecute() {
21911
+ return (args) => {
21912
+ return ["deno", "run", `npm:${args[0]}`, ...args.slice(1)];
21913
+ };
21914
+ }
21915
+ var npm, yarn, yarnBerry, pnpm, bun, deno, COMMANDS2;
21916
+ var init_commands = __esm(() => {
21917
+ npm = {
21918
+ agent: ["npm", 0],
21919
+ run: dashDashArg("npm", "run"),
21920
+ install: ["npm", "i", 0],
21921
+ frozen: ["npm", "ci", 0],
21922
+ global: ["npm", "i", "-g", 0],
21923
+ add: ["npm", "i", 0],
21924
+ upgrade: ["npm", "update", 0],
21925
+ "upgrade-interactive": null,
21926
+ dedupe: ["npm", "dedupe", 0],
21927
+ execute: ["npx", 0],
21928
+ "execute-local": ["npx", 0],
21929
+ uninstall: ["npm", "uninstall", 0],
21930
+ global_uninstall: ["npm", "uninstall", "-g", 0]
21931
+ };
21932
+ yarn = {
21933
+ agent: ["yarn", 0],
21934
+ run: ["yarn", "run", 0],
21935
+ install: ["yarn", "install", 0],
21936
+ frozen: ["yarn", "install", "--frozen-lockfile", 0],
21937
+ global: ["yarn", "global", "add", 0],
21938
+ add: ["yarn", "add", 0],
21939
+ upgrade: ["yarn", "upgrade", 0],
21940
+ "upgrade-interactive": ["yarn", "upgrade-interactive", 0],
21941
+ dedupe: null,
21942
+ execute: ["npx", 0],
21943
+ "execute-local": dashDashArg("yarn", "exec"),
21944
+ uninstall: ["yarn", "remove", 0],
21945
+ global_uninstall: ["yarn", "global", "remove", 0]
21946
+ };
21947
+ yarnBerry = {
21948
+ ...yarn,
21949
+ frozen: ["yarn", "install", "--immutable", 0],
21950
+ upgrade: ["yarn", "up", 0],
21951
+ "upgrade-interactive": ["yarn", "up", "-i", 0],
21952
+ dedupe: ["yarn", "dedupe", 0],
21953
+ execute: ["yarn", "dlx", 0],
21954
+ "execute-local": ["yarn", "exec", 0],
21955
+ global: ["npm", "i", "-g", 0],
21956
+ global_uninstall: ["npm", "uninstall", "-g", 0]
21957
+ };
21958
+ pnpm = {
21959
+ agent: ["pnpm", 0],
21960
+ run: ["pnpm", "run", 0],
21961
+ install: ["pnpm", "i", 0],
21962
+ frozen: ["pnpm", "i", "--frozen-lockfile", 0],
21963
+ global: ["pnpm", "add", "-g", 0],
21964
+ add: ["pnpm", "add", 0],
21965
+ upgrade: ["pnpm", "update", 0],
21966
+ "upgrade-interactive": ["pnpm", "update", "-i", 0],
21967
+ dedupe: ["pnpm", "dedupe", 0],
21968
+ execute: ["pnpm", "dlx", 0],
21969
+ "execute-local": ["pnpm", "exec", 0],
21970
+ uninstall: ["pnpm", "remove", 0],
21971
+ global_uninstall: ["pnpm", "remove", "--global", 0]
21972
+ };
21973
+ bun = {
21974
+ agent: ["bun", 0],
21975
+ run: ["bun", "run", 0],
21976
+ install: ["bun", "install", 0],
21977
+ frozen: ["bun", "install", "--frozen-lockfile", 0],
21978
+ global: ["bun", "add", "-g", 0],
21979
+ add: ["bun", "add", 0],
21980
+ upgrade: ["bun", "update", 0],
21981
+ "upgrade-interactive": ["bun", "update", "-i", 0],
21982
+ dedupe: null,
21983
+ execute: ["bun", "x", 0],
21984
+ "execute-local": ["bun", "x", 0],
21985
+ uninstall: ["bun", "remove", 0],
21986
+ global_uninstall: ["bun", "remove", "-g", 0]
21987
+ };
21988
+ deno = {
21989
+ agent: ["deno", 0],
21990
+ run: ["deno", "task", 0],
21991
+ install: ["deno", "install", 0],
21992
+ frozen: ["deno", "install", "--frozen", 0],
21993
+ global: ["deno", "install", "-g", 0],
21994
+ add: ["deno", "add", 0],
21995
+ upgrade: ["deno", "outdated", "--update", 0],
21996
+ "upgrade-interactive": ["deno", "outdated", "--update", 0],
21997
+ dedupe: null,
21998
+ execute: denoExecute(),
21999
+ "execute-local": ["deno", "task", "--eval", 0],
22000
+ uninstall: ["deno", "remove", 0],
22001
+ global_uninstall: ["deno", "uninstall", "-g", 0]
22002
+ };
22003
+ COMMANDS2 = {
22004
+ npm,
22005
+ yarn,
22006
+ "yarn@berry": yarnBerry,
22007
+ pnpm,
22008
+ "pnpm@6": {
22009
+ ...pnpm,
22010
+ run: dashDashArg("pnpm", "run")
22011
+ },
22012
+ bun,
22013
+ deno
22014
+ };
22015
+ });
22016
+
22152
22017
  // ../../node_modules/@antfu/ni/dist/shared/ni.B5qNAuoI.mjs
22153
- import path4, { join as join7, dirname as dirname6, resolve as resolve7 } from "node:path";
22018
+ import path3, { join as join7, dirname as dirname6, resolve as resolve7 } from "node:path";
22154
22019
  import process$1 from "node:process";
22155
22020
  import require$$0 from "readline";
22156
22021
  import require$$2 from "events";
22157
- import fs6, { promises, existsSync as existsSync2 } from "node:fs";
22022
+ import fs5, { promises, existsSync as existsSync2 } from "node:fs";
22158
22023
  import require$$0$1 from "os";
22159
22024
  import require$$1 from "tty";
22160
22025
  import os4 from "node:os";
@@ -25003,10 +24868,10 @@ function requirePosix() {
25003
24868
  posix.sync = posix.isexe = undefined;
25004
24869
  const fs_1 = require$$0$2;
25005
24870
  const promises_1 = require$$1$1;
25006
- const isexe = async (path5, options2 = {}) => {
24871
+ const isexe = async (path4, options2 = {}) => {
25007
24872
  const { ignoreErrors = false } = options2;
25008
24873
  try {
25009
- return checkStat(await (0, promises_1.stat)(path5), options2);
24874
+ return checkStat(await (0, promises_1.stat)(path4), options2);
25010
24875
  } catch (e2) {
25011
24876
  const er = e2;
25012
24877
  if (ignoreErrors || er.code === "EACCES")
@@ -25015,10 +24880,10 @@ function requirePosix() {
25015
24880
  }
25016
24881
  };
25017
24882
  posix.isexe = isexe;
25018
- const sync = (path5, options2 = {}) => {
24883
+ const sync = (path4, options2 = {}) => {
25019
24884
  const { ignoreErrors = false } = options2;
25020
24885
  try {
25021
- return checkStat((0, fs_1.statSync)(path5), options2);
24886
+ return checkStat((0, fs_1.statSync)(path4), options2);
25022
24887
  } catch (e2) {
25023
24888
  const er = e2;
25024
24889
  if (ignoreErrors || er.code === "EACCES")
@@ -25055,10 +24920,10 @@ function requireWin32() {
25055
24920
  win32.sync = win32.isexe = undefined;
25056
24921
  const fs_1 = require$$0$2;
25057
24922
  const promises_1 = require$$1$1;
25058
- const isexe = async (path5, options2 = {}) => {
24923
+ const isexe = async (path4, options2 = {}) => {
25059
24924
  const { ignoreErrors = false } = options2;
25060
24925
  try {
25061
- return checkStat(await (0, promises_1.stat)(path5), path5, options2);
24926
+ return checkStat(await (0, promises_1.stat)(path4), path4, options2);
25062
24927
  } catch (e2) {
25063
24928
  const er = e2;
25064
24929
  if (ignoreErrors || er.code === "EACCES")
@@ -25067,10 +24932,10 @@ function requireWin32() {
25067
24932
  }
25068
24933
  };
25069
24934
  win32.isexe = isexe;
25070
- const sync = (path5, options2 = {}) => {
24935
+ const sync = (path4, options2 = {}) => {
25071
24936
  const { ignoreErrors = false } = options2;
25072
24937
  try {
25073
- return checkStat((0, fs_1.statSync)(path5), path5, options2);
24938
+ return checkStat((0, fs_1.statSync)(path4), path4, options2);
25074
24939
  } catch (e2) {
25075
24940
  const er = e2;
25076
24941
  if (ignoreErrors || er.code === "EACCES")
@@ -25079,7 +24944,7 @@ function requireWin32() {
25079
24944
  }
25080
24945
  };
25081
24946
  win32.sync = sync;
25082
- const checkPathExt = (path5, options2) => {
24947
+ const checkPathExt = (path4, options2) => {
25083
24948
  const { pathExt = process.env.PATHEXT || "" } = options2;
25084
24949
  const peSplit = pathExt.split(";");
25085
24950
  if (peSplit.indexOf("") !== -1) {
@@ -25087,14 +24952,14 @@ function requireWin32() {
25087
24952
  }
25088
24953
  for (let i2 = 0;i2 < peSplit.length; i2++) {
25089
24954
  const p2 = peSplit[i2].toLowerCase();
25090
- const ext = path5.substring(path5.length - p2.length).toLowerCase();
24955
+ const ext = path4.substring(path4.length - p2.length).toLowerCase();
25091
24956
  if (p2 && ext === p2) {
25092
24957
  return true;
25093
24958
  }
25094
24959
  }
25095
24960
  return false;
25096
24961
  };
25097
- const checkStat = (stat2, path5, options2) => stat2.isFile() && checkPathExt(path5, options2);
24962
+ const checkStat = (stat2, path4, options2) => stat2.isFile() && checkPathExt(path4, options2);
25098
24963
  return win32;
25099
24964
  }
25100
24965
  function requireOptions() {
@@ -25269,7 +25134,7 @@ async function detect2({ autoInstall, programmatic, cwd } = {}) {
25269
25134
  `);
25270
25135
  if (process$1.env.CI)
25271
25136
  process$1.exit(1);
25272
- const link2 = terminalLink(name, INSTALL_PAGE[name]);
25137
+ const link2 = terminalLink(name, INSTALL_PAGE2[name]);
25273
25138
  const { tryInstall } = await prompts({
25274
25139
  name: "tryInstall",
25275
25140
  type: "confirm",
@@ -25344,7 +25209,7 @@ var init_ni_B5qNAuoI = __esm(() => {
25344
25209
  CLI_TEMP_DIR = join7(os4.tmpdir(), "antfu-ni");
25345
25210
  customRcPath = process$1.env.NI_CONFIG_FILE;
25346
25211
  home = process$1.platform === "win32" ? process$1.env.USERPROFILE : process$1.env.HOME;
25347
- defaultRcPath = path4.join(home || "~/", ".nirc");
25212
+ defaultRcPath = path3.join(home || "~/", ".nirc");
25348
25213
  });
25349
25214
 
25350
25215
  // ../../node_modules/@antfu/ni/dist/index.mjs
@@ -25552,10 +25417,10 @@ var init_template = __esm(() => {
25552
25417
  });
25553
25418
 
25554
25419
  // ../../node_modules/execa/lib/utils/standard-stream.js
25555
- import process6 from "node:process";
25420
+ import process5 from "node:process";
25556
25421
  var isStandardStream = (stream2) => STANDARD_STREAMS.includes(stream2), STANDARD_STREAMS, STANDARD_STREAMS_ALIASES, getStreamName = (fdNumber) => STANDARD_STREAMS_ALIASES[fdNumber] ?? `stdio[${fdNumber}]`;
25557
25422
  var init_standard_stream = __esm(() => {
25558
- STANDARD_STREAMS = [process6.stdin, process6.stdout, process6.stderr];
25423
+ STANDARD_STREAMS = [process5.stdin, process5.stdout, process5.stderr];
25559
25424
  STANDARD_STREAMS_ALIASES = ["stdin", "stdout", "stderr"];
25560
25425
  });
25561
25426
 
@@ -25677,11 +25542,11 @@ var init_escape = __esm(() => {
25677
25542
  });
25678
25543
 
25679
25544
  // ../../node_modules/is-unicode-supported/index.js
25680
- import process7 from "node:process";
25545
+ import process6 from "node:process";
25681
25546
  function isUnicodeSupported() {
25682
- const { env: env2 } = process7;
25547
+ const { env: env2 } = process6;
25683
25548
  const { TERM, TERM_PROGRAM } = env2;
25684
- if (process7.platform !== "win32") {
25549
+ if (process6.platform !== "win32") {
25685
25550
  return TERM !== "linux";
25686
25551
  }
25687
25552
  return Boolean(env2.WT_SESSION) || Boolean(env2.TERMINUS_SUBLIME) || env2.ConEmuTask === "{cmd::Cmder}" || TERM_PROGRAM === "Terminus-Sublime" || TERM_PROGRAM === "vscode" || TERM === "xterm-256color" || TERM === "alacritty" || TERM === "rxvt-unicode" || TERM === "rxvt-unicode-256color" || env2.TERMINAL_EMULATOR === "JetBrains-JediTerm";
@@ -26043,7 +25908,6 @@ var init_base = __esm(() => {
26043
25908
  // ../../node_modules/yoctocolors/index.js
26044
25909
  var init_yoctocolors = __esm(() => {
26045
25910
  init_base();
26046
- init_base();
26047
25911
  });
26048
25912
 
26049
25913
  // ../../node_modules/execa/lib/verbose/default.js
@@ -26215,8 +26079,8 @@ var init_command = __esm(() => {
26215
26079
  var require_windows = __commonJS((exports, module) => {
26216
26080
  module.exports = isexe;
26217
26081
  isexe.sync = sync;
26218
- var fs7 = __require("fs");
26219
- function checkPathExt(path5, options3) {
26082
+ var fs6 = __require("fs");
26083
+ function checkPathExt(path4, options3) {
26220
26084
  var pathext = options3.pathExt !== undefined ? options3.pathExt : process.env.PATHEXT;
26221
26085
  if (!pathext) {
26222
26086
  return true;
@@ -26227,25 +26091,25 @@ var require_windows = __commonJS((exports, module) => {
26227
26091
  }
26228
26092
  for (var i2 = 0;i2 < pathext.length; i2++) {
26229
26093
  var p2 = pathext[i2].toLowerCase();
26230
- if (p2 && path5.substr(-p2.length).toLowerCase() === p2) {
26094
+ if (p2 && path4.substr(-p2.length).toLowerCase() === p2) {
26231
26095
  return true;
26232
26096
  }
26233
26097
  }
26234
26098
  return false;
26235
26099
  }
26236
- function checkStat(stat2, path5, options3) {
26100
+ function checkStat(stat2, path4, options3) {
26237
26101
  if (!stat2.isSymbolicLink() && !stat2.isFile()) {
26238
26102
  return false;
26239
26103
  }
26240
- return checkPathExt(path5, options3);
26104
+ return checkPathExt(path4, options3);
26241
26105
  }
26242
- function isexe(path5, options3, cb) {
26243
- fs7.stat(path5, function(er, stat2) {
26244
- cb(er, er ? false : checkStat(stat2, path5, options3));
26106
+ function isexe(path4, options3, cb) {
26107
+ fs6.stat(path4, function(er, stat2) {
26108
+ cb(er, er ? false : checkStat(stat2, path4, options3));
26245
26109
  });
26246
26110
  }
26247
- function sync(path5, options3) {
26248
- return checkStat(fs7.statSync(path5), path5, options3);
26111
+ function sync(path4, options3) {
26112
+ return checkStat(fs6.statSync(path4), path4, options3);
26249
26113
  }
26250
26114
  });
26251
26115
 
@@ -26253,14 +26117,14 @@ var require_windows = __commonJS((exports, module) => {
26253
26117
  var require_mode = __commonJS((exports, module) => {
26254
26118
  module.exports = isexe;
26255
26119
  isexe.sync = sync;
26256
- var fs7 = __require("fs");
26257
- function isexe(path5, options3, cb) {
26258
- fs7.stat(path5, function(er, stat2) {
26120
+ var fs6 = __require("fs");
26121
+ function isexe(path4, options3, cb) {
26122
+ fs6.stat(path4, function(er, stat2) {
26259
26123
  cb(er, er ? false : checkStat(stat2, options3));
26260
26124
  });
26261
26125
  }
26262
- function sync(path5, options3) {
26263
- return checkStat(fs7.statSync(path5), options3);
26126
+ function sync(path4, options3) {
26127
+ return checkStat(fs6.statSync(path4), options3);
26264
26128
  }
26265
26129
  function checkStat(stat2, options3) {
26266
26130
  return stat2.isFile() && checkMode(stat2, options3);
@@ -26282,7 +26146,7 @@ var require_mode = __commonJS((exports, module) => {
26282
26146
 
26283
26147
  // ../../node_modules/isexe/index.js
26284
26148
  var require_isexe = __commonJS((exports, module) => {
26285
- var fs7 = __require("fs");
26149
+ var fs6 = __require("fs");
26286
26150
  var core2;
26287
26151
  if (process.platform === "win32" || global.TESTING_WINDOWS) {
26288
26152
  core2 = require_windows();
@@ -26291,7 +26155,7 @@ var require_isexe = __commonJS((exports, module) => {
26291
26155
  }
26292
26156
  module.exports = isexe;
26293
26157
  isexe.sync = sync;
26294
- function isexe(path5, options3, cb) {
26158
+ function isexe(path4, options3, cb) {
26295
26159
  if (typeof options3 === "function") {
26296
26160
  cb = options3;
26297
26161
  options3 = {};
@@ -26301,7 +26165,7 @@ var require_isexe = __commonJS((exports, module) => {
26301
26165
  throw new TypeError("callback not provided");
26302
26166
  }
26303
26167
  return new Promise(function(resolve8, reject) {
26304
- isexe(path5, options3 || {}, function(er, is2) {
26168
+ isexe(path4, options3 || {}, function(er, is2) {
26305
26169
  if (er) {
26306
26170
  reject(er);
26307
26171
  } else {
@@ -26310,7 +26174,7 @@ var require_isexe = __commonJS((exports, module) => {
26310
26174
  });
26311
26175
  });
26312
26176
  }
26313
- core2(path5, options3 || {}, function(er, is2) {
26177
+ core2(path4, options3 || {}, function(er, is2) {
26314
26178
  if (er) {
26315
26179
  if (er.code === "EACCES" || options3 && options3.ignoreErrors) {
26316
26180
  er = null;
@@ -26320,9 +26184,9 @@ var require_isexe = __commonJS((exports, module) => {
26320
26184
  cb(er, is2);
26321
26185
  });
26322
26186
  }
26323
- function sync(path5, options3) {
26187
+ function sync(path4, options3) {
26324
26188
  try {
26325
- return core2.sync(path5, options3 || {});
26189
+ return core2.sync(path4, options3 || {});
26326
26190
  } catch (er) {
26327
26191
  if (options3 && options3.ignoreErrors || er.code === "EACCES") {
26328
26192
  return false;
@@ -26336,7 +26200,7 @@ var require_isexe = __commonJS((exports, module) => {
26336
26200
  // ../../node_modules/which/which.js
26337
26201
  var require_which = __commonJS((exports, module) => {
26338
26202
  var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
26339
- var path5 = __require("path");
26203
+ var path4 = __require("path");
26340
26204
  var COLON = isWindows ? ";" : ":";
26341
26205
  var isexe = require_isexe();
26342
26206
  var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
@@ -26372,7 +26236,7 @@ var require_which = __commonJS((exports, module) => {
26372
26236
  return opt.all && found.length ? resolve8(found) : reject(getNotFoundError(cmd));
26373
26237
  const ppRaw = pathEnv[i2];
26374
26238
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
26375
- const pCmd = path5.join(pathPart, cmd);
26239
+ const pCmd = path4.join(pathPart, cmd);
26376
26240
  const p2 = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
26377
26241
  resolve8(subStep(p2, i2, 0));
26378
26242
  });
@@ -26399,7 +26263,7 @@ var require_which = __commonJS((exports, module) => {
26399
26263
  for (let i2 = 0;i2 < pathEnv.length; i2++) {
26400
26264
  const ppRaw = pathEnv[i2];
26401
26265
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
26402
- const pCmd = path5.join(pathPart, cmd);
26266
+ const pCmd = path4.join(pathPart, cmd);
26403
26267
  const p2 = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
26404
26268
  for (let j2 = 0;j2 < pathExt.length; j2++) {
26405
26269
  const cur = p2 + pathExt[j2];
@@ -26440,7 +26304,7 @@ var require_path_key = __commonJS((exports, module) => {
26440
26304
 
26441
26305
  // ../../node_modules/cross-spawn/lib/util/resolveCommand.js
26442
26306
  var require_resolveCommand = __commonJS((exports, module) => {
26443
- var path5 = __require("path");
26307
+ var path4 = __require("path");
26444
26308
  var which2 = require_which();
26445
26309
  var getPathKey = require_path_key();
26446
26310
  function resolveCommandAttempt(parsed, withoutPathExt) {
@@ -26457,7 +26321,7 @@ var require_resolveCommand = __commonJS((exports, module) => {
26457
26321
  try {
26458
26322
  resolved = which2.sync(parsed.command, {
26459
26323
  path: env2[getPathKey({ env: env2 })],
26460
- pathExt: withoutPathExt ? path5.delimiter : undefined
26324
+ pathExt: withoutPathExt ? path4.delimiter : undefined
26461
26325
  });
26462
26326
  } catch (e2) {} finally {
26463
26327
  if (shouldSwitchCwd) {
@@ -26465,7 +26329,7 @@ var require_resolveCommand = __commonJS((exports, module) => {
26465
26329
  }
26466
26330
  }
26467
26331
  if (resolved) {
26468
- resolved = path5.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
26332
+ resolved = path4.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
26469
26333
  }
26470
26334
  return resolved;
26471
26335
  }
@@ -26510,8 +26374,8 @@ var require_shebang_command = __commonJS((exports, module) => {
26510
26374
  if (!match) {
26511
26375
  return null;
26512
26376
  }
26513
- const [path5, argument] = match[0].replace(/#! ?/, "").split(" ");
26514
- const binary = path5.split("/").pop();
26377
+ const [path4, argument] = match[0].replace(/#! ?/, "").split(" ");
26378
+ const binary = path4.split("/").pop();
26515
26379
  if (binary === "env") {
26516
26380
  return argument;
26517
26381
  }
@@ -26521,16 +26385,16 @@ var require_shebang_command = __commonJS((exports, module) => {
26521
26385
 
26522
26386
  // ../../node_modules/cross-spawn/lib/util/readShebang.js
26523
26387
  var require_readShebang = __commonJS((exports, module) => {
26524
- var fs7 = __require("fs");
26388
+ var fs6 = __require("fs");
26525
26389
  var shebangCommand = require_shebang_command();
26526
26390
  function readShebang(command) {
26527
26391
  const size2 = 150;
26528
26392
  const buffer2 = Buffer.alloc(size2);
26529
26393
  let fd;
26530
26394
  try {
26531
- fd = fs7.openSync(command, "r");
26532
- fs7.readSync(fd, buffer2, 0, size2, 0);
26533
- fs7.closeSync(fd);
26395
+ fd = fs6.openSync(command, "r");
26396
+ fs6.readSync(fd, buffer2, 0, size2, 0);
26397
+ fs6.closeSync(fd);
26534
26398
  } catch (e2) {}
26535
26399
  return shebangCommand(buffer2.toString());
26536
26400
  }
@@ -26539,7 +26403,7 @@ var require_readShebang = __commonJS((exports, module) => {
26539
26403
 
26540
26404
  // ../../node_modules/cross-spawn/lib/parse.js
26541
26405
  var require_parse3 = __commonJS((exports, module) => {
26542
- var path5 = __require("path");
26406
+ var path4 = __require("path");
26543
26407
  var resolveCommand2 = require_resolveCommand();
26544
26408
  var escape2 = require_escape();
26545
26409
  var readShebang = require_readShebang();
@@ -26564,7 +26428,7 @@ var require_parse3 = __commonJS((exports, module) => {
26564
26428
  const needsShell = !isExecutableRegExp.test(commandFile);
26565
26429
  if (parsed.options.forceShell || needsShell) {
26566
26430
  const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
26567
- parsed.command = path5.normalize(parsed.command);
26431
+ parsed.command = path4.normalize(parsed.command);
26568
26432
  parsed.command = escape2.command(parsed.command);
26569
26433
  parsed.args = parsed.args.map((arg) => escape2.argument(arg, needsDoubleEscapeMetaChars));
26570
26434
  const shellCommand = [parsed.command].concat(parsed.args).join(" ");
@@ -26681,7 +26545,7 @@ function pathKey(options3 = {}) {
26681
26545
  // ../../node_modules/unicorn-magic/node.js
26682
26546
  import { promisify as promisify4 } from "node:util";
26683
26547
  import { execFile as execFileCallback, execFileSync as execFileSyncOriginal } from "node:child_process";
26684
- import path5 from "node:path";
26548
+ import path4 from "node:path";
26685
26549
  import { fileURLToPath as fileURLToPath2 } from "node:url";
26686
26550
  function toPath(urlOrPath) {
26687
26551
  return urlOrPath instanceof URL ? fileURLToPath2(urlOrPath) : urlOrPath;
@@ -26689,12 +26553,12 @@ function toPath(urlOrPath) {
26689
26553
  function traversePathUp(startPath) {
26690
26554
  return {
26691
26555
  *[Symbol.iterator]() {
26692
- let currentPath = path5.resolve(toPath(startPath));
26556
+ let currentPath = path4.resolve(toPath(startPath));
26693
26557
  let previousPath;
26694
26558
  while (previousPath !== currentPath) {
26695
26559
  yield currentPath;
26696
26560
  previousPath = currentPath;
26697
- currentPath = path5.resolve(currentPath, "..");
26561
+ currentPath = path4.resolve(currentPath, "..");
26698
26562
  }
26699
26563
  }
26700
26564
  };
@@ -26706,38 +26570,38 @@ var init_node = __esm(() => {
26706
26570
  });
26707
26571
 
26708
26572
  // ../../node_modules/npm-run-path/index.js
26709
- import process8 from "node:process";
26710
- import path6 from "node:path";
26573
+ import process7 from "node:process";
26574
+ import path5 from "node:path";
26711
26575
  var npmRunPath = ({
26712
- cwd = process8.cwd(),
26713
- path: pathOption = process8.env[pathKey()],
26576
+ cwd = process7.cwd(),
26577
+ path: pathOption = process7.env[pathKey()],
26714
26578
  preferLocal = true,
26715
- execPath = process8.execPath,
26579
+ execPath = process7.execPath,
26716
26580
  addExecPath = true
26717
26581
  } = {}) => {
26718
- const cwdPath = path6.resolve(toPath(cwd));
26582
+ const cwdPath = path5.resolve(toPath(cwd));
26719
26583
  const result = [];
26720
- const pathParts = pathOption.split(path6.delimiter);
26584
+ const pathParts = pathOption.split(path5.delimiter);
26721
26585
  if (preferLocal) {
26722
26586
  applyPreferLocal(result, pathParts, cwdPath);
26723
26587
  }
26724
26588
  if (addExecPath) {
26725
26589
  applyExecPath(result, pathParts, execPath, cwdPath);
26726
26590
  }
26727
- return pathOption === "" || pathOption === path6.delimiter ? `${result.join(path6.delimiter)}${pathOption}` : [...result, pathOption].join(path6.delimiter);
26591
+ return pathOption === "" || pathOption === path5.delimiter ? `${result.join(path5.delimiter)}${pathOption}` : [...result, pathOption].join(path5.delimiter);
26728
26592
  }, applyPreferLocal = (result, pathParts, cwdPath) => {
26729
26593
  for (const directory of traversePathUp(cwdPath)) {
26730
- const pathPart = path6.join(directory, "node_modules/.bin");
26594
+ const pathPart = path5.join(directory, "node_modules/.bin");
26731
26595
  if (!pathParts.includes(pathPart)) {
26732
26596
  result.push(pathPart);
26733
26597
  }
26734
26598
  }
26735
26599
  }, applyExecPath = (result, pathParts, execPath, cwdPath) => {
26736
- const pathPart = path6.resolve(cwdPath, toPath(execPath), "..");
26600
+ const pathPart = path5.resolve(cwdPath, toPath(execPath), "..");
26737
26601
  if (!pathParts.includes(pathPart)) {
26738
26602
  result.push(pathPart);
26739
26603
  }
26740
- }, npmRunPathEnv = ({ env: env2 = process8.env, ...options3 } = {}) => {
26604
+ }, npmRunPathEnv = ({ env: env2 = process7.env, ...options3 } = {}) => {
26741
26605
  env2 = { ...env2 };
26742
26606
  const pathName = pathKey({ env: env2 });
26743
26607
  options3.path = env2[pathName];
@@ -27843,7 +27707,7 @@ var init_timeout = __esm(() => {
27843
27707
 
27844
27708
  // ../../node_modules/execa/lib/methods/node.js
27845
27709
  import { execPath, execArgv } from "node:process";
27846
- import path7 from "node:path";
27710
+ import path6 from "node:path";
27847
27711
  var mapNode = ({ options: options3 }) => {
27848
27712
  if (options3.node === false) {
27849
27713
  throw new TypeError('The "node" option cannot be false with `execaNode()`.');
@@ -27861,7 +27725,7 @@ var mapNode = ({ options: options3 }) => {
27861
27725
  throw new TypeError('The "execPath" option has been removed. Please use the "nodePath" option instead.');
27862
27726
  }
27863
27727
  const normalizedNodePath = safeNormalizeFileUrl(nodePath, 'The "nodePath" option');
27864
- const resolvedNodePath = path7.resolve(cwd, normalizedNodePath);
27728
+ const resolvedNodePath = path6.resolve(cwd, normalizedNodePath);
27865
27729
  const newOptions = {
27866
27730
  ...options3,
27867
27731
  nodePath: resolvedNodePath,
@@ -27871,7 +27735,7 @@ var mapNode = ({ options: options3 }) => {
27871
27735
  if (!shouldHandleNode) {
27872
27736
  return [file, commandArguments, newOptions];
27873
27737
  }
27874
- if (path7.basename(file, ".exe") === "node") {
27738
+ if (path6.basename(file, ".exe") === "node") {
27875
27739
  throw new TypeError('When the "node" option is true, the first argument does not need to be "node".');
27876
27740
  }
27877
27741
  return [
@@ -27962,14 +27826,14 @@ var init_encoding_option = __esm(() => {
27962
27826
 
27963
27827
  // ../../node_modules/execa/lib/arguments/cwd.js
27964
27828
  import { statSync } from "node:fs";
27965
- import path8 from "node:path";
27966
- import process9 from "node:process";
27829
+ import path7 from "node:path";
27830
+ import process8 from "node:process";
27967
27831
  var normalizeCwd = (cwd = getDefaultCwd()) => {
27968
27832
  const cwdString = safeNormalizeFileUrl(cwd, 'The "cwd" option');
27969
- return path8.resolve(cwdString);
27833
+ return path7.resolve(cwdString);
27970
27834
  }, getDefaultCwd = () => {
27971
27835
  try {
27972
- return process9.cwd();
27836
+ return process8.cwd();
27973
27837
  } catch (error2) {
27974
27838
  error2.message = `The current directory does not exist.
27975
27839
  ${error2.message}`;
@@ -27998,8 +27862,8 @@ var init_cwd = __esm(() => {
27998
27862
  });
27999
27863
 
28000
27864
  // ../../node_modules/execa/lib/arguments/options.js
28001
- import path9 from "node:path";
28002
- import process10 from "node:process";
27865
+ import path8 from "node:path";
27866
+ import process9 from "node:process";
28003
27867
  var import_cross_spawn, normalizeOptions = (filePath, rawArguments, rawOptions) => {
28004
27868
  rawOptions.cwd = normalizeCwd(rawOptions.cwd);
28005
27869
  const [processedFile, processedArguments, processedOptions] = handleNodeOption(filePath, rawArguments, rawOptions);
@@ -28016,7 +27880,7 @@ var import_cross_spawn, normalizeOptions = (filePath, rawArguments, rawOptions)
28016
27880
  options3.killSignal = normalizeKillSignal(options3.killSignal);
28017
27881
  options3.forceKillAfterDelay = normalizeForceKillAfterDelay(options3.forceKillAfterDelay);
28018
27882
  options3.lines = options3.lines.map((lines2, fdNumber) => lines2 && !BINARY_ENCODINGS.has(options3.encoding) && options3.buffer[fdNumber]);
28019
- if (process10.platform === "win32" && path9.basename(file, ".exe") === "cmd") {
27883
+ if (process9.platform === "win32" && path8.basename(file, ".exe") === "cmd") {
28020
27884
  commandArguments.unshift("/q");
28021
27885
  }
28022
27886
  return { file, commandArguments, options: options3 };
@@ -28055,7 +27919,7 @@ var import_cross_spawn, normalizeOptions = (filePath, rawArguments, rawOptions)
28055
27919
  ipc,
28056
27920
  serialization
28057
27921
  }), getEnv = ({ env: envOption, extendEnv, preferLocal, node, localDirectory, nodePath }) => {
28058
- const env2 = extendEnv ? { ...process10.env, ...envOption } : envOption;
27922
+ const env2 = extendEnv ? { ...process9.env, ...envOption } : envOption;
28059
27923
  if (preferLocal || node) {
28060
27924
  return npmRunPathEnv({
28061
27925
  env: env2,
@@ -28173,10 +28037,6 @@ function i2() {
28173
28037
  function o2(r2) {
28174
28038
  return this[n2].return(r2);
28175
28039
  }
28176
- function h2({ preventCancel: r2 = false } = {}) {
28177
- const e2 = this.getReader(), t2 = new c2(e2, r2), s2 = Object.create(u2);
28178
- return s2[n2] = t2, s2;
28179
- }
28180
28040
  var a3, n2, u2;
28181
28041
  var init_asyncIterator = __esm(() => {
28182
28042
  a3 = Object.getPrototypeOf(Object.getPrototypeOf(async function* () {}).prototype);
@@ -28209,276 +28069,18 @@ var init_ponyfill = __esm(() => {
28209
28069
  });
28210
28070
 
28211
28071
  // ../../node_modules/get-stream/source/stream.js
28212
- var getAsyncIterable = (stream2) => {
28213
- if (isReadableStream(stream2, { checkOpen: false }) && nodeImports.on !== undefined) {
28214
- return getStreamIterable(stream2);
28215
- }
28216
- if (typeof stream2?.[Symbol.asyncIterator] === "function") {
28217
- return stream2;
28218
- }
28219
- if (toString2.call(stream2) === "[object ReadableStream]") {
28220
- return h2.call(stream2);
28221
- }
28222
- throw new TypeError("The first argument must be a Readable, a ReadableStream, or an async iterable.");
28223
- }, toString2, getStreamIterable = async function* (stream2) {
28224
- const controller = new AbortController;
28225
- const state = {};
28226
- handleStreamEnd(stream2, controller, state);
28227
- try {
28228
- for await (const [chunk] of nodeImports.on(stream2, "data", { signal: controller.signal })) {
28229
- yield chunk;
28230
- }
28231
- } catch (error2) {
28232
- if (state.error !== undefined) {
28233
- throw state.error;
28234
- } else if (!controller.signal.aborted) {
28235
- throw error2;
28236
- }
28237
- } finally {
28238
- stream2.destroy();
28239
- }
28240
- }, handleStreamEnd = async (stream2, controller, state) => {
28241
- try {
28242
- await nodeImports.finished(stream2, {
28243
- cleanup: true,
28244
- readable: true,
28245
- writable: false,
28246
- error: false
28247
- });
28248
- } catch (error2) {
28249
- state.error = error2;
28250
- } finally {
28251
- controller.abort();
28252
- }
28253
- }, nodeImports;
28072
+ var toString2, nodeImports;
28254
28073
  var init_stream = __esm(() => {
28255
28074
  init_ponyfill();
28256
28075
  ({ toString: toString2 } = Object.prototype);
28257
28076
  nodeImports = {};
28258
28077
  });
28259
28078
 
28260
- // ../../node_modules/get-stream/source/contents.js
28261
- var getStreamContents = async (stream2, { init: init2, convertChunk, getSize, truncateChunk, addChunk, getFinalChunk, finalize }, { maxBuffer = Number.POSITIVE_INFINITY } = {}) => {
28262
- const asyncIterable = getAsyncIterable(stream2);
28263
- const state = init2();
28264
- state.length = 0;
28265
- try {
28266
- for await (const chunk of asyncIterable) {
28267
- const chunkType = getChunkType(chunk);
28268
- const convertedChunk = convertChunk[chunkType](chunk, state);
28269
- appendChunk({
28270
- convertedChunk,
28271
- state,
28272
- getSize,
28273
- truncateChunk,
28274
- addChunk,
28275
- maxBuffer
28276
- });
28277
- }
28278
- appendFinalChunk({
28279
- state,
28280
- convertChunk,
28281
- getSize,
28282
- truncateChunk,
28283
- addChunk,
28284
- getFinalChunk,
28285
- maxBuffer
28286
- });
28287
- return finalize(state);
28288
- } catch (error2) {
28289
- const normalizedError = typeof error2 === "object" && error2 !== null ? error2 : new Error(error2);
28290
- normalizedError.bufferedData = finalize(state);
28291
- throw normalizedError;
28292
- }
28293
- }, appendFinalChunk = ({ state, getSize, truncateChunk, addChunk, getFinalChunk, maxBuffer }) => {
28294
- const convertedChunk = getFinalChunk(state);
28295
- if (convertedChunk !== undefined) {
28296
- appendChunk({
28297
- convertedChunk,
28298
- state,
28299
- getSize,
28300
- truncateChunk,
28301
- addChunk,
28302
- maxBuffer
28303
- });
28304
- }
28305
- }, appendChunk = ({ convertedChunk, state, getSize, truncateChunk, addChunk, maxBuffer }) => {
28306
- const chunkSize = getSize(convertedChunk);
28307
- const newLength = state.length + chunkSize;
28308
- if (newLength <= maxBuffer) {
28309
- addNewChunk(convertedChunk, state, addChunk, newLength);
28310
- return;
28311
- }
28312
- const truncatedChunk = truncateChunk(convertedChunk, maxBuffer - state.length);
28313
- if (truncatedChunk !== undefined) {
28314
- addNewChunk(truncatedChunk, state, addChunk, maxBuffer);
28315
- }
28316
- throw new MaxBufferError;
28317
- }, addNewChunk = (convertedChunk, state, addChunk, newLength) => {
28318
- state.contents = addChunk(convertedChunk, state, newLength);
28319
- state.length = newLength;
28320
- }, getChunkType = (chunk) => {
28321
- const typeOfChunk = typeof chunk;
28322
- if (typeOfChunk === "string") {
28323
- return "string";
28324
- }
28325
- if (typeOfChunk !== "object" || chunk === null) {
28326
- return "others";
28327
- }
28328
- if (globalThis.Buffer?.isBuffer(chunk)) {
28329
- return "buffer";
28330
- }
28331
- const prototypeName = objectToString2.call(chunk);
28332
- if (prototypeName === "[object ArrayBuffer]") {
28333
- return "arrayBuffer";
28334
- }
28335
- if (prototypeName === "[object DataView]") {
28336
- return "dataView";
28337
- }
28338
- if (Number.isInteger(chunk.byteLength) && Number.isInteger(chunk.byteOffset) && objectToString2.call(chunk.buffer) === "[object ArrayBuffer]") {
28339
- return "typedArray";
28340
- }
28341
- return "others";
28342
- }, objectToString2, MaxBufferError;
28343
- var init_contents = __esm(() => {
28344
- init_stream();
28345
- ({ toString: objectToString2 } = Object.prototype);
28346
- MaxBufferError = class MaxBufferError extends Error {
28347
- name = "MaxBufferError";
28348
- constructor() {
28349
- super("maxBuffer exceeded");
28350
- }
28351
- };
28352
- });
28353
-
28354
- // ../../node_modules/get-stream/source/utils.js
28355
- var identity2 = (value) => value, noop5 = () => {
28356
- return;
28357
- }, getContentsProperty = ({ contents }) => contents, throwObjectStream = (chunk) => {
28358
- throw new Error(`Streams in object mode are not supported: ${String(chunk)}`);
28359
- }, getLengthProperty = (convertedChunk) => convertedChunk.length;
28360
-
28361
- // ../../node_modules/get-stream/source/array.js
28362
- async function getStreamAsArray(stream2, options3) {
28363
- return getStreamContents(stream2, arrayMethods, options3);
28364
- }
28365
- var initArray = () => ({ contents: [] }), increment = () => 1, addArrayChunk = (convertedChunk, { contents }) => {
28366
- contents.push(convertedChunk);
28367
- return contents;
28368
- }, arrayMethods;
28369
- var init_array = __esm(() => {
28370
- init_contents();
28371
- arrayMethods = {
28372
- init: initArray,
28373
- convertChunk: {
28374
- string: identity2,
28375
- buffer: identity2,
28376
- arrayBuffer: identity2,
28377
- dataView: identity2,
28378
- typedArray: identity2,
28379
- others: identity2
28380
- },
28381
- getSize: increment,
28382
- truncateChunk: noop5,
28383
- addChunk: addArrayChunk,
28384
- getFinalChunk: noop5,
28385
- finalize: getContentsProperty
28386
- };
28387
- });
28388
-
28389
- // ../../node_modules/get-stream/source/array-buffer.js
28390
- async function getStreamAsArrayBuffer(stream2, options3) {
28391
- return getStreamContents(stream2, arrayBufferMethods, options3);
28392
- }
28393
- var initArrayBuffer = () => ({ contents: new ArrayBuffer(0) }), useTextEncoder = (chunk) => textEncoder2.encode(chunk), textEncoder2, useUint8Array = (chunk) => new Uint8Array(chunk), useUint8ArrayWithOffset = (chunk) => new Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength), truncateArrayBufferChunk = (convertedChunk, chunkSize) => convertedChunk.slice(0, chunkSize), addArrayBufferChunk = (convertedChunk, { contents, length: previousLength }, length) => {
28394
- const newContents = hasArrayBufferResize() ? resizeArrayBuffer(contents, length) : resizeArrayBufferSlow(contents, length);
28395
- new Uint8Array(newContents).set(convertedChunk, previousLength);
28396
- return newContents;
28397
- }, resizeArrayBufferSlow = (contents, length) => {
28398
- if (length <= contents.byteLength) {
28399
- return contents;
28400
- }
28401
- const arrayBuffer = new ArrayBuffer(getNewContentsLength(length));
28402
- new Uint8Array(arrayBuffer).set(new Uint8Array(contents), 0);
28403
- return arrayBuffer;
28404
- }, resizeArrayBuffer = (contents, length) => {
28405
- if (length <= contents.maxByteLength) {
28406
- contents.resize(length);
28407
- return contents;
28408
- }
28409
- const arrayBuffer = new ArrayBuffer(length, { maxByteLength: getNewContentsLength(length) });
28410
- new Uint8Array(arrayBuffer).set(new Uint8Array(contents), 0);
28411
- return arrayBuffer;
28412
- }, getNewContentsLength = (length) => SCALE_FACTOR ** Math.ceil(Math.log(length) / Math.log(SCALE_FACTOR)), SCALE_FACTOR = 2, finalizeArrayBuffer = ({ contents, length }) => hasArrayBufferResize() ? contents : contents.slice(0, length), hasArrayBufferResize = () => ("resize" in ArrayBuffer.prototype), arrayBufferMethods;
28413
- var init_array_buffer = __esm(() => {
28414
- init_contents();
28415
- textEncoder2 = new TextEncoder;
28416
- arrayBufferMethods = {
28417
- init: initArrayBuffer,
28418
- convertChunk: {
28419
- string: useTextEncoder,
28420
- buffer: useUint8Array,
28421
- arrayBuffer: useUint8Array,
28422
- dataView: useUint8ArrayWithOffset,
28423
- typedArray: useUint8ArrayWithOffset,
28424
- others: throwObjectStream
28425
- },
28426
- getSize: getLengthProperty,
28427
- truncateChunk: truncateArrayBufferChunk,
28428
- addChunk: addArrayBufferChunk,
28429
- getFinalChunk: noop5,
28430
- finalize: finalizeArrayBuffer
28431
- };
28432
- });
28433
-
28434
- // ../../node_modules/get-stream/source/buffer.js
28435
- var init_buffer = __esm(() => {
28436
- init_array_buffer();
28437
- });
28438
-
28439
- // ../../node_modules/get-stream/source/string.js
28440
- async function getStreamAsString(stream2, options3) {
28441
- return getStreamContents(stream2, stringMethods, options3);
28442
- }
28443
- var initString = () => ({ contents: "", textDecoder: new TextDecoder }), useTextDecoder = (chunk, { textDecoder: textDecoder2 }) => textDecoder2.decode(chunk, { stream: true }), addStringChunk = (convertedChunk, { contents }) => contents + convertedChunk, truncateStringChunk = (convertedChunk, chunkSize) => convertedChunk.slice(0, chunkSize), getFinalStringChunk = ({ textDecoder: textDecoder2 }) => {
28444
- const finalChunk = textDecoder2.decode();
28445
- return finalChunk === "" ? undefined : finalChunk;
28446
- }, stringMethods;
28447
- var init_string = __esm(() => {
28448
- init_contents();
28449
- stringMethods = {
28450
- init: initString,
28451
- convertChunk: {
28452
- string: identity2,
28453
- buffer: useTextDecoder,
28454
- arrayBuffer: useTextDecoder,
28455
- dataView: useTextDecoder,
28456
- typedArray: useTextDecoder,
28457
- others: throwObjectStream
28458
- },
28459
- getSize: getLengthProperty,
28460
- truncateChunk: truncateStringChunk,
28461
- addChunk: addStringChunk,
28462
- getFinalChunk: getFinalStringChunk,
28463
- finalize: getContentsProperty
28464
- };
28465
- });
28466
-
28467
- // ../../node_modules/get-stream/source/exports.js
28468
- var init_exports = __esm(() => {
28469
- init_array();
28470
- init_array_buffer();
28471
- init_buffer();
28472
- init_string();
28473
- init_contents();
28474
- });
28475
-
28476
28079
  // ../../node_modules/get-stream/source/index.js
28477
28080
  import { on } from "node:events";
28478
28081
  import { finished } from "node:stream/promises";
28479
28082
  var init_source5 = __esm(() => {
28480
28083
  init_stream();
28481
- init_exports();
28482
28084
  Object.assign(nodeImports, { on, finished });
28483
28085
  });
28484
28086
 
@@ -29242,7 +28844,7 @@ var init_normalize = __esm(() => {
29242
28844
  });
29243
28845
 
29244
28846
  // ../../node_modules/execa/lib/stdio/direction.js
29245
- import process11 from "node:process";
28847
+ import process10 from "node:process";
29246
28848
  var getStreamDirection = (stdioItems, fdNumber, optionName) => {
29247
28849
  const directions = stdioItems.map((stdioItem) => getStdioItemDirection(stdioItem, fdNumber));
29248
28850
  if (directions.includes("input") && directions.includes("output")) {
@@ -29252,10 +28854,10 @@ var getStreamDirection = (stdioItems, fdNumber, optionName) => {
29252
28854
  }, getStdioItemDirection = ({ type, value }, fdNumber) => KNOWN_DIRECTIONS[fdNumber] ?? guessStreamDirection[type](value), KNOWN_DIRECTIONS, anyDirection = () => {
29253
28855
  return;
29254
28856
  }, alwaysInput = () => "input", guessStreamDirection, getStandardStreamDirection = (value) => {
29255
- if ([0, process11.stdin].includes(value)) {
28857
+ if ([0, process10.stdin].includes(value)) {
29256
28858
  return "input";
29257
28859
  }
29258
- if ([1, 2, process11.stdout, process11.stderr].includes(value)) {
28860
+ if ([1, 2, process10.stdout, process10.stderr].includes(value)) {
29259
28861
  return "output";
29260
28862
  }
29261
28863
  }, DEFAULT_DIRECTION = "output";
@@ -29834,11 +29436,11 @@ var getEncodingTransformGenerator = (binary, encoding, skipped) => {
29834
29436
  transform: encodingStringGenerator.bind(undefined, stringDecoder),
29835
29437
  final: encodingStringFinal.bind(undefined, stringDecoder)
29836
29438
  };
29837
- }, encodingUint8ArrayGenerator = function* (textEncoder3, chunk) {
29439
+ }, encodingUint8ArrayGenerator = function* (textEncoder2, chunk) {
29838
29440
  if (Buffer5.isBuffer(chunk)) {
29839
29441
  yield bufferToUint8Array(chunk);
29840
29442
  } else if (typeof chunk === "string") {
29841
- yield textEncoder3.encode(chunk);
29443
+ yield textEncoder2.encode(chunk);
29842
29444
  } else {
29843
29445
  yield chunk;
29844
29446
  }
@@ -30148,13 +29750,13 @@ var transformOutputSync = ({ fileDescriptors, syncResult: { output }, options: o
30148
29750
  state.error ??= error2;
30149
29751
  }
30150
29752
  }, writeToFiles = (serializedResult, stdioItems, outputFiles) => {
30151
- for (const { path: path10, append } of stdioItems.filter(({ type }) => FILE_TYPES.has(type))) {
30152
- const pathString = typeof path10 === "string" ? path10 : path10.toString();
29753
+ for (const { path: path9, append } of stdioItems.filter(({ type }) => FILE_TYPES.has(type))) {
29754
+ const pathString = typeof path9 === "string" ? path9 : path9.toString();
30153
29755
  if (append || outputFiles.has(pathString)) {
30154
- appendFileSync(path10, serializedResult);
29756
+ appendFileSync(path9, serializedResult);
30155
29757
  } else {
30156
29758
  outputFiles.add(pathString);
30157
- writeFileSync(path10, serializedResult);
29759
+ writeFileSync(path9, serializedResult);
30158
29760
  }
30159
29761
  }
30160
29762
  };
@@ -30520,13 +30122,13 @@ var init_get_each = __esm(() => {
30520
30122
  });
30521
30123
 
30522
30124
  // ../../node_modules/execa/lib/ipc/methods.js
30523
- import process12 from "node:process";
30125
+ import process11 from "node:process";
30524
30126
  var addIpcMethods = (subprocess, { ipc }) => {
30525
30127
  Object.assign(subprocess, getIpcMethods(subprocess, false, ipc));
30526
30128
  }, getIpcExport = () => {
30527
- const anyProcess = process12;
30129
+ const anyProcess = process11;
30528
30130
  const isSubprocess = true;
30529
- const ipc = process12.channel !== undefined;
30131
+ const ipc = process11.channel !== undefined;
30530
30132
  return {
30531
30133
  ...getIpcMethods(anyProcess, isSubprocess, ipc),
30532
30134
  getCancelSignal: getCancelSignal.bind(undefined, {
@@ -30808,13 +30410,13 @@ var getHighWaterMark = (streams, objectMode) => {
30808
30410
  }
30809
30411
  }, errorStream = (stream2, error2) => {
30810
30412
  if (!stream2.destroyed) {
30811
- stream2.once("error", noop6);
30413
+ stream2.once("error", noop5);
30812
30414
  stream2.destroy(error2);
30813
30415
  }
30814
- }, noop6 = () => {}, updateMaxListeners = (passThroughStream, increment2) => {
30416
+ }, noop5 = () => {}, updateMaxListeners = (passThroughStream, increment) => {
30815
30417
  const maxListeners = passThroughStream.getMaxListeners();
30816
30418
  if (maxListeners !== 0 && maxListeners !== Number.POSITIVE_INFINITY) {
30817
- passThroughStream.setMaxListeners(maxListeners + increment2);
30419
+ passThroughStream.setMaxListeners(maxListeners + increment);
30818
30420
  }
30819
30421
  }, PASSTHROUGH_LISTENERS_COUNT = 2, PASSTHROUGH_LISTENERS_PER_STREAM = 1;
30820
30422
  var init_merge_streams = __esm(() => {
@@ -31020,7 +30622,7 @@ class Emitter {
31020
30622
 
31021
30623
  class SignalExitBase {
31022
30624
  }
31023
- var processOk = (process13) => !!process13 && typeof process13 === "object" && typeof process13.removeListener === "function" && typeof process13.emit === "function" && typeof process13.reallyExit === "function" && typeof process13.listeners === "function" && typeof process13.kill === "function" && typeof process13.pid === "number" && typeof process13.on === "function", kExitEmitter, global2, ObjectDefineProperty, signalExitWrap = (handler) => {
30625
+ var processOk = (process12) => !!process12 && typeof process12 === "object" && typeof process12.removeListener === "function" && typeof process12.emit === "function" && typeof process12.reallyExit === "function" && typeof process12.listeners === "function" && typeof process12.kill === "function" && typeof process12.pid === "number" && typeof process12.on === "function", kExitEmitter, global2, ObjectDefineProperty, signalExitWrap = (handler) => {
31024
30626
  return {
31025
30627
  onExit(cb, opts) {
31026
30628
  return handler.onExit(cb, opts);
@@ -31032,7 +30634,7 @@ var processOk = (process13) => !!process13 && typeof process13 === "object" && t
31032
30634
  return handler.unload();
31033
30635
  }
31034
30636
  };
31035
- }, SignalExitFallback, SignalExit, process13, onExit, load, unload;
30637
+ }, SignalExitFallback, SignalExit, process12, onExit, load, unload;
31036
30638
  var init_mjs = __esm(() => {
31037
30639
  init_signals2();
31038
30640
  kExitEmitter = Symbol.for("signal-exit emitter");
@@ -31046,22 +30648,22 @@ var init_mjs = __esm(() => {
31046
30648
  unload() {}
31047
30649
  };
31048
30650
  SignalExit = class SignalExit extends SignalExitBase {
31049
- #hupSig = process13.platform === "win32" ? "SIGINT" : "SIGHUP";
30651
+ #hupSig = process12.platform === "win32" ? "SIGINT" : "SIGHUP";
31050
30652
  #emitter = new Emitter;
31051
30653
  #process;
31052
30654
  #originalProcessEmit;
31053
30655
  #originalProcessReallyExit;
31054
30656
  #sigListeners = {};
31055
30657
  #loaded = false;
31056
- constructor(process13) {
30658
+ constructor(process12) {
31057
30659
  super();
31058
- this.#process = process13;
30660
+ this.#process = process12;
31059
30661
  this.#sigListeners = {};
31060
30662
  for (const sig of signals) {
31061
30663
  this.#sigListeners[sig] = () => {
31062
30664
  const listeners = this.#process.listeners(sig);
31063
30665
  let { count: count2 } = this.#emitter;
31064
- const p2 = process13;
30666
+ const p2 = process12;
31065
30667
  if (typeof p2.__signal_exit_emitter__ === "object" && typeof p2.__signal_exit_emitter__.count === "number") {
31066
30668
  count2 += p2.__signal_exit_emitter__.count;
31067
30669
  }
@@ -31070,12 +30672,12 @@ var init_mjs = __esm(() => {
31070
30672
  const ret = this.#emitter.emit("exit", null, sig);
31071
30673
  const s2 = sig === "SIGHUP" ? this.#hupSig : sig;
31072
30674
  if (!ret)
31073
- process13.kill(process13.pid, s2);
30675
+ process12.kill(process12.pid, s2);
31074
30676
  }
31075
30677
  };
31076
30678
  }
31077
- this.#originalProcessReallyExit = process13.reallyExit;
31078
- this.#originalProcessEmit = process13.emit;
30679
+ this.#originalProcessReallyExit = process12.reallyExit;
30680
+ this.#originalProcessEmit = process12.emit;
31079
30681
  }
31080
30682
  onExit(cb, opts) {
31081
30683
  if (!processOk(this.#process)) {
@@ -31153,12 +30755,12 @@ var init_mjs = __esm(() => {
31153
30755
  }
31154
30756
  }
31155
30757
  };
31156
- process13 = globalThis.process;
30758
+ process12 = globalThis.process;
31157
30759
  ({
31158
30760
  onExit,
31159
30761
  load,
31160
30762
  unload
31161
- } = signalExitWrap(processOk(process13) ? new SignalExit(process13) : new SignalExitFallback));
30763
+ } = signalExitWrap(processOk(process12) ? new SignalExit(process12) : new SignalExitFallback));
31162
30764
  });
31163
30765
 
31164
30766
  // ../../node_modules/execa/lib/terminate/cleanup.js
@@ -31544,7 +31146,7 @@ var getStreamOutput = async ({ stream: stream2, onStreamEnd, fdNumber, encoding,
31544
31146
  allMixed
31545
31147
  });
31546
31148
  const [output] = await Promise.all([
31547
- getStreamContents2({
31149
+ getStreamContents({
31548
31150
  stream: stream2,
31549
31151
  iterable,
31550
31152
  fdNumber,
@@ -31578,7 +31180,7 @@ var getStreamOutput = async ({ stream: stream2, onStreamEnd, fdNumber, encoding,
31578
31180
  if (stream2.readableFlowing === null) {
31579
31181
  stream2.resume();
31580
31182
  }
31581
- }, getStreamContents2 = async ({ stream: stream2, stream: { readableObjectMode }, iterable, fdNumber, encoding, maxBuffer, lines: lines2 }) => {
31183
+ }, getStreamContents = async ({ stream: stream2, stream: { readableObjectMode }, iterable, fdNumber, encoding, maxBuffer, lines: lines2 }) => {
31582
31184
  try {
31583
31185
  if (readableObjectMode || lines2) {
31584
31186
  return await getStreamAsArray(iterable, { maxBuffer });
@@ -31586,7 +31188,7 @@ var getStreamOutput = async ({ stream: stream2, onStreamEnd, fdNumber, encoding,
31586
31188
  if (encoding === "buffer") {
31587
31189
  return new Uint8Array(await getStreamAsArrayBuffer(iterable, { maxBuffer }));
31588
31190
  }
31589
- return await getStreamAsString(iterable, { maxBuffer });
31191
+ return await default4(iterable, { maxBuffer });
31590
31192
  } catch (error2) {
31591
31193
  return handleBufferedData(handleMaxBuffer({
31592
31194
  error: error2,
@@ -31604,7 +31206,7 @@ var getStreamOutput = async ({ stream: stream2, onStreamEnd, fdNumber, encoding,
31604
31206
  return handleBufferedData(error2);
31605
31207
  }
31606
31208
  }, handleBufferedData = ({ bufferedData }) => isArrayBuffer(bufferedData) ? new Uint8Array(bufferedData) : bufferedData;
31607
- var init_contents2 = __esm(() => {
31209
+ var init_contents = __esm(() => {
31608
31210
  init_source5();
31609
31211
  init_uint_array();
31610
31212
  init_output2();
@@ -31699,7 +31301,7 @@ var waitForStdioStreams = ({ subprocess, encoding, buffer: buffer2, maxBuffer, l
31699
31301
  return output;
31700
31302
  };
31701
31303
  var init_stdio = __esm(() => {
31702
- init_contents2();
31304
+ init_contents();
31703
31305
  init_wait_stream();
31704
31306
  });
31705
31307
 
@@ -31909,7 +31511,7 @@ var init_wait_subprocess = __esm(() => {
31909
31511
  init_graceful2();
31910
31512
  init_standard_stream();
31911
31513
  init_type();
31912
- init_contents2();
31514
+ init_contents();
31913
31515
  init_buffer_messages();
31914
31516
  init_ipc_input();
31915
31517
  init_all_async();
@@ -32557,8 +32159,8 @@ var init_execa = __esm(() => {
32557
32159
  });
32558
32160
 
32559
32161
  // src/utils/dependencies.ts
32560
- import { promises as fs7 } from "fs";
32561
- import path10 from "path";
32162
+ import { promises as fs6 } from "fs";
32163
+ import path9 from "path";
32562
32164
  async function getPackageManager(targetDir) {
32563
32165
  const packageManager = await detect2({ programmatic: true, cwd: targetDir });
32564
32166
  if (packageManager === "yarn@berry")
@@ -32573,16 +32175,16 @@ async function getPackageManager(targetDir) {
32573
32175
  }
32574
32176
  async function hasPackageJson(targetDir) {
32575
32177
  try {
32576
- const packageJsonPath = path10.join(targetDir, "package.json");
32577
- await fs7.access(packageJsonPath);
32178
+ const packageJsonPath = path9.join(targetDir, "package.json");
32179
+ await fs6.access(packageJsonPath);
32578
32180
  return true;
32579
32181
  } catch {
32580
32182
  return false;
32581
32183
  }
32582
32184
  }
32583
32185
  async function readPackageJson(targetDir) {
32584
- const packageJsonPath = path10.join(targetDir, "package.json");
32585
- const content = await fs7.readFile(packageJsonPath, "utf-8");
32186
+ const packageJsonPath = path9.join(targetDir, "package.json");
32187
+ const content = await fs6.readFile(packageJsonPath, "utf-8");
32586
32188
  return JSON.parse(content);
32587
32189
  }
32588
32190
  async function getMissingDependenciesFor(targetDir, requiredDeps) {
@@ -32635,7 +32237,7 @@ __export(exports_generate, {
32635
32237
  resolveContract: () => resolveContract,
32636
32238
  generate: () => generate
32637
32239
  });
32638
- import path11 from "path";
32240
+ import path10 from "path";
32639
32241
  import { toCamelCase as toCamelCase7 } from "@secondlayer/stacks/clarity";
32640
32242
  import { getErrorMessage as getErrorMessage2 } from "@secondlayer/shared";
32641
32243
  function isContractAddress(input4) {
@@ -32660,7 +32262,7 @@ async function parseInputs(inputs) {
32660
32262
  continue;
32661
32263
  }
32662
32264
  if (input4.endsWith(".clar")) {
32663
- const absolutePath = path11.resolve(process.cwd(), input4);
32265
+ const absolutePath = path10.resolve(process.cwd(), input4);
32664
32266
  files.push(absolutePath);
32665
32267
  }
32666
32268
  }
@@ -32670,10 +32272,10 @@ async function parseInputs(inputs) {
32670
32272
  };
32671
32273
  }
32672
32274
  function deriveContractName(filePath) {
32673
- const basename = path11.basename(filePath, ".clar");
32275
+ const basename = path10.basename(filePath, ".clar");
32674
32276
  return basename.replace(/[-_](.)/g, (_2, char) => char.toUpperCase()).replace(/^(.)/, (_2, char) => char.toLowerCase()).replace(/^\d/, "_$&");
32675
32277
  }
32676
- async function buildConfigFromInputs(parsedInputs, outPath, apiKey, defaultAddress) {
32278
+ async function buildConfigFromInputs(parsedInputs, outPath, apiKey, defaultAddress, nodeRpcUrl) {
32677
32279
  const contracts = [];
32678
32280
  const deployer = defaultAddress || DEFAULT_DEVNET_ADDRESS;
32679
32281
  if (parsedInputs.files.length > 0 && !defaultAddress) {
@@ -32695,7 +32297,7 @@ async function buildConfigFromInputs(parsedInputs, outPath, apiKey, defaultAddre
32695
32297
  const { address, contractName } = parseContractId(contractId);
32696
32298
  const network = inferNetwork(address) ?? "mainnet";
32697
32299
  try {
32698
- const apiClient = new StacksApiClient(network, apiKey);
32300
+ const apiClient = new StacksApiClient(network, apiKey, nodeRpcUrl);
32699
32301
  const contractInfo = await apiClient.getContractInfo(contractId);
32700
32302
  const abi = parseApiResponse(contractInfo);
32701
32303
  const name = toCamelCase7(contractName);
@@ -32738,7 +32340,8 @@ No .clar files or contract addresses matched the provided inputs`));
32738
32340
  process.exit(1);
32739
32341
  }
32740
32342
  const apiKey = options3.apiKey || process.env.HIRO_API_KEY;
32741
- config = await buildConfigFromInputs(parsedInputs, options3.out, apiKey);
32343
+ const cliConfig = await loadConfig();
32344
+ config = await buildConfigFromInputs(parsedInputs, options3.out, apiKey, undefined, cliConfig.nodeRpcUrl);
32742
32345
  } else {
32743
32346
  config = await loadConfig2(options3.config);
32744
32347
  }
@@ -32797,9 +32400,9 @@ ${getErrorMessage2(error2)}`));
32797
32400
  }
32798
32401
  async function resolveContract(source, network, apiKey, apiUrl) {
32799
32402
  if (source.source) {
32800
- const filePath = path11.resolve(process.cwd(), source.source);
32403
+ const filePath = path10.resolve(process.cwd(), source.source);
32801
32404
  const abi = await parseClarityFile(filePath);
32802
- const name = source.name || path11.basename(source.source, ".clar").replace(/-/g, "_").replace(/^\d/, "_$&");
32405
+ const name = source.name || path10.basename(source.source, ".clar").replace(/-/g, "_").replace(/^\d/, "_$&");
32803
32406
  const address = typeof source.address === "string" ? source.address : source.address?.[network] || DEFAULT_DEVNET_ADDRESS;
32804
32407
  const { address: contractAddress, contractName } = address.includes(".") ? parseContractId(address) : { address, contractName: name };
32805
32408
  return {
@@ -32867,6 +32470,7 @@ var import_fast_glob, DEFAULT_DEVNET_ADDRESS = "ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZ
32867
32470
  var init_generate = __esm(() => {
32868
32471
  init_source4();
32869
32472
  init_config2();
32473
+ init_config();
32870
32474
  init_api();
32871
32475
  init_clarity();
32872
32476
  init_contract();
@@ -32880,12 +32484,12 @@ var exports_init = {};
32880
32484
  __export(exports_init, {
32881
32485
  init: () => init2
32882
32486
  });
32883
- import { promises as fs8 } from "fs";
32884
- import path12 from "path";
32487
+ import { promises as fs7 } from "fs";
32488
+ import path11 from "path";
32885
32489
  async function init2() {
32886
- const configPath = path12.join(process.cwd(), "secondlayer.config.ts");
32490
+ const configPath = path11.join(process.cwd(), "secondlayer.config.ts");
32887
32491
  try {
32888
- await fs8.access(configPath);
32492
+ await fs7.access(configPath);
32889
32493
  console.log(source_default3.yellow("⚠ secondlayer.config.ts already exists"));
32890
32494
  return;
32891
32495
  } catch {}
@@ -32909,13 +32513,13 @@ export default defineConfig({
32909
32513
  plugins: [],
32910
32514
  });`;
32911
32515
  }
32912
- await fs8.writeFile(configPath, config);
32516
+ await fs7.writeFile(configPath, config);
32913
32517
  console.log(source_default3.green("✓ Created `secondlayer.config.ts`"));
32914
32518
  console.log("\nRun `secondlayer generate` to generate type-safe interfaces, functions, and hooks!");
32915
32519
  }
32916
32520
  async function fileExists2(filePath) {
32917
32521
  try {
32918
- await fs8.access(filePath);
32522
+ await fs7.access(filePath);
32919
32523
  return true;
32920
32524
  } catch {
32921
32525
  return false;
@@ -32943,8 +32547,8 @@ var {
32943
32547
  // package.json
32944
32548
  var package_default = {
32945
32549
  name: "@secondlayer/cli",
32946
- version: "1.5.1",
32947
- description: "CLI for streams, views, and real-time blockchain indexing on Stacks",
32550
+ version: "1.6.1",
32551
+ description: "CLI for streams, subgraphs, and real-time blockchain indexing on Stacks",
32948
32552
  type: "module",
32949
32553
  bin: {
32950
32554
  secondlayer: "./dist/cli.js",
@@ -32984,10 +32588,10 @@ var package_default = {
32984
32588
  license: "MIT",
32985
32589
  dependencies: {
32986
32590
  "@inquirer/prompts": "^8.2.0",
32987
- "@secondlayer/sdk": "^0.5.0",
32988
- "@secondlayer/shared": "^0.4.0",
32591
+ "@secondlayer/sdk": "^0.6.0",
32592
+ "@secondlayer/shared": "^0.5.0",
32989
32593
  "@secondlayer/stacks": "^0.2.0",
32990
- "@secondlayer/views": "^0.3.0",
32594
+ "@secondlayer/subgraphs": "^0.5.0",
32991
32595
  "@biomejs/js-api": "^0.7.0",
32992
32596
  "@biomejs/wasm-nodejs": "^1.9.0",
32993
32597
  esbuild: "^0.19.0",
@@ -33335,7 +32939,7 @@ async function printConfigTree(cfg) {
33335
32939
  console.log(blue("ports:"));
33336
32940
  printValue(" api", cfg.ports.api, cfg.ports.api === defaults.ports.api, 2);
33337
32941
  printValue(" indexer", cfg.ports.indexer, cfg.ports.indexer === defaults.ports.indexer, 2);
33338
- printValue(" webhook", cfg.ports.webhook, cfg.ports.webhook === defaults.ports.webhook, 2);
32942
+ printValue(" receiver", cfg.ports.receiver, cfg.ports.receiver === defaults.ports.receiver, 2);
33339
32943
  console.log("");
33340
32944
  console.log(blue("database:"));
33341
32945
  printValue(" type", cfg.database.type, cfg.database.type === "docker", 2);
@@ -33381,13 +32985,13 @@ import { select as select2, input, confirm } from "@inquirer/prompts";
33381
32985
  init_config();
33382
32986
  var STREAMS_DIR = "streams";
33383
32987
  function registerSetupCommand(program2) {
33384
- program2.command("setup").description("Set up a streams project and configure settings").option("--detect-only", "Only detect existing Stacks nodes, don't initialize").option("-y, --yes", "Use defaults without prompts").option("--data-dir <path>", "Data directory path").option("--node-path <path>", "Path to Stacks node").option("--network <network>", "Network (local, testnet, or mainnet)").option("--webhook-url <url>", "Default webhook URL for new streams").action(async (options) => {
32988
+ program2.command("setup").description("Set up a streams project and configure settings").option("--detect-only", "Only detect existing Stacks nodes, don't initialize").option("-y, --yes", "Use defaults without prompts").option("--data-dir <path>", "Data directory path").option("--node-path <path>", "Path to Stacks node").option("--network <network>", "Network (local, testnet, or mainnet)").option("--endpoint-url <url>", "Default endpoint URL for new streams").action(async (options) => {
33385
32989
  try {
33386
32990
  if (options.detectOnly) {
33387
32991
  await runDetection();
33388
32992
  return;
33389
32993
  }
33390
- const hasFlags = options.yes || options.dataDir || options.nodePath || options.network || options.webhookUrl;
32994
+ const hasFlags = options.yes || options.dataDir || options.nodePath || options.network || options.endpointUrl;
33391
32995
  if (hasFlags) {
33392
32996
  await runNonInteractive(options);
33393
32997
  return;
@@ -33416,7 +33020,7 @@ async function runNonInteractive(options) {
33416
33020
  return;
33417
33021
  }
33418
33022
  config.dataDir = options.dataDir || config.dataDir || "~/.secondlayer/data";
33419
- config.defaultWebhookUrl = options.webhookUrl || config.defaultWebhookUrl;
33023
+ config.defaultEndpointUrl = options.endpointUrl || config.defaultEndpointUrl;
33420
33024
  if (options.nodePath) {
33421
33025
  config.node = {
33422
33026
  installPath: options.nodePath,
@@ -33460,8 +33064,8 @@ async function runWizard() {
33460
33064
  if (nodeConfig) {
33461
33065
  config.node = nodeConfig;
33462
33066
  }
33463
- const webhookUrl = await promptWebhookUrl(config);
33464
- config.defaultWebhookUrl = webhookUrl;
33067
+ const endpointUrl = await promptEndpointUrl(config);
33068
+ config.defaultEndpointUrl = endpointUrl;
33465
33069
  await saveConfig(config);
33466
33070
  await Bun.$`mkdir -p ${STREAMS_DIR}`.quiet();
33467
33071
  await Bun.write(`${STREAMS_DIR}/.gitkeep`, "");
@@ -33588,10 +33192,10 @@ async function promptNetwork() {
33588
33192
  });
33589
33193
  return network;
33590
33194
  }
33591
- async function promptWebhookUrl(config) {
33592
- const internalUrl = "http://localhost:3900/webhook";
33195
+ async function promptEndpointUrl(config) {
33196
+ const internalUrl = "http://localhost:3900/receiver";
33593
33197
  const choice = await select2({
33594
- message: "Default webhook URL for new streams?",
33198
+ message: "Default endpoint URL for new streams?",
33595
33199
  choices: [
33596
33200
  { name: `Internal test server (${internalUrl})`, value: "internal" },
33597
33201
  { name: "Custom URL...", value: "custom" }
@@ -33601,8 +33205,8 @@ async function promptWebhookUrl(config) {
33601
33205
  return internalUrl;
33602
33206
  }
33603
33207
  const customUrl = await input({
33604
- message: "Enter webhook URL:",
33605
- default: config.defaultWebhookUrl !== internalUrl ? config.defaultWebhookUrl : undefined,
33208
+ message: "Enter endpoint URL:",
33209
+ default: config.defaultEndpointUrl !== internalUrl ? config.defaultEndpointUrl : undefined,
33606
33210
  validate: (value) => {
33607
33211
  if (!value.trim())
33608
33212
  return "URL cannot be empty";
@@ -33700,8 +33304,8 @@ function printSummary(config) {
33700
33304
  console.log();
33701
33305
  console.log(" Settings:");
33702
33306
  console.log(` Data directory: ${config.dataDir}`);
33703
- if (config.defaultWebhookUrl) {
33704
- console.log(` Webhook URL: ${config.defaultWebhookUrl}`);
33307
+ if (config.defaultEndpointUrl) {
33308
+ console.log(` Endpoint URL: ${config.defaultEndpointUrl}`);
33705
33309
  }
33706
33310
  if (config.node) {
33707
33311
  console.log(` Node path: ${config.node.installPath}`);
@@ -33750,10 +33354,10 @@ function printNodeInfo(node) {
33750
33354
  import { join as join3 } from "node:path";
33751
33355
 
33752
33356
  // src/templates/stream.ts
33753
- function generateStreamTemplate(name, webhookUrl) {
33357
+ function generateStreamTemplate(name, endpointUrl) {
33754
33358
  return {
33755
33359
  name,
33756
- webhookUrl: webhookUrl || "https://example.com/webhook",
33360
+ endpointUrl: endpointUrl || "https://example.com/endpoint",
33757
33361
  filters: [
33758
33362
  {
33759
33363
  type: "contract_call",
@@ -33789,12 +33393,12 @@ function registerNewCommand(program2) {
33789
33393
  if (dir) {
33790
33394
  await ensureDir(dir);
33791
33395
  }
33792
- const template = generateStreamTemplate(name, config.defaultWebhookUrl);
33396
+ const template = generateStreamTemplate(name, config.defaultEndpointUrl);
33793
33397
  await writeTextFile(outputPath, JSON.stringify(template, null, 2) + `
33794
33398
  `);
33795
33399
  success(`Created ${outputPath}`);
33796
- if (!config.defaultWebhookUrl) {
33797
- warn("Edit the webhookUrl before registering — it must be a reachable HTTPS endpoint");
33400
+ if (!config.defaultEndpointUrl) {
33401
+ warn("Edit the endpointUrl before registering — it must be a reachable HTTPS endpoint");
33798
33402
  }
33799
33403
  console.log(`
33800
33404
  Edit the file to configure your stream, then run:`);
@@ -33857,7 +33461,7 @@ function registerGetCommand(program2) {
33857
33461
  ["ID", stream.id],
33858
33462
  ["Name", stream.name],
33859
33463
  ["Status", statusColor(stream.status)],
33860
- ["Webhook URL", stream.webhookUrl],
33464
+ ["Endpoint URL", stream.endpointUrl],
33861
33465
  ["Total Deliveries", stream.totalDeliveries.toString()],
33862
33466
  ["Failed Deliveries", stream.failedDeliveries.toString()],
33863
33467
  ["Last Triggered", stream.lastTriggeredAt || dim("never")],
@@ -33925,10 +33529,10 @@ function registerRegisterCommand(program2) {
33925
33529
  console.log(formatKeyValue([
33926
33530
  ["ID", result.stream.id],
33927
33531
  ["Name", result.stream.name],
33928
- ["Webhook Secret", result.webhookSecret]
33532
+ ["Signing Secret", result.signingSecret]
33929
33533
  ]));
33930
33534
  console.log(dim(`
33931
- Save the webhook secret - it won't be shown again!`));
33535
+ Save the signing secret - it won't be shown again!`));
33932
33536
  } catch (err) {
33933
33537
  handleApiError(err, "register stream");
33934
33538
  }
@@ -34424,12 +34028,12 @@ init_api_client();
34424
34028
  init_output();
34425
34029
  import { confirm as confirm3 } from "@inquirer/prompts";
34426
34030
  function registerRotateSecretCommand(program2) {
34427
- program2.command("rotate-secret <id>").description("Generate a new webhook secret for a stream").option("-y, --yes", "Skip confirmation prompt").action(async (id, options) => {
34031
+ program2.command("rotate-secret <id>").description("Generate a new signing secret for a stream").option("-y, --yes", "Skip confirmation prompt").action(async (id, options) => {
34428
34032
  try {
34429
34033
  const stream = await getStream(id);
34430
34034
  if (!options.yes) {
34431
34035
  const confirmed = await confirm3({
34432
- message: `Rotate webhook secret for "${stream.name}"? The current secret will be invalidated.`,
34036
+ message: `Rotate signing secret for "${stream.name}"? The current secret will be invalidated.`,
34433
34037
  default: false
34434
34038
  });
34435
34039
  if (!confirmed) {
@@ -34438,13 +34042,13 @@ function registerRotateSecretCommand(program2) {
34438
34042
  }
34439
34043
  }
34440
34044
  const result = await rotateSecret(stream.id);
34441
- success(`Rotated webhook secret for: ${stream.name}`);
34045
+ success(`Rotated signing secret for: ${stream.name}`);
34442
34046
  console.log(formatKeyValue([
34443
34047
  ["Stream", stream.name],
34444
- ["Webhook Secret", result.secret]
34048
+ ["Signing Secret", result.secret]
34445
34049
  ]));
34446
34050
  console.log(dim(`
34447
- Save the webhook secret - it won't be shown again!`));
34051
+ Save the signing secret - it won't be shown again!`));
34448
34052
  } catch (err) {
34449
34053
  handleApiError(err, "rotate secret");
34450
34054
  }
@@ -34566,11 +34170,11 @@ function printStatus(status) {
34566
34170
  [" Error", status.streams.error > 0 ? red(status.streams.error.toString()) : "0"]
34567
34171
  ]));
34568
34172
  console.log("");
34569
- if (status.activeViews !== undefined || status.recentDeliveries !== undefined) {
34173
+ if (status.activeSubgraphs !== undefined || status.recentDeliveries !== undefined) {
34570
34174
  console.log(blue("Activity"));
34571
34175
  const pairs = [];
34572
- if (status.activeViews !== undefined)
34573
- pairs.push([" Active Views", status.activeViews.toString()]);
34176
+ if (status.activeSubgraphs !== undefined)
34177
+ pairs.push([" Active Subgraphs", status.activeSubgraphs.toString()]);
34574
34178
  if (status.recentDeliveries !== undefined)
34575
34179
  pairs.push([" Deliveries (24h)", status.recentDeliveries.toString()]);
34576
34180
  console.log(formatKeyValue(pairs));
@@ -35127,15 +34731,15 @@ async function resyncDatabase(skipConfirm, backfill) {
35127
34731
  process.exit(1);
35128
34732
  }
35129
34733
  }
35130
- // src/commands/webhook.ts
34734
+ // src/commands/receiver.ts
35131
34735
  init_output();
35132
34736
  init_config();
35133
34737
  import { join as join5 } from "node:path";
35134
- function registerWebhookCommand(program2) {
35135
- const webhook = program2.command("webhook").description("Webhook development tools").hook("preAction", async () => {
34738
+ function registerReceiverCommand(program2) {
34739
+ const receiver = program2.command("receiver").description("Receiver development tools").hook("preAction", async () => {
35136
34740
  await requireLocalNetwork();
35137
34741
  });
35138
- webhook.command("init <directory>").description("Scaffold a webhook handler with types and signature verification").option("-n, --name <name>", "Stream name", "my-stream").option("--network <network>", "Network (mainnet/testnet)", "mainnet").option("-p, --port <port>", "Server port", "4000").action(async (directory, options) => {
34742
+ receiver.command("init <directory>").description("Scaffold a receiver handler with types and signature verification").option("-n, --name <name>", "Stream name", "my-stream").option("--network <network>", "Network (mainnet/testnet)", "mainnet").option("-p, --port <port>", "Server port", "4000").action(async (directory, options) => {
35139
34743
  try {
35140
34744
  const config = await loadConfig();
35141
34745
  const port = parseInt(options.port);
@@ -35149,13 +34753,13 @@ function registerWebhookCommand(program2) {
35149
34753
  await Bun.$`mkdir -p ${dir}`.quiet();
35150
34754
  await generateServerFile(dir, port);
35151
34755
  await generateTypesFile(dir);
35152
- await generateStreamJson(dir, options.name, network, port, config.defaultWebhookUrl);
34756
+ await generateStreamJson(dir, options.name, network, port, config.defaultEndpointUrl);
35153
34757
  await generateEnvFile(dir);
35154
34758
  await generatePackageJson(dir, options.name);
35155
- success(`Created webhook handler in ${directory}/`);
34759
+ success(`Created receiver handler in ${directory}/`);
35156
34760
  console.log("");
35157
34761
  console.log(" Files created:");
35158
- console.log(` ${dim("server.ts")} Webhook server with HMAC verification`);
34762
+ console.log(` ${dim("server.ts")} Receiver server with HMAC verification`);
35159
34763
  console.log(` ${dim("types.ts")} Payload type definitions`);
35160
34764
  console.log(` ${dim("stream.json")} Stream configuration`);
35161
34765
  console.log(` ${dim(".env")} Environment variables`);
@@ -35170,26 +34774,26 @@ function registerWebhookCommand(program2) {
35170
34774
  console.log(` sl streams register ${directory}/stream.json`);
35171
34775
  console.log("");
35172
34776
  } catch (err) {
35173
- error(`Failed to scaffold webhook: ${err}`);
34777
+ error(`Failed to scaffold receiver: ${err}`);
35174
34778
  process.exit(1);
35175
34779
  }
35176
34780
  });
35177
34781
  }
35178
34782
  async function generateServerFile(dir, port) {
35179
- const content = `import type { WebhookPayload } from "./types.ts";
34783
+ const content = `import type { DeliveryPayload } from "./types.ts";
35180
34784
 
35181
- const WEBHOOK_SECRET = process.env.STREAMS_WEBHOOK_SECRET;
34785
+ const SIGNING_SECRET = process.env.STREAMS_SIGNING_SECRET;
35182
34786
 
35183
34787
  /**
35184
34788
  * Verify HMAC signature from Stacks Streams
35185
34789
  */
35186
34790
  async function verifySignature(body: string, signature: string | null): Promise<boolean> {
35187
- if (!WEBHOOK_SECRET || !signature) return false;
34791
+ if (!SIGNING_SECRET || !signature) return false;
35188
34792
 
35189
34793
  const encoder = new TextEncoder();
35190
34794
  const key = await crypto.subtle.importKey(
35191
34795
  "raw",
35192
- encoder.encode(WEBHOOK_SECRET),
34796
+ encoder.encode(SIGNING_SECRET),
35193
34797
  { name: "HMAC", hash: "SHA-256" },
35194
34798
  false,
35195
34799
  ["sign"]
@@ -35202,9 +34806,9 @@ async function verifySignature(body: string, signature: string | null): Promise<
35202
34806
  }
35203
34807
 
35204
34808
  /**
35205
- * Handle incoming webhook payload
34809
+ * Handle incoming delivery payload
35206
34810
  */
35207
- async function handlePayload(payload: WebhookPayload): Promise<void> {
34811
+ async function handlePayload(payload: DeliveryPayload): Promise<void> {
35208
34812
  console.log(\`Block \${payload.block.height}: \${payload.matches.events.length} events\`);
35209
34813
 
35210
34814
  for (const event of payload.matches.events) {
@@ -35243,13 +34847,13 @@ Bun.serve({
35243
34847
  return new Response("ok");
35244
34848
  }
35245
34849
 
35246
- // Webhook endpoint
34850
+ // Receiver endpoint
35247
34851
  if (req.method === "POST" && url.pathname === "/payload") {
35248
34852
  const body = await req.text();
35249
34853
  const signature = req.headers.get("x-streams-signature");
35250
34854
 
35251
34855
  // Verify signature
35252
- if (WEBHOOK_SECRET) {
34856
+ if (SIGNING_SECRET) {
35253
34857
  const valid = await verifySignature(body, signature);
35254
34858
  if (!valid) {
35255
34859
  console.error("Invalid signature");
@@ -35258,7 +34862,7 @@ Bun.serve({
35258
34862
  }
35259
34863
 
35260
34864
  try {
35261
- const payload: WebhookPayload = JSON.parse(body);
34865
+ const payload: DeliveryPayload = JSON.parse(body);
35262
34866
  await handlePayload(payload);
35263
34867
  return new Response("ok");
35264
34868
  } catch (err) {
@@ -35271,18 +34875,18 @@ Bun.serve({
35271
34875
  },
35272
34876
  });
35273
34877
 
35274
- console.log(\`Webhook server listening on http://localhost:${port}/payload\`);
34878
+ console.log(\`Receiver server listening on http://localhost:${port}/payload\`);
35275
34879
  `;
35276
34880
  await Bun.write(join5(dir, "server.ts"), content);
35277
34881
  }
35278
34882
  async function generateTypesFile(dir) {
35279
34883
  const content = `/**
35280
- * Stacks Streams Webhook Payload Types
34884
+ * Stacks Streams Delivery Payload Types
35281
34885
  *
35282
34886
  * These types match the payload structure sent by Stacks Streams.
35283
34887
  */
35284
34888
 
35285
- export interface WebhookPayload {
34889
+ export interface DeliveryPayload {
35286
34890
  streamId: string;
35287
34891
  streamName: string;
35288
34892
  network: "mainnet" | "testnet";
@@ -35404,11 +35008,11 @@ export function isPrintEvent(event: EventMatch): event is PrintEvent {
35404
35008
  `;
35405
35009
  await Bun.write(join5(dir, "types.ts"), content);
35406
35010
  }
35407
- async function generateStreamJson(dir, name, network, port, _defaultWebhookUrl) {
35011
+ async function generateStreamJson(dir, name, network, port, _defaultEndpointUrl) {
35408
35012
  const content = {
35409
35013
  name,
35410
35014
  network,
35411
- webhookUrl: `http://localhost:${port}/payload`,
35015
+ endpointUrl: `http://localhost:${port}/payload`,
35412
35016
  filters: [
35413
35017
  {
35414
35018
  type: "stx_transfer",
@@ -35428,9 +35032,9 @@ async function generateStreamJson(dir, name, network, port, _defaultWebhookUrl)
35428
35032
  `);
35429
35033
  }
35430
35034
  async function generateEnvFile(dir) {
35431
- const content = `# Stacks Streams Webhook Secret
35035
+ const content = `# Stacks Streams Signing Secret
35432
35036
  # Get this from: sl streams register stream.json
35433
- STREAMS_WEBHOOK_SECRET=
35037
+ STREAMS_SIGNING_SECRET=
35434
35038
 
35435
35039
  # Add your database connection, etc.
35436
35040
  # DATABASE_URL=postgres://...
@@ -35439,7 +35043,7 @@ STREAMS_WEBHOOK_SECRET=
35439
35043
  }
35440
35044
  async function generatePackageJson(dir, name) {
35441
35045
  const content = {
35442
- name: `${name}-webhook`,
35046
+ name: `${name}-receiver`,
35443
35047
  version: "0.1.0",
35444
35048
  type: "module",
35445
35049
  scripts: {
@@ -35454,21 +35058,21 @@ async function generatePackageJson(dir, name) {
35454
35058
  await Bun.write(join5(dir, "package.json"), JSON.stringify(content, null, 2) + `
35455
35059
  `);
35456
35060
  }
35457
- // src/commands/views.ts
35061
+ // src/commands/subgraphs.ts
35458
35062
  init_output();
35459
35063
  import { resolve } from "node:path";
35460
35064
  import { existsSync, mkdirSync, watch } from "node:fs";
35461
35065
 
35462
- // src/templates/view.ts
35463
- function generateViewTemplate(name) {
35464
- return `import { defineView } from "@secondlayer/views";
35066
+ // src/templates/subgraph.ts
35067
+ function generateSubgraphTemplate(name) {
35068
+ return `import { defineSubgraph } from "@secondlayer/subgraphs";
35465
35069
 
35466
- export default defineView({
35070
+ export default defineSubgraph({
35467
35071
  name: "${name}",
35468
35072
  version: "1.0.0",
35469
- description: "TODO: describe what this view tracks",
35073
+ description: "TODO: describe what this subgraph tracks",
35470
35074
 
35471
- // Sources define what blockchain data this view processes.
35075
+ // Sources define what blockchain data this subgraph processes.
35472
35076
  // Each source filters transactions/events by contract, type, function, or event.
35473
35077
  // Examples:
35474
35078
  // { contract: "SP000...::my-contract" } — all txs to a contract
@@ -35479,7 +35083,7 @@ export default defineView({
35479
35083
  { contract: "SP000000000000000000002Q6VF78.pox-4" },
35480
35084
  ],
35481
35085
 
35482
- // Schema defines the tables this view creates.
35086
+ // Schema defines the tables this subgraph creates.
35483
35087
  // Each table gets auto-columns: _id, _block_height, _tx_id, _created_at.
35484
35088
  // Column types: text, uint, int, principal, boolean, timestamp, jsonb
35485
35089
  schema: {
@@ -35510,22 +35114,22 @@ export default defineView({
35510
35114
  `;
35511
35115
  }
35512
35116
 
35513
- // src/commands/views.ts
35117
+ // src/commands/subgraphs.ts
35514
35118
  init_api_client();
35515
35119
  init_config();
35516
35120
  init_fs();
35517
35121
 
35518
- // src/generators/view-scaffold.ts
35122
+ // src/generators/subgraph-scaffold.ts
35519
35123
  init_format();
35520
35124
 
35521
- // src/generators/clarity-to-view.ts
35125
+ // src/generators/clarity-to-subgraph.ts
35522
35126
  import {
35523
35127
  isAbiBuffer,
35524
35128
  isAbiStringAscii,
35525
35129
  isAbiStringUtf8,
35526
35130
  isAbiOptional
35527
35131
  } from "@secondlayer/stacks/clarity";
35528
- function clarityTypeToViewColumn(abiType) {
35132
+ function clarityTypeToSubgraphColumn(abiType) {
35529
35133
  return mapType(abiType, false);
35530
35134
  }
35531
35135
  function mapType(abiType, nullable) {
@@ -35565,19 +35169,19 @@ function mapType(abiType, nullable) {
35565
35169
  return { type: "jsonb", nullable };
35566
35170
  }
35567
35171
 
35568
- // src/generators/view-scaffold.ts
35569
- async function generateViewScaffold(input2) {
35172
+ // src/generators/subgraph-scaffold.ts
35173
+ async function generateSubgraphScaffold(input2) {
35570
35174
  const { contractId, functions } = input2;
35571
35175
  const contractParts = contractId.split(".");
35572
35176
  const contractName = contractParts[contractParts.length - 1] ?? contractId;
35573
- const viewName = input2.viewName ?? contractName;
35177
+ const subgraphName = input2.subgraphName ?? contractName;
35574
35178
  const publicFunctions = functions.filter((f) => f.access === "public");
35575
35179
  if (publicFunctions.length === 0) {
35576
35180
  throw new Error(`No public functions found in ${contractId}`);
35577
35181
  }
35578
35182
  const tables = publicFunctions.map((fn) => {
35579
35183
  const columns = fn.args.map((arg) => {
35580
- const mapped = clarityTypeToViewColumn(arg.type);
35184
+ const mapped = clarityTypeToSubgraphColumn(arg.type);
35581
35185
  const nullable = mapped.nullable ? ", nullable: true" : "";
35582
35186
  return ` ${arg.name.replace(/-/g, "_")}: { type: '${mapped.type}'${nullable} }`;
35583
35187
  }).join(`,
@@ -35602,10 +35206,10 @@ ${columns || " _placeholder: { type: 'text' }"}
35602
35206
 
35603
35207
  `);
35604
35208
  const code = `
35605
- import { defineView } from '@secondlayer/views';
35209
+ import { defineSubgraph } from '@secondlayer/subgraphs';
35606
35210
 
35607
- export default defineView({
35608
- name: '${viewName}',
35211
+ export default defineSubgraph({
35212
+ name: '${subgraphName}',
35609
35213
  sources: [{ contract: '${contractId}' }],
35610
35214
  schema: {
35611
35215
  ${schemaBlock}
@@ -35618,7 +35222,7 @@ ${handlersBlock}
35618
35222
  return formatCode(code);
35619
35223
  }
35620
35224
 
35621
- // src/generators/views.ts
35225
+ // src/generators/subgraphs.ts
35622
35226
  init_format();
35623
35227
 
35624
35228
  // src/utils/case-conversion.ts
@@ -35630,13 +35234,13 @@ function toPascalCase(str) {
35630
35234
  return capitalize(toCamelCase(str));
35631
35235
  }
35632
35236
 
35633
- // src/generators/views.ts
35634
- async function generateViewConsumer(viewName, detail) {
35237
+ // src/generators/subgraphs.ts
35238
+ async function generateSubgraphConsumer(subgraphName, detail) {
35635
35239
  const tables = Object.entries(detail.tables);
35636
35240
  const rowInterfaces = tables.map(([tableName, tableDef]) => {
35637
35241
  const typeName = toPascalCase(tableName) + "Row";
35638
35242
  const fields = Object.entries(tableDef.columns).map(([colName, colMeta]) => {
35639
- const tsType = viewTypeToTS(colMeta.type);
35243
+ const tsType = subgraphTypeToTS(colMeta.type);
35640
35244
  const optional = colMeta.nullable ? "?" : "";
35641
35245
  return ` ${colName}${optional}: ${tsType};`;
35642
35246
  }).join(`
@@ -35661,29 +35265,29 @@ ${cols}
35661
35265
  `);
35662
35266
  const code = `
35663
35267
  // Auto-generated by secondlayer. Do not edit.
35664
- import { getView } from '@secondlayer/sdk';
35665
- import type { InferViewClient } from '@secondlayer/views';
35268
+ import { getSubgraph } from '@secondlayer/sdk';
35269
+ import type { InferSubgraphClient } from '@secondlayer/subgraphs';
35666
35270
 
35667
35271
  ${rowInterfaces.join(`
35668
35272
 
35669
35273
  `)}
35670
35274
 
35671
35275
  const _schema = {
35672
- name: '${viewName}',
35276
+ name: '${subgraphName}',
35673
35277
  schema: {
35674
35278
  ${schemaBlock}
35675
35279
  }
35676
35280
  } as const;
35677
35281
 
35678
- export type Client = InferViewClient<typeof _schema>;
35282
+ export type Client = InferSubgraphClient<typeof _schema>;
35679
35283
 
35680
35284
  export function createClient(options?: { apiKey?: string; baseUrl?: string }): Client {
35681
- return getView(_schema, options ?? {});
35285
+ return getSubgraph(_schema, options ?? {});
35682
35286
  }
35683
35287
  `.trimStart();
35684
35288
  return formatCode(code);
35685
35289
  }
35686
- function viewTypeToTS(type) {
35290
+ function subgraphTypeToTS(type) {
35687
35291
  switch (type) {
35688
35292
  case "uint":
35689
35293
  case "int":
@@ -35703,13 +35307,13 @@ function viewTypeToTS(type) {
35703
35307
  }
35704
35308
  }
35705
35309
 
35706
- // src/commands/views.ts
35310
+ // src/commands/subgraphs.ts
35707
35311
  init_api();
35708
35312
  init_clarity();
35709
- function registerViewsCommand(program2) {
35710
- const views = program2.command("views").description("Manage materialized views");
35711
- views.command("new <name>").description("Scaffold a new view definition file").action(async (name) => {
35712
- const dir = resolve("views");
35313
+ function registerSubgraphsCommand(program2) {
35314
+ const subgraphs = program2.command("subgraphs").description("Manage materialized subgraphs");
35315
+ subgraphs.command("new <name>").description("Scaffold a new subgraph definition file").action(async (name) => {
35316
+ const dir = resolve("subgraphs");
35713
35317
  const filePath = resolve(dir, `${name}.ts`);
35714
35318
  if (existsSync(filePath)) {
35715
35319
  error(`File already exists: ${filePath}`);
@@ -35718,12 +35322,12 @@ function registerViewsCommand(program2) {
35718
35322
  if (!existsSync(dir)) {
35719
35323
  mkdirSync(dir, { recursive: true });
35720
35324
  }
35721
- const content = generateViewTemplate(name);
35325
+ const content = generateSubgraphTemplate(name);
35722
35326
  await writeTextFile(filePath, content);
35723
35327
  success(`Created ${filePath}`);
35724
- info(`Next: sl views deploy views/${name}.ts`);
35328
+ info(`Next: sl subgraphs deploy subgraphs/${name}.ts`);
35725
35329
  });
35726
- views.command("dev <file>").description("Watch a view file and auto-redeploy on change").action(async (file) => {
35330
+ subgraphs.command("dev <file>").description("Watch a subgraph file and auto-redeploy on change").action(async (file) => {
35727
35331
  await requireLocalNetwork();
35728
35332
  const absPath = resolve(file);
35729
35333
  if (!existsSync(absPath)) {
@@ -35733,27 +35337,27 @@ function registerViewsCommand(program2) {
35733
35337
  info(`Watching ${absPath} for changes...`);
35734
35338
  info(`Press Ctrl+C to stop
35735
35339
  `);
35736
- const deployView = async () => {
35340
+ const deploySubgraph = async () => {
35737
35341
  try {
35738
35342
  delete __require.cache[absPath];
35739
35343
  const mod = await import(`${absPath}?t=${Date.now()}`);
35740
35344
  const def = mod.default ?? mod;
35741
- const { validateViewDefinition } = await import("@secondlayer/views/validate");
35742
- const { deploySchema } = await import("@secondlayer/views");
35345
+ const { validateSubgraphDefinition } = await import("@secondlayer/subgraphs/validate");
35346
+ const { deploySchema } = await import("@secondlayer/subgraphs");
35743
35347
  const { getDb: getDb3 } = await import("@secondlayer/shared/db");
35744
- validateViewDefinition(def);
35348
+ validateSubgraphDefinition(def);
35745
35349
  const db = getDb3();
35746
35350
  const result = await deploySchema(db, def, absPath, { forceReindex: false });
35747
35351
  if (result.action === "unchanged") {
35748
35352
  info(`[${new Date().toLocaleTimeString()}] No schema changes`);
35749
35353
  } else if (result.action === "created") {
35750
- success(`[${new Date().toLocaleTimeString()}] View "${def.name}" created`);
35354
+ success(`[${new Date().toLocaleTimeString()}] Subgraph "${def.name}" created`);
35751
35355
  } else if (result.action === "updated") {
35752
- success(`[${new Date().toLocaleTimeString()}] View "${def.name}" updated (additive)`);
35356
+ success(`[${new Date().toLocaleTimeString()}] Subgraph "${def.name}" updated (additive)`);
35753
35357
  } else if (result.action === "reindexed") {
35754
- success(`[${new Date().toLocaleTimeString()}] View "${def.name}" reindexed (breaking schema change)`);
35358
+ success(`[${new Date().toLocaleTimeString()}] Subgraph "${def.name}" reindexed (breaking schema change)`);
35755
35359
  } else {
35756
- success(`[${new Date().toLocaleTimeString()}] View "${def.name}" deployed (${result.action})`);
35360
+ success(`[${new Date().toLocaleTimeString()}] Subgraph "${def.name}" deployed (${result.action})`);
35757
35361
  }
35758
35362
  const handlerKeys = Object.keys(def.handlers);
35759
35363
  info(` Handlers: ${handlerKeys.join(", ")}`);
@@ -35761,7 +35365,7 @@ function registerViewsCommand(program2) {
35761
35365
  error(`[${new Date().toLocaleTimeString()}] ${err}`);
35762
35366
  }
35763
35367
  };
35764
- await deployView();
35368
+ await deploySubgraph();
35765
35369
  let timeout = null;
35766
35370
  const watcher = watch(absPath, () => {
35767
35371
  if (timeout)
@@ -35769,7 +35373,7 @@ function registerViewsCommand(program2) {
35769
35373
  timeout = setTimeout(async () => {
35770
35374
  console.log("");
35771
35375
  info("File changed, redeploying...");
35772
- await deployView();
35376
+ await deploySubgraph();
35773
35377
  }, 300);
35774
35378
  });
35775
35379
  process.on("SIGINT", () => {
@@ -35782,15 +35386,15 @@ Stopped watching.`);
35782
35386
  });
35783
35387
  await new Promise(() => {});
35784
35388
  });
35785
- views.command("deploy <file>").description("Deploy a view definition file").option("--reindex", "Force reindex on breaking schema change (drops and rebuilds all data)").action(async (file, options2) => {
35389
+ subgraphs.command("deploy <file>").description("Deploy a subgraph definition file").option("--reindex", "Force reindex on breaking schema change (drops and rebuilds all data)").action(async (file, options2) => {
35786
35390
  try {
35787
35391
  const absPath = resolve(file);
35788
35392
  const config = await loadConfig();
35789
- info(`Loading view from ${absPath}`);
35393
+ info(`Loading subgraph from ${absPath}`);
35790
35394
  const mod = await import(absPath);
35791
35395
  const def = mod.default ?? mod;
35792
- const { validateViewDefinition } = await import("@secondlayer/views/validate");
35793
- validateViewDefinition(def);
35396
+ const { validateSubgraphDefinition } = await import("@secondlayer/subgraphs/validate");
35397
+ validateSubgraphDefinition(def);
35794
35398
  if (config.network !== "local") {
35795
35399
  info(`Bundling for remote deploy (${config.network})...`);
35796
35400
  const esbuild = await import("esbuild");
@@ -35799,11 +35403,11 @@ Stopped watching.`);
35799
35403
  bundle: true,
35800
35404
  platform: "node",
35801
35405
  format: "esm",
35802
- external: ["@secondlayer/views"],
35406
+ external: ["@secondlayer/subgraphs"],
35803
35407
  write: false
35804
35408
  });
35805
35409
  const handlerCode = new TextDecoder().decode(buildResult.outputFiles[0].contents);
35806
- const result = await deployViewApi({
35410
+ const result = await deploySubgraphApi({
35807
35411
  name: def.name,
35808
35412
  version: def.version,
35809
35413
  description: def.description,
@@ -35813,41 +35417,41 @@ Stopped watching.`);
35813
35417
  reindex: options2.reindex
35814
35418
  });
35815
35419
  if (result.action === "unchanged") {
35816
- info(`View "${def.name}" is up to date (no schema changes)`);
35420
+ info(`Subgraph "${def.name}" is up to date (no schema changes)`);
35817
35421
  } else {
35818
- success(`View "${def.name}" ${result.action} (remote)`);
35422
+ success(`Subgraph "${def.name}" ${result.action} (remote)`);
35819
35423
  }
35820
35424
  } else {
35821
- const { deploySchema } = await import("@secondlayer/views");
35425
+ const { deploySchema } = await import("@secondlayer/subgraphs");
35822
35426
  const { getDb: getDb3, closeDb } = await import("@secondlayer/shared/db");
35823
35427
  const db = getDb3();
35824
35428
  const result = await deploySchema(db, def, absPath, { forceReindex: options2.reindex });
35825
35429
  if (result.action === "unchanged") {
35826
- info(`View "${def.name}" is up to date (no schema changes)`);
35430
+ info(`Subgraph "${def.name}" is up to date (no schema changes)`);
35827
35431
  } else if (result.action === "created") {
35828
- success(`View "${def.name}" created (id: ${result.viewId.slice(0, 8)})`);
35432
+ success(`Subgraph "${def.name}" created (id: ${result.subgraphId.slice(0, 8)})`);
35829
35433
  } else if (result.action === "reindexed") {
35830
- success(`View "${def.name}" schema rebuilt (id: ${result.viewId.slice(0, 8)})`);
35831
- info(`Reindexing will begin when view processor starts.`);
35434
+ success(`Subgraph "${def.name}" schema rebuilt (id: ${result.subgraphId.slice(0, 8)})`);
35435
+ info(`Reindexing will begin when subgraph processor starts.`);
35832
35436
  } else {
35833
- success(`View "${def.name}" updated (id: ${result.viewId.slice(0, 8)})`);
35437
+ success(`Subgraph "${def.name}" updated (id: ${result.subgraphId.slice(0, 8)})`);
35834
35438
  }
35835
35439
  await closeDb();
35836
35440
  }
35837
35441
  } catch (err) {
35838
- error(`Failed to deploy view: ${err}`);
35442
+ error(`Failed to deploy subgraph: ${err}`);
35839
35443
  process.exit(1);
35840
35444
  }
35841
35445
  });
35842
- views.command("list").alias("ls").description("List all deployed views").option("--json", "Output as JSON").action(async (options2) => {
35446
+ subgraphs.command("list").alias("ls").description("List all deployed subgraphs").option("--json", "Output as JSON").action(async (options2) => {
35843
35447
  try {
35844
- const { data } = await listViewsApi();
35448
+ const { data } = await listSubgraphsApi();
35845
35449
  if (options2.json) {
35846
35450
  console.log(JSON.stringify(data, null, 2));
35847
35451
  return;
35848
35452
  }
35849
35453
  if (data.length === 0) {
35850
- console.log("No views deployed");
35454
+ console.log("No subgraphs deployed");
35851
35455
  return;
35852
35456
  }
35853
35457
  const tableRows = data.map((v) => {
@@ -35862,31 +35466,31 @@ Stopped watching.`);
35862
35466
  });
35863
35467
  console.log(formatTable(["Name", "Version", "Status", "Last Block", "Tables"], tableRows));
35864
35468
  console.log(dim(`
35865
- ${data.length} view(s) total`));
35469
+ ${data.length} subgraph(s) total`));
35866
35470
  } catch (err) {
35867
- handleApiError(err, "list views");
35471
+ handleApiError(err, "list subgraphs");
35868
35472
  }
35869
35473
  });
35870
- views.command("status <name>").description("Show detailed view status").action(async (name) => {
35474
+ subgraphs.command("status <name>").description("Show detailed subgraph status").action(async (name) => {
35871
35475
  try {
35872
- const view = await getViewApi(name);
35873
- const rowCounts = Object.entries(view.tables).map(([t, info2]) => `${t}: ${info2.rowCount}`).join(", ") || "N/A";
35874
- const errorRate = view.health.totalProcessed > 0 ? `${(view.health.errorRate * 100).toFixed(2)}%` : "N/A";
35476
+ const subgraph = await getSubgraphApi(name);
35477
+ const rowCounts = Object.entries(subgraph.tables).map(([t, info2]) => `${t}: ${info2.rowCount}`).join(", ") || "N/A";
35478
+ const errorRate = subgraph.health.totalProcessed > 0 ? `${(subgraph.health.errorRate * 100).toFixed(2)}%` : "N/A";
35875
35479
  console.log(formatKeyValue([
35876
- ["Name", view.name],
35877
- ["Version", view.version],
35878
- ["Status", view.status],
35879
- ["Last Block", String(view.lastProcessedBlock)],
35480
+ ["Name", subgraph.name],
35481
+ ["Version", subgraph.version],
35482
+ ["Status", subgraph.status],
35483
+ ["Last Block", String(subgraph.lastProcessedBlock)],
35880
35484
  ["Row Count", rowCounts],
35881
- ["Total Processed", String(view.health.totalProcessed)],
35882
- ["Total Errors", String(view.health.totalErrors)],
35485
+ ["Total Processed", String(subgraph.health.totalProcessed)],
35486
+ ["Total Errors", String(subgraph.health.totalErrors)],
35883
35487
  ["Error Rate", errorRate],
35884
- ["Last Error", view.health.lastError ?? "none"],
35885
- ["Last Error At", view.health.lastErrorAt ?? "N/A"],
35886
- ["Created", view.createdAt],
35887
- ["Updated", view.updatedAt]
35488
+ ["Last Error", subgraph.health.lastError ?? "none"],
35489
+ ["Last Error At", subgraph.health.lastErrorAt ?? "N/A"],
35490
+ ["Created", subgraph.createdAt],
35491
+ ["Updated", subgraph.updatedAt]
35888
35492
  ]));
35889
- const tableEntries = Object.entries(view.tables);
35493
+ const tableEntries = Object.entries(subgraph.tables);
35890
35494
  if (tableEntries.length > 0) {
35891
35495
  console.log(dim(`
35892
35496
  Table endpoints:`));
@@ -35895,23 +35499,23 @@ Table endpoints:`));
35895
35499
  }
35896
35500
  }
35897
35501
  } catch (err) {
35898
- handleApiError(err, "get view status");
35502
+ handleApiError(err, "get subgraph status");
35899
35503
  }
35900
35504
  });
35901
- views.command("reindex <name>").description("Reindex a view from historical blocks").option("--from <block>", "Start block height").option("--to <block>", "End block height").action(async (name, options2) => {
35505
+ subgraphs.command("reindex <name>").description("Reindex a subgraph from historical blocks").option("--from <block>", "Start block height").option("--to <block>", "End block height").action(async (name, options2) => {
35902
35506
  try {
35903
- info(`Reindexing view "${name}"...`);
35904
- const result = await reindexViewApi(name, {
35507
+ info(`Reindexing subgraph "${name}"...`);
35508
+ const result = await reindexSubgraphApi(name, {
35905
35509
  fromBlock: options2.from ? parseInt(options2.from, 10) : undefined,
35906
35510
  toBlock: options2.to ? parseInt(options2.to, 10) : undefined
35907
35511
  });
35908
35512
  success(result.message);
35909
35513
  info(`From block ${result.fromBlock} to ${result.toBlock}`);
35910
35514
  } catch (err) {
35911
- handleApiError(err, "reindex view");
35515
+ handleApiError(err, "reindex subgraph");
35912
35516
  }
35913
35517
  });
35914
- views.command("query <name> <table>").description("Query a view table").option("--sort <column>", "Sort by column").option("--order <dir>", "Sort direction (asc|desc)", "asc").option("--limit <n>", "Max rows to return", "20").option("--offset <n>", "Skip first N rows").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").action(async (name, table, options2) => {
35518
+ 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("--offset <n>", "Skip first N rows").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").action(async (name, table, options2) => {
35915
35519
  try {
35916
35520
  const filters = {};
35917
35521
  if (options2.filter) {
@@ -35933,7 +35537,7 @@ Table endpoints:`));
35933
35537
  filters: Object.keys(filters).length > 0 ? filters : undefined
35934
35538
  };
35935
35539
  if (options2.count) {
35936
- const result = await queryViewTableCount(name, table, params);
35540
+ const result = await querySubgraphTableCount(name, table, params);
35937
35541
  if (options2.json) {
35938
35542
  console.log(JSON.stringify(result, null, 2));
35939
35543
  } else {
@@ -35941,7 +35545,7 @@ Table endpoints:`));
35941
35545
  }
35942
35546
  return;
35943
35547
  }
35944
- const rows = await queryViewTable(name, table, params);
35548
+ const rows = await querySubgraphTable(name, table, params);
35945
35549
  if (options2.json) {
35946
35550
  console.log(JSON.stringify(rows, null, 2));
35947
35551
  return;
@@ -35963,28 +35567,28 @@ Table endpoints:`));
35963
35567
  console.log(dim(`
35964
35568
  ${rows.length} row(s)`));
35965
35569
  } catch (err) {
35966
- handleApiError(err, "query view");
35570
+ handleApiError(err, "query subgraph");
35967
35571
  }
35968
35572
  });
35969
- views.command("delete <name>").description("Delete a view and its data").option("-y, --yes", "Skip confirmation").action(async (name, options2) => {
35573
+ subgraphs.command("delete <name>").description("Delete a subgraph and its data").option("-y, --yes", "Skip confirmation").action(async (name, options2) => {
35970
35574
  try {
35971
35575
  if (!options2.yes) {
35972
35576
  const { confirm: confirm6 } = await import("@inquirer/prompts");
35973
35577
  const ok = await confirm6({
35974
- message: `Delete view "${name}" and all its data? This cannot be undone.`
35578
+ message: `Delete subgraph "${name}" and all its data? This cannot be undone.`
35975
35579
  });
35976
35580
  if (!ok) {
35977
35581
  info("Cancelled");
35978
35582
  return;
35979
35583
  }
35980
35584
  }
35981
- const result = await deleteViewApi(name);
35585
+ const result = await deleteSubgraphApi(name);
35982
35586
  success(result.message);
35983
35587
  } catch (err) {
35984
- handleApiError(err, "delete view");
35588
+ handleApiError(err, "delete subgraph");
35985
35589
  }
35986
35590
  });
35987
- views.command("scaffold <contractAddress>").description("Scaffold a defineView() file from a contract ABI").option("-o, --output <path>", "Output file path (required)").option("--api-key <key>", "Hiro API key").action(async (contractAddress, options2) => {
35591
+ subgraphs.command("scaffold <contractAddress>").description("Scaffold a defineSubgraph() file from a contract ABI").option("-o, --output <path>", "Output file path (required)").option("--api-key <key>", "Hiro API key").action(async (contractAddress, options2) => {
35988
35592
  try {
35989
35593
  if (!options2.output) {
35990
35594
  error("--output <path> is required");
@@ -35992,13 +35596,14 @@ ${rows.length} row(s)`));
35992
35596
  }
35993
35597
  const outPath = resolve(options2.output);
35994
35598
  const network = inferNetwork(contractAddress) ?? "mainnet";
35599
+ const config = await loadConfig();
35995
35600
  const apiKey = options2.apiKey ?? process.env.HIRO_API_KEY;
35996
35601
  info(`Fetching ABI for ${contractAddress}...`);
35997
- const client = new StacksApiClient(network, apiKey);
35602
+ const client = new StacksApiClient(network, apiKey, config.nodeRpcUrl);
35998
35603
  const contractInfo = await client.getContractInfo(contractAddress);
35999
35604
  const abi = parseApiResponse(contractInfo);
36000
35605
  info(`Generating scaffold...`);
36001
- const content = await generateViewScaffold({
35606
+ const content = await generateSubgraphScaffold({
36002
35607
  contractId: contractAddress,
36003
35608
  functions: abi.functions
36004
35609
  });
@@ -36007,30 +35612,30 @@ ${rows.length} row(s)`));
36007
35612
  mkdirSync(dir, { recursive: true });
36008
35613
  await writeTextFile(outPath, content);
36009
35614
  success(`Created ${outPath}`);
36010
- info(`Next: sl views deploy ${options2.output}`);
35615
+ info(`Next: sl subgraphs deploy ${options2.output}`);
36011
35616
  } catch (err) {
36012
- error(`Failed to scaffold view: ${err}`);
35617
+ error(`Failed to scaffold subgraph: ${err}`);
36013
35618
  process.exit(1);
36014
35619
  }
36015
35620
  });
36016
- views.command("generate <viewName>").description("Generate a typed client for a deployed view").option("-o, --output <path>", "Output file path (required)").action(async (viewName, options2) => {
35621
+ subgraphs.command("generate <subgraphName>").description("Generate a typed client for a deployed subgraph").option("-o, --output <path>", "Output file path (required)").action(async (subgraphName, options2) => {
36017
35622
  try {
36018
35623
  if (!options2.output) {
36019
35624
  error("--output <path> is required");
36020
35625
  process.exit(1);
36021
35626
  }
36022
35627
  const outPath = resolve(options2.output);
36023
- info(`Fetching view metadata for "${viewName}"...`);
36024
- const viewDetail = await getViewApi(viewName);
35628
+ info(`Fetching subgraph metadata for "${subgraphName}"...`);
35629
+ const subgraphDetail = await getSubgraphApi(subgraphName);
36025
35630
  info(`Generating typed client...`);
36026
- const content = await generateViewConsumer(viewName, viewDetail);
35631
+ const content = await generateSubgraphConsumer(subgraphName, subgraphDetail);
36027
35632
  const dir = resolve(outPath, "..");
36028
35633
  if (!existsSync(dir))
36029
35634
  mkdirSync(dir, { recursive: true });
36030
35635
  await writeTextFile(outPath, content);
36031
35636
  success(`Created ${outPath}`);
36032
35637
  } catch (err) {
36033
- handleApiError(err, "generate view client");
35638
+ handleApiError(err, "generate subgraph client");
36034
35639
  }
36035
35640
  });
36036
35641
  }
@@ -36346,7 +35951,7 @@ async function checkHealth() {
36346
35951
  const portsToCheck = [
36347
35952
  { port: config.ports.api, name: "API" },
36348
35953
  { port: config.ports.indexer, name: "Indexer" },
36349
- { port: config.ports.webhook, name: "Webhook" },
35954
+ { port: config.ports.receiver, name: "Receiver" },
36350
35955
  { port: 20443, name: "Node RPC" }
36351
35956
  ];
36352
35957
  for (const { port, name } of portsToCheck) {
@@ -36604,9 +36209,9 @@ function registerAuthCommand(program2) {
36604
36209
  body: JSON.stringify({ email })
36605
36210
  });
36606
36211
  await assertOk(mlRes);
36607
- console.log(dim("Check your email for a login token."));
36212
+ console.log(dim("Check your email for a 6-digit login code."));
36608
36213
  const token = await input2({
36609
- message: "Token:",
36214
+ message: "Code:",
36610
36215
  validate: (v) => v.trim().length > 0 || "Token is required"
36611
36216
  });
36612
36217
  const verifyRes = await fetch(`${apiUrl}/api/auth/verify`, {
@@ -36818,14 +36423,14 @@ init_config();
36818
36423
  init_dev_state();
36819
36424
  init_node_manager();
36820
36425
  init_output();
36821
- var DEV_SERVICES = ["api", "indexer", "worker", "webhook", "views"];
36426
+ var DEV_SERVICES = ["api", "indexer", "worker", "receiver", "subgraphs"];
36822
36427
  function registerLocalCommand(program2) {
36823
36428
  const local = program2.command("local").description("Manage local development environment and Stacks node").hook("preAction", async (_thisCommand, actionCommand) => {
36824
36429
  if (actionCommand.name() === "help")
36825
36430
  return;
36826
36431
  await requireLocalNetwork();
36827
36432
  });
36828
- local.command("start").description("Start all local dev services (API, indexer, worker, webhook)").option("--indexer-port <port>", "Indexer port", "3700").option("--api-port <port>", "API port", "3800").option("--webhook-port <port>", "Test webhook server port", "3900").option("--no-webhook", "Skip test webhook server").option("--no-worker", "Skip worker service").option("--secret <secret>", "Webhook secret for signature verification").option("--stacks-node", "Use port 3701 for indexer (avoids conflict with stacks-blockchain-api)").option("-f, --foreground", "Run in foreground (blocking)").action(async (options2) => {
36433
+ local.command("start").description("Start all local dev services (API, indexer, worker, receiver)").option("--indexer-port <port>", "Indexer port", "3700").option("--api-port <port>", "API port", "3800").option("--receiver-port <port>", "Test receiver server port", "3900").option("--no-receiver", "Skip test receiver server").option("--no-worker", "Skip worker service").option("--secret <secret>", "Signing secret for signature verification").option("--stacks-node", "Use port 3701 for indexer (avoids conflict with stacks-blockchain-api)").option("-f, --foreground", "Run in foreground (blocking)").action(async (options2) => {
36829
36434
  const { runBackground: runBackground2, runForeground: runForeground2, isDevAlreadyRunning: isDevAlreadyRunning2 } = await Promise.resolve().then(() => (init_dev_impl(), exports_dev_impl));
36830
36435
  if (await isDevAlreadyRunning2()) {
36831
36436
  return;
@@ -36847,7 +36452,7 @@ function registerLocalCommand(program2) {
36847
36452
  local.command("status").description("Show local environment status").action(async () => {
36848
36453
  await showLocalStatus();
36849
36454
  });
36850
- local.command("logs").description("View local service logs (dev + node)").option("-s, --service <name>", "Filter by service (api, indexer, worker, webhook, views, node)").option("-f, --follow", "Follow log output").option("-n, --lines <n>", "Number of lines to show", "50").option("-q, --quiet", "Filter out common noise").option("-v, --verbose", "Show full payloads").action(async (options2) => {
36455
+ local.command("logs").description("View local service logs (dev + node)").option("-s, --service <name>", "Filter by service (api, indexer, worker, receiver, subgraphs, node)").option("-f, --follow", "Follow log output").option("-n, --lines <n>", "Number of lines to show", "50").option("-q, --quiet", "Filter out common noise").option("-v, --verbose", "Show full payloads").action(async (options2) => {
36851
36456
  await showLocalLogs(options2);
36852
36457
  });
36853
36458
  const node = local.command("node").description("Manage local Stacks node");
@@ -36923,8 +36528,8 @@ var serviceColors2 = {
36923
36528
  api: blue,
36924
36529
  indexer: cyan,
36925
36530
  worker: yellow,
36926
- views: magenta,
36927
- webhook: green,
36531
+ subgraphs: magenta,
36532
+ receiver: green,
36928
36533
  node: red
36929
36534
  };
36930
36535
  async function showLocalLogs(options2) {
@@ -37076,17 +36681,17 @@ function formatLogLine3(service, line, verbose) {
37076
36681
  return `${prefix} ${dimTimestamp} ${dim(level + ":")} ${dim(message)}`;
37077
36682
  }
37078
36683
  }
37079
- if (service === "webhook" && !verbose) {
37080
- const summary = formatWebhookSummary2(line);
36684
+ if (service === "receiver" && !verbose) {
36685
+ const summary = formatDeliverySummary2(line);
37081
36686
  if (summary)
37082
36687
  return `${prefix} ${summary}`;
37083
36688
  }
37084
36689
  return `${prefix} ${line}`;
37085
36690
  }
37086
- function formatWebhookSummary2(jsonStr) {
36691
+ function formatDeliverySummary2(jsonStr) {
37087
36692
  try {
37088
36693
  const data = JSON.parse(jsonStr);
37089
- if (data.type !== "webhook" || !data.body)
36694
+ if (data.type !== "delivery" || !data.body)
37090
36695
  return null;
37091
36696
  const { body, method, path, timestamp } = data;
37092
36697
  const streamName = body.streamName ?? body.streamId?.slice(0, 8) ?? "unknown";
@@ -37137,7 +36742,7 @@ function registerWhoamiCommand(program2) {
37137
36742
  }
37138
36743
  // src/cli.ts
37139
36744
  var { version } = package_default;
37140
- program.name("secondlayer").alias("sl").description("SecondLayer CLI — streams, views, and real-time indexing for Stacks").version(version).option("--network <network>", "Override network (local, testnet, mainnet)");
36745
+ program.name("secondlayer").alias("sl").description("SecondLayer CLI — streams, subgraphs, and real-time indexing for Stacks").version(version).option("--network <network>", "Override network (local, testnet, mainnet)");
37141
36746
  program.hook("preAction", (thisCommand) => {
37142
36747
  const net3 = thisCommand.opts().network;
37143
36748
  if (net3)
@@ -37159,7 +36764,7 @@ program.command("init").description("Initialize a new secondlayer.config.ts file
37159
36764
  await init3();
37160
36765
  });
37161
36766
  registerStreamsCommand(program);
37162
- registerViewsCommand(program);
36767
+ registerSubgraphsCommand(program);
37163
36768
  registerStatusCommand(program);
37164
36769
  registerLocalCommand(program);
37165
36770
  registerStackCommand(program);
@@ -37170,8 +36775,8 @@ registerSetupCommand(program);
37170
36775
  registerConfigCommand(program);
37171
36776
  registerAuthCommand(program);
37172
36777
  registerWhoamiCommand(program);
37173
- registerWebhookCommand(program);
36778
+ registerReceiverCommand(program);
37174
36779
  program.parse();
37175
36780
 
37176
- //# debugId=623C283AFFA2A54D64756E2164756E21
36781
+ //# debugId=9817C710C5B4B19A64756E2164756E21
37177
36782
  //# sourceMappingURL=cli.js.map