@secondlayer/subgraphs 3.11.0 → 3.13.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/dist/src/index.d.ts +36 -1
- package/dist/src/index.js +542 -180
- package/dist/src/index.js.map +12 -12
- package/dist/src/runtime/block-processor.d.ts +34 -1
- package/dist/src/runtime/block-processor.js +501 -72
- package/dist/src/runtime/block-processor.js.map +9 -8
- package/dist/src/runtime/catchup.d.ts +10 -0
- package/dist/src/runtime/catchup.js +520 -118
- package/dist/src/runtime/catchup.js.map +10 -9
- package/dist/src/runtime/context.d.ts +65 -3
- package/dist/src/runtime/context.js +390 -8
- package/dist/src/runtime/context.js.map +6 -4
- package/dist/src/runtime/processor.js +590 -230
- package/dist/src/runtime/processor.js.map +13 -13
- package/dist/src/runtime/reindex.d.ts +14 -0
- package/dist/src/runtime/reindex.js +538 -180
- package/dist/src/runtime/reindex.js.map +10 -10
- package/dist/src/runtime/reorg.d.ts +10 -0
- package/dist/src/runtime/reorg.js +521 -73
- package/dist/src/runtime/reorg.js.map +10 -9
- package/dist/src/runtime/replay.js.map +2 -2
- package/dist/src/runtime/runner.d.ts +73 -2
- package/dist/src/runtime/runner.js +56 -58
- package/dist/src/runtime/runner.js.map +3 -3
- package/dist/src/runtime/source-matcher.d.ts +2 -0
- package/dist/src/runtime/source-matcher.js.map +2 -2
- package/dist/src/schema/index.d.ts +10 -0
- package/dist/src/schema/index.js +19 -1
- package/dist/src/schema/index.js.map +5 -5
- package/dist/src/service.js +590 -230
- package/dist/src/service.js.map +13 -13
- package/dist/src/types.d.ts +10 -0
- package/dist/src/validate.d.ts +10 -0
- package/dist/src/validate.js +2 -1
- package/dist/src/validate.js.map +3 -3
- package/package.json +2 -2
|
@@ -165,6 +165,13 @@ interface SubgraphContext {
|
|
|
165
165
|
update(table: string, where: Record<string, unknown>, set: Record<string, unknown>): void;
|
|
166
166
|
upsert(table: string, key: Record<string, unknown>, row: Record<string, unknown>): void;
|
|
167
167
|
delete(table: string, where: Record<string, unknown>): void;
|
|
168
|
+
/**
|
|
169
|
+
* Atomic counter update — the blessed accumulator primitive. Applies
|
|
170
|
+
* `col = COALESCE(col, 0) + delta` per column (insert-or-add); deltas may
|
|
171
|
+
* be negative. Requires a uniqueKeys constraint matching `key`. Prefer
|
|
172
|
+
* this over patchOrInsert with functional updaters for running totals.
|
|
173
|
+
*/
|
|
174
|
+
increment(table: string, key: Record<string, unknown>, deltas: Record<string, bigint | number>): void;
|
|
168
175
|
/** Partial update — sets only specified fields, preserves others */
|
|
169
176
|
patch(table: string, where: Record<string, unknown>, set: Record<string, unknown>): void;
|
|
170
177
|
/** Find-then-merge-or-insert. Values can be functions: (existing) => newValue */
|
|
@@ -196,6 +203,9 @@ interface SubgraphDefinition {
|
|
|
196
203
|
description?: string;
|
|
197
204
|
/** Block height to start indexing from (default: 1) */
|
|
198
205
|
startBlock?: number;
|
|
206
|
+
/** 'concurrent' = tip-first: live at tip now, history backfills behind.
|
|
207
|
+
* Requires order-tolerant handlers. Default 'blocking'. */
|
|
208
|
+
backfillMode?: "blocking" | "concurrent";
|
|
199
209
|
/** Named source filters — keys become handler keys */
|
|
200
210
|
sources: Record<string, SubgraphFilter>;
|
|
201
211
|
/** Tables in this subgraph */
|
|
@@ -239,6 +249,29 @@ interface ProcessBlockOptions {
|
|
|
239
249
|
skipProgressUpdate?: boolean;
|
|
240
250
|
/** Pre-loaded block data — skips DB reads when provided (used by batch catch-up). */
|
|
241
251
|
preloaded?: PreloadedBlockData;
|
|
252
|
+
/**
|
|
253
|
+
* Crash-safe sequential processing (the reindex path). When set:
|
|
254
|
+
* - a block whose writes flush commits `last_processed_block = blockHeight`
|
|
255
|
+
* (with this status) in the SAME transaction, so a crash can never leave
|
|
256
|
+
* committed writes ahead of the checkpoint;
|
|
257
|
+
* - a block at or below the checkpoint is skipped entirely, so a replay
|
|
258
|
+
* (crash-resume overshoot, duplicate dispatch) can never double-apply
|
|
259
|
+
* deltas.
|
|
260
|
+
* Only valid for strictly ascending block walks over the subgraph's own
|
|
261
|
+
* cursor — backfill/reorg paths that legitimately revisit heights below
|
|
262
|
+
* the cursor must not set this.
|
|
263
|
+
*/
|
|
264
|
+
atomicProgress?: {
|
|
265
|
+
status: string
|
|
266
|
+
};
|
|
242
267
|
}
|
|
268
|
+
/** Default per-block retry schedule before a failure counts as persistent. */
|
|
269
|
+
declare const BLOCK_RETRY_DELAYS_MS: unknown;
|
|
270
|
+
/**
|
|
271
|
+
* processBlock with bounded retries. Throws the last error once the schedule
|
|
272
|
+
* is exhausted — callers decide whether that halts the walk (strict paths) or
|
|
273
|
+
* records a gap (backfill). Never advances any cursor on failure.
|
|
274
|
+
*/
|
|
275
|
+
declare function processBlockWithRetry(subgraph: SubgraphDefinition, subgraphName: string, blockHeight: number, opts?: ProcessBlockOptions, retryDelaysMs?: number[]): Promise<ProcessBlockResult>;
|
|
243
276
|
declare function processBlock(subgraph: SubgraphDefinition, subgraphName: string, blockHeight: number, opts?: ProcessBlockOptions): Promise<ProcessBlockResult>;
|
|
244
|
-
export { processBlock, invalidateSubgraphRoute, ProcessBlockTiming, ProcessBlockResult, ProcessBlockOptions, PreloadedBlockData };
|
|
277
|
+
export { processBlockWithRetry, processBlock, invalidateSubgraphRoute, ProcessBlockTiming, ProcessBlockResult, ProcessBlockOptions, PreloadedBlockData, BLOCK_RETRY_DELAYS_MS };
|