@mikeatlast/ponder 0.16.1-fork.1
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/CHANGELOG.md +3415 -0
- package/README.md +186 -0
- package/dist/esm/bin/commands/codegen.js +46 -0
- package/dist/esm/bin/commands/codegen.js.map +1 -0
- package/dist/esm/bin/commands/createViews.js +196 -0
- package/dist/esm/bin/commands/createViews.js.map +1 -0
- package/dist/esm/bin/commands/dev.js +430 -0
- package/dist/esm/bin/commands/dev.js.map +1 -0
- package/dist/esm/bin/commands/list.js +148 -0
- package/dist/esm/bin/commands/list.js.map +1 -0
- package/dist/esm/bin/commands/prune.js +223 -0
- package/dist/esm/bin/commands/prune.js.map +1 -0
- package/dist/esm/bin/commands/serve.js +198 -0
- package/dist/esm/bin/commands/serve.js.map +1 -0
- package/dist/esm/bin/commands/start.js +253 -0
- package/dist/esm/bin/commands/start.js.map +1 -0
- package/dist/esm/bin/isolatedController.js +200 -0
- package/dist/esm/bin/isolatedController.js.map +1 -0
- package/dist/esm/bin/isolatedWorker.js +146 -0
- package/dist/esm/bin/isolatedWorker.js.map +1 -0
- package/dist/esm/bin/ponder.js +137 -0
- package/dist/esm/bin/ponder.js.map +1 -0
- package/dist/esm/bin/utils/codegen.js +25 -0
- package/dist/esm/bin/utils/codegen.js.map +1 -0
- package/dist/esm/bin/utils/exit.js +100 -0
- package/dist/esm/bin/utils/exit.js.map +1 -0
- package/dist/esm/build/config.js +745 -0
- package/dist/esm/build/config.js.map +1 -0
- package/dist/esm/build/factory.js +82 -0
- package/dist/esm/build/factory.js.map +1 -0
- package/dist/esm/build/index.js +567 -0
- package/dist/esm/build/index.js.map +1 -0
- package/dist/esm/build/plugin.js +53 -0
- package/dist/esm/build/plugin.js.map +1 -0
- package/dist/esm/build/pre.js +83 -0
- package/dist/esm/build/pre.js.map +1 -0
- package/dist/esm/build/schema.js +202 -0
- package/dist/esm/build/schema.js.map +1 -0
- package/dist/esm/build/stacktrace.js +137 -0
- package/dist/esm/build/stacktrace.js.map +1 -0
- package/dist/esm/client/index.js +441 -0
- package/dist/esm/client/index.js.map +1 -0
- package/dist/esm/config/address.js +2 -0
- package/dist/esm/config/address.js.map +1 -0
- package/dist/esm/config/eventFilter.js +2 -0
- package/dist/esm/config/eventFilter.js.map +1 -0
- package/dist/esm/config/index.js +2 -0
- package/dist/esm/config/index.js.map +1 -0
- package/dist/esm/config/utilityTypes.js +2 -0
- package/dist/esm/config/utilityTypes.js.map +1 -0
- package/dist/esm/database/actions.js +445 -0
- package/dist/esm/database/actions.js.map +1 -0
- package/dist/esm/database/index.js +604 -0
- package/dist/esm/database/index.js.map +1 -0
- package/dist/esm/database/queryBuilder.js +314 -0
- package/dist/esm/database/queryBuilder.js.map +1 -0
- package/dist/esm/drizzle/bigint.js +38 -0
- package/dist/esm/drizzle/bigint.js.map +1 -0
- package/dist/esm/drizzle/bytes.js +47 -0
- package/dist/esm/drizzle/bytes.js.map +1 -0
- package/dist/esm/drizzle/hex.js +40 -0
- package/dist/esm/drizzle/hex.js.map +1 -0
- package/dist/esm/drizzle/index.js +28 -0
- package/dist/esm/drizzle/index.js.map +1 -0
- package/dist/esm/drizzle/json.js +123 -0
- package/dist/esm/drizzle/json.js.map +1 -0
- package/dist/esm/drizzle/kit/index.js +927 -0
- package/dist/esm/drizzle/kit/index.js.map +1 -0
- package/dist/esm/drizzle/onchain.js +184 -0
- package/dist/esm/drizzle/onchain.js.map +1 -0
- package/dist/esm/drizzle/text.js +61 -0
- package/dist/esm/drizzle/text.js.map +1 -0
- package/dist/esm/graphql/graphiql.html.js +59 -0
- package/dist/esm/graphql/graphiql.html.js.map +1 -0
- package/dist/esm/graphql/index.js +934 -0
- package/dist/esm/graphql/index.js.map +1 -0
- package/dist/esm/graphql/json.js +42 -0
- package/dist/esm/graphql/json.js.map +1 -0
- package/dist/esm/graphql/middleware.js +83 -0
- package/dist/esm/graphql/middleware.js.map +1 -0
- package/dist/esm/index.js +9 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/indexing/addStackTrace.js +54 -0
- package/dist/esm/indexing/addStackTrace.js.map +1 -0
- package/dist/esm/indexing/client.js +675 -0
- package/dist/esm/indexing/client.js.map +1 -0
- package/dist/esm/indexing/index.js +663 -0
- package/dist/esm/indexing/index.js.map +1 -0
- package/dist/esm/indexing/profile.js +584 -0
- package/dist/esm/indexing/profile.js.map +1 -0
- package/dist/esm/indexing-store/cache.js +666 -0
- package/dist/esm/indexing-store/cache.js.map +1 -0
- package/dist/esm/indexing-store/index.js +461 -0
- package/dist/esm/indexing-store/index.js.map +1 -0
- package/dist/esm/indexing-store/profile.js +428 -0
- package/dist/esm/indexing-store/profile.js.map +1 -0
- package/dist/esm/indexing-store/utils.js +111 -0
- package/dist/esm/indexing-store/utils.js.map +1 -0
- package/dist/esm/internal/common.js +2 -0
- package/dist/esm/internal/common.js.map +1 -0
- package/dist/esm/internal/errors.js +300 -0
- package/dist/esm/internal/errors.js.map +1 -0
- package/dist/esm/internal/logger.js +178 -0
- package/dist/esm/internal/logger.js.map +1 -0
- package/dist/esm/internal/metrics.js +1049 -0
- package/dist/esm/internal/metrics.js.map +1 -0
- package/dist/esm/internal/options.js +73 -0
- package/dist/esm/internal/options.js.map +1 -0
- package/dist/esm/internal/shutdown.js +24 -0
- package/dist/esm/internal/shutdown.js.map +1 -0
- package/dist/esm/internal/telemetry.js +200 -0
- package/dist/esm/internal/telemetry.js.map +1 -0
- package/dist/esm/internal/types.js +2 -0
- package/dist/esm/internal/types.js.map +1 -0
- package/dist/esm/rpc/actions.js +988 -0
- package/dist/esm/rpc/actions.js.map +1 -0
- package/dist/esm/rpc/http.js +130 -0
- package/dist/esm/rpc/http.js.map +1 -0
- package/dist/esm/rpc/index.js +749 -0
- package/dist/esm/rpc/index.js.map +1 -0
- package/dist/esm/runtime/events.js +664 -0
- package/dist/esm/runtime/events.js.map +1 -0
- package/dist/esm/runtime/filter.js +476 -0
- package/dist/esm/runtime/filter.js.map +1 -0
- package/dist/esm/runtime/fragments.js +478 -0
- package/dist/esm/runtime/fragments.js.map +1 -0
- package/dist/esm/runtime/historical.js +954 -0
- package/dist/esm/runtime/historical.js.map +1 -0
- package/dist/esm/runtime/index.js +316 -0
- package/dist/esm/runtime/index.js.map +1 -0
- package/dist/esm/runtime/init.js +12 -0
- package/dist/esm/runtime/init.js.map +1 -0
- package/dist/esm/runtime/isolated.js +464 -0
- package/dist/esm/runtime/isolated.js.map +1 -0
- package/dist/esm/runtime/multichain.js +511 -0
- package/dist/esm/runtime/multichain.js.map +1 -0
- package/dist/esm/runtime/omnichain.js +546 -0
- package/dist/esm/runtime/omnichain.js.map +1 -0
- package/dist/esm/runtime/realtime.js +722 -0
- package/dist/esm/runtime/realtime.js.map +1 -0
- package/dist/esm/server/error.js +56 -0
- package/dist/esm/server/error.js.map +1 -0
- package/dist/esm/server/index.js +121 -0
- package/dist/esm/server/index.js.map +1 -0
- package/dist/esm/sync-historical/index.js +703 -0
- package/dist/esm/sync-historical/index.js.map +1 -0
- package/dist/esm/sync-realtime/bloom.js +76 -0
- package/dist/esm/sync-realtime/bloom.js.map +1 -0
- package/dist/esm/sync-realtime/index.js +918 -0
- package/dist/esm/sync-realtime/index.js.map +1 -0
- package/dist/esm/sync-store/encode.js +105 -0
- package/dist/esm/sync-store/encode.js.map +1 -0
- package/dist/esm/sync-store/index.js +885 -0
- package/dist/esm/sync-store/index.js.map +1 -0
- package/dist/esm/sync-store/migrations.js +1595 -0
- package/dist/esm/sync-store/migrations.js.map +1 -0
- package/dist/esm/sync-store/schema.js +181 -0
- package/dist/esm/sync-store/schema.js.map +1 -0
- package/dist/esm/types/db.js +2 -0
- package/dist/esm/types/db.js.map +1 -0
- package/dist/esm/types/eth.js +2 -0
- package/dist/esm/types/eth.js.map +1 -0
- package/dist/esm/types/utils.js +2 -0
- package/dist/esm/types/utils.js.map +1 -0
- package/dist/esm/types/virtual.js +2 -0
- package/dist/esm/types/virtual.js.map +1 -0
- package/dist/esm/ui/app.js +157 -0
- package/dist/esm/ui/app.js.map +1 -0
- package/dist/esm/ui/index.js +29 -0
- package/dist/esm/ui/index.js.map +1 -0
- package/dist/esm/ui/patch.js +140 -0
- package/dist/esm/ui/patch.js.map +1 -0
- package/dist/esm/utils/abi.js +55 -0
- package/dist/esm/utils/abi.js.map +1 -0
- package/dist/esm/utils/bigint.js +37 -0
- package/dist/esm/utils/bigint.js.map +1 -0
- package/dist/esm/utils/chains.js +21 -0
- package/dist/esm/utils/chains.js.map +1 -0
- package/dist/esm/utils/checkpoint.js +139 -0
- package/dist/esm/utils/checkpoint.js.map +1 -0
- package/dist/esm/utils/chunk.js +8 -0
- package/dist/esm/utils/chunk.js.map +1 -0
- package/dist/esm/utils/copy.js +129 -0
- package/dist/esm/utils/copy.js.map +1 -0
- package/dist/esm/utils/date.js +27 -0
- package/dist/esm/utils/date.js.map +1 -0
- package/dist/esm/utils/debug.js +2 -0
- package/dist/esm/utils/debug.js.map +1 -0
- package/dist/esm/utils/decodeAbiParameters.js +290 -0
- package/dist/esm/utils/decodeAbiParameters.js.map +1 -0
- package/dist/esm/utils/decodeEventLog.js +75 -0
- package/dist/esm/utils/decodeEventLog.js.map +1 -0
- package/dist/esm/utils/dedupe.js +29 -0
- package/dist/esm/utils/dedupe.js.map +1 -0
- package/dist/esm/utils/duplicates.js +19 -0
- package/dist/esm/utils/duplicates.js.map +1 -0
- package/dist/esm/utils/estimate.js +6 -0
- package/dist/esm/utils/estimate.js.map +1 -0
- package/dist/esm/utils/finality.js +38 -0
- package/dist/esm/utils/finality.js.map +1 -0
- package/dist/esm/utils/format.js +20 -0
- package/dist/esm/utils/format.js.map +1 -0
- package/dist/esm/utils/generators.js +121 -0
- package/dist/esm/utils/generators.js.map +1 -0
- package/dist/esm/utils/hash.js +11 -0
- package/dist/esm/utils/hash.js.map +1 -0
- package/dist/esm/utils/interval.js +171 -0
- package/dist/esm/utils/interval.js.map +1 -0
- package/dist/esm/utils/lowercase.js +7 -0
- package/dist/esm/utils/lowercase.js.map +1 -0
- package/dist/esm/utils/mutex.js +26 -0
- package/dist/esm/utils/mutex.js.map +1 -0
- package/dist/esm/utils/never.js +4 -0
- package/dist/esm/utils/never.js.map +1 -0
- package/dist/esm/utils/offset.js +101 -0
- package/dist/esm/utils/offset.js.map +1 -0
- package/dist/esm/utils/order.js +18 -0
- package/dist/esm/utils/order.js.map +1 -0
- package/dist/esm/utils/partition.js +46 -0
- package/dist/esm/utils/partition.js.map +1 -0
- package/dist/esm/utils/pg.js +175 -0
- package/dist/esm/utils/pg.js.map +1 -0
- package/dist/esm/utils/pglite.js +80 -0
- package/dist/esm/utils/pglite.js.map +1 -0
- package/dist/esm/utils/port.js +30 -0
- package/dist/esm/utils/port.js.map +1 -0
- package/dist/esm/utils/print.js +23 -0
- package/dist/esm/utils/print.js.map +1 -0
- package/dist/esm/utils/promiseAllSettledWithThrow.js +19 -0
- package/dist/esm/utils/promiseAllSettledWithThrow.js.map +1 -0
- package/dist/esm/utils/promiseWithResolvers.js +13 -0
- package/dist/esm/utils/promiseWithResolvers.js.map +1 -0
- package/dist/esm/utils/queue.js +150 -0
- package/dist/esm/utils/queue.js.map +1 -0
- package/dist/esm/utils/range.js +8 -0
- package/dist/esm/utils/range.js.map +1 -0
- package/dist/esm/utils/result.js +10 -0
- package/dist/esm/utils/result.js.map +1 -0
- package/dist/esm/utils/sql-parse.js +1326 -0
- package/dist/esm/utils/sql-parse.js.map +1 -0
- package/dist/esm/utils/timer.js +9 -0
- package/dist/esm/utils/timer.js.map +1 -0
- package/dist/esm/utils/truncate.js +15 -0
- package/dist/esm/utils/truncate.js.map +1 -0
- package/dist/esm/utils/wait.js +10 -0
- package/dist/esm/utils/wait.js.map +1 -0
- package/dist/esm/utils/zipper.js +67 -0
- package/dist/esm/utils/zipper.js.map +1 -0
- package/dist/types/bin/commands/codegen.d.ts +5 -0
- package/dist/types/bin/commands/codegen.d.ts.map +1 -0
- package/dist/types/bin/commands/createViews.d.ts +8 -0
- package/dist/types/bin/commands/createViews.d.ts.map +1 -0
- package/dist/types/bin/commands/dev.d.ts +5 -0
- package/dist/types/bin/commands/dev.d.ts.map +1 -0
- package/dist/types/bin/commands/list.d.ts +5 -0
- package/dist/types/bin/commands/list.d.ts.map +1 -0
- package/dist/types/bin/commands/prune.d.ts +5 -0
- package/dist/types/bin/commands/prune.d.ts.map +1 -0
- package/dist/types/bin/commands/serve.d.ts +5 -0
- package/dist/types/bin/commands/serve.d.ts.map +1 -0
- package/dist/types/bin/commands/start.d.ts +19 -0
- package/dist/types/bin/commands/start.d.ts.map +1 -0
- package/dist/types/bin/isolatedController.d.ts +13 -0
- package/dist/types/bin/isolatedController.d.ts.map +1 -0
- package/dist/types/bin/isolatedWorker.d.ts +9 -0
- package/dist/types/bin/isolatedWorker.d.ts.map +1 -0
- package/dist/types/bin/ponder.d.ts +37 -0
- package/dist/types/bin/ponder.d.ts.map +1 -0
- package/dist/types/bin/utils/codegen.d.ts +6 -0
- package/dist/types/bin/utils/codegen.d.ts.map +1 -0
- package/dist/types/bin/utils/exit.d.ts +10 -0
- package/dist/types/bin/utils/exit.d.ts.map +1 -0
- package/dist/types/build/config.d.ts +97 -0
- package/dist/types/build/config.d.ts.map +1 -0
- package/dist/types/build/factory.d.ts +15 -0
- package/dist/types/build/factory.d.ts.map +1 -0
- package/dist/types/build/index.d.ts +84 -0
- package/dist/types/build/index.d.ts.map +1 -0
- package/dist/types/build/plugin.d.ts +4 -0
- package/dist/types/build/plugin.d.ts.map +1 -0
- package/dist/types/build/pre.d.ts +29 -0
- package/dist/types/build/pre.d.ts.map +1 -0
- package/dist/types/build/schema.d.ts +20 -0
- package/dist/types/build/schema.d.ts.map +1 -0
- package/dist/types/build/stacktrace.d.ts +13 -0
- package/dist/types/build/stacktrace.d.ts.map +1 -0
- package/dist/types/client/index.d.ts +27 -0
- package/dist/types/client/index.d.ts.map +1 -0
- package/dist/types/config/address.d.ts +34 -0
- package/dist/types/config/address.d.ts.map +1 -0
- package/dist/types/config/eventFilter.d.ts +18 -0
- package/dist/types/config/eventFilter.d.ts.map +1 -0
- package/dist/types/config/index.d.ts +144 -0
- package/dist/types/config/index.d.ts.map +1 -0
- package/dist/types/config/utilityTypes.d.ts +43 -0
- package/dist/types/config/utilityTypes.d.ts.map +1 -0
- package/dist/types/database/actions.d.ts +99 -0
- package/dist/types/database/actions.d.ts.map +1 -0
- package/dist/types/database/index.d.ts +493 -0
- package/dist/types/database/index.d.ts.map +1 -0
- package/dist/types/database/queryBuilder.d.ts +65 -0
- package/dist/types/database/queryBuilder.d.ts.map +1 -0
- package/dist/types/drizzle/bigint.d.ts +25 -0
- package/dist/types/drizzle/bigint.d.ts.map +1 -0
- package/dist/types/drizzle/bytes.d.ts +31 -0
- package/dist/types/drizzle/bytes.d.ts.map +1 -0
- package/dist/types/drizzle/hex.d.ts +25 -0
- package/dist/types/drizzle/hex.d.ts.map +1 -0
- package/dist/types/drizzle/index.d.ts +6 -0
- package/dist/types/drizzle/index.d.ts.map +1 -0
- package/dist/types/drizzle/json.d.ts +51 -0
- package/dist/types/drizzle/json.d.ts.map +1 -0
- package/dist/types/drizzle/kit/index.d.ts +187 -0
- package/dist/types/drizzle/kit/index.d.ts.map +1 -0
- package/dist/types/drizzle/onchain.d.ts +298 -0
- package/dist/types/drizzle/onchain.d.ts.map +1 -0
- package/dist/types/drizzle/text.d.ts +29 -0
- package/dist/types/drizzle/text.d.ts.map +1 -0
- package/dist/types/graphql/graphiql.html.d.ts +2 -0
- package/dist/types/graphql/graphiql.html.d.ts.map +1 -0
- package/dist/types/graphql/index.d.ts +12 -0
- package/dist/types/graphql/index.d.ts.map +1 -0
- package/dist/types/graphql/json.d.ts +3 -0
- package/dist/types/graphql/json.d.ts.map +1 -0
- package/dist/types/graphql/middleware.d.ts +29 -0
- package/dist/types/graphql/middleware.d.ts.map +1 -0
- package/dist/types/index.d.ts +23 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/indexing/addStackTrace.d.ts +3 -0
- package/dist/types/indexing/addStackTrace.d.ts.map +1 -0
- package/dist/types/indexing/client.d.ts +154 -0
- package/dist/types/indexing/client.d.ts.map +1 -0
- package/dist/types/indexing/index.d.ts +72 -0
- package/dist/types/indexing/index.d.ts.map +1 -0
- package/dist/types/indexing/profile.d.ts +16 -0
- package/dist/types/indexing/profile.d.ts.map +1 -0
- package/dist/types/indexing-store/cache.d.ts +115 -0
- package/dist/types/indexing-store/cache.d.ts.map +1 -0
- package/dist/types/indexing-store/index.d.ts +24 -0
- package/dist/types/indexing-store/index.d.ts.map +1 -0
- package/dist/types/indexing-store/profile.d.ts +7 -0
- package/dist/types/indexing-store/profile.d.ts.map +1 -0
- package/dist/types/indexing-store/utils.d.ts +19 -0
- package/dist/types/indexing-store/utils.d.ts.map +1 -0
- package/dist/types/internal/common.d.ts +15 -0
- package/dist/types/internal/common.d.ts.map +1 -0
- package/dist/types/internal/errors.d.ts +101 -0
- package/dist/types/internal/errors.d.ts.map +1 -0
- package/dist/types/internal/logger.d.ts +37 -0
- package/dist/types/internal/logger.d.ts.map +1 -0
- package/dist/types/internal/metrics.d.ts +120 -0
- package/dist/types/internal/metrics.d.ts.map +1 -0
- package/dist/types/internal/options.d.ts +62 -0
- package/dist/types/internal/options.d.ts.map +1 -0
- package/dist/types/internal/shutdown.d.ts +8 -0
- package/dist/types/internal/shutdown.d.ts.map +1 -0
- package/dist/types/internal/telemetry.d.ts +43 -0
- package/dist/types/internal/telemetry.d.ts.map +1 -0
- package/dist/types/internal/types.d.ts +443 -0
- package/dist/types/internal/types.d.ts.map +1 -0
- package/dist/types/rpc/actions.d.ts +360 -0
- package/dist/types/rpc/actions.d.ts.map +1 -0
- package/dist/types/rpc/http.d.ts +17 -0
- package/dist/types/rpc/http.d.ts.map +1 -0
- package/dist/types/rpc/index.d.ts +43 -0
- package/dist/types/rpc/index.d.ts.map +1 -0
- package/dist/types/runtime/events.d.ts +40 -0
- package/dist/types/runtime/events.d.ts.map +1 -0
- package/dist/types/runtime/filter.d.ts +96 -0
- package/dist/types/runtime/filter.d.ts.map +1 -0
- package/dist/types/runtime/fragments.d.ts +30 -0
- package/dist/types/runtime/fragments.d.ts.map +1 -0
- package/dist/types/runtime/historical.d.ts +123 -0
- package/dist/types/runtime/historical.d.ts.map +1 -0
- package/dist/types/runtime/index.d.ts +89 -0
- package/dist/types/runtime/index.d.ts.map +1 -0
- package/dist/types/runtime/init.d.ts +28 -0
- package/dist/types/runtime/init.d.ts.map +1 -0
- package/dist/types/runtime/isolated.d.ts +14 -0
- package/dist/types/runtime/isolated.d.ts.map +1 -0
- package/dist/types/runtime/multichain.d.ts +13 -0
- package/dist/types/runtime/multichain.d.ts.map +1 -0
- package/dist/types/runtime/omnichain.d.ts +23 -0
- package/dist/types/runtime/omnichain.d.ts.map +1 -0
- package/dist/types/runtime/realtime.d.ts +93 -0
- package/dist/types/runtime/realtime.d.ts.map +1 -0
- package/dist/types/server/error.d.ts +5 -0
- package/dist/types/server/error.d.ts.map +1 -0
- package/dist/types/server/index.d.ts +13 -0
- package/dist/types/server/index.d.ts.map +1 -0
- package/dist/types/sync-historical/index.d.ts +36 -0
- package/dist/types/sync-historical/index.d.ts.map +1 -0
- package/dist/types/sync-realtime/bloom.d.ts +18 -0
- package/dist/types/sync-realtime/bloom.d.ts.map +1 -0
- package/dist/types/sync-realtime/index.d.ts +48 -0
- package/dist/types/sync-realtime/index.d.ts.map +1 -0
- package/dist/types/sync-store/encode.d.ts +25 -0
- package/dist/types/sync-store/encode.d.ts.map +1 -0
- package/dist/types/sync-store/index.d.ts +135 -0
- package/dist/types/sync-store/index.d.ts.map +1 -0
- package/dist/types/sync-store/migrations.d.ts +8 -0
- package/dist/types/sync-store/migrations.d.ts.map +1 -0
- package/dist/types/sync-store/schema.d.ts +1828 -0
- package/dist/types/sync-store/schema.d.ts.map +1 -0
- package/dist/types/types/db.d.ts +213 -0
- package/dist/types/types/db.d.ts.map +1 -0
- package/dist/types/types/eth.d.ts +196 -0
- package/dist/types/types/eth.d.ts.map +1 -0
- package/dist/types/types/utils.d.ts +38 -0
- package/dist/types/types/utils.d.ts.map +1 -0
- package/dist/types/types/virtual.d.ts +99 -0
- package/dist/types/types/virtual.d.ts.map +1 -0
- package/dist/types/ui/app.d.ts +22 -0
- package/dist/types/ui/app.d.ts.map +1 -0
- package/dist/types/ui/index.d.ts +5 -0
- package/dist/types/ui/index.d.ts.map +1 -0
- package/dist/types/ui/patch.d.ts +7 -0
- package/dist/types/ui/patch.d.ts.map +1 -0
- package/dist/types/utils/abi.d.ts +23 -0
- package/dist/types/utils/abi.d.ts.map +1 -0
- package/dist/types/utils/bigint.d.ts +15 -0
- package/dist/types/utils/bigint.d.ts.map +1 -0
- package/dist/types/utils/chains.d.ts +42 -0
- package/dist/types/utils/chains.d.ts.map +1 -0
- package/dist/types/utils/checkpoint.d.ts +52 -0
- package/dist/types/utils/checkpoint.d.ts.map +1 -0
- package/dist/types/utils/chunk.d.ts +2 -0
- package/dist/types/utils/chunk.d.ts.map +1 -0
- package/dist/types/utils/copy.d.ts +16 -0
- package/dist/types/utils/copy.d.ts.map +1 -0
- package/dist/types/utils/date.d.ts +7 -0
- package/dist/types/utils/date.d.ts.map +1 -0
- package/dist/types/utils/debug.d.ts +105 -0
- package/dist/types/utils/debug.d.ts.map +1 -0
- package/dist/types/utils/decodeAbiParameters.d.ts +28 -0
- package/dist/types/utils/decodeAbiParameters.d.ts.map +1 -0
- package/dist/types/utils/decodeEventLog.d.ts +12 -0
- package/dist/types/utils/decodeEventLog.d.ts.map +1 -0
- package/dist/types/utils/dedupe.d.ts +20 -0
- package/dist/types/utils/dedupe.d.ts.map +1 -0
- package/dist/types/utils/duplicates.d.ts +7 -0
- package/dist/types/utils/duplicates.d.ts.map +1 -0
- package/dist/types/utils/estimate.d.ts +11 -0
- package/dist/types/utils/estimate.d.ts.map +1 -0
- package/dist/types/utils/finality.d.ts +12 -0
- package/dist/types/utils/finality.d.ts.map +1 -0
- package/dist/types/utils/format.d.ts +3 -0
- package/dist/types/utils/format.d.ts.map +1 -0
- package/dist/types/utils/generators.d.ts +42 -0
- package/dist/types/utils/generators.d.ts.map +1 -0
- package/dist/types/utils/hash.d.ts +11 -0
- package/dist/types/utils/hash.d.ts.map +1 -0
- package/dist/types/utils/interval.d.ts +53 -0
- package/dist/types/utils/interval.d.ts.map +1 -0
- package/dist/types/utils/lowercase.d.ts +5 -0
- package/dist/types/utils/lowercase.d.ts.map +1 -0
- package/dist/types/utils/mutex.d.ts +5 -0
- package/dist/types/utils/mutex.d.ts.map +1 -0
- package/dist/types/utils/never.d.ts +2 -0
- package/dist/types/utils/never.d.ts.map +1 -0
- package/dist/types/utils/offset.d.ts +8 -0
- package/dist/types/utils/offset.d.ts.map +1 -0
- package/dist/types/utils/order.d.ts +2 -0
- package/dist/types/utils/order.d.ts.map +1 -0
- package/dist/types/utils/partition.d.ts +22 -0
- package/dist/types/utils/partition.d.ts.map +1 -0
- package/dist/types/utils/pg.d.ts +8 -0
- package/dist/types/utils/pg.d.ts.map +1 -0
- package/dist/types/utils/pglite.d.ts +25 -0
- package/dist/types/utils/pglite.d.ts.map +1 -0
- package/dist/types/utils/port.d.ts +5 -0
- package/dist/types/utils/port.d.ts.map +1 -0
- package/dist/types/utils/print.d.ts +2 -0
- package/dist/types/utils/print.d.ts.map +1 -0
- package/dist/types/utils/promiseAllSettledWithThrow.d.ts +8 -0
- package/dist/types/utils/promiseAllSettledWithThrow.d.ts.map +1 -0
- package/dist/types/utils/promiseWithResolvers.d.ts +10 -0
- package/dist/types/utils/promiseWithResolvers.d.ts.map +1 -0
- package/dist/types/utils/queue.d.ts +33 -0
- package/dist/types/utils/queue.d.ts.map +1 -0
- package/dist/types/utils/range.d.ts +8 -0
- package/dist/types/utils/range.d.ts.map +1 -0
- package/dist/types/utils/result.d.ts +17 -0
- package/dist/types/utils/result.d.ts.map +1 -0
- package/dist/types/utils/sql-parse.d.ts +21 -0
- package/dist/types/utils/sql-parse.d.ts.map +1 -0
- package/dist/types/utils/timer.d.ts +6 -0
- package/dist/types/utils/timer.d.ts.map +1 -0
- package/dist/types/utils/truncate.d.ts +9 -0
- package/dist/types/utils/truncate.d.ts.map +1 -0
- package/dist/types/utils/wait.d.ts +6 -0
- package/dist/types/utils/wait.d.ts.map +1 -0
- package/dist/types/utils/zipper.d.ts +36 -0
- package/dist/types/utils/zipper.d.ts.map +1 -0
- package/package.json +114 -0
- package/src/bin/commands/codegen.ts +56 -0
- package/src/bin/commands/createViews.ts +318 -0
- package/src/bin/commands/dev.ts +490 -0
- package/src/bin/commands/list.ts +208 -0
- package/src/bin/commands/prune.ts +322 -0
- package/src/bin/commands/serve.ts +236 -0
- package/src/bin/commands/start.ts +319 -0
- package/src/bin/isolatedController.ts +300 -0
- package/src/bin/isolatedWorker.ts +192 -0
- package/src/bin/ponder.ts +208 -0
- package/src/bin/utils/codegen.ts +32 -0
- package/src/bin/utils/exit.ts +112 -0
- package/src/build/config.ts +1141 -0
- package/src/build/factory.ts +147 -0
- package/src/build/index.ts +790 -0
- package/src/build/plugin.ts +58 -0
- package/src/build/pre.ts +114 -0
- package/src/build/schema.ts +358 -0
- package/src/build/stacktrace.ts +137 -0
- package/src/client/index.ts +551 -0
- package/src/config/address.ts +45 -0
- package/src/config/eventFilter.ts +33 -0
- package/src/config/index.ts +240 -0
- package/src/config/utilityTypes.ts +152 -0
- package/src/database/actions.ts +873 -0
- package/src/database/index.ts +1029 -0
- package/src/database/queryBuilder.ts +537 -0
- package/src/drizzle/bigint.ts +57 -0
- package/src/drizzle/bytes.ts +68 -0
- package/src/drizzle/hex.ts +58 -0
- package/src/drizzle/index.ts +40 -0
- package/src/drizzle/json.ts +159 -0
- package/src/drizzle/kit/index.ts +1348 -0
- package/src/drizzle/onchain.ts +476 -0
- package/src/drizzle/text.ts +77 -0
- package/src/graphql/graphiql.html.ts +59 -0
- package/src/graphql/index.ts +1351 -0
- package/src/graphql/json.ts +62 -0
- package/src/graphql/middleware.ts +115 -0
- package/src/index.ts +139 -0
- package/src/indexing/addStackTrace.ts +69 -0
- package/src/indexing/client.ts +1184 -0
- package/src/indexing/index.ts +976 -0
- package/src/indexing/profile.ts +771 -0
- package/src/indexing-store/cache.ts +1057 -0
- package/src/indexing-store/index.ts +628 -0
- package/src/indexing-store/profile.ts +557 -0
- package/src/indexing-store/utils.ts +162 -0
- package/src/internal/common.ts +15 -0
- package/src/internal/errors.ts +228 -0
- package/src/internal/logger.ts +252 -0
- package/src/internal/metrics.ts +1030 -0
- package/src/internal/options.ts +130 -0
- package/src/internal/shutdown.ts +32 -0
- package/src/internal/telemetry.ts +303 -0
- package/src/internal/types.ts +611 -0
- package/src/rpc/actions.ts +1344 -0
- package/src/rpc/http.ts +164 -0
- package/src/rpc/index.ts +959 -0
- package/src/runtime/events.ts +875 -0
- package/src/runtime/filter.ts +705 -0
- package/src/runtime/fragments.ts +674 -0
- package/src/runtime/historical.ts +1522 -0
- package/src/runtime/index.ts +569 -0
- package/src/runtime/init.ts +49 -0
- package/src/runtime/isolated.ts +775 -0
- package/src/runtime/multichain.ts +860 -0
- package/src/runtime/omnichain.ts +920 -0
- package/src/runtime/realtime.ts +1164 -0
- package/src/server/error.ts +68 -0
- package/src/server/index.ts +173 -0
- package/src/sync-historical/index.ts +1065 -0
- package/src/sync-realtime/bloom.ts +102 -0
- package/src/sync-realtime/index.ts +1304 -0
- package/src/sync-store/encode.ts +153 -0
- package/src/sync-store/index.ts +1633 -0
- package/src/sync-store/migrations.ts +1801 -0
- package/src/sync-store/schema.ts +248 -0
- package/src/types/db.ts +292 -0
- package/src/types/eth.ts +216 -0
- package/src/types/utils.ts +47 -0
- package/src/types/virtual.ts +244 -0
- package/src/types.d.ts +38 -0
- package/src/ui/app.ts +207 -0
- package/src/ui/index.ts +37 -0
- package/src/ui/patch.ts +204 -0
- package/src/utils/abi.ts +103 -0
- package/src/utils/bigint.ts +41 -0
- package/src/utils/chains.ts +22 -0
- package/src/utils/checkpoint.ts +203 -0
- package/src/utils/chunk.ts +7 -0
- package/src/utils/copy.ts +151 -0
- package/src/utils/date.ts +26 -0
- package/src/utils/debug.ts +110 -0
- package/src/utils/decodeAbiParameters.ts +428 -0
- package/src/utils/decodeEventLog.ts +100 -0
- package/src/utils/dedupe.ts +32 -0
- package/src/utils/duplicates.ts +19 -0
- package/src/utils/estimate.ts +27 -0
- package/src/utils/finality.ts +40 -0
- package/src/utils/format.ts +22 -0
- package/src/utils/generators.ts +157 -0
- package/src/utils/hash.ts +22 -0
- package/src/utils/interval.ts +212 -0
- package/src/utils/lowercase.ts +6 -0
- package/src/utils/mutex.ts +33 -0
- package/src/utils/never.ts +3 -0
- package/src/utils/offset.ts +133 -0
- package/src/utils/order.ts +16 -0
- package/src/utils/partition.ts +53 -0
- package/src/utils/pg.ts +230 -0
- package/src/utils/pglite.ts +97 -0
- package/src/utils/port.ts +34 -0
- package/src/utils/print.ts +31 -0
- package/src/utils/promiseAllSettledWithThrow.ts +27 -0
- package/src/utils/promiseWithResolvers.ts +20 -0
- package/src/utils/queue.ts +258 -0
- package/src/utils/range.ts +8 -0
- package/src/utils/result.ts +26 -0
- package/src/utils/sql-parse.ts +1477 -0
- package/src/utils/timer.ts +8 -0
- package/src/utils/truncate.ts +15 -0
- package/src/utils/wait.ts +8 -0
- package/src/utils/zipper.ts +80 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { Common } from "@/internal/common.js";
|
|
2
|
+
import type { Plugin } from "vite";
|
|
3
|
+
|
|
4
|
+
const virtualModule = () => `export const ponder = {
|
|
5
|
+
fns: [],
|
|
6
|
+
on(name, fn) {
|
|
7
|
+
this.fns.push({ name, fn });
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
const schemaModule = (
|
|
13
|
+
schemaPath: string,
|
|
14
|
+
) => `import * as schema from "${schemaPath}";
|
|
15
|
+
export * from "${schemaPath}";
|
|
16
|
+
export default schema;
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
const apiModule = () => `import { createPublicClient, custom } from "viem";
|
|
20
|
+
|
|
21
|
+
if (globalThis.PONDER_INDEXING_BUILD === undefined || globalThis.PONDER_DATABASE === undefined) {
|
|
22
|
+
throw new Error('Invalid dependency graph. Config, schema, and indexing function files cannot import objects from the API function file "src/api/index.ts".')
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const publicClients = {};
|
|
26
|
+
|
|
27
|
+
for (let i = 0; i < globalThis.PONDER_INDEXING_BUILD.chains.length; i++) {
|
|
28
|
+
const chain = globalThis.PONDER_INDEXING_BUILD.chains[i];
|
|
29
|
+
const rpc = globalThis.PONDER_INDEXING_BUILD.rpcs[i];
|
|
30
|
+
publicClients[chain.name] = createPublicClient({
|
|
31
|
+
chain: chain.viemChain,
|
|
32
|
+
transport: custom({
|
|
33
|
+
request(body) {
|
|
34
|
+
return rpc.request(body);
|
|
35
|
+
}
|
|
36
|
+
}),
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const db = globalThis.PONDER_DATABASE.readonlyQB.raw;
|
|
41
|
+
export { publicClients };
|
|
42
|
+
`;
|
|
43
|
+
|
|
44
|
+
export const vitePluginPonder = (options: Common["options"]): Plugin => {
|
|
45
|
+
// On Windows, options.schemaFile is a Windows-style path. We need to convert it to a
|
|
46
|
+
// Unix-style path for codegen, because TS import paths are Unix-style even on Windows.
|
|
47
|
+
const schemaPath = options.schemaFile.replace(/\\/g, "/");
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
name: "ponder",
|
|
51
|
+
load: (id) => {
|
|
52
|
+
if (id === "ponder:registry") return virtualModule();
|
|
53
|
+
if (id === "ponder:schema") return schemaModule(schemaPath);
|
|
54
|
+
if (id === "ponder:api") return apiModule();
|
|
55
|
+
return null;
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
};
|
package/src/build/pre.ts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import type { Config } from "@/config/index.js";
|
|
3
|
+
import { BuildError } from "@/internal/errors.js";
|
|
4
|
+
import type { Logger } from "@/internal/logger.js";
|
|
5
|
+
import type { Options } from "@/internal/options.js";
|
|
6
|
+
import type { DatabaseConfig } from "@/internal/types.js";
|
|
7
|
+
|
|
8
|
+
export function buildPre({
|
|
9
|
+
config,
|
|
10
|
+
options,
|
|
11
|
+
logger,
|
|
12
|
+
}: {
|
|
13
|
+
config: Config;
|
|
14
|
+
options: Pick<Options, "rootDir" | "ponderDir">;
|
|
15
|
+
logger: Logger;
|
|
16
|
+
}): {
|
|
17
|
+
databaseConfig: DatabaseConfig;
|
|
18
|
+
ordering: NonNullable<Config["ordering"]>;
|
|
19
|
+
} {
|
|
20
|
+
// Build database.
|
|
21
|
+
let databaseConfig: DatabaseConfig;
|
|
22
|
+
|
|
23
|
+
// Determine PGlite directory, preferring config.database.directory if available
|
|
24
|
+
const pgliteDir =
|
|
25
|
+
config.database?.kind === "pglite" && config.database.directory
|
|
26
|
+
? config.database.directory === "memory://"
|
|
27
|
+
? "memory://"
|
|
28
|
+
: path.resolve(config.database.directory)
|
|
29
|
+
: path.join(options.ponderDir, "pglite");
|
|
30
|
+
|
|
31
|
+
if (config.database?.kind) {
|
|
32
|
+
if (config.database.kind === "postgres") {
|
|
33
|
+
let connectionString: string | undefined = undefined;
|
|
34
|
+
|
|
35
|
+
if (config.database.connectionString) {
|
|
36
|
+
connectionString = config.database.connectionString;
|
|
37
|
+
} else if (process.env.DATABASE_PRIVATE_URL) {
|
|
38
|
+
connectionString = process.env.DATABASE_PRIVATE_URL;
|
|
39
|
+
} else if (process.env.DATABASE_URL) {
|
|
40
|
+
connectionString = process.env.DATABASE_URL;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (connectionString === undefined) {
|
|
44
|
+
if (config.database.poolConfig === undefined) {
|
|
45
|
+
throw new Error(
|
|
46
|
+
"Invalid database configuration: Either 'connectionString' or 'poolConfig' must be defined.",
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
logger.warn({
|
|
50
|
+
msg: "No database connection string set. Using 'poolConfig' for connection authentication.",
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const poolConfig = {
|
|
55
|
+
// Note: Override `connectionString` with `poolConfig` if available.
|
|
56
|
+
connectionString,
|
|
57
|
+
...(config.database.poolConfig ?? {}),
|
|
58
|
+
max: config.database.poolConfig?.max ?? 30,
|
|
59
|
+
ssl: config.database.poolConfig?.ssl ?? false,
|
|
60
|
+
} satisfies (DatabaseConfig & { kind: "postgres" })["poolConfig"];
|
|
61
|
+
|
|
62
|
+
databaseConfig = { kind: "postgres", poolConfig };
|
|
63
|
+
} else {
|
|
64
|
+
databaseConfig = { kind: "pglite", options: { dataDir: pgliteDir } };
|
|
65
|
+
}
|
|
66
|
+
} else {
|
|
67
|
+
let connectionString: string | undefined = undefined;
|
|
68
|
+
if (process.env.DATABASE_PRIVATE_URL) {
|
|
69
|
+
connectionString = process.env.DATABASE_PRIVATE_URL;
|
|
70
|
+
} else if (process.env.DATABASE_URL) {
|
|
71
|
+
connectionString = process.env.DATABASE_URL;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// If either of the DATABASE_URL env vars are set, use Postgres.
|
|
75
|
+
if (connectionString !== undefined) {
|
|
76
|
+
const poolConfig = { connectionString, max: 30 };
|
|
77
|
+
|
|
78
|
+
databaseConfig = { kind: "postgres", poolConfig };
|
|
79
|
+
} else {
|
|
80
|
+
// Fall back to PGlite.
|
|
81
|
+
|
|
82
|
+
databaseConfig = { kind: "pglite", options: { dataDir: pgliteDir } };
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
databaseConfig,
|
|
88
|
+
ordering: config.ordering ?? "multichain",
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function safeBuildPre({
|
|
93
|
+
config,
|
|
94
|
+
options,
|
|
95
|
+
logger,
|
|
96
|
+
}: {
|
|
97
|
+
config: Config;
|
|
98
|
+
options: Pick<Options, "rootDir" | "ponderDir">;
|
|
99
|
+
logger: Logger;
|
|
100
|
+
}) {
|
|
101
|
+
try {
|
|
102
|
+
const result = buildPre({ config, options, logger });
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
status: "success",
|
|
106
|
+
databaseConfig: result.databaseConfig,
|
|
107
|
+
ordering: result.ordering,
|
|
108
|
+
} as const;
|
|
109
|
+
} catch (_error) {
|
|
110
|
+
const buildError = new BuildError((_error as Error).message);
|
|
111
|
+
buildError.stack = undefined;
|
|
112
|
+
return { status: "error", error: buildError } as const;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PONDER_CHECKPOINT_TABLE_NAME,
|
|
3
|
+
PONDER_META_TABLE_NAME,
|
|
4
|
+
} from "@/database/index.js";
|
|
5
|
+
import { getPrimaryKeyColumns } from "@/drizzle/index.js";
|
|
6
|
+
import { getSql } from "@/drizzle/kit/index.js";
|
|
7
|
+
import { MAX_DATABASE_OBJECT_NAME_LENGTH } from "@/drizzle/onchain.js";
|
|
8
|
+
import { BuildError } from "@/internal/errors.js";
|
|
9
|
+
import type { PreBuild, Schema } from "@/internal/types.js";
|
|
10
|
+
import {
|
|
11
|
+
SQL,
|
|
12
|
+
getTableColumns,
|
|
13
|
+
getTableName,
|
|
14
|
+
getViewName,
|
|
15
|
+
is,
|
|
16
|
+
} from "drizzle-orm";
|
|
17
|
+
import {
|
|
18
|
+
PgBigSerial53,
|
|
19
|
+
PgBigSerial64,
|
|
20
|
+
PgColumn,
|
|
21
|
+
PgSequence,
|
|
22
|
+
PgSerial,
|
|
23
|
+
PgSmallSerial,
|
|
24
|
+
PgTable,
|
|
25
|
+
PgView,
|
|
26
|
+
getTableConfig,
|
|
27
|
+
getViewConfig,
|
|
28
|
+
} from "drizzle-orm/pg-core";
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @dev The maximum notify message size is 8KB (8000 / 63 > 100).
|
|
32
|
+
*/
|
|
33
|
+
const TABLE_LIMIT = 100;
|
|
34
|
+
|
|
35
|
+
export const buildSchema = ({
|
|
36
|
+
schema,
|
|
37
|
+
preBuild,
|
|
38
|
+
}: { schema: Schema; preBuild: Pick<PreBuild, "ordering"> }) => {
|
|
39
|
+
const statements = getSql(schema);
|
|
40
|
+
|
|
41
|
+
const tableNames = new Set<string>();
|
|
42
|
+
const viewNames = new Set<string>();
|
|
43
|
+
const indexNames = new Set<string>();
|
|
44
|
+
|
|
45
|
+
for (const [name, s] of Object.entries(schema)) {
|
|
46
|
+
if (is(s, PgTable)) {
|
|
47
|
+
let hasPrimaryKey = false;
|
|
48
|
+
let hasChainIdColumn = false;
|
|
49
|
+
|
|
50
|
+
if (
|
|
51
|
+
name === PONDER_META_TABLE_NAME ||
|
|
52
|
+
name === PONDER_CHECKPOINT_TABLE_NAME
|
|
53
|
+
) {
|
|
54
|
+
throw new Error(
|
|
55
|
+
`Schema validation failed: '${name}' is a reserved table name.`,
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (name.length > MAX_DATABASE_OBJECT_NAME_LENGTH) {
|
|
60
|
+
throw new Error(
|
|
61
|
+
`Schema validation failed: '${name}' table name cannot be longer than ${MAX_DATABASE_OBJECT_NAME_LENGTH} characters.`,
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const columnNames = new Set<string>();
|
|
66
|
+
|
|
67
|
+
for (const [columnName, column] of Object.entries(getTableColumns(s))) {
|
|
68
|
+
if (column.primary) {
|
|
69
|
+
if (hasPrimaryKey) {
|
|
70
|
+
throw new Error(
|
|
71
|
+
`Schema validation failed: '${name}' has multiple primary keys.`,
|
|
72
|
+
);
|
|
73
|
+
} else {
|
|
74
|
+
hasPrimaryKey = true;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (
|
|
79
|
+
column instanceof PgSerial ||
|
|
80
|
+
column instanceof PgSmallSerial ||
|
|
81
|
+
column instanceof PgBigSerial53 ||
|
|
82
|
+
column instanceof PgBigSerial64
|
|
83
|
+
) {
|
|
84
|
+
throw new Error(
|
|
85
|
+
`Schema validation failed: '${name}.${columnName}' has a serial column and serial columns are unsupported.`,
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (column.isUnique) {
|
|
90
|
+
throw new Error(
|
|
91
|
+
`Schema validation failed: '${name}.${columnName}' has a unique constraint and unique constraints are unsupported.`,
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (column.generated !== undefined) {
|
|
96
|
+
throw new Error(
|
|
97
|
+
`Schema validation failed: '${name}.${columnName}' is a generated column and generated columns are unsupported.`,
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (column.generatedIdentity !== undefined) {
|
|
102
|
+
throw new Error(
|
|
103
|
+
`Schema validation failed: '${name}.${columnName}' is a generated column and generated columns are unsupported.`,
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (column.hasDefault) {
|
|
108
|
+
if (column.default && column.default instanceof SQL) {
|
|
109
|
+
throw new Error(
|
|
110
|
+
`Schema validation failed: '${name}.${columnName}' is a default column and default columns with raw sql are unsupported.`,
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (column.defaultFn && column.defaultFn() instanceof SQL) {
|
|
115
|
+
throw new Error(
|
|
116
|
+
`Schema validation failed: '${name}.${columnName}' is a default column and default columns with raw sql are unsupported.`,
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (column.onUpdateFn && column.onUpdateFn() instanceof SQL) {
|
|
121
|
+
throw new Error(
|
|
122
|
+
`Schema validation failed: '${name}.${columnName}' is a default column and default columns with raw sql are unsupported.`,
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// TODO(kyle) It is an invariant that `getColumnCasing(column, "snake_case") === column.name`
|
|
128
|
+
if (columnName === "chainId" && column.name === "chain_id") {
|
|
129
|
+
hasChainIdColumn = true;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Note: Ponder lets postgres handle the column name length limit and truncation.
|
|
133
|
+
|
|
134
|
+
if (
|
|
135
|
+
column.name === "operation_id" ||
|
|
136
|
+
column.name === "operation" ||
|
|
137
|
+
column.name === "checkpoint"
|
|
138
|
+
) {
|
|
139
|
+
throw new Error(
|
|
140
|
+
`Schema validation failed: '${name}.${columnName}' is a reserved column name.`,
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (columnNames.has(column.name)) {
|
|
145
|
+
throw new Error(
|
|
146
|
+
`Schema validation failed: '${name}.${column.name}' column name is used multiple times.`,
|
|
147
|
+
);
|
|
148
|
+
} else {
|
|
149
|
+
columnNames.add(column.name);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (preBuild.ordering === "experimental_isolated") {
|
|
154
|
+
if (hasChainIdColumn === false) {
|
|
155
|
+
throw new Error(
|
|
156
|
+
`Schema validation failed: '${name}' does not have required 'chainId' column.`,
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (
|
|
161
|
+
getTableColumns(s).chainId!.dataType !== "number" &&
|
|
162
|
+
getTableColumns(s).chainId!.dataType !== "bigint"
|
|
163
|
+
) {
|
|
164
|
+
throw new Error(
|
|
165
|
+
`Schema validation failed: '${name}'.chainId column must be an integer or numeric.`,
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (
|
|
170
|
+
getPrimaryKeyColumns(s).some(({ sql }) => sql === "chain_id") ===
|
|
171
|
+
false
|
|
172
|
+
) {
|
|
173
|
+
throw new Error(
|
|
174
|
+
`Schema validation failed: '${name}.chain_id' column is required to be in the primary key when ordering is 'isolated'.`,
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (tableNames.has(getTableName(s))) {
|
|
180
|
+
throw new Error(
|
|
181
|
+
`Schema validation failed: table name '${getTableName(s)}' is used multiple times.`,
|
|
182
|
+
);
|
|
183
|
+
} else {
|
|
184
|
+
tableNames.add(getTableName(s));
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (getTableConfig(s).primaryKeys.length > 1) {
|
|
188
|
+
throw new Error(
|
|
189
|
+
`Schema validation failed: '${name}' has multiple primary keys.`,
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (getTableConfig(s).primaryKeys.length === 1 && hasPrimaryKey) {
|
|
194
|
+
throw new Error(
|
|
195
|
+
`Schema validation failed: '${name}' has multiple primary keys.`,
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (
|
|
200
|
+
getTableConfig(s).primaryKeys.length === 0 &&
|
|
201
|
+
hasPrimaryKey === false
|
|
202
|
+
) {
|
|
203
|
+
throw new Error(
|
|
204
|
+
`Schema validation failed: '${name}' has no primary key. Declare one with ".primaryKey()".`,
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (getTableConfig(s).foreignKeys.length > 0) {
|
|
209
|
+
throw new Error(
|
|
210
|
+
`Schema validation failed: '${name}' has a foreign key constraint and foreign key constraints are unsupported.`,
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (getTableConfig(s).checks.length > 0) {
|
|
215
|
+
throw new Error(
|
|
216
|
+
`Schema validation failed: '${name}' has a check constraint and check constraints are unsupported.`,
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (getTableConfig(s).uniqueConstraints.length > 0) {
|
|
221
|
+
throw new Error(
|
|
222
|
+
`Schema validation failed: '${name}' has a unique constraint and unique constraints are unsupported.`,
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
for (const index of getTableConfig(s).indexes) {
|
|
227
|
+
// Note: Ponder lets postgres handle the index name length limit and truncation.
|
|
228
|
+
|
|
229
|
+
if (index.config.name && indexNames.has(index.config.name)) {
|
|
230
|
+
throw new Error(
|
|
231
|
+
`Schema validation failed: index name '${index.config.name}' is used multiple times.`,
|
|
232
|
+
);
|
|
233
|
+
} else if (index.config.name) {
|
|
234
|
+
indexNames.add(index.config.name);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if (is(s, PgSequence)) {
|
|
240
|
+
throw new Error(
|
|
241
|
+
`Schema validation failed: '${name}' is a sequence and sequences are unsupported.`,
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if (is(s, PgView)) {
|
|
246
|
+
// Note: Ponder lets postgres handle the view name length limit and truncation.
|
|
247
|
+
|
|
248
|
+
if (viewNames.has(getViewName(s))) {
|
|
249
|
+
throw new Error(
|
|
250
|
+
`Schema validation failed: view name '${getViewName(s)}' is used multiple times.`,
|
|
251
|
+
);
|
|
252
|
+
} else {
|
|
253
|
+
viewNames.add(getViewName(s));
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const viewConfig = getViewConfig(s);
|
|
257
|
+
|
|
258
|
+
if (viewConfig.selectedFields.length === 0) {
|
|
259
|
+
throw new Error(
|
|
260
|
+
`Schema validation failed: view '${getViewName(s)}' has no selected fields.`,
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (viewConfig.isExisting) {
|
|
265
|
+
throw new Error(
|
|
266
|
+
`Schema validation failed: view '${getViewName(s)}' is an existing view and existing views are unsupported.`,
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
if (viewConfig.query === undefined) {
|
|
271
|
+
throw new Error(
|
|
272
|
+
`Schema validation failed: view '${getViewName(s)}' has no underlying query.`,
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
const columnNames = new Set<string>();
|
|
277
|
+
|
|
278
|
+
if (viewConfig)
|
|
279
|
+
for (const [columnName, column] of Object.entries(
|
|
280
|
+
viewConfig.selectedFields,
|
|
281
|
+
)) {
|
|
282
|
+
if (
|
|
283
|
+
is(column, PgColumn) === false &&
|
|
284
|
+
is(column, SQL.Aliased) === false
|
|
285
|
+
) {
|
|
286
|
+
throw new Error(
|
|
287
|
+
`Schema validation failed: view '${getViewName(s)}.${columnName}' is a non-column selected field.`,
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
if (is(column, PgColumn)) {
|
|
292
|
+
if (
|
|
293
|
+
column instanceof PgSerial ||
|
|
294
|
+
column instanceof PgSmallSerial ||
|
|
295
|
+
column instanceof PgBigSerial53 ||
|
|
296
|
+
column instanceof PgBigSerial64
|
|
297
|
+
) {
|
|
298
|
+
throw new Error(
|
|
299
|
+
`Schema validation failed: '${name}.${columnName}' has a serial column and serial columns are unsupported.`,
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
if (column.isUnique) {
|
|
304
|
+
throw new Error(
|
|
305
|
+
`Schema validation failed: '${name}.${columnName}' has a unique constraint and unique constraints are unsupported.`,
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
if (column.generated !== undefined) {
|
|
310
|
+
throw new Error(
|
|
311
|
+
`Schema validation failed: '${name}.${columnName}' is a generated column and generated columns are unsupported.`,
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
if (column.generatedIdentity !== undefined) {
|
|
316
|
+
throw new Error(
|
|
317
|
+
`Schema validation failed: '${name}.${columnName}' is a generated column and generated columns are unsupported.`,
|
|
318
|
+
);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
if (columnNames.has((column as PgColumn).name)) {
|
|
322
|
+
throw new Error(
|
|
323
|
+
`Schema validation failed: '${name}.${(column as PgColumn).name}' column name is used multiple times.`,
|
|
324
|
+
);
|
|
325
|
+
} else {
|
|
326
|
+
columnNames.add((column as PgColumn).name);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
if (tableNames.size > TABLE_LIMIT) {
|
|
334
|
+
throw new Error(
|
|
335
|
+
`Schema validation failed: the maximum number of tables is ${TABLE_LIMIT}.`,
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
return { statements };
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
export const safeBuildSchema = ({
|
|
343
|
+
schema,
|
|
344
|
+
preBuild,
|
|
345
|
+
}: { schema: Schema; preBuild: Pick<PreBuild, "ordering"> }) => {
|
|
346
|
+
try {
|
|
347
|
+
const result = buildSchema({ schema, preBuild });
|
|
348
|
+
|
|
349
|
+
return {
|
|
350
|
+
status: "success",
|
|
351
|
+
...result,
|
|
352
|
+
} as const;
|
|
353
|
+
} catch (_error) {
|
|
354
|
+
const buildError = new BuildError((_error as Error).message);
|
|
355
|
+
buildError.stack = undefined;
|
|
356
|
+
return { status: "error", error: buildError } as const;
|
|
357
|
+
}
|
|
358
|
+
};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { codeFrameColumns } from "@babel/code-frame";
|
|
3
|
+
import { parse as parseStackTrace } from "stacktrace-parser";
|
|
4
|
+
|
|
5
|
+
class ESBuildTransformError extends Error {
|
|
6
|
+
override name = "ESBuildTransformError";
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
class ESBuildBuildError extends Error {
|
|
10
|
+
override name = "ESBuildBuildError";
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
class ESBuildContextError extends Error {
|
|
14
|
+
override name = "ESBuildContextError";
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type ViteNodeError =
|
|
18
|
+
| ESBuildTransformError
|
|
19
|
+
| ESBuildBuildError
|
|
20
|
+
| ESBuildContextError
|
|
21
|
+
| Error;
|
|
22
|
+
|
|
23
|
+
export function parseViteNodeError(file: string, error: Error): ViteNodeError {
|
|
24
|
+
let resolvedError: ViteNodeError;
|
|
25
|
+
|
|
26
|
+
if (/^(Transform failed|Build failed|Context failed)/.test(error.message)) {
|
|
27
|
+
// Handle ESBuild errors based on this error message construction logic:
|
|
28
|
+
// https://github.com/evanw/esbuild/blob/4e11b50fe3178ed0a78c077df78788d66304d379/lib/shared/common.ts#L1659
|
|
29
|
+
const errorKind = error.message.split(" with ")[0] as
|
|
30
|
+
| "Transform failed"
|
|
31
|
+
| "Build failed"
|
|
32
|
+
| "Context failed";
|
|
33
|
+
const innerError = error.message
|
|
34
|
+
.split("\n")
|
|
35
|
+
.slice(1)
|
|
36
|
+
.map((message) => {
|
|
37
|
+
let location: string | undefined = undefined;
|
|
38
|
+
let detail: string | undefined = undefined;
|
|
39
|
+
if (message.includes(": ERROR: ")) {
|
|
40
|
+
// /path/to/file.ts:11:9: ERROR: Expected ")" but found ";"
|
|
41
|
+
const s = message.split(": ERROR: ");
|
|
42
|
+
location = s[0];
|
|
43
|
+
detail = s[1];
|
|
44
|
+
} else {
|
|
45
|
+
// error: some error without a location
|
|
46
|
+
detail = message.slice(7);
|
|
47
|
+
}
|
|
48
|
+
return { location, detail };
|
|
49
|
+
})[0];
|
|
50
|
+
|
|
51
|
+
// If we aren't able to extract an inner error, just return the original.
|
|
52
|
+
if (!innerError) return error;
|
|
53
|
+
|
|
54
|
+
resolvedError =
|
|
55
|
+
errorKind === "Transform failed"
|
|
56
|
+
? new ESBuildTransformError(innerError.detail)
|
|
57
|
+
: errorKind === "Build failed"
|
|
58
|
+
? new ESBuildBuildError(innerError.detail)
|
|
59
|
+
: new ESBuildContextError(innerError.detail);
|
|
60
|
+
if (innerError.location)
|
|
61
|
+
resolvedError.stack = ` at ${innerError.location}`;
|
|
62
|
+
}
|
|
63
|
+
// If it's not an ESBuild error, it's a user-land vm.runModuleInContext execution error.
|
|
64
|
+
// Attempt to build a user-land stack trace.
|
|
65
|
+
else if (error.stack) {
|
|
66
|
+
const stackFrames = parseStackTrace(error.stack);
|
|
67
|
+
|
|
68
|
+
const userStackFrames = [];
|
|
69
|
+
for (const rawStackFrame of stackFrames) {
|
|
70
|
+
if (rawStackFrame.methodName.includes("ViteNodeRunner.runModule")) break;
|
|
71
|
+
userStackFrames.push(rawStackFrame);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const userStack = userStackFrames
|
|
75
|
+
.map(({ file, lineNumber, column, methodName }) => {
|
|
76
|
+
const prefix = " at";
|
|
77
|
+
const path = `${file}${lineNumber !== null ? `:${lineNumber}` : ""}${
|
|
78
|
+
column !== null ? `:${column}` : ""
|
|
79
|
+
}`;
|
|
80
|
+
if (methodName === null || methodName === "<unknown>") {
|
|
81
|
+
return `${prefix} ${path}`;
|
|
82
|
+
} else {
|
|
83
|
+
return `${prefix} ${methodName} (${path})`;
|
|
84
|
+
}
|
|
85
|
+
})
|
|
86
|
+
.join("\n");
|
|
87
|
+
|
|
88
|
+
resolvedError = error;
|
|
89
|
+
resolvedError.stack = userStack;
|
|
90
|
+
}
|
|
91
|
+
// Still a vm.runModuleInContext execution error, but no stack.
|
|
92
|
+
else {
|
|
93
|
+
resolvedError = error;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Attempt to build a code frame for the top of the user stack. This works for
|
|
97
|
+
// both ESBuild and vm.runModuleInContext errors.
|
|
98
|
+
if (resolvedError.stack) {
|
|
99
|
+
const userStackFrames = parseStackTrace(resolvedError.stack);
|
|
100
|
+
|
|
101
|
+
let codeFrame: string | undefined = undefined;
|
|
102
|
+
for (const { file, lineNumber, column } of userStackFrames) {
|
|
103
|
+
if (file !== null && lineNumber !== null) {
|
|
104
|
+
try {
|
|
105
|
+
const sourceFileContents = readFileSync(file, { encoding: "utf-8" });
|
|
106
|
+
codeFrame = codeFrameColumns(
|
|
107
|
+
sourceFileContents,
|
|
108
|
+
{ start: { line: lineNumber, column: column ?? undefined } },
|
|
109
|
+
{ highlightCode: true },
|
|
110
|
+
);
|
|
111
|
+
break;
|
|
112
|
+
} catch (err) {
|
|
113
|
+
// No-op.
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
resolvedError.stack = `${resolvedError.name}: ${resolvedError.message}\n${resolvedError.stack}`;
|
|
119
|
+
if (codeFrame) resolvedError.stack += `\n${codeFrame}`;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Finally, add a useful relative file name and verb to the error message.
|
|
123
|
+
const verb =
|
|
124
|
+
resolvedError.name === "ESBuildTransformError"
|
|
125
|
+
? "transforming"
|
|
126
|
+
: resolvedError.name === "ESBuildBuildError" ||
|
|
127
|
+
resolvedError.name === "ESBuildContextError"
|
|
128
|
+
? "building"
|
|
129
|
+
: "executing";
|
|
130
|
+
|
|
131
|
+
// This can throw with "Cannot set property message of [object Object] which has only a getter"
|
|
132
|
+
try {
|
|
133
|
+
resolvedError.message = `Error while ${verb} ${file}: ${resolvedError.message}`;
|
|
134
|
+
} catch (e) {}
|
|
135
|
+
|
|
136
|
+
return resolvedError;
|
|
137
|
+
}
|