@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
package/dist/src/index.d.ts
CHANGED
|
@@ -206,6 +206,13 @@ interface SubgraphContext {
|
|
|
206
206
|
update(table: string, where: Record<string, unknown>, set: Record<string, unknown>): void;
|
|
207
207
|
upsert(table: string, key: Record<string, unknown>, row: Record<string, unknown>): void;
|
|
208
208
|
delete(table: string, where: Record<string, unknown>): void;
|
|
209
|
+
/**
|
|
210
|
+
* Atomic counter update — the blessed accumulator primitive. Applies
|
|
211
|
+
* `col = COALESCE(col, 0) + delta` per column (insert-or-add); deltas may
|
|
212
|
+
* be negative. Requires a uniqueKeys constraint matching `key`. Prefer
|
|
213
|
+
* this over patchOrInsert with functional updaters for running totals.
|
|
214
|
+
*/
|
|
215
|
+
increment(table: string, key: Record<string, unknown>, deltas: Record<string, bigint | number>): void;
|
|
209
216
|
/** Partial update — sets only specified fields, preserves others */
|
|
210
217
|
patch(table: string, where: Record<string, unknown>, set: Record<string, unknown>): void;
|
|
211
218
|
/** Find-then-merge-or-insert. Values can be functions: (existing) => newValue */
|
|
@@ -237,6 +244,9 @@ interface SubgraphDefinition {
|
|
|
237
244
|
description?: string;
|
|
238
245
|
/** Block height to start indexing from (default: 1) */
|
|
239
246
|
startBlock?: number;
|
|
247
|
+
/** 'concurrent' = tip-first: live at tip now, history backfills behind.
|
|
248
|
+
* Requires order-tolerant handlers. Default 'blocking'. */
|
|
249
|
+
backfillMode?: "blocking" | "concurrent";
|
|
240
250
|
/** Named source filters — keys become handler keys */
|
|
241
251
|
sources: Record<string, SubgraphFilter>;
|
|
242
252
|
/** Tables in this subgraph */
|
|
@@ -252,6 +262,8 @@ interface ReindexOptions {
|
|
|
252
262
|
fromBlock?: number;
|
|
253
263
|
toBlock?: number;
|
|
254
264
|
schemaName?: string;
|
|
265
|
+
/** Op row to receive processed_events on each progress flush. */
|
|
266
|
+
operationId?: string;
|
|
255
267
|
signal?: AbortSignal;
|
|
256
268
|
}
|
|
257
269
|
/**
|
|
@@ -269,6 +281,7 @@ declare function reindexSubgraph(def: SubgraphDefinition, opts?: ReindexOptions)
|
|
|
269
281
|
*/
|
|
270
282
|
declare function resumeReindex(def: SubgraphDefinition, opts: {
|
|
271
283
|
schemaName: string
|
|
284
|
+
operationId?: string
|
|
272
285
|
signal?: AbortSignal
|
|
273
286
|
}): Promise<{
|
|
274
287
|
processed: number
|
|
@@ -282,6 +295,7 @@ declare function backfillSubgraph(def: SubgraphDefinition, opts: {
|
|
|
282
295
|
fromBlock: number
|
|
283
296
|
toBlock: number
|
|
284
297
|
schemaName?: string
|
|
298
|
+
operationId?: string
|
|
285
299
|
signal?: AbortSignal
|
|
286
300
|
}): Promise<{
|
|
287
301
|
processed: number
|
|
@@ -727,6 +741,14 @@ interface ColumnDiff {
|
|
|
727
741
|
* Compare two multi-table subgraph schemas and return differences.
|
|
728
742
|
*/
|
|
729
743
|
declare function diffSchema(existing: SubgraphSchema, incoming: SubgraphSchema): TableDiff;
|
|
744
|
+
/**
|
|
745
|
+
* Returns true if the diff contains any breaking changes
|
|
746
|
+
* (removed tables, removed columns, or changed column types).
|
|
747
|
+
*/
|
|
748
|
+
declare function hasBreakingChanges(diff: TableDiff): {
|
|
749
|
+
breaking: boolean
|
|
750
|
+
reasons: string[]
|
|
751
|
+
};
|
|
730
752
|
interface DeployDiff {
|
|
731
753
|
addedTables: string[];
|
|
732
754
|
removedTables: string[];
|
|
@@ -794,4 +816,17 @@ declare function deploySchema(db: AnyDb, def: SubgraphDefinition, handlerPath: s
|
|
|
794
816
|
version: string
|
|
795
817
|
diff?: DeployDiff
|
|
796
818
|
}>;
|
|
797
|
-
|
|
819
|
+
/** A (decoded event type, optional contract scope) pair the sparse probe
|
|
820
|
+
* checks. Contract scoping is what makes token-subgraph reindexes leap over
|
|
821
|
+
* everything that isn't their token. */
|
|
822
|
+
type SparseProbeTarget = {
|
|
823
|
+
eventType: string
|
|
824
|
+
contractId?: string
|
|
825
|
+
};
|
|
826
|
+
/** Sparse scanning is sound only when EVERY source is an event-type filter —
|
|
827
|
+
* a contract_call/contract_deploy source matches transactions, which the
|
|
828
|
+
* event probe can't see. */
|
|
829
|
+
declare function canSparseScan(subgraph: SubgraphDefinition): boolean;
|
|
830
|
+
/** Probe targets for a subgraph's filters: decoded type + contract scope when\\n* the filter pins one (assetIdentifier "SP….contract::asset" or contractId). */
|
|
831
|
+
declare function sparseProbeTargets(subgraph: SubgraphDefinition): SparseProbeTarget[];
|
|
832
|
+
export { validateSubgraphDefinition, sparseProbeTargets, resumeReindex, renderDeployPlan, reindexSubgraph, pgSchemaName, hasBreakingChanges, generateSubgraphSQL, generatePrismaSchema, generateKyselySchema, generateIndexSchema, generateDrizzleSchema, diffSchema, deploySchema, defineSubgraph, canSparseScan, 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, PrintEventPayload, PrintEventFor, PrintEventFilter, NftTransferPayload, NftTransferFilter, NftMintPayload, NftMintFilter, NftBurnPayload, NftBurnFilter, KyselyGenOptions, InferTableRow, InferSubgraphClient, InferColumnType, IndexCodegenTarget, IndexCodegenOptions, INDEX_CODEGEN_TABLES, GeneratedSQL, FtTransferPayload, FtTransferFilter, FtMintPayload, FtMintFilter, FtBurnPayload, FtBurnFilter, FindManyOptions, EventForFilter, DrizzleGenOptions, DeployPlan, DeployDiff, ContractDeployPayload, ContractDeployFilter, ContractCallPayload, ContractCallFilter, ContractCallEvent, ComputedValue, ComparisonFilter, ColumnType, ColumnToTS, ColumnDiff, ByoMigrationPlan, ByoBreakingChangeError, AnyEvent, AggregateSpec, AggregateResult };
|