@secondlayer/subgraphs 3.25.1 → 3.26.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.
@@ -459,9 +459,28 @@ declare function filterFieldsByType(): Array<{
459
459
  type: string
460
460
  fields: string[]
461
461
  }>;
462
+ /** A (decoded event type, optional contract scope) pair the sparse probe
463
+ * checks. Contract scoping is what makes token-subgraph reindexes leap over
464
+ * everything that isn't their token. */
465
+ type SparseProbeTarget = {
466
+ eventType: string
467
+ contractId?: string
468
+ };
469
+ /** Sparse scanning is sound only when EVERY source is an event-type filter —
470
+ * a contract_call/contract_deploy source matches transactions, which the
471
+ * event probe can't see. */
472
+ declare function canSparseScan(subgraph: SubgraphDefinition): boolean;
473
+ /** Probe targets for a subgraph's filters: decoded type + contract scope when\\n* the filter pins one (assetIdentifier "SP….contract::asset" or contractId). */
474
+ declare function sparseProbeTargets(subgraph: SubgraphDefinition): SparseProbeTarget[];
462
475
  interface ReindexOptions {
463
- fromBlock?: number;
464
- toBlock?: number;
476
+ /**
477
+ * Policy floor on the walk's first block — NOT a caller-supplied range.
478
+ * Free-tier accounts may not reindex below their registered `start_block`
479
+ * (see `resolveGenesisPolicy` on the API side); this raises the walk start
480
+ * and can never lower it. There is deliberately no `toBlock` counterpart:
481
+ * a reindex always runs to chain tip. See {@link resolveBlockRange}.
482
+ */
483
+ startBlockFloor?: number;
465
484
  schemaName?: string;
466
485
  /** Op row to receive processed_events on each progress flush. */
467
486
  operationId?: string;
@@ -470,6 +489,13 @@ interface ReindexOptions {
470
489
  /**
471
490
  * Reindex a subgraph by dropping its tables, recreating them, and reprocessing
472
491
  * all historical blocks through the handler pipeline.
492
+ *
493
+ * Always whole-subgraph: `[start_block, chain tip]`. There is no ranged
494
+ * reindex — the drop cannot be scoped to a range without re-running delta
495
+ * handlers (`ctx.increment` / `ctx.update` / `ctx.patchOrInsert`) over rows
496
+ * that were never removed, which is the exact double-count hazard `backfill`
497
+ * already refuses. Use `backfillSubgraph` for ranged, additive work.
498
+ *
473
499
  * Supports cancellation via AbortSignal — on shutdown abort, status stays
474
500
  * "reindexing" for auto-resume; on user cancel, status resets to "active".
475
501
  */
@@ -1076,10 +1102,10 @@ declare function generateIndexSchema(target: IndexCodegenTarget, opts?: IndexCod
1076
1102
  /** Index tables available to codegen, for help text and validation. */
1077
1103
  declare const INDEX_CODEGEN_TABLES: readonly string[];
1078
1104
  import { pgSchemaName } from "@secondlayer/shared/db/queries/subgraphs";
1079
- import { Database as Database2 } from "@secondlayer/shared/db";
1105
+ import { Database as Database3 } from "@secondlayer/shared/db";
1080
1106
  import { ByoBreakingChangeDetails } from "@secondlayer/shared/errors";
1081
- import { Kysely as Kysely2 } from "kysely";
1082
- type AnyDb = Kysely2<Database2>;
1107
+ import { Kysely as Kysely3 } from "kysely";
1108
+ type AnyDb = Kysely3<Database3>;
1083
1109
  interface TableDiff {
1084
1110
  /** Tables added to the schema */
1085
1111
  addedTables: string[];
@@ -1200,17 +1226,4 @@ declare function deploySchema(db: AnyDb, def: SubgraphDefinition, handlerPath: s
1200
1226
  /** Non-fatal caveats the caller should surface (e.g. handler grafts at tip). */
1201
1227
  warnings?: string[]
1202
1228
  }>;
1203
- /** A (decoded event type, optional contract scope) pair the sparse probe
1204
- * checks. Contract scoping is what makes token-subgraph reindexes leap over
1205
- * everything that isn't their token. */
1206
- type SparseProbeTarget = {
1207
- eventType: string
1208
- contractId?: string
1209
- };
1210
- /** Sparse scanning is sound only when EVERY source is an event-type filter —
1211
- * a contract_call/contract_deploy source matches transactions, which the
1212
- * event probe can't see. */
1213
- declare function canSparseScan(subgraph: SubgraphDefinition): boolean;
1214
- /** Probe targets for a subgraph's filters: decoded type + contract scope when\\n* the filter pins one (assetIdentifier "SP….contract::asset" or contractId). */
1215
- declare function sparseProbeTargets(subgraph: SubgraphDefinition): SparseProbeTarget[];
1216
1229
  export { validateSubgraphDefinition, validatePrintPayload, sparseProbeTargets, resumeReindex, renderDeployPlan, reindexSubgraph, readContractAt, pgSchemaName, inferPrintTopics, hasBreakingChanges, generateSubgraphSQL, generatePrismaSchema, generateKyselySchema, generateIndexSchema, generateDrizzleSchema, filterFieldsByType, diffSchema, deploySchema, defineSubgraph, defineSchema, canSparseScan, camelizeDataKey, backfillSubgraph, WriteRow, WhereInput, TypedSubgraphDefinition, TypedSubgraphContext, TypedHandlers, TxMeta, TableDiff, SystemRow, SubscribeOptions, SubgraphTableClient, SubgraphTable, SubgraphSchema, SubgraphHandler, SubgraphFilter, SubgraphDefinition, SubgraphContext, SubgraphColumn, StxTransferPayload, StxTransferFilter, StxMintPayload, StxMintFilter, StxLockPayload, StxLockFilter, StxBurnPayload, StxBurnFilter, SparseProbeTarget, RowValue, ReindexOptions, PrismaGenOptions, PrintValidationResult, PrintSample, PrintFieldToTS, PrintField, PrintEventPayload, PrintEventFor, PrintEventFilter, PrintDataOf, NftTransferPayload, NftTransferFilter, NftMintPayload, NftMintFilter, NftBurnPayload, NftBurnFilter, KyselyGenOptions, InferredTopicSchema, InferredPrintField, InferTableRow, InferSubgraphClient, InferContext, InferColumnType, IndexCodegenTarget, IndexCodegenOptions, INDEX_CODEGEN_TABLES, GeneratedSQL, FtTransferPayload, FtTransferFilter, FtMintPayload, FtMintFilter, FtBurnPayload, FtBurnFilter, FindManyOptions, FactoryScope, EventForFilter, ErasedChainReadClient, DrizzleGenOptions, DeployPlan, DeployDiff, ContractDeployPayload, ContractDeployFilter, ContractCallPayload, ContractCallFilter, ContractCallEvent, ComputedValue, ComparisonFilter, ColumnType, ColumnToTS, ColumnDiff, ChainReadOptions, ChainReadMethods, ChainReadError, ChainReadClient, ChainReadCacheMode, ByoMigrationPlan, ByoBreakingChangeError, AnyEvent, AggregateSpec, AggregateResult };
package/dist/src/index.js CHANGED
@@ -3568,9 +3568,9 @@ async function processBlockRange(def, opts) {
3568
3568
  return { blocksProcessed, totalEventsProcessed, totalErrors, aborted };
3569
3569
  }
3570
3570
  async function resolveBlockRange(source, def, opts) {
3571
- const fromBlock = opts?.fromBlock ?? def.startBlock ?? 1;
3572
- const toBlock = opts?.toBlock != null ? opts.toBlock : await source.getTip();
3573
- return { fromBlock, toBlock };
3571
+ const definitionStart = def.startBlock ?? 1;
3572
+ const fromBlock = opts?.startBlockFloor != null ? Math.max(definitionStart, opts.startBlockFloor) : definitionStart;
3573
+ return { fromBlock, toBlock: await source.getTip() };
3574
3574
  }
3575
3575
  async function clearReindexMetadata(db, subgraphName) {
3576
3576
  await db.updateTable("subgraphs").set({ reindex_from_block: null, reindex_to_block: null }).where("name", "=", subgraphName).execute();
@@ -5086,5 +5086,5 @@ export {
5086
5086
  ByoBreakingChangeError
5087
5087
  };
5088
5088
 
5089
- //# debugId=8CAA9C7AD1208F2564756E2164756E21
5089
+ //# debugId=06A0A7FF47E0C5EE64756E2164756E21
5090
5090
  //# sourceMappingURL=index.js.map