import { P as Prettify, H as HasOnlyIdProperty, a as HasRequiredPropertiesOtherThanId } from './utils-0kAkCPl6.js'; import { AbiEvent, Abi, AbiFunction, AbiParametersToPrimitiveTypes, FormatAbiItem } from 'abitype'; import { GetEventArgs, ParseAbiItem, Abi as Abi$1, Narrow, Transport, Hex, Hash, Address, AccessList, TransactionType, Chain, Client, PublicRpcSchema, GetBalanceParameters, GetBalanceReturnType, GetCodeParameters, GetCodeReturnType, GetStorageAtParameters, GetStorageAtReturnType, MulticallParameters, MulticallReturnType, ContractFunctionName, ContractFunctionArgs, ReadContractParameters, ReadContractReturnType, GetEnsNameParameters, GetEnsNameReturnType } from 'viem'; import { Table as Table$1, SQL, SQLWrapper, QueryPromise, Dialect, SelectedFieldsFlat, Query, Param, Subquery, SelectedFieldsOrdered, Simplify, Placeholder, DrizzleTypeError, UpdateTableConfig, Column as Column$1, MakeColumnConfig, Assume, TableConfig, SelectedFields, entityKind, BuildColumns, ColumnBuilderBase } from 'drizzle-orm'; export { and, asc, avg, avgDistinct, between, count, countDistinct, desc, eq, exists, gt, gte, inArray, isNotNull, isNull, like, lt, lte, max, min, ne, not, notBetween, notExists, notIlike, notInArray, or, sql, sum, sumDistinct } from 'drizzle-orm'; import { TypedQueryBuilder } from 'drizzle-orm/query-builders/query-builder'; import { SelectResultFields, GetSelectTableName, GetSelectTableSelection, SelectMode, JoinNullability, SelectResult, BuildSubquerySelection, JoinType, AddAliasToSelection, AppendToResult, AppendToNullabilityMap } from 'drizzle-orm/query-builders/select.types'; import { RunnableQuery } from 'drizzle-orm/runnable-query'; import { PreparedQuery } from 'drizzle-orm/session'; import { QueryBuilder, AnySQLiteColumn } from 'drizzle-orm/sqlite-core'; import { View, ColumnsSelection, SQL as SQL$1, Placeholder as Placeholder$1, Query as Query$1 } from 'drizzle-orm/sql'; import { Input as Input$1, BlankInput, HandlerResponse, Next } from 'hono/types'; import * as hono from 'hono'; import { Hono, Input, Context as Context$1, Env } from 'hono'; export { MergeAbis, ReplaceBigInts, loadBalance, mergeAbis, rateLimit, replaceBigInts } from '@ponder/utils'; type GetAddress = contract extends { factory: unknown; } ? contract extends { factory: { event: infer event extends AbiEvent; }; } ? { address?: never; factory?: { /** Address of the factory contract that creates this contract. */ address: `0x${string}` | readonly `0x${string}`[]; /** ABI event that announces the creation of a new instance of this contract. */ event: AbiEvent; /** Name of the factory event parameter that contains the new child contract address. */ parameter: Exclude; }; } : { address?: never; factory?: { /** Address of the factory contract that creates this contract. */ address: `0x${string}` | readonly `0x${string}`[]; /** ABI event that announces the creation of a new instance of this contract. */ event: AbiEvent; /** Name of the factory event parameter that contains the new child contract address. */ parameter: string; }; } : contract extends { address: `0x${string}` | readonly `0x${string}`[]; } ? { address?: `0x${string}` | readonly `0x${string}`[]; factory?: never; } : { address?: `0x${string}` | readonly `0x${string}`[]; factory?: { /** Address of the factory contract that creates this contract. */ address: `0x${string}` | readonly `0x${string}`[]; /** ABI event that announces the creation of a new instance of this contract. */ event: AbiEvent; /** Name of the factory event parameter that contains the new child contract address. */ parameter: string; }; }; type NonStrictPick = { [P in Extract]: T[P]; }; type ExtractAbiEvents> = [events] extends [never] ? AbiEvent : events; type ExtractAbiFunctions> = [functions] extends [never] ? AbiFunction : functions; /** Return the abi event given the abi and compact signature. */ type ParseAbiEvent, noOverloadEvent = Extract, overloadEvent = Extract>> = [noOverloadEvent] extends [never] ? [overloadEvent] extends [never] ? AbiEvent : overloadEvent : noOverloadEvent; /** Return the abi function given the abi and compact signature. */ type ParseAbiFunction, noOverloadFunction = Extract, overloadFunction = Extract>> = [overloadFunction] extends [never] ? [noOverloadFunction] extends [never] ? AbiFunction : noOverloadFunction : overloadFunction; /** Return the compact signature given the abi and abi event. */ type FormatAbiEvent, matchingNameEvents extends AbiEvent = Extract> = [matchingNameEvents] extends [never] ? Abi extends abi ? event["name"] : never : [Exclude] extends [never] ? event["name"] : FormatAbiItem extends `event ${infer signature}` ? signature : never; /** Return the compact signature given the abi and abi function. */ type FormatAbiFunction, matchingNameFunctions extends AbiFunction = Extract> = [matchingNameFunctions] extends [never] ? Abi extends abi ? `${_function["name"]}()` : never : [Exclude] extends [never] ? `${_function["name"]}()` : FormatAbiItem<_function> extends `function ${infer signature}` ? signature : never; /** * Return an union of safe event names that handle event overridding. */ type SafeEventNames> = abiEvents extends abiEvents ? FormatAbiEvent : never; /** * Return an union of safe function names that handle function overridding. */ type SafeFunctionNames> = abiFunctions extends abiFunctions ? FormatAbiFunction : never; type FormatEventArgs = GetEventArgs>; type FormatFunctionArgs["inputs"]>> = readonly [] extends args ? never : args; type FormatFunctionResult["outputs"]>> = readonly [] extends result ? never : result extends readonly [unknown] ? result[0] : result; type GetEventFilter> = contract extends { filter: { event: infer event extends readonly string[] | string; }; } ? event extends readonly string[] ? { filter?: { event: readonly safeEventNames[]; }; } : event extends safeEventNames ? { filter?: { event: safeEventNames | event; args?: GetEventArgs>; }; } : { filter?: { event: safeEventNames; args?: GetEventArgs; }; } : { filter?: { event: safeEventNames | readonly safeEventNames[]; args?: GetEventArgs; }; }; type BlockConfig$1 = { /** Block number at which to start indexing events (inclusive). If `undefined`, events will be processed from block 0. Default: `undefined`. */ startBlock?: number; /** Block number at which to stop indexing events (inclusive). If `undefined`, events will be processed in real-time. Default: `undefined`. */ endBlock?: number; }; type DatabaseConfig$1 = { kind: "sqlite"; /** Directory path to use for SQLite database files. Default: `".ponder/sqlite"`. */ directory?: string; } | { kind: "postgres"; /** Postgres database connection string. Default: `DATABASE_PRIVATE_URL` > `DATABASE_URL` environment variable. */ connectionString?: string; /** Postgres schema to use for indexed data. Default: 'public', or `RAILWAY_SERVICE_NAME`-`RAILWAY_DEPLOYMENT_ID` environment variables if provided. */ schema?: string; /** Postgres schema to use for views returning indexed data. Default: undefined, or `RAILWAY_SERVICE_NAME` environment variable if provided. */ publishSchema?: string; /** Postgres pool configuration passed to `node-postgres`. */ poolConfig?: { /** Maximum number of clients in the pool. Default: `30`. */ max?: number; }; }; type NetworkConfig$1 = { /** Chain ID of the network. */ chainId: network extends { chainId: infer chainId extends number; } ? chainId | number : number; /** A viem `http`, `webSocket`, or `fallback` [Transport](https://viem.sh/docs/clients/transports/http.html). * * __To avoid rate limiting, include a custom RPC URL.__ Usage: * * ```ts * import { http } from "viem"; * * const network = { * name: "mainnet", * chainId: 1, * transport: http("https://eth-mainnet.g.alchemy.com/v2/..."), * } * ``` */ transport: Transport; /** Polling interval (in ms). Default: `1_000`. */ pollingInterval?: number; /** Maximum number of RPC requests per second. Default: `50`. */ maxRequestsPerSecond?: number; /** Disable RPC request caching. Default: `false`. */ disableCache?: boolean; }; type BlockFilterConfig = { /** Block number at which to start indexing events (inclusive). If `undefined`, events will be processed from block 0. Default: `undefined`. */ startBlock?: number; /** Block number at which to stop indexing events (inclusive). If `undefined`, events will be processed in real-time. Default: `undefined`. */ endBlock?: number; interval?: number; }; type GetBlockFilter = BlockFilterConfig & { network: allNetworkNames | { [name in allNetworkNames]?: BlockFilterConfig; }; }; type AbiConfig = { /** Contract application byte interface. */ abi: abi; }; type TransactionReceiptConfig = { includeTransactionReceipts?: boolean; }; type FunctionCallConfig = { includeCallTraces?: boolean; }; type GetNetwork = contract extends { network: infer network; } ? { /** * Network that this contract is deployed to. Must match a network name in `networks`. * Any filter information overrides the values in the higher level "contracts" property. * Factories cannot override an address and vice versa. */ network: allNetworkNames | { [name in allNetworkNames]?: Prettify> & GetEventFilter> & TransactionReceiptConfig & FunctionCallConfig & BlockConfig$1>; }; } : { /** * Network that this contract is deployed to. Must match a network name in `networks`. * Any filter information overrides the values in the higher level "contracts" property. * Factories cannot override an address and vice versa. */ network: allNetworkNames | { [name in allNetworkNames]?: Prettify & GetEventFilter & TransactionReceiptConfig & FunctionCallConfig & BlockConfig$1>; }; }; type ContractConfig$1 = Prettify & GetNetwork, abi> & GetAddress> & GetEventFilter> & TransactionReceiptConfig & FunctionCallConfig & BlockConfig$1>; type GetContract = contract extends { abi: infer abi extends Abi; } ? ContractConfig$1 : ContractConfig$1; type ContractsConfig = {} extends contracts ? {} : { [name in keyof contracts]: GetContract; }; type NetworksConfig = {} extends networks ? {} : { [networkName in keyof networks]: NetworkConfig$1; }; type BlockFiltersConfig = {} extends blocks ? {} : { [name in keyof blocks]: GetBlockFilter; }; declare const createConfig: (config: { networks: NetworksConfig>; contracts?: ContractsConfig> | undefined; database?: DatabaseConfig$1 | undefined; blocks?: BlockFiltersConfig | undefined; }) => CreateConfigReturnType; type Config = { networks: { [networkName: string]: NetworkConfig$1; }; contracts: { [contractName: string]: GetContract; }; database?: DatabaseConfig$1; blocks: { [sourceName: string]: GetBlockFilter; }; }; type CreateConfigReturnType = { networks: networks; contracts: contracts; database?: DatabaseConfig$1; blocks: blocks; }; type Scalar = "string" | "int" | "float" | "boolean" | "hex" | "bigint"; type ID = "string" | "int" | "bigint" | "hex"; type ScalarColumn = { " type": "scalar"; " scalar": scalar; " optional": optional; " list": list; }; type IdColumn = ScalarColumn; type ReferenceColumn = { " type": "reference"; " scalar": scalar; " optional": optional; " reference": reference; }; type JSONColumn = { " type": "json"; " json": type; " optional": optional; }; type OneColumn = { " type": "one"; " reference": reference; }; type ManyColumn = { " type": "many"; " referenceTable": referenceTable; " referenceColumn": referenceColumn; }; type EnumColumn<_enum extends string = string, optional extends boolean = boolean, list extends boolean = boolean> = { " type": "enum"; " enum": _enum; " optional": optional; " list": list; }; type Index = { " type": "index"; " column": column; " order": order; " nulls": nulls; }; type Column = ScalarColumn | ReferenceColumn | JSONColumn | OneColumn | ManyColumn | EnumColumn; type Table = { id: IdColumn; } & { [columnName: string]: Column; }; type Enum = readonly string[]; type Constraints = { [name: string]: Index; }; type Schema = { [name: string]: { table: Table; constraints: Constraints; } | Enum; }; type ExtractTableNames = names extends names ? schema[names & keyof schema] extends { table: Table; constraints: Constraints; } ? names : never : never; type ExtractEnumNames = names extends names ? schema[names & keyof schema] extends Enum ? names : never : never; type ExtractOptionalColumnNames = columnNames extends columnNames ? table[columnNames & keyof table] extends ScalarColumn | ReferenceColumn | JSONColumn | EnumColumn ? table[columnNames & keyof table][" optional"] extends true ? columnNames : never : never : never; type ExtractRequiredColumnNames = columnNames extends columnNames ? table[columnNames & keyof table] extends ScalarColumn | ReferenceColumn | JSONColumn | EnumColumn ? table[columnNames & keyof table][" optional"] extends false ? columnNames : never : never : never; type ExtractReferenceColumnNames = columnNames extends columnNames ? table[columnNames & keyof table] extends ReferenceColumn ? columnNames : never : never; type ExtractNonVirtualColumnNames = columnNames extends columnNames ? table[columnNames & keyof table] extends ReferenceColumn | ScalarColumn | EnumColumn | JSONColumn ? columnNames : never : never; type Optional = () => BuilderScalarColumn; type List = () => BuilderScalarColumn; type EnumOptional = () => BuilderEnumColumn; type EnumList = () => BuilderEnumColumn; type Asc = () => BuilderIndex; type Desc = () => BuilderIndex; type NullsFirst = () => BuilderIndex; type NullsLast = () => BuilderIndex; type ReferenceOptional = () => BuilderReferenceColumn; type References = (ref: reference) => BuilderReferenceColumn; type JSONOptional = () => BuilderJSONColumn; type BuilderScalarColumn = ScalarColumn> = list extends false ? optional extends false ? base & { /** * Mark the column as optional. * * - Docs: https://ponder.sh/docs/schema#optional * * @example * import { createSchema } from "@ponder/core"; * * export default createSchema((p) => ({ * t: p.createTable({ * id: p.string(), * o: p.int().optional(), * }) * })); */ optional: Optional; /** * Mark the column as a list. * * - Docs: https://ponder.sh/docs/schema#list * * @example * import { createSchema } from "@ponder/core"; * * export default createSchema((p) => ({ * t: p.createTable({ * id: p.string(), * l: p.int().list(), * }) * })); */ list: List; references: References; } : base & { /** * Mark the column as a list. * * - Docs: https://ponder.sh/docs/schema#list * * @example * import { createSchema } from "@ponder/core"; * * export default createSchema((p) => ({ * t: p.createTable({ * id: p.string(), * l: p.int().list(), * }) * })) */ list: List; /** * Mark the column as a foreign key. * * - Docs: https://ponder.sh/docs/schema#foreign-key * * @param references Table that this column is a key of. * * @example * import { createSchema } from "@ponder/core"; * * export default createSchema((p) => ({ * a: p.createTable({ * id: p.string(), * b_id: p.string.references("b.id"), * }) * b: p.createTable({ * id: p.string(), * }) * })); */ references: References; } : optional extends false ? base & { /** * Mark the column as optional. * * - Docs: https://ponder.sh/docs/schema#optional * * @example * import { createSchema } from "@ponder/core"; * * export default createSchema((p) => ({ * t: p.createTable({ * id: p.string(), * o: p.int().optional(), * }) * })); */ optional: Optional; } : base; type BuilderReferenceColumn = ReferenceColumn> = optional extends false ? base & { /** * Mark the column as optional. * * - Docs: https://ponder.sh/docs/schema#optional * * @example * import { createSchema } from "@ponder/core"; * * export default createSchema((p) => ({ * t: p.createTable({ * id: p.string(), * o: p.int().optional(), * }) * }) */ optional: ReferenceOptional; } : base; type BuilderJSONColumn = JSONColumn> = optional extends false ? base & { /** * Mark the column as optional. * * - Docs: https://ponder.sh/docs/schema#optional * * @example * import { createSchema } from "@ponder/core"; * * export default createSchema((p) => ({ * t: p.createTable({ * id: p.string(), * o: p.json().optional(), * }) * })); */ optional: JSONOptional; } : base; type BuilderOneColumn = { " type": "one"; " reference": reference; }; type BuilderManyColumn = { " type": "many"; " referenceTable": referenceTable; " referenceColumn": referenceColumn; }; type BuilderEnumColumn<_enum extends string = string, optional extends boolean = boolean, list extends boolean = boolean, base extends EnumColumn<_enum, optional, list> = EnumColumn<_enum, optional, list>> = list extends false ? optional extends false ? base & { /** * Mark the column as optional. * * - Docs: https://ponder.sh/docs/schema#optional * * @example * import { createSchema } from "@ponder/core"; * * export default createSchema((p) => ({ * e: p.createEnum(["ONE", "TWO"]) * t: p.createTable({ * id: p.string(), * a: p.enum("e").optional(), * }) * })); */ optional: EnumOptional; /** * Mark the column as a list. * * - Docs: https://ponder.sh/docs/schema#list * * @example * import { createSchema } from "@ponder/core"; * * export default createSchema((p) => ({ * e: p.createEnum(["ONE", "TWO"]) * t: p.createTable({ * id: p.string(), * a: p.enum("e").list(), * }) * })); */ list: EnumList; } : base & { /** * Mark the column as a list. * * - Docs: https://ponder.sh/docs/schema#list * * @example * import { createSchema } from "@ponder/core"; * * export default createSchema((p) => ({ * e: p.createEnum(["ONE", "TWO"]) * t: p.createTable({ * id: p.string(), * a: p.enum("e").list(), * }) * })); */ list: EnumList; } : optional extends false ? base & { /** * Mark the column as optional. * * - Docs: https://ponder.sh/docs/schema#optional * * @example * import { createSchema } from "@ponder/core"; * * export default createSchema((p) => ({ * e: p.createEnum(["ONE", "TWO"]) * t: p.createTable({ * id: p.string(), * a: p.enum("e").optional(), * }) * })); */ optional: EnumOptional; } : base; type BuilderIndex = Index, isSingleColumn = column extends readonly string[] ? false : true> = order extends undefined ? nulls extends undefined ? isSingleColumn extends true ? base & { asc: Asc; desc: Desc; nullsFirst: NullsFirst; nullsLast: NullsLast; } : base : isSingleColumn extends true ? base & { asc: Asc; desc: Desc; } : base : nulls extends undefined ? isSingleColumn extends true ? base & { nullsFirst: NullsFirst; nullsLast: NullsLast; } : base : base; type GetTable, enumNames extends string = {} extends schema ? string : ExtractEnumNames> = {} extends table ? {} : table extends { id: IdColumn; } ? { [columnName in keyof table]: table[columnName] extends ScalarColumn ? ScalarColumn : table[columnName] extends ReferenceColumn ? ReferenceColumn : table[columnName] extends JSONColumn ? JSONColumn : table[columnName] extends OneColumn ? OneColumn> : table[columnName] extends ManyColumn ? {} extends schema ? ManyColumn : table[columnName] extends ManyColumn ? ManyColumn & string> : ManyColumn> : table[columnName] extends EnumColumn ? EnumColumn : Column; } : { id: IdColumn; } & { [columnName: string]: Column; }; type GetConstraints> = {} extends constraints ? {} : { [name in keyof constraints]: Index; }; declare const P: { createTable: (t: GetTable, c?: GetConstraints> | undefined) => { table: table; constraints: constraints; }; createEnum: (e: _enum) => _enum; string: () => { " type": "scalar"; " scalar": "string"; " optional": false; " list": false; optional: () => ScalarColumn<"string", true, false> & { list: () => ScalarColumn<"string", true, true>; references: (ref: reference) => ReferenceColumn<"string", true, reference>; }; list: () => ScalarColumn<"string", false, true> & { optional: () => ScalarColumn<"string", true, true>; }; references: (ref: reference_1) => ReferenceColumn<"string", false, reference_1> & { optional: () => ReferenceColumn<"string", true, reference_1>; }; }; bigint: () => { " type": "scalar"; " scalar": "bigint"; " optional": false; " list": false; optional: () => ScalarColumn<"bigint", true, false> & { list: () => ScalarColumn<"bigint", true, true>; references: (ref: reference_2) => ReferenceColumn<"bigint", true, reference_2>; }; list: () => ScalarColumn<"bigint", false, true> & { optional: () => ScalarColumn<"bigint", true, true>; }; references: (ref: reference_3) => ReferenceColumn<"bigint", false, reference_3> & { optional: () => ReferenceColumn<"bigint", true, reference_3>; }; }; int: () => { " type": "scalar"; " scalar": "int"; " optional": false; " list": false; optional: () => ScalarColumn<"int", true, false> & { list: () => ScalarColumn<"int", true, true>; references: (ref: reference_4) => ReferenceColumn<"int", true, reference_4>; }; list: () => ScalarColumn<"int", false, true> & { optional: () => ScalarColumn<"int", true, true>; }; references: (ref: reference_5) => ReferenceColumn<"int", false, reference_5> & { optional: () => ReferenceColumn<"int", true, reference_5>; }; }; float: () => { " type": "scalar"; " scalar": "float"; " optional": false; " list": false; optional: () => ScalarColumn<"float", true, false> & { list: () => ScalarColumn<"float", true, true>; references: (ref: reference_6) => ReferenceColumn<"float", true, reference_6>; }; list: () => ScalarColumn<"float", false, true> & { optional: () => ScalarColumn<"float", true, true>; }; references: (ref: reference_7) => ReferenceColumn<"float", false, reference_7> & { optional: () => ReferenceColumn<"float", true, reference_7>; }; }; hex: () => { " type": "scalar"; " scalar": "hex"; " optional": false; " list": false; optional: () => ScalarColumn<"hex", true, false> & { list: () => ScalarColumn<"hex", true, true>; references: (ref: reference_8) => ReferenceColumn<"hex", true, reference_8>; }; list: () => ScalarColumn<"hex", false, true> & { optional: () => ScalarColumn<"hex", true, true>; }; references: (ref: reference_9) => ReferenceColumn<"hex", false, reference_9> & { optional: () => ReferenceColumn<"hex", true, reference_9>; }; }; boolean: () => { " type": "scalar"; " scalar": "boolean"; " optional": false; " list": false; optional: () => ScalarColumn<"boolean", true, false> & { list: () => ScalarColumn<"boolean", true, true>; references: (ref: reference_10) => ReferenceColumn<"boolean", true, reference_10>; }; list: () => ScalarColumn<"boolean", false, true> & { optional: () => ScalarColumn<"boolean", true, true>; }; references: (ref: reference_11) => ReferenceColumn<"boolean", false, reference_11> & { optional: () => ReferenceColumn<"boolean", true, reference_11>; }; }; json: () => JSONColumn & { optional: () => JSONColumn; }; one: (ref: reference_12) => BuilderOneColumn; many: (ref: `${referenceTable}.${referenceColumn}`) => BuilderManyColumn; enum: <_enum_1 extends string>(__enum: _enum_1) => { " type": "enum"; " enum": _enum_1; " optional": false; " list": false; optional: () => EnumColumn<_enum_1, true, false> & { list: () => EnumColumn<_enum_1, true, true>; }; list: () => EnumColumn<_enum_1, false, true> & { optional: () => EnumColumn<_enum_1, true, true>; }; }; index: (c: column) => (column extends readonly string[] ? false : true) extends infer T ? T extends (column extends readonly string[] ? false : true) ? T extends true ? Index & { asc: () => (column extends readonly string[] ? false : true) extends infer T_1 ? T_1 extends (column extends readonly string[] ? false : true) ? T_1 extends true ? Index & { nullsFirst: () => Index; nullsLast: () => Index; } : Index : never : never; desc: () => (column extends readonly string[] ? false : true) extends infer T_2 ? T_2 extends (column extends readonly string[] ? false : true) ? T_2 extends true ? Index & { nullsFirst: () => Index; nullsLast: () => Index; } : Index : never : never; nullsFirst: () => (column extends readonly string[] ? false : true) extends infer T_3 ? T_3 extends (column extends readonly string[] ? false : true) ? T_3 extends true ? Index & { asc: () => Index; desc: () => Index; } : Index : never : never; nullsLast: () => (column extends readonly string[] ? false : true) extends infer T_4 ? T_4 extends (column extends readonly string[] ? false : true) ? T_4 extends true ? Index & { asc: () => Index; desc: () => Index; } : Index : never : never; } : Index : never : never; }; type P = { /** * Create a database table. * * - Docs: https://ponder.sh/docs/schema#tables * * @example * export default createSchema((p) => ({ * t: p.createTable({ * id: p.string(), * }) * })); */ createTable: (t: GetTable
, c?: GetConstraints) => { table: table; constraints: constraints; }; /** * Create an Enum type for the database. * * - Docs: https://ponder.sh/docs/schema#tables * * @example * export default createSchema((p) => ({ * e: p.createEnum(["ONE", "TWO"]) * t: p.createTable({ * id: p.string(), * a: p.enum("e"), * }) * })); */ createEnum: (e: _enum) => _enum; /** * Primitive `string` column type. * * - Docs: https://ponder.sh/docs/schema#primitives * * @example * import { createSchema } from "@ponder/core"; * * export default createSchema((p) => ({ * t: p.createTable({ * id: p.string(), * }) * })); */ string: () => BuilderScalarColumn<"string", false, false>; /** * Primitive `bigint` column type. * * - Docs: https://ponder.sh/docs/schema#primitives * * @example * import { createSchema } from "@ponder/core"; * * export default createSchema((p) => ({ * t: p.createTable({ * id: p.bigint(), * }) * })); */ bigint: () => BuilderScalarColumn<"bigint", false, false>; /** * Primitive `int` column type. * * - Docs: https://ponder.sh/docs/schema#primitives * * @example * import { createSchema } from "@ponder/core"; * * export default createSchema((p) => ({ * t: p.createTable({ * id: p.int(), * }) * })); */ int: () => BuilderScalarColumn<"int", false, false>; /** * Primitive `float` column type. * * - Docs: https://ponder.sh/docs/schema#primitives * * @example * import { createSchema } from "@ponder/core"; * * export default createSchema((p) => ({ * t: p.createTable({ * id: p.string(), * f: p.float(), * }) * })); */ float: () => BuilderScalarColumn<"float", false, false>; /** * Primitive `hex` column type. * * - Docs: https://ponder.sh/docs/schema#primitives * * @example * import { createSchema } from "@ponder/core"; * * export default createSchema((p) => ({ * t: p.createTable({ * id: p.hex(), * }) * })); */ hex: () => BuilderScalarColumn<"hex", false, false>; /** * Primitive `boolean` column type. * * - Docs: https://ponder.sh/docs/schema#primitives * * @example * import { createSchema } from "@ponder/core"; * * export default createSchema((p) => ({ * t: p.createTable({ * id: p.string(), * b: p.boolean(), * }) * })); */ boolean: () => BuilderScalarColumn<"boolean", false, false>; /** * Primitive `JSON` column type. * * - Docs: https://ponder.sh/docs/schema#primitives * * @example * import { createSchema } from "@ponder/core"; * * export default createSchema((p) => ({ * t: p.createTable({ * id: p.string(), * b: p.json(), * }) * })); */ json: () => BuilderJSONColumn; /** * One-to-one column type.`one` columns don't exist in the database. They are only present when querying data from the GraphQL API. * * - Docs: https://ponder.sh/docs/schema#one-to-one * * @param reference Reference column to be resolved. * * @example * import { createSchema } from "@ponder/core"; * * export default createSchema((p) => ({ * a: p.createTable({ * id: p.string(), * b_id: p.string.references("b.id"), * b: p.one("b_id"), * }) * b: p.createTable({ * id: p.string(), * }) * })); */ one: (ref: reference) => BuilderOneColumn; /** * Many-to-one column type. `many` columns don't exist in the database. They are only present when querying data from the GraphQL API. * * - Docs: https://ponder.sh/docs/schema#one-to-many * * @param reference Reference column that references the `id` column of the current table. * * @example * import { createSchema } from "@ponder/core"; * * export default createSchema((p) => ({ * a: p.createTable({ * id: p.string(), * ref: p.string.references("b.id"), * }) * b: p.createTable({ * id: p.string(), * m: p.many("a.ref"), * }) * })); */ many: (ref: `${referenceTable}.${referenceColumn}`) => BuilderManyColumn; /** * Custom defined allowable value column type. * * - Docs: https://ponder.sh/docs/schema#enum * * @param type Enum defined elsewhere in the schema with `p.createEnum()`. * * @example * export default createSchema((p) => ({ * e: p.createEnum(["ONE", "TWO"]) * t: p.createTable({ * id: p.string(), * a: p.enum("e"), * }) * })); */ enum: <_enum extends string>(__enum: _enum) => BuilderEnumColumn<_enum, false, false>; /** * Create a table index. * * - Docs: https://ponder.sh/docs/schema#indexes * * @param columns Column or columns to include in the index. * * @example * export default createSchema((p) => ({ * t: p.createTable({ * id: p.string(), * age: p.int(), * }, { * ageIndex: p.index("age"), * }) * })); */ index: (c: column) => BuilderIndex; }; type CreateSchemaParameters = {} extends schema ? {} : { [tableName in keyof schema]: schema[tableName] extends { table: infer table extends Table; constraints: infer constraints extends Constraints; } ? { table: GetTable; constraints: GetConstraints; } : readonly string[]; }; declare const createSchema: (_schema: (p: P) => CreateSchemaParameters) => unknown extends schema ? Schema : schema; /** * A confirmed Ethereum block. * * @link https://docs.soliditylang.org/en/v0.8.20/introduction-to-smart-contracts.html#blocks */ type Block = { /** Base fee per gas */ baseFeePerGas: bigint | null; /** Difficulty for this block */ difficulty: bigint; /** "Extra data" field of this block */ extraData: Hex; /** Maximum gas allowed in this block */ gasLimit: bigint; /** Total used gas by all transactions in this block */ gasUsed: bigint; /** Block hash */ hash: Hash; /** Logs bloom filter */ logsBloom: Hex; /** Address that received this block’s mining rewards */ miner: Address; /** Unique identifier for the block. */ mixHash: Hash | null; /** Proof-of-work hash */ nonce: Hex | null; /** Block number */ number: bigint; /** Parent block hash */ parentHash: Hash; /** Root of the this block’s receipts trie */ receiptsRoot: Hex; /** SHA3 of the uncles data in this block */ sha3Uncles: Hash | null; /** Size of this block in bytes */ size: bigint; /** Root of this block’s final state trie */ stateRoot: Hash; /** Unix timestamp of when this block was collated */ timestamp: bigint; /** Total difficulty of the chain until this block */ totalDifficulty: bigint | null; /** Root of this block’s transaction trie */ transactionsRoot: Hash; }; /** * A confirmed Ethereum transaction. Contains `legacy`, `EIP-1559`, or `EIP-2930` fee values depending on the transaction `type`. * * @link https://docs.soliditylang.org/en/v0.8.20/introduction-to-smart-contracts.html#transactions */ type Transaction = Prettify<{ /** Hash of block containing this transaction */ blockHash: Hash; /** Number of block containing this transaction */ blockNumber: bigint; /** Transaction sender */ from: Address; /** Gas provided for transaction execution */ gas: bigint; /** Hash of this transaction */ hash: Hash; /** Contract code or a hashed method call */ input: Hex; /** Unique number identifying this transaction */ nonce: number; /** ECDSA signature r */ r: Hex | null; /** ECDSA signature s */ s: Hex | null; /** Transaction recipient or `null` if deploying a contract */ to: Address | null; /** Index of this transaction in the block */ transactionIndex: number; /** ECDSA recovery ID */ v: bigint | null; /** Value in wei sent with this transaction */ value: bigint; } & ({ /** Transaction type. */ type: "legacy"; accessList?: never; /** Base fee per gas. Only present in legacy and EIP-2930 transactions. */ gasPrice: bigint; maxFeePerGas?: never; maxPriorityFeePerGas?: never; } | { /** Transaction type. */ type: "eip2930"; /** List of addresses and storage keys the transaction will access. */ accessList: AccessList; /** Base fee per gas. Only present in legacy and EIP-2930 transactions. */ gasPrice: bigint; maxFeePerGas?: never; maxPriorityFeePerGas?: never; } | { /** Transaction type. */ type: "eip1559"; accessList?: never; gasPrice?: never; /** Total fee per gas in wei (gasPrice/baseFeePerGas + maxPriorityFeePerGas). Only present in EIP-1559 transactions. */ maxFeePerGas: bigint; /** Max priority fee per gas (in wei). Only present in EIP-1559 transactions. */ maxPriorityFeePerGas: bigint; } | { /** Transaction type. */ type: "deposit"; accessList?: never; gasPrice?: never; /** Total fee per gas in wei (gasPrice/baseFeePerGas + maxPriorityFeePerGas). Only present in EIP-1559 transactions. */ maxFeePerGas?: bigint; /** Max priority fee per gas (in wei). Only present in EIP-1559 transactions. */ maxPriorityFeePerGas?: bigint; } | { /** Transaction type. */ type: Hex; gasPrice?: never; accessList?: never; maxFeePerGas?: never; maxPriorityFeePerGas?: never; })>; /** * A confirmed Ethereum log. * * @link https://docs.soliditylang.org/en/v0.8.20/abi-spec.html#events */ type Log = { /** Globally unique identifier for this log (`${blockHash}-${logIndex}`) */ id: string; /** The address from which this log originated */ address: Address; /** Hash of block containing this log */ blockHash: Hash; /** Number of block containing this log */ blockNumber: bigint; /** Contains the non-indexed arguments of the log */ data: Hex; /** Index of this log within its block */ logIndex: number; /** `true` if this log has been removed in a chain reorganization */ removed: boolean; /** List of order-dependent topics */ topics: [Hex, ...Hex[]] | []; /** Hash of the transaction that created this log */ transactionHash: Hash; /** Index of the transaction that created this log */ transactionIndex: number; }; /** * A confirmed Ethereum transaction receipt. */ type TransactionReceipt = { /** Hash of block containing this transaction */ blockHash: Hash; /** Number of block containing this transaction */ blockNumber: bigint; /** Address of new contract or `null` if no contract was created */ contractAddress: Address | null; /** Gas used by this and all preceding transactions in this block */ cumulativeGasUsed: bigint; /** Pre-London, it is equal to the transaction's gasPrice. Post-London, it is equal to the actual gas price paid for inclusion. */ effectiveGasPrice: bigint; /** Transaction sender */ from: Address; /** Gas used by this transaction */ gasUsed: bigint; /** List of log objects generated by this transaction */ logs: Log[]; /** Logs bloom filter */ logsBloom: Hex; /** `success` if this transaction was successful or `reverted` if it failed */ status: "success" | "reverted"; /** Transaction recipient or `null` if deploying a contract */ to: Address | null; /** Hash of this transaction */ transactionHash: Hash; /** Index of this transaction in the block */ transactionIndex: number; /** Transaction type */ type: TransactionType; }; type _TraceAddress = number | _TraceAddress[]; type TraceAddress = _TraceAddress[]; /** * An Ethereum call trace. */ type CallTrace = { /** Globally unique identifier for this trace (`${transactionHash}-${traceAddress}`) */ id: string; /** Message sender */ from: Address; /** Message receipient */ to: Address; /** Amount of gas allocated to this call */ gas: bigint; /** Value in wei sent with this call */ value: bigint; /** Calldata sent with this call */ input: Hex; /** Contains return data */ output: Hex; /** Total used gas by this trace */ gasUsed: bigint; /** Number of traces created by this trace */ subtraces: number; /** Description of this traces position within all traces in the transaction */ traceAddress: TraceAddress; /** Hash of block containing this trace */ blockHash: Hash; /** Number of block containing this trace */ blockNumber: bigint; /** Hash of the transaction that created this trace */ transactionHash: Hash; /** Index of the transaction that created this trace */ transactionIndex: number; /** EVM opcode used to make this call */ callType: "call" | "staticcall" | "delegatecall" | "callcode"; }; interface InsertConfig { table: TTable; values: Record[] | InsertSelectQueryBuilder | SQL; withList?: Subquery[]; onConflict?: SQL; returning?: SelectedFieldsOrdered; select?: boolean; } type InsertValue = Simplify<{ [Key in keyof TTable["$inferInsert"]]: TTable["$inferInsert"][Key] | SQL | Placeholder; }>; type InsertSelectQueryBuilder = TypedQueryBuilder<{ [K in keyof TTable["$inferInsert"]]: AnySQLiteColumn | SQL | SQL.Aliased | TTable["$inferInsert"][K]; }>; type InsertBuilder = { values(value: InsertValue): InsertBase; values(values: InsertValue[]): InsertBase; values(values: InsertValue | InsertValue[]): InsertBase; select(selectQuery: (qb: QueryBuilder) => InsertSelectQueryBuilder): InsertBase; select(selectQuery: (qb: QueryBuilder) => SQL): InsertBase; select(selectQuery: SQL): InsertBase; select(selectQuery: InsertSelectQueryBuilder): InsertBase; select(selectQuery: SQL | InsertSelectQueryBuilder | ((qb: QueryBuilder) => InsertSelectQueryBuilder | SQL)): InsertBase; }; type InsertWithout = TDynamic extends true ? T : Omit, T["_"]["excludedMethods"] | K>; type InsertReturning> = InsertWithout, TDynamic, T["_"]["excludedMethods"]>, TDynamic, "returning">; type InsertReturningAll = InsertWithout, TDynamic, "returning">; type InsertOnConflictDoUpdateConfig = { target: any | any[]; /** @deprecated - use either `targetWhere` or `setWhere` */ where?: SQL; targetWhere?: SQL; setWhere?: SQL; set: Table$1; }; type InsertDynamic = Insert; type InsertExecute = T["_"]["returning"] extends undefined ? T["_"]["runResult"] : T["_"]["returning"][]; type InsertPrepare = PreparedQuery & { type: T["_"]["resultType"]; run: T["_"]["runResult"]; all: T["_"]["returning"] extends undefined ? DrizzleTypeError<".all() cannot be used without .returning()"> : T["_"]["returning"][]; get: T["_"]["returning"] extends undefined ? DrizzleTypeError<".get() cannot be used without .returning()"> : T["_"]["returning"]; values: T["_"]["returning"] extends undefined ? DrizzleTypeError<".values() cannot be used without .returning()"> : any[][]; execute: InsertExecute; }; type AnyInsert = InsertBase; type Insert = InsertBase; interface InsertBase extends SQLWrapper, QueryPromise, RunnableQuery { readonly _: { readonly dialect: Dialect; readonly table: TTable; readonly resultType: TResultType; readonly runResult: TRunResult; readonly returning: TReturning; readonly dynamic: TDynamic; readonly excludedMethods: TExcludedMethods; readonly result: TReturning extends undefined ? TRunResult : TReturning[]; }; } interface InsertBase extends SQLWrapper, QueryPromise, RunnableQuery { readonly _: { readonly dialect: Dialect; readonly table: TTable; readonly resultType: TResultType; readonly runResult: TRunResult; readonly returning: TReturning; readonly dynamic: TDynamic; readonly excludedMethods: TExcludedMethods; readonly result: TReturning extends undefined ? TRunResult : TReturning[]; }; /** @internal */ config: InsertConfig; /** * Adds a `returning` clause to the query. * * Calling this method will return the specified fields of the inserted rows. If no fields are specified, all fields will be returned. * * See docs: {@link https://orm.drizzle.team/docs/insert#insert-returning} * * @example * ```ts * // Insert one row and return all fields * const insertedCar: Car[] = await db.insert(cars) * .values({ brand: 'BMW' }) * .returning(); * * // Insert one row and return only the id * const insertedCarId: { id: number }[] = await db.insert(cars) * .values({ brand: 'BMW' }) * .returning({ id: cars.id }); * ``` */ returning(): InsertReturningAll; returning>(fields: TSelectedFields): InsertReturning; returning(fields: SelectedFieldsFlat): InsertWithout; /** * Adds an `on conflict do nothing` clause to the query. * * Calling this method simply avoids inserting a row as its alternative action. * * See docs: {@link https://orm.drizzle.team/docs/insert#on-conflict-do-nothing} * * @param config The `target` and `where` clauses. * * @example * ```ts * // Insert one row and cancel the insert if there's a conflict * await db.insert(cars) * .values({ id: 1, brand: 'BMW' }) * .onConflictDoNothing(); * * // Explicitly specify conflict target * await db.insert(cars) * .values({ id: 1, brand: 'BMW' }) * .onConflictDoNothing({ target: cars.id }); * ``` */ onConflictDoNothing(config: { target?: any | any[]; where?: SQL; }): this; /** * Adds an `on conflict do update` clause to the query. * * Calling this method will update the existing row that conflicts with the row proposed for insertion as its alternative action. * * See docs: {@link https://orm.drizzle.team/docs/insert#upserts-and-conflicts} * * @param config The `target`, `set` and `where` clauses. * * @example * ```ts * // Update the row if there's a conflict * await db.insert(cars) * .values({ id: 1, brand: 'BMW' }) * .onConflictDoUpdate({ * target: cars.id, * set: { brand: 'Porsche' } * }); * * // Upsert with 'where' clause * await db.insert(cars) * .values({ id: 1, brand: 'BMW' }) * .onConflictDoUpdate({ * target: cars.id, * set: { brand: 'newBMW' }, * where: sql`${cars.createdAt} > '2023-01-01'::date`, * }); * ``` */ onConflictDoUpdate(config: InsertOnConflictDoUpdateConfig): this; toSQL(): Query; prepare(): InsertPrepare; run: ReturnType["run"]; all: ReturnType["all"]; get: ReturnType["get"]; values: ReturnType["values"]; execute(): Promise>; $dynamic(): InsertDynamic; } /** * https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/sqlite-core/query-builders/select.ts#L54 * https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/pg-core/query-builders/select.ts#L50 */ type SelectBuilder | undefined, TResultType extends "sync" | "async", TRunResult, TBuilderMode extends "db" | "qb" = "db"> = { from: (source: TFrom) => CreateSelectFromBuilderMode, TResultType, TRunResult, TSelection extends undefined ? GetSelectTableSelection : TSelection, TSelection extends undefined ? "single" : "partial">; }; /** * https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/sqlite-core/query-builders/select.ts#L126 * https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/pg-core/query-builders/select.ts#L130 */ declare abstract class SelectQueryBuilderBase = TTableName extends string ? Record : {}, TDynamic extends boolean = false, TExcludedMethods extends string = never, TResult extends any[] = SelectResult[], TSelectedFields extends ColumnsSelection = BuildSubquerySelection> extends TypedQueryBuilder { [entityKind]: string; _: { readonly hkt: THKT; readonly tableName: TTableName; readonly resultType: TResultType; readonly runResult: TRunResult; readonly selection: TSelection; readonly selectMode: TSelectMode; readonly nullabilityMap: TNullabilityMap; readonly dynamic: TDynamic; readonly excludedMethods: TExcludedMethods; readonly result: TResult; readonly selectedFields: TSelectedFields; }; leftJoin: JoinFn; rightJoin: JoinFn; innerJoin: JoinFn; fullJoin: JoinFn; private setOperator; union: typeof this.setOperator; unionAll: typeof this.setOperator; intersect: typeof this.setOperator; intersectAll: typeof this.setOperator; except: typeof this.setOperator; exceptAll: typeof this.setOperator; where: (where: ((aliases: TSelection) => SQL$1 | undefined) | SQL$1 | undefined) => SelectWithout; having: (having: ((aliases: this["_"]["selection"]) => SQL$1 | undefined) | SQL$1 | undefined) => SelectWithout; groupBy: (...columns: (Column$1 | SQL$1)[]) => SelectWithout; orderBy: (...columns: (Column$1 | SQL$1)[]) => SelectWithout; limit: (limit: number | Placeholder$1) => SelectWithout; offset: (offset: number | Placeholder$1) => SelectWithout; toSQL: () => Query$1; as: (alias: TAlias) => SubqueryWithSelection; $dynamic: () => SelectDynamic; } /** * https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/sqlite-core/query-builders/select.ts#L803 * https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/pg-core/query-builders/select.ts#L903 */ type SelectBase = TTableName extends string ? Record : {}, TDynamic extends boolean = false, TExcludedMethods extends string = never, TResult = SelectResult[], TSelectedFields extends ColumnsSelection = BuildSubquerySelection> = SelectQueryBuilderBase & QueryPromise; /** * https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/sqlite-core/query-builders/select.types.ts#L38 * https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/pg-core/query-builders/select.types.ts#L30 */ type BuildAliasTable = tableOrView extends Table$1 ? TableWithColumns; }>> : tableOrView extends View ? ViewWithSelection> : never; /** * https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/sqlite-core/query-builders/select.types.ts#L75 * https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/pg-core/query-builders/select.types.ts#L82 */ type Join = GetSelectTableName> = T extends any ? SelectWithout> : never, T["_"]["selectMode"]>, T["_"]["selectMode"] extends "partial" ? T["_"]["selectMode"] : "multiple", AppendToNullabilityMap, T["_"]["dynamic"], T["_"]["excludedMethods"]>, TDynamic, T["_"]["excludedMethods"]> : never; /** * https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/sqlite-core/query-builders/select.types.ts#L106 * https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/pg-core/query-builders/select.types.ts#L111 */ type JoinFn = = GetSelectTableName>(table: TJoinedTable, on: ((aliases: T["_"]["selection"]) => SQL$1 | undefined) | SQL$1 | undefined) => Join; /** * https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/query-builders/select.types.ts#L75 */ type MapColumnsToTableAlias = { [Key in keyof TColumns]: TColumns[Key] extends Column$1 ? Column$1["_"], TAlias>> : TColumns[Key]; } & {}; /** * https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/sqlite-core/query-builders/select.types.ts#L124 * https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/pg-core/query-builders/select.types.ts#L146 */ type SelectHKTBase = { tableName: string | undefined; resultType: "sync" | "async"; runResult: unknown; selection: unknown; selectMode: SelectMode; nullabilityMap: unknown; dynamic: boolean; excludedMethods: string; result: unknown; selectedFields: unknown; _type: unknown; }; /** * https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/sqlite-core/query-builders/select.types.ts#L138 * https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/pg-core/query-builders/select.types.ts#L158 */ type SelectKind, TDynamic extends boolean, TExcludedMethods extends string, TResult = SelectResult[], TSelectedFields = BuildSubquerySelection> = (T & { tableName: TTableName; resultType: TResultType; runResult: TRunResult; selection: TSelection; selectMode: TSelectMode; nullabilityMap: TNullabilityMap; dynamic: TDynamic; excludedMethods: TExcludedMethods; result: TResult; selectedFields: TSelectedFields; })["_type"]; /** * https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/sqlite-core/query-builders/select.types.ts#L163 * https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/pg-core/query-builders/select.types.ts#L179 */ interface SelectQueryBuilderHKT extends SelectHKTBase { _type: SelectQueryBuilderBase, this["selectMode"], Assume>, this["dynamic"], this["excludedMethods"], Assume, Assume>; } /** * https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/sqlite-core/query-builders/select.types.ts#L179 * https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/pg-core/query-builders/select.types.ts#L193 */ interface SelectHKT extends SelectHKTBase { _type: SelectBase, this["selectMode"], Assume>, this["dynamic"], this["excludedMethods"], Assume, Assume>; } /** * https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/sqlite-core/query-builders/select.types.ts#L204 * https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/pg-core/query-builders/select.types.ts#L206 */ type CreateSelectFromBuilderMode = TBuilderMode extends "db" ? SelectBase : SelectQueryBuilderBase; /** * https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/sqlite-core/query-builders/select.types.ts#L227 * https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/pg-core/query-builders/select.types.ts#L224 */ type SelectWithout = TDynamic extends true ? T : Omit, TResetExcluded extends true ? K : T["_"]["excludedMethods"] | K>; type SelectDynamic = SelectKind; type AnySelectQueryBuilder = SelectQueryBuilderBase; type SubqueryWithSelection = Subquery> & AddAliasToSelection; /** * https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/sqlite-core/table.ts#L49 * https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/pg-core/table.ts#L43 */ type TableWithColumns = Table$1 & { [key in keyof T["columns"]]: T["columns"][key]; }; /** * https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/sqlite-core/view.ts#L154 * https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/pg-core/view.ts#L305 */ type ViewWithSelection = View & TSelection; type DrizzleDb = { insert(table: TTable): InsertBuilder; select(): SelectBuilder; select>(fields: TSelection): SelectBuilder; select(fields?: SelectedFields): SelectBuilder | undefined, "async", void>; /** * Execute a raw read-only SQL query.. * * @example * import { ponder } from "@/generated"; * import { sql } from "@ponder/core"; * * ponder.get("/", async (c) => { * const result = await c.db.execute(sql`SELECT * from "Accounts"`); * return c.json(result); * }); * * @see https://orm.drizzle.team/docs/sql */ execute: >(query: SQLWrapper) => Promise; }; type InferScalarType = scalar extends "string" ? string : scalar extends "int" ? number : scalar extends "float" ? number : scalar extends "boolean" ? boolean : scalar extends "hex" ? Hex : scalar extends "bigint" ? bigint : never; type InferColumnType = column extends ScalarColumn ? column[" list"] extends true ? InferScalarType[] : InferScalarType : column extends ReferenceColumn ? InferScalarType : column extends JSONColumn ? column[" json"] : column extends EnumColumn ? (schema[column[" enum"] & keyof schema] & Enum)[number] : never; type InferTableType = table extends { table: Table; constraints: Constraints; } ? Prettify<{ [columnName in ExtractRequiredColumnNames
]: InferColumnType; } & { [columnName in ExtractOptionalColumnNames
]?: InferColumnType; }> : never; type InferSchemaType = { [tableName in ExtractTableNames]: InferTableType; }; /** * Performs type transformation between Ponder and Drizzle column representation. * * @returns TableWithColumns */ type DrizzleTable = TableWithColumns<{ name: tableName; schema: undefined; columns: BuildColumns]: ColumnBuilderBase<{ name: columnName & string; dataType: "custom"; columnType: "ponder"; data: InferColumnType; driverParam: unknown; enumValues: undefined; notNull: (table[columnName] & (ScalarColumn | ReferenceColumn | EnumColumn | JSONColumn))[" optional"] extends true ? false : true; primaryKey: columnName extends "id" ? true : false; }>; }, "common">; dialect: "common"; }>; type ApiContext = { db: DrizzleDb; tables: { [tableName in ExtractTableNames]: DrizzleTable; }; }; type ApiRegistry = { get: HandlerInterface; post: HandlerInterface; use: MiddlewareHandlerInterface; hono: Hono<{ Variables: ApiContext; }>; }; type Context = ApiContext & { /** * Hono request object. * * @see https://hono.dev/docs/api/context#req */ req: Context$1["req"]; /** * Hono response object. * * @see https://hono.dev/docs/api/context#res */ res: Context$1["req"]; /** * Return the HTTP response. * * @see https://hono.dev/docs/api/context#body */ body: Context$1["body"]; /** * Render text as `Content-Type:text/plain`. * * @see https://hono.dev/docs/api/context#text */ text: Context$1["text"]; /** * Render JSON as `Content-Type:application/json`. * * @see https://hono.dev/docs/api/context#json */ json: Context$1["json"]; /** * Hono redirect. * * @see https://hono.dev/docs/api/context#redirect */ redirect: Context$1["redirect"]; }; type MiddlewareContext = ApiContext & Context$1; type Handler = any> = (c: Context) => response; type MiddlewareHandler = (c: MiddlewareContext, next: Next) => Promise; type BasePath = "/"; type HandlerInterface = { = any>(handler: Handler): ApiRegistry; = any>(...handlers: [ Handler, Handler ]): ApiRegistry; = any, input extends Input$1 = BlankInput>(path: path, handler: Handler): ApiRegistry; = any, input extends Input$1 = BlankInput, input2 extends Input$1 = input, input3 extends Input$1 = input & input2>(...handlers: [ MiddlewareHandler, MiddlewareHandler, Handler ]): ApiRegistry; = any, input extends Input$1 = BlankInput, input2 extends Input$1 = input>(path: path, ...handlers: [ MiddlewareHandler, Handler ]): ApiRegistry; = any, input extends Input$1 = BlankInput, input2 extends Input$1 = input, input3 extends Input$1 = input & input2, input4 extends Input$1 = input & input2 & input3>(...handlers: [ MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, Handler ]): ApiRegistry; = any, input extends Input$1 = BlankInput, input2 extends Input$1 = input, input3 extends Input$1 = input & input2>(path: path, ...handlers: [ MiddlewareHandler, MiddlewareHandler, Handler ]): ApiRegistry; = any, input extends Input$1 = BlankInput, input2 extends Input$1 = input, input3 extends Input$1 = input & input2, input4 extends Input$1 = input & input2 & input3, input5 extends Input$1 = input & input2 & input3 & input4>(...handlers: [ MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, Handler ]): ApiRegistry; = any, input extends Input$1 = BlankInput, input2 extends Input$1 = input, input3 extends Input$1 = input & input2, input4 extends Input$1 = input & input2 & input3>(path: path, ...handlers: [ MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, Handler ]): ApiRegistry; = any, input extends Input$1 = BlankInput, input2 extends Input$1 = input, input3 extends Input$1 = input & input2, input4 extends Input$1 = input & input2 & input3, input5 extends Input$1 = input & input2 & input3 & input4, input6 extends Input$1 = input & input2 & input3 & input4 & input5>(...handlers: [ MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, Handler ]): ApiRegistry; = any, input extends Input$1 = BlankInput, input2 extends Input$1 = input, input3 extends Input$1 = input & input2, input4 extends Input$1 = input & input2 & input3, input5 extends Input$1 = input & input2 & input3 & input4>(path: path, ...handlers: [ MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, Handler ]): ApiRegistry; = any, input extends Input$1 = BlankInput, input2 extends Input$1 = input, input3 extends Input$1 = input & input2, input4 extends Input$1 = input & input2 & input3, input5 extends Input$1 = input & input2 & input3 & input4, input6 extends Input$1 = input & input2 & input3 & input4 & input5, input7 extends Input$1 = input & input2 & input3 & input4 & input5 & input6>(...handlers: [ MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, Handler ]): ApiRegistry; = any, input extends Input$1 = BlankInput, input2 extends Input$1 = input, input3 extends Input$1 = input & input2, input4 extends Input$1 = input & input2 & input3, input5 extends Input$1 = input & input2 & input3 & input4, input6 extends Input$1 = input & input2 & input3 & input4 & input5>(path: path, ...handlers: [ MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, Handler ]): ApiRegistry; = any, input extends Input$1 = BlankInput, input2 extends Input$1 = input, input3 extends Input$1 = input & input2, input4 extends Input$1 = input & input2 & input3, input5 extends Input$1 = input & input2 & input3 & input4, input6 extends Input$1 = input & input2 & input3 & input4 & input5, input7 extends Input$1 = input & input2 & input3 & input4 & input5 & input6, input8 extends Input$1 = input & input2 & input3 & input4 & input5 & input6 & input7>(...handlers: [ MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, Handler ]): ApiRegistry; = any, input extends Input$1 = BlankInput, input2 extends Input$1 = input, input3 extends Input$1 = input & input2, input4 extends Input$1 = input & input2 & input3, input5 extends Input$1 = input & input2 & input3 & input4, input6 extends Input$1 = input & input2 & input3 & input4 & input5, input7 extends Input$1 = input & input2 & input3 & input4 & input5 & input6>(path: path, ...handlers: [ MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, Handler ]): ApiRegistry; = any, input extends Input$1 = BlankInput, input2 extends Input$1 = input, input3 extends Input$1 = input & input2, input4 extends Input$1 = input & input2 & input3, input5 extends Input$1 = input & input2 & input3 & input4, input6 extends Input$1 = input & input2 & input3 & input4 & input5, input7 extends Input$1 = input & input2 & input3 & input4 & input5 & input6, input8 extends Input$1 = input & input2 & input3 & input4 & input5 & input6 & input7, input9 extends Input$1 = input & input2 & input3 & input4 & input5 & input6 & input7 & input8>(...handlers: [ MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, Handler ]): ApiRegistry; = any, input extends Input$1 = BlankInput, input2 extends Input$1 = input, input3 extends Input$1 = input & input2, input4 extends Input$1 = input & input2 & input3, input5 extends Input$1 = input & input2 & input3 & input4, input6 extends Input$1 = input & input2 & input3 & input4 & input5, input7 extends Input$1 = input & input2 & input3 & input4 & input5 & input6, input8 extends Input$1 = input & input2 & input3 & input4 & input5 & input6 & input7>(path: path, ...handlers: [ MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, Handler ]): ApiRegistry; = any, input extends Input$1 = BlankInput, input2 extends Input$1 = input, input3 extends Input$1 = input & input2, input4 extends Input$1 = input & input2 & input3, input5 extends Input$1 = input & input2 & input3 & input4, input6 extends Input$1 = input & input2 & input3 & input4 & input5, input7 extends Input$1 = input & input2 & input3 & input4 & input5 & input6, input8 extends Input$1 = input & input2 & input3 & input4 & input5 & input6 & input7, input9 extends Input$1 = input & input2 & input3 & input4 & input5 & input6 & input7 & input8, input10 extends Input$1 = input & input2 & input3 & input4 & input5 & input6 & input7 & input8 & input9>(...handlers: [ MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, Handler ]): ApiRegistry; = any, input extends Input$1 = BlankInput, input2 extends Input$1 = input, input3 extends Input$1 = input & input2, input4 extends Input$1 = input & input2 & input3, input5 extends Input$1 = input & input2 & input3 & input4, input6 extends Input$1 = input & input2 & input3 & input4 & input5, input7 extends Input$1 = input & input2 & input3 & input4 & input5 & input6, input8 extends Input$1 = input & input2 & input3 & input4 & input5 & input6 & input7, input9 extends Input$1 = input & input2 & input3 & input4 & input5 & input6 & input7 & input8>(path: path, ...handlers: [ MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, Handler ]): ApiRegistry; = any, input extends Input$1 = BlankInput, input2 extends Input$1 = input, input3 extends Input$1 = input & input2, input4 extends Input$1 = input & input2 & input3, input5 extends Input$1 = input & input2 & input3 & input4, input6 extends Input$1 = input & input2 & input3 & input4 & input5, input7 extends Input$1 = input & input2 & input3 & input4 & input5 & input6, input8 extends Input$1 = input & input2 & input3 & input4 & input5 & input6 & input7, input9 extends Input$1 = input & input2 & input3 & input4 & input5 & input6 & input7 & input8, input10 extends Input$1 = input & input2 & input3 & input4 & input5 & input6 & input7 & input8 & input9>(path: path, ...handlers: [ MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, Handler ]): ApiRegistry; = any>(...handlers: Handler[]): ApiRegistry; = any>(path: path, ...handlers: Handler[]): ApiRegistry; (path: path): ApiRegistry; }; interface MiddlewareHandlerInterface { (...handlers: MiddlewareHandler[]): ApiRegistry; (handler: MiddlewareHandler): ApiRegistry; (...handlers: [ MiddlewareHandler, MiddlewareHandler ]): ApiRegistry; (path: path, handler: MiddlewareHandler): ApiRegistry; (...handlers: [ MiddlewareHandler, MiddlewareHandler, MiddlewareHandler ]): ApiRegistry; (path: path, ...handlers: [ MiddlewareHandler, MiddlewareHandler ]): ApiRegistry; (...handlers: [ MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler ]): ApiRegistry; (path: path, ...handlers: [ MiddlewareHandler, MiddlewareHandler, MiddlewareHandler ]): ApiRegistry; (...handlers: [ MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler ]): ApiRegistry; (path: path, ...handlers: [ MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler ]): ApiRegistry; (...handlers: [ MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler ]): ApiRegistry; (path: path, ...handlers: [ MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler ]): ApiRegistry; (...handlers: [ MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler ]): ApiRegistry; (path: path, ...handlers: [ MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler ]): ApiRegistry; (...handlers: [ MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler ]): ApiRegistry; (path: path, ...handlers: [ MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler ]): ApiRegistry; (...handlers: [ MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler ]): ApiRegistry; (path: path, ...handlers: [ MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler ]): ApiRegistry; (...handlers: [ MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler ]): ApiRegistry; (path: path, ...handlers: [ MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler, MiddlewareHandler ]): ApiRegistry; (path: path, ...handlers: MiddlewareHandler[]): ApiRegistry; } /** * Fix issue with Array.isArray not checking readonly arrays * {@link https://github.com/microsoft/TypeScript/issues/17002} */ declare global { interface ArrayConstructor { isArray(arg: ReadonlyArray | any): arg is ReadonlyArray; } } type UserValue = string | string[] | number | number[] | boolean | boolean[] | Hex | Hex[] | bigint | bigint[] | object | null | undefined; type UserTable = { id: string | number | Hex | bigint; [columnName: string]: UserValue; }; type OperatorMap = { equals?: column; not?: column; } & (column extends unknown[] ? { has?: column[number]; notHas?: column[number]; } : { in?: column[]; notIn?: column[]; }) & (column extends string ? column extends Hex ? {} : { contains?: column; notContains?: column; startsWith?: column; notStartsWith?: column; endsWith?: column; notEndsWith?: column; } : {}) & (column extends number | bigint | Hex ? { gt?: column; gte?: column; lt?: column; lte?: column; } : {}); type WhereInput
= { [columnName in keyof table]?: Prettify> | table[columnName]; } & { AND?: Prettify>[]; OR?: Prettify>[]; }; type OrderByInput = { [ColumnName in columns]?: "asc" | "desc"; }; type DatabaseModel
= { create: (options: Prettify<{ id: table["id"]; } & (HasOnlyIdProperty
extends true ? { data?: never; } : HasRequiredPropertiesOtherThanId
extends true ? { data: Prettify>; } : { data?: Prettify>; })>) => Promise>; createMany: (options: { data: Prettify
[]; }) => Promise[]>; update: (options: Prettify<{ id: table["id"]; } & (HasOnlyIdProperty
extends true ? { data?: never; } : HasRequiredPropertiesOtherThanId
extends true ? { data: Prettify, "id">> | ((options: { current: Prettify
; }) => Prettify, "id">>); } : { data?: Prettify, "id">> | ((options: { current: Prettify
; }) => Prettify, "id">>); })>) => Promise>; updateMany: (options: { where: Prettify>; data: Prettify, "id">> | ((options: { current: Prettify
; }) => Prettify, "id">>); }) => Promise[]>; upsert: (options: Prettify<{ id: table["id"]; } & (HasOnlyIdProperty
extends true ? { create?: never; update?: never; } : HasRequiredPropertiesOtherThanId
extends true ? { create: Prettify>; update: Prettify, "id">> | ((options: { current: Prettify
; }) => Prettify, "id">>); } : { create?: Prettify>; update?: Prettify, "id">> | ((options: { current: Prettify
; }) => Prettify, "id">>); })>) => Promise>; findUnique: (options: { id: table["id"]; }) => Promise | null>; findMany: (options?: { where?: Prettify>; orderBy?: Prettify>; limit?: number; before?: string; after?: string; }) => Promise<{ items: Prettify
[]; pageInfo: { startCursor: string | null; endCursor: string | null; hasNextPage: boolean; hasPreviousPage: boolean; }; }>; delete: (options: { id: table["id"]; }) => Promise; }; type BlockOptions = { cache?: undefined; blockNumber?: undefined; } | { cache: "immutable"; blockNumber?: undefined; } | { cache?: undefined; blockNumber: bigint; }; type PonderActions = { getBalance: (args: Omit & BlockOptions) => Promise; getCode: (args: Omit & BlockOptions) => Promise; getStorageAt: (args: Omit & BlockOptions) => Promise; multicall: (args: Omit, "blockTag" | "blockNumber"> & BlockOptions) => Promise>; readContract: , const args extends ContractFunctionArgs>(args: Omit, "blockTag" | "blockNumber"> & BlockOptions) => Promise>; getEnsName: (args: Omit & BlockOptions) => Promise; }; type ReadOnlyClient = Prettify>; declare namespace Virtual { type Setup = "setup"; type _FormatEventNames> = string extends safeEventNames ? never : contract extends { filter: { event: infer event extends string | readonly string[]; }; } ? event extends safeEventNames ? event : event[number] extends safeEventNames ? event[number] : safeEventNames : safeEventNames; type _FormatFunctionNames> = string extends safeFunctionNames ? never : safeFunctionNames; /** "{ContractName}:{EventName}" | "{ContractName}.{FunctionName}()" | "{SourceName}:block" . */ export type FormatEventNames = { [name in keyof contracts]: `${name & string}:${_FormatEventNames | Setup}`; }[keyof contracts] | { [name in keyof blocks]: `${name & string}:block`; }[keyof blocks] | { [name in keyof contracts]: true extends ExtractOverridenProperty ? `${name & string}.${_FormatFunctionNames}` : never; }[keyof contracts]; type FormatTransactionReceipts> = includeTxr extends includeTxr ? includeTxr extends true ? { transactionReceipt: Prettify; } : { transactionReceipt?: never; } : never; export type ExtractEventName = name extends `${string}:${infer EventName extends string}` ? EventName : name extends `${string}.${infer EventName extends string}` ? EventName : never; export type ExtractSourceName = name extends `${infer SourceName extends string}:${string}` ? SourceName : name extends `${infer SourceName extends string}.${string}` ? SourceName : never; export type EventNames = FormatEventNames; export type Event, contractName extends ExtractSourceName = ExtractSourceName, eventName extends ExtractEventName = ExtractEventName> = name extends `${string}:block` ? { block: Prettify; } : name extends `${string}.${string}` ? Prettify<{ args: FormatFunctionArgs; result: FormatFunctionResult; trace: Prettify; block: Prettify; transaction: Prettify; } & FormatTransactionReceipts> : eventName extends Setup ? never : Prettify<{ name: eventName; args: FormatEventArgs; log: Prettify; block: Prettify; transaction: Prettify; } & FormatTransactionReceipts>; type ContextContractProperty = Exclude; type ExtractOverridenProperty[property], override = Extract[property]> = ([base] extends [never] ? undefined : base) | override; export type Context, sourceName extends ExtractSourceName = ExtractSourceName, sourceNetwork = sourceName extends sourceName ? (unknown extends config["contracts"][sourceName]["network"] ? never : config["contracts"][sourceName]["network"]) | (unknown extends config["blocks"][sourceName]["network"] ? never : config["blocks"][sourceName]["network"]) : never> = { contracts: { [_contractName in keyof config["contracts"]]: { abi: config["contracts"][_contractName]["abi"]; address: ExtractOverridenProperty; startBlock: ExtractOverridenProperty; endBlock: ExtractOverridenProperty; }; }; network: sourceNetwork extends string ? { name: sourceNetwork; chainId: config["networks"][sourceNetwork]["chainId"]; } : { [key in keyof sourceNetwork]: { name: key; chainId: config["networks"][key & keyof config["networks"]]["chainId"]; }; }[keyof sourceNetwork]; client: Prettify>; db: { [key in keyof InferSchemaType]: DatabaseModel[key]>; }; }; export type Drizzle = ApiContext; export type IndexingFunctionArgs> = { event: Event; context: Context; }; export type Schema = InferSchemaType; export type Registry = { on: >(_name: name, indexingFunction: (args: { event: Event; } & { context: Prettify>; }) => Promise | void) => void; } & ApiRegistry; export { }; } /** * Middleware for GraphQL with an interactive web view. * * - Docs: https://ponder.sh/docs/query/api-functions#register-graphql-middleware * * @example * import { ponder } from "@/generated"; * import { graphql } from "@ponder/core"; * * ponder.use("/graphql", graphql()); * */ declare const graphql: ({ maxOperationTokens, maxOperationDepth, maxOperationAliases, }?: { maxOperationTokens?: number | undefined; maxOperationDepth?: number | undefined; maxOperationAliases?: number | undefined; }) => hono.MiddlewareHandler; declare function alias(table: tableOrView, alias: alias): BuildAliasTable; type ContractConfig = Prettify; type NetworkConfig = Prettify; type BlockConfig = Prettify; type DatabaseConfig = Prettify; export { type Block, type BlockConfig, type ContractConfig, type DatabaseConfig, type Log, type NetworkConfig, type Transaction, type TransactionReceipt, Virtual, alias, createConfig, createSchema, graphql };