@secondlayer/subgraphs 3.12.0 → 3.14.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 +54 -1
- package/dist/src/index.js +952 -199
- package/dist/src/index.js.map +12 -11
- package/dist/src/runtime/block-processor.d.ts +36 -1
- package/dist/src/runtime/block-processor.js +568 -86
- package/dist/src/runtime/block-processor.js.map +9 -8
- package/dist/src/runtime/catchup.d.ts +7 -0
- package/dist/src/runtime/catchup.js +587 -132
- 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 +665 -248
- package/dist/src/runtime/processor.js.map +13 -13
- package/dist/src/runtime/reindex.d.ts +7 -0
- package/dist/src/runtime/reindex.js +618 -198
- package/dist/src/runtime/reindex.js.map +10 -10
- package/dist/src/runtime/reorg.d.ts +7 -0
- package/dist/src/runtime/reorg.js +588 -87
- 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 +70 -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 +7 -0
- package/dist/src/schema/index.js +20 -2
- package/dist/src/schema/index.js.map +4 -4
- package/dist/src/service.js +665 -248
- package/dist/src/service.js.map +13 -13
- package/dist/src/types.d.ts +7 -0
- package/dist/src/validate.d.ts +7 -0
- package/dist/src/validate.js +3 -2
- 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 */
|
|
@@ -242,6 +249,34 @@ interface ProcessBlockOptions {
|
|
|
242
249
|
skipProgressUpdate?: boolean;
|
|
243
250
|
/** Pre-loaded block data — skips DB reads when provided (used by batch catch-up). */
|
|
244
251
|
preloaded?: PreloadedBlockData;
|
|
252
|
+
/**
|
|
253
|
+
* Crash-safe sequential processing. Two checkpoint scopes:
|
|
254
|
+
* - `{ status }` (reindex): a written block commits
|
|
255
|
+
* `subgraphs.last_processed_block = blockHeight` in the SAME transaction
|
|
256
|
+
* as its writes; replays skip at/below the cursor. Only for strictly
|
|
257
|
+
* ascending walks over the subgraph's own cursor.
|
|
258
|
+
* - `{ operationId }` (backfill): same guarantee against the OPERATION's
|
|
259
|
+
* own `cursor_block` — backfills legitimately revisit heights below the
|
|
260
|
+
* live cursor, so they must never checkpoint (or read) the subgraph
|
|
261
|
+
* cursor. The advance is a CONDITIONAL monotonic UPDATE: concurrent
|
|
262
|
+
* writers serialize on it, and the loser's whole block tx rolls back
|
|
263
|
+
* (surfaced as `skipped`, never an error/gap).
|
|
264
|
+
* Either way: a crash can never leave committed deltas ahead of the
|
|
265
|
+
* relevant checkpoint.
|
|
266
|
+
*/
|
|
267
|
+
atomicProgress?: {
|
|
268
|
+
status: string
|
|
269
|
+
} | {
|
|
270
|
+
operationId: string
|
|
271
|
+
};
|
|
245
272
|
}
|
|
273
|
+
/** Default per-block retry schedule before a failure counts as persistent. */
|
|
274
|
+
declare const BLOCK_RETRY_DELAYS_MS: number[];
|
|
275
|
+
/**
|
|
276
|
+
* processBlock with bounded retries. Throws the last error once the schedule
|
|
277
|
+
* is exhausted — callers decide whether that halts the walk (strict paths) or
|
|
278
|
+
* records a gap (backfill). Never advances any cursor on failure.
|
|
279
|
+
*/
|
|
280
|
+
declare function processBlockWithRetry(subgraph: SubgraphDefinition, subgraphName: string, blockHeight: number, opts?: ProcessBlockOptions, retryDelaysMs?: number[]): Promise<ProcessBlockResult>;
|
|
246
281
|
declare function processBlock(subgraph: SubgraphDefinition, subgraphName: string, blockHeight: number, opts?: ProcessBlockOptions): Promise<ProcessBlockResult>;
|
|
247
|
-
export { processBlock, invalidateSubgraphRoute, ProcessBlockTiming, ProcessBlockResult, ProcessBlockOptions, PreloadedBlockData };
|
|
282
|
+
export { processBlockWithRetry, processBlock, invalidateSubgraphRoute, ProcessBlockTiming, ProcessBlockResult, ProcessBlockOptions, PreloadedBlockData, BLOCK_RETRY_DELAYS_MS };
|