@secondlayer/subgraphs 0.5.7 → 0.7.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 +17 -5
- package/dist/src/index.js +467 -191
- package/dist/src/index.js.map +16 -15
- package/dist/src/runtime/block-processor.d.ts +9 -1
- package/dist/src/runtime/block-processor.js +216 -144
- package/dist/src/runtime/block-processor.js.map +9 -9
- package/dist/src/runtime/catchup.d.ts +2 -2
- package/dist/src/runtime/catchup.js +366 -160
- package/dist/src/runtime/catchup.js.map +12 -11
- package/dist/src/runtime/clarity.js.map +2 -2
- package/dist/src/runtime/context.d.ts +4 -2
- package/dist/src/runtime/context.js +79 -36
- package/dist/src/runtime/context.js.map +3 -3
- package/dist/src/runtime/processor.js +384 -166
- package/dist/src/runtime/processor.js.map +14 -13
- package/dist/src/runtime/reindex.d.ts +13 -1
- package/dist/src/runtime/reindex.js +459 -189
- package/dist/src/runtime/reindex.js.map +13 -12
- package/dist/src/runtime/reorg.js +229 -148
- package/dist/src/runtime/reorg.js.map +10 -10
- package/dist/src/runtime/runner.d.ts +4 -2
- package/dist/src/runtime/runner.js +7 -3
- package/dist/src/runtime/runner.js.map +4 -4
- package/dist/src/runtime/source-matcher.js.map +3 -3
- package/dist/src/runtime/stats.d.ts +1 -1
- package/dist/src/runtime/stats.js +2 -2
- package/dist/src/runtime/stats.js.map +3 -3
- package/dist/src/schema/index.d.ts +1 -1
- package/dist/src/schema/index.js +9 -3
- package/dist/src/schema/index.js.map +5 -5
- package/dist/src/service.js +385 -167
- package/dist/src/service.js.map +15 -14
- package/dist/src/templates.js.map +2 -2
- package/dist/src/types.js.map +2 -2
- package/dist/src/validate.js +2 -2
- package/dist/src/validate.js.map +3 -3
- package/package.json +51 -51
package/dist/src/index.d.ts
CHANGED
|
@@ -94,6 +94,18 @@ declare function reindexSubgraph(def: SubgraphDefinition, opts?: ReindexOptions)
|
|
|
94
94
|
processed: number
|
|
95
95
|
}>;
|
|
96
96
|
/**
|
|
97
|
+
* Backfill a subgraph by re-processing a block range WITHOUT dropping the schema.
|
|
98
|
+
* Uses upserts so existing data is updated, not duplicated. Safe to run while
|
|
99
|
+
* the subgraph is actively syncing.
|
|
100
|
+
*/
|
|
101
|
+
declare function backfillSubgraph(def: SubgraphDefinition, opts: {
|
|
102
|
+
fromBlock: number
|
|
103
|
+
toBlock: number
|
|
104
|
+
schemaName?: string
|
|
105
|
+
}): Promise<{
|
|
106
|
+
processed: number
|
|
107
|
+
}>;
|
|
108
|
+
/**
|
|
97
109
|
* Identity function that preserves schema literal types for type inference.
|
|
98
110
|
*
|
|
99
111
|
* The generic `S` is narrowed to the exact schema shape so that column type
|
|
@@ -126,8 +138,8 @@ interface GeneratedSQL {
|
|
|
126
138
|
*/
|
|
127
139
|
declare function generateSubgraphSQL(def: SubgraphDefinition, schemaNameOverride?: string): GeneratedSQL;
|
|
128
140
|
import { pgSchemaName } from "@secondlayer/shared/db/queries/subgraphs";
|
|
129
|
-
import { Kysely } from "kysely";
|
|
130
141
|
import { Database } from "@secondlayer/shared/db";
|
|
142
|
+
import { Kysely } from "kysely";
|
|
131
143
|
type AnyDb = Kysely<Database>;
|
|
132
144
|
interface TableDiff {
|
|
133
145
|
/** Tables added to the schema */
|
|
@@ -162,13 +174,13 @@ declare function deploySchema(db: AnyDb, def: SubgraphDefinition, handlerPath: s
|
|
|
162
174
|
subgraphId: string
|
|
163
175
|
}>;
|
|
164
176
|
/** Maps a ColumnType string literal to its TypeScript equivalent */
|
|
165
|
-
type ColumnToTS<T extends string> = T extends "uint" | "int" ?
|
|
177
|
+
type ColumnToTS<T extends string> = T extends "uint" | "int" ? bigint : T extends "text" | "principal" | "timestamp" ? string : T extends "boolean" ? boolean : T extends "jsonb" ? Record<string, unknown> : unknown;
|
|
166
178
|
/** Infer TS type for a single column definition, respecting nullable */
|
|
167
179
|
type InferColumnType<C extends SubgraphColumn> = C["type"] extends ColumnType ? C["nullable"] extends true ? ColumnToTS<C["type"]> | null : ColumnToTS<C["type"]> : unknown;
|
|
168
180
|
/** Shape of system columns on every returned row (camelCase, underscore-prefixed) */
|
|
169
181
|
interface SystemRow {
|
|
170
182
|
_id: string;
|
|
171
|
-
_blockHeight:
|
|
183
|
+
_blockHeight: bigint;
|
|
172
184
|
_txId: string;
|
|
173
185
|
_createdAt: string;
|
|
174
186
|
}
|
|
@@ -190,7 +202,7 @@ type WhereInput<TRow> = { [K in keyof TRow]? : TRow[K] | ComparisonFilter<TRow[K
|
|
|
190
202
|
* Both `_blockHeight` and `blockHeight` are valid — serializer handles mapping.
|
|
191
203
|
*/
|
|
192
204
|
type SystemWhereAliases = {
|
|
193
|
-
blockHeight?:
|
|
205
|
+
blockHeight?: bigint | ComparisonFilter<bigint>
|
|
194
206
|
txId?: string | ComparisonFilter<string>
|
|
195
207
|
createdAt?: string | ComparisonFilter<string>
|
|
196
208
|
id?: string | ComparisonFilter<string>
|
|
@@ -216,4 +228,4 @@ interface SubgraphTableClient<TRow> {
|
|
|
216
228
|
type InferSubgraphClient<T> = T extends {
|
|
217
229
|
schema: infer S
|
|
218
230
|
} ? { [K in keyof S] : S[K] extends SubgraphTable ? SubgraphTableClient<InferTableRow<S[K]>> : never } : never;
|
|
219
|
-
export { validateSubgraphDefinition, sourceKey, reindexSubgraph, pgSchemaName, generateSubgraphSQL, diffSchema, deploySchema, defineSubgraph, WhereInput, TableDiff, SystemRow, SubgraphTableClient, SubgraphTable, SubgraphSource, SubgraphSchema, SubgraphHandler, SubgraphDefinition, SubgraphContext, SubgraphColumn, ReindexOptions, InferTableRow, InferSubgraphClient, InferColumnType, GeneratedSQL, FindManyOptions, ComparisonFilter, ColumnType, ColumnToTS, ColumnDiff };
|
|
231
|
+
export { validateSubgraphDefinition, sourceKey, reindexSubgraph, pgSchemaName, generateSubgraphSQL, diffSchema, deploySchema, defineSubgraph, backfillSubgraph, WhereInput, TableDiff, SystemRow, SubgraphTableClient, SubgraphTable, SubgraphSource, SubgraphSchema, SubgraphHandler, SubgraphDefinition, SubgraphContext, SubgraphColumn, ReindexOptions, InferTableRow, InferSubgraphClient, InferColumnType, GeneratedSQL, FindManyOptions, ComparisonFilter, ColumnType, ColumnToTS, ColumnDiff };
|