@secondlayer/subgraphs 7.0.1 → 7.0.3
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/index.d.ts +148 -53
- package/dist/index.js +6 -5
- package/dist/index.js.map +15 -15
- package/dist/runtime/replay.d.ts +3 -0
- package/dist/runtime/replay.js +6 -5
- package/dist/runtime/replay.js.map +7 -7
- package/dist/schema/index.d.ts +18 -7
- package/dist/schema/index.js +6 -5
- package/dist/schema/index.js.map +6 -6
- package/dist/testing/index.d.ts +62 -10
- package/dist/testing/index.js +6 -5
- package/dist/testing/index.js.map +10 -10
- package/dist/types.d.ts +9 -2
- package/dist/validate.d.ts +18 -7
- package/dist/validate.js.map +2 -2
- package/dist/verification.d.ts +15 -4
- package/dist/verification.js +6 -5
- package/dist/verification.js.map +3 -3
- package/dist/verify/index.d.ts +37 -14
- package/dist/verify/index.js +6 -5
- package/dist/verify/index.js.map +10 -10
- package/package.json +5 -4
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ import { AbiContract, ExtractFunctionArgs, ExtractFunctionOutput, ExtractReadOnl
|
|
|
17
17
|
* first answer forever, so it is opt-in and never inferred.
|
|
18
18
|
*/
|
|
19
19
|
type ChainReadCacheMode = "per-block" | "contract-constant";
|
|
20
|
+
/** Options for a contract read, such as cache mode. */
|
|
20
21
|
type ChainReadOptions = {
|
|
21
22
|
cache?: ChainReadCacheMode;
|
|
22
23
|
};
|
|
@@ -77,13 +78,24 @@ type ChainReadMethods<C extends AbiContract> = { [N in ExtractReadOnlyFunctions<
|
|
|
77
78
|
* one and handlers get full inference.
|
|
78
79
|
*/
|
|
79
80
|
interface ErasedChainReadClient {
|
|
81
|
+
/**
|
|
82
|
+
* Reads a contract's read-only functions at the block being processed.
|
|
83
|
+
*
|
|
84
|
+
* Results are untyped here. Call it through `readContractAt` to get typed
|
|
85
|
+
* results from the contract's ABI.
|
|
86
|
+
*/
|
|
80
87
|
contract(contractId: string, abi: unknown, options?: ChainReadOptions): {
|
|
81
88
|
read: Record<string, (args?: Record<string, unknown>) => Promise<unknown>>;
|
|
82
89
|
};
|
|
83
90
|
}
|
|
84
91
|
/**
|
|
85
|
-
*
|
|
92
|
+
* Reads a contract's read-only functions from a handler, with typed results.
|
|
86
93
|
*
|
|
94
|
+
* Pass `ctx`, the contract id and its ABI. Every call is pinned to the block
|
|
95
|
+
* being processed. Set `options.cache` to `"contract-constant"` to fetch a
|
|
96
|
+
* value once per contract instead of once per block.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
87
99
|
* ```ts
|
|
88
100
|
* const token = readContractAt(ctx, contractId, SIP010_ABI, {
|
|
89
101
|
* cache: "contract-constant",
|
|
@@ -126,7 +138,7 @@ interface SubgraphTable {
|
|
|
126
138
|
/** Unique key constraints (each entry is an array of column names). Required for upsert. */
|
|
127
139
|
uniqueKeys?: readonly (readonly string[])[];
|
|
128
140
|
}
|
|
129
|
-
/**
|
|
141
|
+
/** Maps table names to table definitions. */
|
|
130
142
|
type SubgraphSchema = Record<string, SubgraphTable>;
|
|
131
143
|
/** STX event filters */
|
|
132
144
|
interface StxTransferFilter {
|
|
@@ -398,7 +410,7 @@ type UnpinnedPrintEventFilter = PrintEventFields & {
|
|
|
398
410
|
* `prints`; trait and unpinned sources may omit it.
|
|
399
411
|
*/
|
|
400
412
|
type PrintEventFilter = PinnedPrintEventFilter | TraitPrintEventFilter | UnpinnedPrintEventFilter;
|
|
401
|
-
/**
|
|
413
|
+
/** A subgraph filter, discriminated on `type`. */
|
|
402
414
|
type SubgraphFilter = StxTransferFilter | StxMintFilter | StxBurnFilter | StxLockFilter | FtTransferFilter | FtMintFilter | FtBurnFilter | NftTransferFilter | NftMintFilter | NftBurnFilter | ContractCallFilter | ContractDeployFilter | PrintEventFilter | NestedContractCallFilter | VarSetFilter | MapWriteFilter;
|
|
403
415
|
/** Transaction metadata available in handlers */
|
|
404
416
|
interface TxMeta {
|
|
@@ -669,21 +681,53 @@ interface TypedSubgraphContext<S extends SubgraphSchema> {
|
|
|
669
681
|
* `readContractAt(ctx, id, abi)` for full ABI typing at the call site.
|
|
670
682
|
*/
|
|
671
683
|
client: ErasedChainReadClient;
|
|
684
|
+
/**
|
|
685
|
+
* Queues a new row for a table.
|
|
686
|
+
*
|
|
687
|
+
* Writes are batched and applied together when the block commits.
|
|
688
|
+
* `_block_height` and `_tx_id` are filled in for you.
|
|
689
|
+
*/
|
|
672
690
|
insert<T extends TableName<S>>(table: T, row: WriteRow<S[T]>): void;
|
|
691
|
+
/**
|
|
692
|
+
* Queues an update to the rows matching `where`.
|
|
693
|
+
*
|
|
694
|
+
* `set` holds only the columns to change.
|
|
695
|
+
*/
|
|
673
696
|
update<T extends TableName<S>>(table: T, where: RowWhere<S, T>, set: Partial<WriteRow<S[T]>>): void;
|
|
697
|
+
/**
|
|
698
|
+
* Inserts a row, or updates the one with the same key.
|
|
699
|
+
*
|
|
700
|
+
* `key` should match a `uniqueKeys` constraint of the table. Without one the
|
|
701
|
+
* write falls back to a lookup first and logs a warning.
|
|
702
|
+
*/
|
|
674
703
|
upsert<
|
|
675
704
|
T extends TableName<S>,
|
|
676
705
|
K extends Partial<WriteRow<S[T]>>
|
|
677
706
|
>(table: T, key: K, row: Omit<WriteRow<S[T]>, keyof K> & Partial<WriteRow<S[T]>>): void;
|
|
707
|
+
/** Queues deletion of the rows matching `where`. */
|
|
678
708
|
delete<T extends TableName<S>>(table: T, where: RowWhere<S, T>): void;
|
|
679
709
|
/**
|
|
680
|
-
*
|
|
681
|
-
*
|
|
682
|
-
*
|
|
683
|
-
*
|
|
710
|
+
* Adds signed deltas to a counter row, creating it if missing.
|
|
711
|
+
*
|
|
712
|
+
* It compiles to `INSERT … ON CONFLICT (key) DO UPDATE SET col =
|
|
713
|
+
* COALESCE(col,0) + delta`. Deltas commute, so it is the reorg-safe way to
|
|
714
|
+
* keep running totals such as per-cycle aggregates and balances. It needs a
|
|
715
|
+
* `uniqueKeys` constraint matching `key`, and deltas may be `number` or
|
|
716
|
+
* `bigint`.
|
|
684
717
|
*/
|
|
685
718
|
increment<T extends TableName<S>>(table: T, key: Partial<WriteRow<S[T]>>, deltas: Partial<Record<ColumnName<S, T>, bigint | number>>): void;
|
|
719
|
+
/**
|
|
720
|
+
* Returns the first row matching `where`, or `null`.
|
|
721
|
+
*
|
|
722
|
+
* Reads see the writes queued earlier in the same block, and rows come back
|
|
723
|
+
* in insertion order.
|
|
724
|
+
*/
|
|
686
725
|
findOne<T extends TableName<S>>(table: T, where: RowWhere<S, T>): Promise<InferTableRow<S[T]> | null>;
|
|
726
|
+
/**
|
|
727
|
+
* Returns every row matching `where`, in insertion order.
|
|
728
|
+
*
|
|
729
|
+
* Reads see the writes queued earlier in the same block.
|
|
730
|
+
*/
|
|
687
731
|
findMany<T extends TableName<S>>(table: T, where: RowWhere<S, T>): Promise<InferTableRow<S[T]>[]>;
|
|
688
732
|
}
|
|
689
733
|
/** Infer a typed client object from a subgraph definition shape */
|
|
@@ -900,8 +944,11 @@ type TypedHandlers<
|
|
|
900
944
|
Sources extends Record<string, SubgraphFilter>,
|
|
901
945
|
S extends SubgraphSchema
|
|
902
946
|
> = { [K in keyof Sources]-? : HandlerFn<Sources[K], S> };
|
|
903
|
-
/**
|
|
904
|
-
*
|
|
947
|
+
/**
|
|
948
|
+
* A subgraph definition that keeps `sources` and `schema` literals typed.
|
|
949
|
+
*
|
|
950
|
+
* Preserved for typed handlers and downstream query-client inference (`getSubgraph`).
|
|
951
|
+
*/
|
|
905
952
|
type TypedSubgraphDefinition<
|
|
906
953
|
Sources extends Record<string, SubgraphFilter>,
|
|
907
954
|
S extends SubgraphSchema
|
|
@@ -911,8 +958,10 @@ type TypedSubgraphDefinition<
|
|
|
911
958
|
handlers: TypedHandlers<Sources, S>;
|
|
912
959
|
};
|
|
913
960
|
/**
|
|
914
|
-
*
|
|
915
|
-
*
|
|
961
|
+
* Declares a subgraph and keeps its source and schema literal types.
|
|
962
|
+
*
|
|
963
|
+
* Handlers are typed per source, and the schema drives query-client inference.
|
|
964
|
+
* It returns its argument unchanged.
|
|
916
965
|
*
|
|
917
966
|
* @example
|
|
918
967
|
* ```ts
|
|
@@ -934,9 +983,14 @@ declare function defineSubgraph<
|
|
|
934
983
|
const S extends SubgraphSchema
|
|
935
984
|
>(def: TypedSubgraphDefinition<Sources, S>): TypedSubgraphDefinition<Sources, S>;
|
|
936
985
|
/**
|
|
937
|
-
*
|
|
938
|
-
*
|
|
986
|
+
* Declares a schema you can hoist out of `defineSubgraph()` and reuse.
|
|
987
|
+
*
|
|
988
|
+
* It keeps the schema's literal types, so table names and row columns stay
|
|
989
|
+
* checked in helpers typed `TypedSubgraphContext<typeof schema>`. `as const`
|
|
990
|
+
* alone does not work: it produces `readonly` arrays that a mutable
|
|
991
|
+
* `uniqueKeys` rejects, and a bare literal widens `type` to `string`.
|
|
939
992
|
*
|
|
993
|
+
* @example
|
|
940
994
|
* ```ts
|
|
941
995
|
* const schema = defineSchema({
|
|
942
996
|
* balances: {
|
|
@@ -945,19 +999,14 @@ declare function defineSubgraph<
|
|
|
945
999
|
* },
|
|
946
1000
|
* });
|
|
947
1001
|
*
|
|
948
|
-
* // An extracted helper keeps the full typed surface
|
|
949
|
-
* // columns are still checked
|
|
1002
|
+
* // An extracted helper keeps the full typed surface: table names and row
|
|
1003
|
+
* // columns are still checked.
|
|
950
1004
|
* function credit(ctx: TypedSubgraphContext<typeof schema>, holder: string) {
|
|
951
1005
|
* ctx.increment("balances", { holder }, { amount: 1n });
|
|
952
1006
|
* }
|
|
953
1007
|
*
|
|
954
1008
|
* defineSubgraph({ name: "balances", schema, sources, handlers });
|
|
955
1009
|
* ```
|
|
956
|
-
*
|
|
957
|
-
* `as const` alone does not work here (it produces `readonly` arrays that a
|
|
958
|
-
* mutable `uniqueKeys` rejected) and a bare literal widens `type` to `string`.
|
|
959
|
-
* That gap is why the shipped starter typed its helper `ctx: any` — and in
|
|
960
|
-
* doing so modelled a non-commutative read-modify-write the docs warn against.
|
|
961
1010
|
*/
|
|
962
1011
|
declare function defineSchema<const S extends SubgraphSchema>(schema: S): S;
|
|
963
1012
|
/**
|
|
@@ -976,14 +1025,18 @@ type InferContext<D> = D extends {
|
|
|
976
1025
|
schema: infer S extends SubgraphSchema;
|
|
977
1026
|
} ? TypedSubgraphContext<S> : never;
|
|
978
1027
|
/**
|
|
979
|
-
* Validates a subgraph definition
|
|
1028
|
+
* Validates a subgraph definition and returns the parsed result.
|
|
1029
|
+
*
|
|
1030
|
+
* It throws when the definition is invalid.
|
|
980
1031
|
*/
|
|
981
1032
|
declare function validateSubgraphDefinition(def: unknown): SubgraphDefinition;
|
|
982
1033
|
/**
|
|
983
|
-
*
|
|
984
|
-
*
|
|
985
|
-
*
|
|
986
|
-
*
|
|
1034
|
+
* Lists the fields each source filter type accepts.
|
|
1035
|
+
*
|
|
1036
|
+
* The list is derived from {@link SubgraphFilterSchema}. Agent-facing surfaces
|
|
1037
|
+
* such as the MCP filters reference used to keep a parallel copy by hand;
|
|
1038
|
+
* deriving it means adding a field to a filter can never leave the
|
|
1039
|
+
* documentation behind.
|
|
987
1040
|
*/
|
|
988
1041
|
declare function filterFieldsByType(): Array<{
|
|
989
1042
|
type: string;
|
|
@@ -1021,6 +1074,7 @@ interface InferredPrintField {
|
|
|
1021
1074
|
/** Only when optional observed: share of present samples that were some */
|
|
1022
1075
|
optional_some_rate?: number;
|
|
1023
1076
|
}
|
|
1077
|
+
/** The fields seen in one `print` topic, with counts and heights. */
|
|
1024
1078
|
interface InferredTopicSchema {
|
|
1025
1079
|
topic: string;
|
|
1026
1080
|
count: number;
|
|
@@ -1029,8 +1083,12 @@ interface InferredTopicSchema {
|
|
|
1029
1083
|
non_tuple: boolean;
|
|
1030
1084
|
fields: InferredPrintField[];
|
|
1031
1085
|
}
|
|
1032
|
-
/**
|
|
1033
|
-
*
|
|
1086
|
+
/**
|
|
1087
|
+
* Camelizes object keys recursively, the way print payloads are.
|
|
1088
|
+
*
|
|
1089
|
+
* It uses the print-payload helper, not ABI `toCamelCase`, which strips `-STX`
|
|
1090
|
+
* and prefixes leading digits.
|
|
1091
|
+
*/
|
|
1034
1092
|
declare function camelizeKeys(obj: unknown): unknown;
|
|
1035
1093
|
/**
|
|
1036
1094
|
* Infers per-topic field schemas from sampled print events. Counts and
|
|
@@ -1062,6 +1120,7 @@ interface HandlerFinding {
|
|
|
1062
1120
|
/** 1-based. */
|
|
1063
1121
|
column: number;
|
|
1064
1122
|
}
|
|
1123
|
+
/** Formats a handler finding as `file:line:column name: reason`. */
|
|
1065
1124
|
declare function formatFinding(f: HandlerFinding): string;
|
|
1066
1125
|
/**
|
|
1067
1126
|
* Derive how far a subgraph's rows can be checked. Level = the highest any
|
|
@@ -1072,10 +1131,13 @@ declare function formatFinding(f: HandlerFinding): string;
|
|
|
1072
1131
|
*/
|
|
1073
1132
|
declare function deriveVerification(def: Pick<SubgraphDefinition, "sources" | "backfillMode">, findings?: readonly HandlerFinding[]): SubgraphVerification;
|
|
1074
1133
|
/**
|
|
1075
|
-
*
|
|
1076
|
-
*
|
|
1134
|
+
* Tells whether a deploy must be refused for breaking determinism.
|
|
1135
|
+
*
|
|
1136
|
+
* It is refused when the sources are provable (`state`), so the determinism
|
|
1137
|
+
* contract is enforced, and the scan broke it.
|
|
1077
1138
|
*/
|
|
1078
1139
|
declare function isDeterminismViolation(v: SubgraphVerification): boolean;
|
|
1140
|
+
/** What a pin is computed from: schema hash, handler code, network. */
|
|
1079
1141
|
interface PinInput {
|
|
1080
1142
|
/** Existing `schema_hash` (name + schema + sources). */
|
|
1081
1143
|
schemaHash: string;
|
|
@@ -1109,11 +1171,13 @@ declare class HandlerReadError extends Error {
|
|
|
1109
1171
|
name: string;
|
|
1110
1172
|
}
|
|
1111
1173
|
/**
|
|
1112
|
-
*
|
|
1113
|
-
*
|
|
1114
|
-
*
|
|
1174
|
+
* Loads a bundled handler into a fresh deterministic realm.
|
|
1175
|
+
*
|
|
1176
|
+
* The bundle is ESM, as stored in `handler_code`. The returned definition has
|
|
1177
|
+
* every handler wrapped to receive the {@link deterministicContext} facade.
|
|
1115
1178
|
*/
|
|
1116
1179
|
declare function loadDeterministicDefinition(handlerCode: string): Promise<SubgraphDefinition>;
|
|
1180
|
+
/** The SQL statements for a subgraph's tables and their hash. */
|
|
1117
1181
|
interface GeneratedSQL {
|
|
1118
1182
|
statements: string[];
|
|
1119
1183
|
hash: string;
|
|
@@ -1124,6 +1188,7 @@ interface GeneratedSQL {
|
|
|
1124
1188
|
* each with auto-columns and indexes.
|
|
1125
1189
|
*/
|
|
1126
1190
|
declare function generateSubgraphSQL(def: SubgraphDefinition, schemaNameOverride?: string): GeneratedSQL;
|
|
1191
|
+
/** Options for generating Prisma models. */
|
|
1127
1192
|
interface PrismaGenOptions {
|
|
1128
1193
|
/** Postgres schema the tables live in (account-scoped). */
|
|
1129
1194
|
schemaName?: string;
|
|
@@ -1135,15 +1200,25 @@ interface PrismaGenOptions {
|
|
|
1135
1200
|
*/
|
|
1136
1201
|
modelsOnly?: boolean;
|
|
1137
1202
|
}
|
|
1203
|
+
/**
|
|
1204
|
+
* Generates a Prisma schema for a subgraph's tables.
|
|
1205
|
+
*
|
|
1206
|
+
* Set `modelsOnly` to emit just the `model` blocks, to compose with your own
|
|
1207
|
+
* schema.
|
|
1208
|
+
*/
|
|
1138
1209
|
declare function generatePrismaSchema(def: SubgraphDefinition, opts?: PrismaGenOptions): string;
|
|
1210
|
+
/** Options for generating Drizzle table definitions. */
|
|
1139
1211
|
interface DrizzleGenOptions {
|
|
1140
1212
|
schemaName?: string;
|
|
1141
1213
|
}
|
|
1214
|
+
/** Generates Drizzle table definitions for a subgraph's tables. */
|
|
1142
1215
|
declare function generateDrizzleSchema(def: SubgraphDefinition, opts?: DrizzleGenOptions): string;
|
|
1216
|
+
/** Options for generating Kysely table interfaces. */
|
|
1143
1217
|
interface KyselyGenOptions {
|
|
1144
1218
|
/** Postgres schema the tables live in (account-scoped). */
|
|
1145
1219
|
schemaName?: string;
|
|
1146
1220
|
}
|
|
1221
|
+
/** Generates Kysely table interfaces for a subgraph's tables. */
|
|
1147
1222
|
declare function generateKyselySchema(def: SubgraphDefinition, opts?: KyselyGenOptions): string;
|
|
1148
1223
|
/**
|
|
1149
1224
|
* Emit a portable, typed schema for the public Index read domain (blocks,
|
|
@@ -1157,7 +1232,9 @@ declare function generateKyselySchema(def: SubgraphDefinition, opts?: KyselyGenO
|
|
|
1157
1232
|
* physical PK is a synthetic id excluded from the read contract (chain_reorgs) have
|
|
1158
1233
|
* no read-set key and are omitted from Prisma output (other targets still emit them).
|
|
1159
1234
|
*/
|
|
1235
|
+
/** A portable, typed schema target for the public Index read domain. */
|
|
1160
1236
|
type IndexCodegenTarget = "prisma" | "kysely" | "drizzle" | "json-schema";
|
|
1237
|
+
/** Options for generating the Index schema: tables, schema name. */
|
|
1161
1238
|
interface IndexCodegenOptions {
|
|
1162
1239
|
/** Restrict output to these Index tables (default: all). */
|
|
1163
1240
|
tables?: string[];
|
|
@@ -1166,11 +1243,18 @@ interface IndexCodegenOptions {
|
|
|
1166
1243
|
/** Prisma only: datasource url env var (default DATABASE_URL). */
|
|
1167
1244
|
datasourceEnv?: string;
|
|
1168
1245
|
}
|
|
1246
|
+
/**
|
|
1247
|
+
* Generates a typed schema for Index tables.
|
|
1248
|
+
*
|
|
1249
|
+
* `target` picks Prisma, Kysely, Drizzle or JSON Schema. Use `tables` to limit
|
|
1250
|
+
* the output. Prisma omits tables with no read-set key.
|
|
1251
|
+
*/
|
|
1169
1252
|
declare function generateIndexSchema(target: IndexCodegenTarget, opts?: IndexCodegenOptions): string;
|
|
1170
1253
|
import { pgSchemaName } from "@secondlayer/shared/db/queries/subgraphs";
|
|
1171
1254
|
import { Database as Database2 } from "@secondlayer/shared/db";
|
|
1172
1255
|
import { Kysely as Kysely2 } from "kysely";
|
|
1173
1256
|
type AnyDb = Kysely2<Database2>;
|
|
1257
|
+
/** Tables added, removed, or changed between two schemas. */
|
|
1174
1258
|
interface TableDiff {
|
|
1175
1259
|
/** Tables added to the schema */
|
|
1176
1260
|
addedTables: string[];
|
|
@@ -1209,15 +1293,17 @@ interface ConstraintDiff {
|
|
|
1209
1293
|
*/
|
|
1210
1294
|
declare function diffSchema(existing: SubgraphSchema, incoming: SubgraphSchema): TableDiff;
|
|
1211
1295
|
/**
|
|
1212
|
-
*
|
|
1213
|
-
*
|
|
1214
|
-
*
|
|
1215
|
-
*
|
|
1296
|
+
* Tells whether a schema diff is breaking, with the reasons.
|
|
1297
|
+
*
|
|
1298
|
+
* Breaking means removed tables, removed columns, changed column types or
|
|
1299
|
+
* removed `uniqueKeys`, which handler upserts conflict on. Index-flag and
|
|
1300
|
+
* composite-index changes are never breaking.
|
|
1216
1301
|
*/
|
|
1217
1302
|
declare function hasBreakingChanges(diff: TableDiff): {
|
|
1218
1303
|
breaking: boolean;
|
|
1219
1304
|
reasons: string[];
|
|
1220
1305
|
};
|
|
1306
|
+
/** The tables and columns a deploy adds, removes, or breaks. */
|
|
1221
1307
|
interface DeployDiff {
|
|
1222
1308
|
addedTables: string[];
|
|
1223
1309
|
removedTables: string[];
|
|
@@ -1228,6 +1314,7 @@ interface DeployDiff {
|
|
|
1228
1314
|
/** uniqueKeys added in place via ALTER TABLE … ADD CONSTRAINT. */
|
|
1229
1315
|
addedUniqueKeys?: Record<string, string[][]>;
|
|
1230
1316
|
}
|
|
1317
|
+
/** The schema name and SQL a deploy will run. */
|
|
1231
1318
|
interface DeployPlan {
|
|
1232
1319
|
schemaName: string;
|
|
1233
1320
|
/** `DROP SCHEMA … CASCADE` a destructive rebuild would run first. */
|
|
@@ -1241,11 +1328,12 @@ interface DeployPlan {
|
|
|
1241
1328
|
*/
|
|
1242
1329
|
declare function renderDeployPlan(def: SubgraphDefinition, schemaName?: string): DeployPlan;
|
|
1243
1330
|
/**
|
|
1244
|
-
*
|
|
1245
|
-
*
|
|
1246
|
-
*
|
|
1247
|
-
*
|
|
1248
|
-
*
|
|
1331
|
+
* Deploys a subgraph schema to the database.
|
|
1332
|
+
*
|
|
1333
|
+
* A new subgraph gets its schema and tables created and registered. The same
|
|
1334
|
+
* schema hash only updates the handler path. An additive change adds columns
|
|
1335
|
+
* and tables in place, and a breaking change reindexes by dropping and
|
|
1336
|
+
* recreating the tables.
|
|
1249
1337
|
*/
|
|
1250
1338
|
declare function deploySchema(db: AnyDb, def: SubgraphDefinition, handlerPath: string, opts?: {
|
|
1251
1339
|
forceReindex?: boolean;
|
|
@@ -1275,14 +1363,20 @@ type SparseProbeTarget = {
|
|
|
1275
1363
|
eventType: string;
|
|
1276
1364
|
contractId?: string;
|
|
1277
1365
|
};
|
|
1278
|
-
/**
|
|
1279
|
-
*
|
|
1280
|
-
*
|
|
1366
|
+
/**
|
|
1367
|
+
* Tells whether a subgraph can skip blocks without its events.
|
|
1368
|
+
*
|
|
1369
|
+
* Sparse scanning is sound only when every source is an event-type filter. A
|
|
1370
|
+
* `contract_call` or `contract_deploy` source matches transactions, which the
|
|
1371
|
+
* event probe cannot see.
|
|
1372
|
+
*/
|
|
1281
1373
|
declare function canSparseScan(subgraph: SubgraphDefinition): boolean;
|
|
1282
1374
|
/**
|
|
1283
|
-
*
|
|
1284
|
-
*
|
|
1285
|
-
*
|
|
1375
|
+
* Lists the event types and contract scopes a subgraph's filters match.
|
|
1376
|
+
*
|
|
1377
|
+
* Each target is a decoded event type with an optional contract scope. One
|
|
1378
|
+
* function feeds both the sparse probe and the event walks, so a new
|
|
1379
|
+
* contract-pinning filter field is added here once.
|
|
1286
1380
|
*
|
|
1287
1381
|
* Per event type: if ANY filter for it is unscoped, a single unscoped target
|
|
1288
1382
|
* covers everything (today's behavior); otherwise one target per distinct
|
|
@@ -1290,12 +1384,13 @@ declare function canSparseScan(subgraph: SubgraphDefinition): boolean;
|
|
|
1290
1384
|
*/
|
|
1291
1385
|
declare function sparseProbeTargets(subgraph: SubgraphDefinition): SparseProbeTarget[];
|
|
1292
1386
|
/**
|
|
1293
|
-
*
|
|
1294
|
-
*
|
|
1295
|
-
*
|
|
1296
|
-
*
|
|
1297
|
-
*
|
|
1298
|
-
* the
|
|
1387
|
+
* Tells whether a subgraph's sources can be read from the Streams index.
|
|
1388
|
+
*
|
|
1389
|
+
* Every source must be a known event-type, `contract_call` or
|
|
1390
|
+
* `contract_deploy` filter, and array-style sources never qualify because they
|
|
1391
|
+
* leak the unreconstructable `_eventId`. Trait scope is allowed: trait
|
|
1392
|
+
* resolution reads the contract registry on the platform database, which the
|
|
1393
|
+
* processor always holds. Everything else stays on the database tap.
|
|
1299
1394
|
*/
|
|
1300
1395
|
declare function isStreamsIndexEligible(subgraph: SubgraphDefinition): boolean;
|
|
1301
1396
|
interface ReindexOptions {
|
package/dist/index.js
CHANGED
|
@@ -787,7 +787,7 @@ import { createHash } from "node:crypto";
|
|
|
787
787
|
// package.json
|
|
788
788
|
var package_default = {
|
|
789
789
|
name: "@secondlayer/subgraphs",
|
|
790
|
-
version: "7.0.
|
|
790
|
+
version: "7.0.3",
|
|
791
791
|
description: "Describe the Stacks data you want as one TypeScript file; it fills itself and survives reorgs.",
|
|
792
792
|
license: "MIT",
|
|
793
793
|
repository: {
|
|
@@ -843,12 +843,13 @@ var package_default = {
|
|
|
843
843
|
dev: "bunup --watch",
|
|
844
844
|
test: "bun test",
|
|
845
845
|
typecheck: "tsc --noEmit",
|
|
846
|
+
openpkg: "bun scripts/sync-openpkg.ts",
|
|
846
847
|
prepublishOnly: "bun run build"
|
|
847
848
|
},
|
|
848
849
|
dependencies: {
|
|
849
|
-
"@secondlayer/shared": "^12.
|
|
850
|
-
"@secondlayer/stacks": "^6.2.
|
|
851
|
-
"@secondlayer/verify": "^0.5.
|
|
850
|
+
"@secondlayer/shared": "^12.1.2",
|
|
851
|
+
"@secondlayer/stacks": "^6.2.2",
|
|
852
|
+
"@secondlayer/verify": "^0.5.4",
|
|
852
853
|
esbuild: "^0.28.2",
|
|
853
854
|
kysely: "0.28.17",
|
|
854
855
|
zod: "^4.3.6"
|
|
@@ -2948,5 +2949,5 @@ export {
|
|
|
2948
2949
|
validateSubgraphDefinition
|
|
2949
2950
|
};
|
|
2950
2951
|
|
|
2951
|
-
//# debugId=
|
|
2952
|
+
//# debugId=E3F910C01BB06DA264756E2164756E21
|
|
2952
2953
|
//# sourceMappingURL=index.js.map
|