@secondlayer/subgraphs 3.8.0 → 3.9.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 +49 -1
- package/package.json +2 -2
package/dist/src/index.d.ts
CHANGED
|
@@ -355,10 +355,58 @@ interface SubscribeOptions<TRow> {
|
|
|
355
355
|
/** Called on stream/connection errors. */
|
|
356
356
|
onError?: (err: unknown) => void;
|
|
357
357
|
}
|
|
358
|
+
/**
|
|
359
|
+
* Numeric column keys of a row — those whose (non-null) TS type is `bigint`
|
|
360
|
+
* (uint/int columns, incl. nullable, plus the system `_blockHeight`). Only
|
|
361
|
+
* these are valid SUM/MIN/MAX targets at compile time.
|
|
362
|
+
*/
|
|
363
|
+
type NumericKeys<TRow> = { [K in keyof TRow]-? : NonNullable<TRow[K]> extends bigint ? K : never }[keyof TRow] & string;
|
|
364
|
+
/** Any column key of a row (valid COUNT DISTINCT target). */
|
|
365
|
+
type AnyKey<TRow> = keyof TRow & string;
|
|
366
|
+
/** Aggregate request spec. SUM/MIN/MAX restricted to numeric columns. */
|
|
367
|
+
interface AggregateSpec<TRow> {
|
|
368
|
+
count?: boolean;
|
|
369
|
+
countDistinct?: AnyKey<TRow>[];
|
|
370
|
+
sum?: NumericKeys<TRow>[];
|
|
371
|
+
min?: NumericKeys<TRow>[];
|
|
372
|
+
max?: NumericKeys<TRow>[];
|
|
373
|
+
where?: WhereInput<TRow> & SystemWhereAliases;
|
|
374
|
+
}
|
|
375
|
+
/** Narrows the literal column names listed under a spec key. */
|
|
376
|
+
type ColsOf<
|
|
377
|
+
A,
|
|
378
|
+
K extends keyof A
|
|
379
|
+
> = A[K] extends readonly (infer C extends string)[] ? C : never;
|
|
380
|
+
/**
|
|
381
|
+
* Result shape inferred from an `AggregateSpec`. Each block is present only when
|
|
382
|
+
* the corresponding spec key was provided. Counts are numbers; sum/min/max are
|
|
383
|
+
* lossless strings (min/max nullable over an empty/all-null set).
|
|
384
|
+
*/
|
|
385
|
+
type AggregateResult<
|
|
386
|
+
TRow,
|
|
387
|
+
A extends AggregateSpec<TRow>
|
|
388
|
+
> = (A["count"] extends true ? {
|
|
389
|
+
count: number
|
|
390
|
+
} : unknown) & (A["countDistinct"] extends readonly string[] ? {
|
|
391
|
+
countDistinct: Record<ColsOf<A, "countDistinct">, number>
|
|
392
|
+
} : unknown) & (A["sum"] extends readonly string[] ? {
|
|
393
|
+
sum: Record<ColsOf<A, "sum">, string>
|
|
394
|
+
} : unknown) & (A["min"] extends readonly string[] ? {
|
|
395
|
+
min: Record<ColsOf<A, "min">, string | null>
|
|
396
|
+
} : unknown) & (A["max"] extends readonly string[] ? {
|
|
397
|
+
max: Record<ColsOf<A, "max">, string | null>
|
|
398
|
+
} : unknown);
|
|
358
399
|
interface SubgraphTableClient<TRow> {
|
|
359
400
|
findMany(options?: FindManyOptions<TRow>): Promise<TRow[]>;
|
|
360
401
|
count(where?: WhereInput<TRow> & SystemWhereAliases): Promise<number>;
|
|
361
402
|
/**
|
|
403
|
+
* Scalar aggregates over the filtered set. SUM/MIN/MAX accept numeric columns
|
|
404
|
+
* only (compile-time enforced). The result type is narrowed from the spec —
|
|
405
|
+
* no `as const` needed thanks to the `const` type parameter. SUM/MIN/MAX are
|
|
406
|
+
* lossless strings; counts are numbers.
|
|
407
|
+
*/
|
|
408
|
+
aggregate<const A extends AggregateSpec<TRow>>(spec: A): Promise<AggregateResult<TRow, A>>;
|
|
409
|
+
/**
|
|
362
410
|
* Stream rows as they're indexed over Server-Sent Events. `onRow` fires for
|
|
363
411
|
* each new row (block-cadence). Returns an unsubscribe function that closes
|
|
364
412
|
* the connection. Requires a global `EventSource` (browsers, Node >= 22).
|
|
@@ -725,4 +773,4 @@ declare function deploySchema(db: AnyDb, def: SubgraphDefinition, handlerPath: s
|
|
|
725
773
|
version: string
|
|
726
774
|
diff?: DeployDiff
|
|
727
775
|
}>;
|
|
728
|
-
export { validateSubgraphDefinition, resumeReindex, renderDeployPlan, reindexSubgraph, pgSchemaName, generateSubgraphSQL, generatePrismaSchema, generateKyselySchema, generateIndexSchema, generateDrizzleSchema, diffSchema, deploySchema, defineSubgraph, 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, 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, ContractDeployPayload, ContractDeployFilter, ContractCallPayload, ContractCallFilter, ContractCallEvent, ComputedValue, ComparisonFilter, ColumnType, ColumnToTS, ColumnDiff, AnyEvent };
|
|
776
|
+
export { validateSubgraphDefinition, resumeReindex, renderDeployPlan, reindexSubgraph, pgSchemaName, generateSubgraphSQL, generatePrismaSchema, generateKyselySchema, generateIndexSchema, generateDrizzleSchema, diffSchema, deploySchema, defineSubgraph, 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, 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, ContractDeployPayload, ContractDeployFilter, ContractCallPayload, ContractCallFilter, ContractCallEvent, ComputedValue, ComparisonFilter, ColumnType, ColumnToTS, ColumnDiff, AnyEvent, AggregateSpec, AggregateResult };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@secondlayer/subgraphs",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"prepublishOnly": "bun run build"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@secondlayer/shared": "^6.
|
|
59
|
+
"@secondlayer/shared": "^6.26.0",
|
|
60
60
|
"@secondlayer/stacks": "^2.3.0",
|
|
61
61
|
"kysely": "0.28.15",
|
|
62
62
|
"zod": "^4.3.6"
|