@secondlayer/cli 3.3.2 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -63,7 +63,7 @@ One instance per project. The platform API spawns a dedicated `sl-pg-{slug}`,
63
63
 
64
64
  | Command | What it does |
65
65
  |---|---|
66
- | `sl create subscription <name> --runtime <inngest\|trigger\|cloudflare\|node> [--filter key=value]` | Scaffold a receiver project wired to a new subscription. Copies the runtime template into `./<name>/`, provisions through the active project/instance, supports scalar filters, and wires the signing secret so the dev server starts consuming events immediately. |
66
+ | `sl create subscription <name> --runtime <inngest\|trigger\|cloudflare\|node> [--auth-token <token>] [--filter key=value]` | Scaffold a receiver project wired to a new subscription. Copies the runtime template into `./<name>/`, provisions through the active project/instance, supports scalar filters and bearer auth, and wires the signing secret so the dev server starts consuming events immediately. |
67
67
 
68
68
  ### Subscriptions (tenant-scoped)
69
69
 
@@ -76,7 +76,7 @@ active project/instance the same way as `sl subgraphs ...`; `SL_API_URL` and
76
76
  |---|---|
77
77
  | `sl subscriptions list` | List subscriptions with status, target table, format, and last success |
78
78
  | `sl subscriptions get <id\|name>` | Show full config, filter, retry/circuit state |
79
- | `sl subscriptions update <id\|name> --url <url> [--filter key.gte=value]` | Patch URL, filter, format, runtime, retry, timeout, concurrency |
79
+ | `sl subscriptions update <id\|name> --url <url> [--auth-token <token>] [--filter key.gte=value]` | Patch URL, bearer auth, filter, format, runtime, retry, timeout, concurrency |
80
80
  | `sl subscriptions pause/resume <id\|name>` | Stop or restart delivery |
81
81
  | `sl subscriptions rotate-secret <id\|name>` | Rotate signing secret and print the new value once |
82
82
  | `sl subscriptions deliveries <id\|name>` | Last 100 delivery attempts |
@@ -99,7 +99,7 @@ invocation. No long-lived key on disk.
99
99
  | Command | What it does |
100
100
  |---|---|
101
101
  | `sl subgraphs new <name>` | Scaffold a subgraph definition file |
102
- | `sl subgraphs deploy <file>` | Deploy to the active instance |
102
+ | `sl subgraphs deploy <file> [--start-block <n>]` | Deploy to the active instance; `--start-block` overrides the definition start block for that deploy |
103
103
  | `sl subgraphs dev <file>` | Watch + hot-redeploy |
104
104
  | `sl subgraphs list` | List deployed subgraphs |
105
105
  | `sl subgraphs status <name>` | Indexing progress, row counts, gaps |
package/dist/cli.js CHANGED
@@ -32430,7 +32430,7 @@ var {
32430
32430
  // package.json
32431
32431
  var package_default = {
32432
32432
  name: "@secondlayer/cli",
32433
- version: "3.3.2",
32433
+ version: "3.4.0",
32434
32434
  description: "CLI for subgraphs and blockchain indexing on Stacks",
32435
32435
  type: "module",
32436
32436
  bin: {
@@ -32473,8 +32473,8 @@ var package_default = {
32473
32473
  dependencies: {
32474
32474
  "@inquirer/prompts": "^8.2.0",
32475
32475
  "@secondlayer/bundler": "^0.3.1",
32476
- "@secondlayer/sdk": "^3.1.0",
32477
- "@secondlayer/shared": "^4.1.1",
32476
+ "@secondlayer/sdk": "^3.2.0",
32477
+ "@secondlayer/shared": "^4.2.0",
32478
32478
  "@secondlayer/stacks": "^2.0.0",
32479
32479
  "@secondlayer/subgraphs": "^1.2.0",
32480
32480
  "@biomejs/js-api": "^0.7.0",
@@ -33138,11 +33138,22 @@ async function promptFor(_name, opts) {
33138
33138
  });
33139
33139
  return { runtime, subgraph, table, url };
33140
33140
  }
33141
+ function buildSubscriptionAuthConfig(authToken) {
33142
+ if (authToken === undefined)
33143
+ return;
33144
+ const token = authToken.trim();
33145
+ if (token.length === 0) {
33146
+ throw new Error("--auth-token must not be empty");
33147
+ }
33148
+ return { authType: "bearer", token };
33149
+ }
33141
33150
  async function createSubscription(name, opts) {
33142
33151
  const { runtime, subgraph, table, url } = await promptFor(name, opts);
33143
33152
  let filter;
33153
+ let authConfig;
33144
33154
  try {
33145
33155
  filter = parseSubscriptionFilter(opts.filter);
33156
+ authConfig = buildSubscriptionAuthConfig(opts.authToken);
33146
33157
  } catch (err) {
33147
33158
  error(err instanceof Error ? err.message : String(err));
33148
33159
  process.exit(1);
@@ -33187,7 +33198,8 @@ async function createSubscription(name, opts) {
33187
33198
  url,
33188
33199
  format: FORMAT_BY_RUNTIME[runtime],
33189
33200
  runtime,
33190
- ...filter ? { filter } : {}
33201
+ ...filter ? { filter } : {},
33202
+ ...authConfig ? { authConfig } : {}
33191
33203
  });
33192
33204
  signingSecret = res.signingSecret;
33193
33205
  success(`Subscription provisioned: ${blue(res.subscription.id)}`);
@@ -33253,7 +33265,7 @@ async function getSubscriptionClient(opts) {
33253
33265
  }
33254
33266
  function registerCreateCommand(program2) {
33255
33267
  const create = program2.command("create").description("Scaffold new resources (subscription receivers, etc.)");
33256
- create.command("subscription <name>").description("Scaffold a subscription receiver for a runtime").option("-r, --runtime <runtime>", "inngest | trigger | cloudflare | node").option("-s, --subgraph <name>", "Subgraph to subscribe to").option("-t, --table <name>", "Table to subscribe to").option("-u, --url <url>", "Webhook URL").option("--filter <kv...>", "Filter as key=value (supports .eq/.neq/.gt/.gte/.lt/.lte suffixes)").option("--service-key <key>", "SL_SERVICE_KEY override").option("--base-url <url>", "SL_API_URL override").option("--skip-api", "Copy template only, don't call the API").action(async (name, options) => {
33268
+ create.command("subscription <name>").description("Scaffold a subscription receiver for a runtime").option("-r, --runtime <runtime>", "inngest | trigger | cloudflare | node").option("-s, --subgraph <name>", "Subgraph to subscribe to").option("-t, --table <name>", "Table to subscribe to").option("-u, --url <url>", "Webhook URL").option("--auth-token <token>", "Bearer token for receiver API auth").option("--filter <kv...>", "Filter as key=value (supports .eq/.neq/.gt/.gte/.lt/.lte suffixes)").option("--service-key <key>", "SL_SERVICE_KEY override").option("--base-url <url>", "SL_API_URL override").option("--skip-api", "Copy template only, don't call the API").action(async (name, options) => {
33257
33269
  await createSubscription(name, options);
33258
33270
  });
33259
33271
  }
@@ -33412,6 +33424,9 @@ function buildUpdatePatch(options) {
33412
33424
  patch.name = options.name;
33413
33425
  if (options.url)
33414
33426
  patch.url = options.url;
33427
+ const authConfig = buildSubscriptionAuthConfig(options.authToken);
33428
+ if (authConfig)
33429
+ patch.authConfig = authConfig;
33415
33430
  if (options.format) {
33416
33431
  patch.format = options.format;
33417
33432
  }
@@ -33722,7 +33737,7 @@ ${data.length} subscription(s) total`));
33722
33737
  handleApiError(err, "get subscription");
33723
33738
  }
33724
33739
  });
33725
- commonOptions(subscriptions.command("update <idOrName>").description("Update subscription config").option("--name <name>", "Rename subscription").option("--url <url>", "Webhook URL").option("--format <format>", "standard-webhooks | inngest | trigger | cloudflare | cloudevents | raw").option("--runtime <runtime>", "inngest | trigger | cloudflare | node | none").option("--filter <kv...>", "Filter as key=value (supports .eq/.neq/.gt/.gte/.lt/.lte suffixes)").option("--clear-filter", "Replace filter with {}").option("--max-retries <n>", "Maximum delivery retries").option("--timeout-ms <n>", "Delivery timeout in milliseconds").option("--concurrency <n>", "Per-subscription delivery concurrency").option("--json", "Output as JSON")).action(async (idOrName, options) => {
33740
+ commonOptions(subscriptions.command("update <idOrName>").description("Update subscription config").option("--name <name>", "Rename subscription").option("--url <url>", "Webhook URL").option("--auth-token <token>", "Set bearer token auth config").option("--format <format>", "standard-webhooks | inngest | trigger | cloudflare | cloudevents | raw").option("--runtime <runtime>", "inngest | trigger | cloudflare | node | none").option("--filter <kv...>", "Filter as key=value (supports .eq/.neq/.gt/.gte/.lt/.lte suffixes)").option("--clear-filter", "Replace filter with {}").option("--max-retries <n>", "Maximum delivery retries").option("--timeout-ms <n>", "Delivery timeout in milliseconds").option("--concurrency <n>", "Per-subscription delivery concurrency").option("--json", "Output as JSON")).action(async (idOrName, options) => {
33726
33741
  try {
33727
33742
  const client = await getSubscriptionClient(options);
33728
33743
  const patch = buildUpdatePatch(options);
@@ -34548,6 +34563,19 @@ export default defineSubgraph({
34548
34563
 
34549
34564
  // src/commands/subgraphs.ts
34550
34565
  init_api();
34566
+ function parseStartBlockOption(value) {
34567
+ if (value === undefined)
34568
+ return;
34569
+ const trimmed = value.trim();
34570
+ if (!/^(0|[1-9]\d*)$/.test(trimmed)) {
34571
+ throw new Error("--start-block must be a nonnegative integer");
34572
+ }
34573
+ const parsed = Number(trimmed);
34574
+ if (!Number.isSafeInteger(parsed)) {
34575
+ throw new Error("--start-block must be a safe integer");
34576
+ }
34577
+ return parsed;
34578
+ }
34551
34579
  function registerSubgraphsCommand(program2) {
34552
34580
  const subgraphs = program2.command("subgraphs").description("Manage materialized subgraphs");
34553
34581
  subgraphs.command("new <name>").description("Scaffold a new subgraph definition file").action(async (name) => {
@@ -34626,15 +34654,20 @@ Stopped watching.`);
34626
34654
  });
34627
34655
  await new Promise(() => {});
34628
34656
  });
34629
- subgraphs.command("deploy <file>").description("Deploy a subgraph definition file").option("--version <semver>", "Explicit version (default: auto-increment patch)").option("--force", "Skip confirmation prompt for reindex operations").action(async (file, options2) => {
34657
+ subgraphs.command("deploy <file>").description("Deploy a subgraph definition file").option("--version <semver>", "Explicit version (default: auto-increment patch)").option("--start-block <n>", "Override the subgraph definition startBlock for this deploy").option("--force", "Skip confirmation prompt for reindex operations").action(async (file, options2) => {
34630
34658
  try {
34631
34659
  const absPath = resolve3(file);
34632
34660
  const config = await loadConfig();
34661
+ const startBlock = parseStartBlockOption(options2.startBlock);
34662
+ if (startBlock !== undefined) {
34663
+ warn(`--start-block ${startBlock} overrides the definition's startBlock for this deploy.`);
34664
+ }
34633
34665
  info(`Loading subgraph from ${absPath}`);
34634
34666
  const mod = await import(absPath);
34635
34667
  const def = mod.default ?? mod;
34668
+ const effectiveDef = startBlock === undefined ? def : { ...def, startBlock };
34636
34669
  const { validateSubgraphDefinition } = await import("@secondlayer/subgraphs/validate");
34637
- validateSubgraphDefinition(def);
34670
+ validateSubgraphDefinition(effectiveDef);
34638
34671
  if (config.network !== "local") {
34639
34672
  info(`Bundling for remote deploy (${config.network})...`);
34640
34673
  const { readFile: readFile4 } = await import("node:fs/promises");
@@ -34643,17 +34676,18 @@ Stopped watching.`);
34643
34676
  const bundled = await bundleSubgraphCode(source);
34644
34677
  const handlerCode = bundled.handlerCode;
34645
34678
  const result = await deploySubgraphApi({
34646
- name: def.name,
34679
+ name: effectiveDef.name,
34647
34680
  version: options2.version,
34648
- description: def.description,
34649
- sources: def.sources,
34650
- schema: def.schema,
34651
- handlerCode
34681
+ description: effectiveDef.description,
34682
+ sources: effectiveDef.sources,
34683
+ schema: effectiveDef.schema,
34684
+ handlerCode,
34685
+ ...startBlock !== undefined ? { startBlock } : {}
34652
34686
  });
34653
34687
  if (result.action === "unchanged") {
34654
- info(`Subgraph "${def.name}" is up to date (v${result.version} — no changes)`);
34688
+ info(`Subgraph "${effectiveDef.name}" is up to date (v${result.version} — no changes)`);
34655
34689
  } else if (result.action === "created") {
34656
- success(`Subgraph "${def.name}" created → v${result.version}`);
34690
+ success(`Subgraph "${effectiveDef.name}" created → v${result.version}`);
34657
34691
  } else if (result.action === "reindexed") {
34658
34692
  if (result.diff) {
34659
34693
  const { addedTables, addedColumns, breakingChanges } = result.diff;
@@ -34675,7 +34709,7 @@ Stopped watching.`);
34675
34709
  info("Aborted.");
34676
34710
  process.exit(0);
34677
34711
  }
34678
- success(`Subgraph "${def.name}" updated → v${result.version} (reindexing)`);
34712
+ success(`Subgraph "${effectiveDef.name}" updated → v${result.version} (reindexing)`);
34679
34713
  } else {
34680
34714
  if (result.diff) {
34681
34715
  const { addedTables, addedColumns } = result.diff;
@@ -34685,23 +34719,24 @@ Stopped watching.`);
34685
34719
  info(` + columns: ${t}.${cols.join(", ")}`);
34686
34720
  }
34687
34721
  }
34688
- success(`Subgraph "${def.name}" updated → v${result.version}`);
34722
+ success(`Subgraph "${effectiveDef.name}" updated → v${result.version}`);
34689
34723
  }
34690
34724
  } else {
34691
34725
  const { deploySchema } = await import("@secondlayer/subgraphs");
34692
34726
  const { getDb: getDb2, closeDb } = await import("@secondlayer/shared/db");
34693
34727
  const db = getDb2();
34694
- const result = await deploySchema(db, def, absPath, {
34695
- version: options2.version
34728
+ const result = await deploySchema(db, effectiveDef, absPath, {
34729
+ version: options2.version,
34730
+ forceReindex: startBlock !== undefined
34696
34731
  });
34697
34732
  if (result.action === "unchanged") {
34698
- info(`Subgraph "${def.name}" is up to date (v${result.version} — no changes)`);
34733
+ info(`Subgraph "${effectiveDef.name}" is up to date (v${result.version} — no changes)`);
34699
34734
  } else if (result.action === "created") {
34700
- success(`Subgraph "${def.name}" created → v${result.version}`);
34735
+ success(`Subgraph "${effectiveDef.name}" created → v${result.version}`);
34701
34736
  } else if (result.action === "reindexed") {
34702
- success(`Subgraph "${def.name}" updated → v${result.version} (reindexing)`);
34737
+ success(`Subgraph "${effectiveDef.name}" updated → v${result.version} (reindexing)`);
34703
34738
  } else {
34704
- success(`Subgraph "${def.name}" updated → v${result.version}`);
34739
+ success(`Subgraph "${effectiveDef.name}" updated → v${result.version}`);
34705
34740
  }
34706
34741
  await closeDb();
34707
34742
  }
@@ -36314,5 +36349,5 @@ registerLocalCommand(program);
36314
36349
  registerAccountCommand(program);
36315
36350
  program.parse();
36316
36351
 
36317
- //# debugId=6B94E8C4AE7AD17564756E2164756E21
36352
+ //# debugId=5D73330C3279063064756E2164756E21
36318
36353
  //# sourceMappingURL=cli.js.map