@secondlayer/subgraphs 3.11.0 → 3.12.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.
@@ -196,6 +196,9 @@ interface SubgraphDefinition {
196
196
  description?: string;
197
197
  /** Block height to start indexing from (default: 1) */
198
198
  startBlock?: number;
199
+ /** 'concurrent' = tip-first: live at tip now, history backfills behind.
200
+ * Requires order-tolerant handlers. Default 'blocking'. */
201
+ backfillMode?: "blocking" | "concurrent";
199
202
  /** Named source filters — keys become handler keys */
200
203
  sources: Record<string, SubgraphFilter>;
201
204
  /** Tables in this subgraph */
@@ -196,6 +196,9 @@ interface SubgraphDefinition {
196
196
  description?: string;
197
197
  /** Block height to start indexing from (default: 1) */
198
198
  startBlock?: number;
199
+ /** 'concurrent' = tip-first: live at tip now, history backfills behind.
200
+ * Requires order-tolerant handlers. Default 'blocking'. */
201
+ backfillMode?: "blocking" | "concurrent";
199
202
  /** Named source filters — keys become handler keys */
200
203
  sources: Record<string, SubgraphFilter>;
201
204
  /** Tables in this subgraph */
@@ -1782,6 +1782,7 @@ import {
1782
1782
  recordGapBatch,
1783
1783
  resolveGaps
1784
1784
  } from "@secondlayer/shared/db/queries/subgraph-gaps";
1785
+ import { updateOperationProcessedEvents } from "@secondlayer/shared/db/queries/subgraph-operations";
1785
1786
  import {
1786
1787
  recordSubgraphProcessed as recordSubgraphProcessed2,
1787
1788
  updateSubgraphStatus as updateSubgraphStatus2
@@ -2048,6 +2049,9 @@ async function processBlockRange(def, opts) {
2048
2049
  const shouldFlushProgress = blocksProcessed % 100 === 0 || now - lastProgressFlushAt >= PROGRESS_FLUSH_INTERVAL_MS;
2049
2050
  if (shouldFlushProgress) {
2050
2051
  await updateSubgraphStatus2(targetDb, subgraphName, status, height);
2052
+ if (opts.operationId) {
2053
+ await updateOperationProcessedEvents(targetDb, opts.operationId, totalEventsProcessed).catch(() => {});
2054
+ }
2051
2055
  lastProgressFlushAt = now;
2052
2056
  }
2053
2057
  if (blocksProcessed % LOG_INTERVAL === 0) {
@@ -2165,6 +2169,7 @@ async function reindexSubgraph(def, opts) {
2165
2169
  isCatchup: false,
2166
2170
  apiKeyId: null,
2167
2171
  subgraphId: subgraphRow?.id,
2172
+ operationId: opts?.operationId,
2168
2173
  signal: opts?.signal
2169
2174
  });
2170
2175
  if (result.aborted) {
@@ -2240,6 +2245,7 @@ async function resumeReindex(def, opts) {
2240
2245
  isCatchup: false,
2241
2246
  apiKeyId: null,
2242
2247
  subgraphId: row.id,
2248
+ operationId: opts.operationId,
2243
2249
  signal: opts.signal
2244
2250
  });
2245
2251
  if (result.aborted) {
@@ -2288,6 +2294,7 @@ async function backfillSubgraph(def, opts) {
2288
2294
  isCatchup: false,
2289
2295
  apiKeyId: null,
2290
2296
  subgraphId: subgraphRow?.id,
2297
+ operationId: opts.operationId,
2291
2298
  signal: opts.signal
2292
2299
  });
2293
2300
  if (result.aborted) {
@@ -2830,6 +2837,7 @@ async function runSubgraphOperation(operation, signal) {
2830
2837
  fromBlock: Number(operation.from_block),
2831
2838
  toBlock: Number(operation.to_block),
2832
2839
  schemaName,
2840
+ operationId: operation.id,
2833
2841
  signal
2834
2842
  });
2835
2843
  return result2.processed;
@@ -2839,13 +2847,18 @@ async function runSubgraphOperation(operation, signal) {
2839
2847
  }
2840
2848
  const hasResumeMetadata = subgraph.status === "reindexing" && subgraph.reindex_from_block != null && subgraph.reindex_to_block != null;
2841
2849
  if (hasResumeMetadata) {
2842
- const result2 = await resumeReindex(def, { schemaName, signal });
2850
+ const result2 = await resumeReindex(def, {
2851
+ schemaName,
2852
+ operationId: operation.id,
2853
+ signal
2854
+ });
2843
2855
  return result2.processed;
2844
2856
  }
2845
2857
  const result = await reindexSubgraph(def, {
2846
2858
  fromBlock: operation.from_block == null ? undefined : Number(operation.from_block),
2847
2859
  toBlock: operation.to_block == null ? undefined : Number(operation.to_block),
2848
2860
  schemaName,
2861
+ operationId: operation.id,
2849
2862
  signal
2850
2863
  });
2851
2864
  return result.processed;
@@ -3055,5 +3068,5 @@ export {
3055
3068
  startSubgraphOperationRunner
3056
3069
  };
3057
3070
 
3058
- //# debugId=B5C517086F325E0564756E2164756E21
3071
+ //# debugId=CA67CC38C44D43DF64756E2164756E21
3059
3072
  //# sourceMappingURL=processor.js.map