ponder 0.16.9 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/dist/esm/bin/commands/codegen.js +3 -12
- package/dist/esm/bin/commands/codegen.js.map +1 -1
- package/dist/esm/bin/commands/createViews.js +2 -5
- package/dist/esm/bin/commands/createViews.js.map +1 -1
- package/dist/esm/bin/commands/dev.js +4 -22
- package/dist/esm/bin/commands/dev.js.map +1 -1
- package/dist/esm/bin/commands/list.js +4 -8
- package/dist/esm/bin/commands/list.js.map +1 -1
- package/dist/esm/bin/commands/prune.js +4 -8
- package/dist/esm/bin/commands/prune.js.map +1 -1
- package/dist/esm/bin/commands/serve.js +5 -20
- package/dist/esm/bin/commands/serve.js.map +1 -1
- package/dist/esm/bin/commands/start.js +4 -20
- package/dist/esm/bin/commands/start.js.map +1 -1
- package/dist/esm/bin/isolatedController.js +3 -3
- package/dist/esm/bin/isolatedController.js.map +1 -1
- package/dist/esm/bin/isolatedWorker.js +0 -5
- package/dist/esm/bin/isolatedWorker.js.map +1 -1
- package/dist/esm/bin/ponder.js.map +1 -1
- package/dist/esm/bin/utils/exit.js +1 -5
- package/dist/esm/bin/utils/exit.js.map +1 -1
- package/dist/esm/build/config.js +2 -2
- package/dist/esm/build/config.js.map +1 -1
- package/dist/esm/build/factory.js +1 -1
- package/dist/esm/build/factory.js.map +1 -1
- package/dist/esm/build/index.js +17 -14
- package/dist/esm/build/index.js.map +1 -1
- package/dist/esm/build/pre.js +2 -2
- package/dist/esm/build/pre.js.map +1 -1
- package/dist/esm/build/schema.js +2 -2
- package/dist/esm/build/schema.js.map +1 -1
- package/dist/esm/build/stacktrace.js +5 -5
- package/dist/esm/build/stacktrace.js.map +1 -1
- package/dist/esm/client/index.js +8 -9
- package/dist/esm/client/index.js.map +1 -1
- package/dist/esm/database/actions.js +7 -9
- package/dist/esm/database/actions.js.map +1 -1
- package/dist/esm/database/index.js +7 -7
- package/dist/esm/database/index.js.map +1 -1
- package/dist/esm/database/queryBuilder.js +4 -7
- package/dist/esm/database/queryBuilder.js.map +1 -1
- package/dist/esm/drizzle/bigint.js +3 -5
- package/dist/esm/drizzle/bigint.js.map +1 -1
- package/dist/esm/drizzle/bytes.js +3 -5
- package/dist/esm/drizzle/bytes.js.map +1 -1
- package/dist/esm/drizzle/hex.js +3 -5
- package/dist/esm/drizzle/hex.js.map +1 -1
- package/dist/esm/drizzle/index.js.map +1 -1
- package/dist/esm/drizzle/json.js +8 -12
- package/dist/esm/drizzle/json.js.map +1 -1
- package/dist/esm/drizzle/kit/index.js +24 -38
- package/dist/esm/drizzle/kit/index.js.map +1 -1
- package/dist/esm/drizzle/onchain.js +15 -17
- package/dist/esm/drizzle/onchain.js.map +1 -1
- package/dist/esm/drizzle/text.js +3 -5
- package/dist/esm/drizzle/text.js.map +1 -1
- package/dist/esm/graphql/index.js +6 -6
- package/dist/esm/graphql/index.js.map +1 -1
- package/dist/esm/graphql/json.js.map +1 -1
- package/dist/esm/graphql/middleware.js +2 -2
- package/dist/esm/graphql/middleware.js.map +1 -1
- package/dist/esm/index.js +5 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/indexing/addStackTrace.js +1 -1
- package/dist/esm/indexing/addStackTrace.js.map +1 -1
- package/dist/esm/indexing/client.js +11 -12
- package/dist/esm/indexing/client.js.map +1 -1
- package/dist/esm/indexing/index.js +6 -4
- package/dist/esm/indexing/index.js.map +1 -1
- package/dist/esm/indexing/profile.js +2 -2
- package/dist/esm/indexing/profile.js.map +1 -1
- package/dist/esm/indexing-store/cache.js +4 -4
- package/dist/esm/indexing-store/cache.js.map +1 -1
- package/dist/esm/indexing-store/index.js +10 -13
- package/dist/esm/indexing-store/index.js.map +1 -1
- package/dist/esm/indexing-store/profile.js +3 -3
- package/dist/esm/indexing-store/profile.js.map +1 -1
- package/dist/esm/indexing-store/utils.js +3 -3
- package/dist/esm/indexing-store/utils.js.map +1 -1
- package/dist/esm/internal/logger.js +7 -7
- package/dist/esm/internal/logger.js.map +1 -1
- package/dist/esm/internal/metrics.js +15 -15
- package/dist/esm/internal/metrics.js.map +1 -1
- package/dist/esm/internal/options.js +6 -9
- package/dist/esm/internal/options.js.map +1 -1
- package/dist/esm/internal/shutdown.js.map +1 -1
- package/dist/esm/rpc/actions.js +7 -8
- package/dist/esm/rpc/actions.js.map +1 -1
- package/dist/esm/rpc/http.js +8 -4
- package/dist/esm/rpc/http.js.map +1 -1
- package/dist/esm/rpc/index.js +19 -19
- package/dist/esm/rpc/index.js.map +1 -1
- package/dist/esm/runtime/events.js +7 -9
- package/dist/esm/runtime/events.js.map +1 -1
- package/dist/esm/runtime/filter.js +1 -1
- package/dist/esm/runtime/filter.js.map +1 -1
- package/dist/esm/runtime/fragments.js.map +1 -1
- package/dist/esm/runtime/historical.js +7 -7
- package/dist/esm/runtime/historical.js.map +1 -1
- package/dist/esm/runtime/index.js +2 -2
- package/dist/esm/runtime/index.js.map +1 -1
- package/dist/esm/runtime/isolated.js +18 -11
- package/dist/esm/runtime/isolated.js.map +1 -1
- package/dist/esm/runtime/multichain.js +19 -12
- package/dist/esm/runtime/multichain.js.map +1 -1
- package/dist/esm/runtime/omnichain.js +19 -12
- package/dist/esm/runtime/omnichain.js.map +1 -1
- package/dist/esm/runtime/realtime.js +12 -12
- package/dist/esm/runtime/realtime.js.map +1 -1
- package/dist/esm/server/error.js +1 -1
- package/dist/esm/server/error.js.map +1 -1
- package/dist/esm/server/index.js +4 -4
- package/dist/esm/server/index.js.map +1 -1
- package/dist/esm/sync-historical/index.js +2 -2
- package/dist/esm/sync-historical/index.js.map +1 -1
- package/dist/esm/sync-realtime/bloom.js +1 -1
- package/dist/esm/sync-realtime/bloom.js.map +1 -1
- package/dist/esm/sync-realtime/index.js +1 -1
- package/dist/esm/sync-realtime/index.js.map +1 -1
- package/dist/esm/sync-store/encode.js +1 -1
- package/dist/esm/sync-store/encode.js.map +1 -1
- package/dist/esm/sync-store/index.js +12 -31
- package/dist/esm/sync-store/index.js.map +1 -1
- package/dist/esm/sync-store/migrations.js +1 -1
- package/dist/esm/sync-store/migrations.js.map +1 -1
- package/dist/esm/sync-store/schema.js +2 -2
- package/dist/esm/sync-store/schema.js.map +1 -1
- package/dist/esm/types/db.js.map +1 -1
- package/dist/esm/ui/app.js +2 -2
- package/dist/esm/ui/app.js.map +1 -1
- package/dist/esm/ui/patch.js +1 -2
- package/dist/esm/ui/patch.js.map +1 -1
- package/dist/esm/utils/abi.js +1 -1
- package/dist/esm/utils/abi.js.map +1 -1
- package/dist/esm/utils/bigint.js.map +1 -1
- package/dist/esm/utils/checkpoint.js.map +1 -1
- package/dist/esm/utils/chunk.js.map +1 -1
- package/dist/esm/utils/copy.js +1 -1
- package/dist/esm/utils/copy.js.map +1 -1
- package/dist/esm/utils/decodeAbiParameters.js +2 -3
- package/dist/esm/utils/decodeAbiParameters.js.map +1 -1
- package/dist/esm/utils/decodeEventLog.js.map +1 -1
- package/dist/esm/utils/duplicates.js.map +1 -1
- package/dist/esm/utils/finality.js.map +1 -1
- package/dist/esm/utils/generators.js.map +1 -1
- package/dist/esm/utils/interval.js.map +1 -1
- package/dist/esm/utils/mutex.js.map +1 -1
- package/dist/esm/utils/offset.js.map +1 -1
- package/dist/esm/utils/order.js.map +1 -1
- package/dist/esm/utils/partition.js.map +1 -1
- package/dist/esm/utils/pg.js +2 -2
- package/dist/esm/utils/pg.js.map +1 -1
- package/dist/esm/utils/pglite.js +4 -6
- package/dist/esm/utils/pglite.js.map +1 -1
- package/dist/esm/utils/port.js.map +1 -1
- package/dist/esm/utils/promiseAllSettledWithThrow.js.map +1 -1
- package/dist/esm/utils/queue.js +7 -7
- package/dist/esm/utils/queue.js.map +1 -1
- package/dist/esm/utils/result.js +1 -1
- package/dist/esm/utils/result.js.map +1 -1
- package/dist/esm/utils/sql-parse.js +10 -10
- package/dist/esm/utils/sql-parse.js.map +1 -1
- package/dist/esm/utils/zipper.js.map +1 -1
- package/dist/types/bin/commands/codegen.d.ts.map +1 -1
- package/dist/types/bin/commands/createViews.d.ts.map +1 -1
- package/dist/types/bin/commands/dev.d.ts.map +1 -1
- package/dist/types/bin/commands/list.d.ts.map +1 -1
- package/dist/types/bin/commands/prune.d.ts.map +1 -1
- package/dist/types/bin/commands/serve.d.ts.map +1 -1
- package/dist/types/bin/commands/start.d.ts.map +1 -1
- package/dist/types/bin/isolatedController.d.ts.map +1 -1
- package/dist/types/bin/isolatedWorker.d.ts.map +1 -1
- package/dist/types/bin/ponder.d.ts +1 -1
- package/dist/types/bin/ponder.d.ts.map +1 -1
- package/dist/types/bin/utils/exit.d.ts +1 -1
- package/dist/types/bin/utils/exit.d.ts.map +1 -1
- package/dist/types/build/config.d.ts +1 -1
- package/dist/types/build/config.d.ts.map +1 -1
- package/dist/types/build/factory.d.ts.map +1 -1
- package/dist/types/build/index.d.ts +1 -1
- package/dist/types/build/index.d.ts.map +1 -1
- package/dist/types/build/plugin.d.ts +1 -1
- package/dist/types/build/plugin.d.ts.map +1 -1
- package/dist/types/build/schema.d.ts.map +1 -1
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/config/address.d.ts +1 -1
- package/dist/types/config/address.d.ts.map +1 -1
- package/dist/types/config/index.d.ts +6 -6
- package/dist/types/config/index.d.ts.map +1 -1
- package/dist/types/database/actions.d.ts +5 -5
- package/dist/types/database/actions.d.ts.map +1 -1
- package/dist/types/database/index.d.ts +2 -2
- package/dist/types/database/index.d.ts.map +1 -1
- package/dist/types/database/queryBuilder.d.ts +4 -4
- package/dist/types/database/queryBuilder.d.ts.map +1 -1
- package/dist/types/drizzle/bigint.d.ts +1 -1
- package/dist/types/drizzle/bigint.d.ts.map +1 -1
- package/dist/types/drizzle/bytes.d.ts +2 -1
- package/dist/types/drizzle/bytes.d.ts.map +1 -1
- package/dist/types/drizzle/hex.d.ts +1 -1
- package/dist/types/drizzle/hex.d.ts.map +1 -1
- package/dist/types/drizzle/index.d.ts.map +1 -1
- package/dist/types/drizzle/json.d.ts.map +1 -1
- package/dist/types/drizzle/kit/index.d.ts.map +1 -1
- package/dist/types/drizzle/onchain.d.ts +1 -1
- package/dist/types/drizzle/onchain.d.ts.map +1 -1
- package/dist/types/drizzle/text.d.ts +1 -1
- package/dist/types/drizzle/text.d.ts.map +1 -1
- package/dist/types/graphql/index.d.ts +2 -2
- package/dist/types/graphql/index.d.ts.map +1 -1
- package/dist/types/graphql/middleware.d.ts +3 -3
- package/dist/types/graphql/middleware.d.ts.map +1 -1
- package/dist/types/index.d.ts +11 -11
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/indexing/addStackTrace.d.ts.map +1 -1
- package/dist/types/indexing/client.d.ts +2 -3
- package/dist/types/indexing/client.d.ts.map +1 -1
- package/dist/types/indexing/index.d.ts +2 -2
- package/dist/types/indexing/index.d.ts.map +1 -1
- package/dist/types/indexing/profile.d.ts.map +1 -1
- package/dist/types/indexing-store/cache.d.ts +2 -2
- package/dist/types/indexing-store/cache.d.ts.map +1 -1
- package/dist/types/indexing-store/index.d.ts +3 -4
- package/dist/types/indexing-store/index.d.ts.map +1 -1
- package/dist/types/indexing-store/profile.d.ts +1 -1
- package/dist/types/indexing-store/profile.d.ts.map +1 -1
- package/dist/types/indexing-store/utils.d.ts.map +1 -1
- package/dist/types/internal/common.d.ts +0 -2
- package/dist/types/internal/common.d.ts.map +1 -1
- package/dist/types/internal/logger.d.ts +1 -1
- package/dist/types/internal/logger.d.ts.map +1 -1
- package/dist/types/internal/metrics.d.ts +1 -1
- package/dist/types/internal/metrics.d.ts.map +1 -1
- package/dist/types/internal/options.d.ts +1 -7
- package/dist/types/internal/options.d.ts.map +1 -1
- package/dist/types/internal/types.d.ts +4 -4
- package/dist/types/internal/types.d.ts.map +1 -1
- package/dist/types/rpc/actions.d.ts.map +1 -1
- package/dist/types/rpc/http.d.ts +1 -1
- package/dist/types/rpc/http.d.ts.map +1 -1
- package/dist/types/rpc/index.d.ts +2 -2
- package/dist/types/rpc/index.d.ts.map +1 -1
- package/dist/types/runtime/events.d.ts +1 -1
- package/dist/types/runtime/events.d.ts.map +1 -1
- package/dist/types/runtime/filter.d.ts +1 -1
- package/dist/types/runtime/filter.d.ts.map +1 -1
- package/dist/types/runtime/fragments.d.ts +1 -1
- package/dist/types/runtime/fragments.d.ts.map +1 -1
- package/dist/types/runtime/historical.d.ts.map +1 -1
- package/dist/types/runtime/index.d.ts +2 -3
- package/dist/types/runtime/index.d.ts.map +1 -1
- package/dist/types/runtime/isolated.d.ts.map +1 -1
- package/dist/types/runtime/multichain.d.ts.map +1 -1
- package/dist/types/runtime/omnichain.d.ts.map +1 -1
- package/dist/types/runtime/realtime.d.ts.map +1 -1
- package/dist/types/server/error.d.ts +1 -1
- package/dist/types/server/error.d.ts.map +1 -1
- package/dist/types/server/index.d.ts +1 -1
- package/dist/types/server/index.d.ts.map +1 -1
- package/dist/types/sync-historical/index.d.ts +1 -1
- package/dist/types/sync-historical/index.d.ts.map +1 -1
- package/dist/types/sync-realtime/bloom.d.ts +1 -1
- package/dist/types/sync-realtime/bloom.d.ts.map +1 -1
- package/dist/types/sync-realtime/index.d.ts +1 -1
- package/dist/types/sync-realtime/index.d.ts.map +1 -1
- package/dist/types/sync-store/encode.d.ts.map +1 -1
- package/dist/types/sync-store/index.d.ts +2 -2
- package/dist/types/sync-store/index.d.ts.map +1 -1
- package/dist/types/sync-store/migrations.d.ts +1 -1
- package/dist/types/sync-store/migrations.d.ts.map +1 -1
- package/dist/types/sync-store/schema.d.ts +2 -2
- package/dist/types/sync-store/schema.d.ts.map +1 -1
- package/dist/types/types/db.d.ts +3 -3
- package/dist/types/types/db.d.ts.map +1 -1
- package/dist/types/ui/app.d.ts +3 -3
- package/dist/types/ui/app.d.ts.map +1 -1
- package/dist/types/ui/patch.d.ts.map +1 -1
- package/dist/types/utils/abi.d.ts.map +1 -1
- package/dist/types/utils/chains.d.ts +2 -0
- package/dist/types/utils/chains.d.ts.map +1 -1
- package/dist/types/utils/checkpoint.d.ts.map +1 -1
- package/dist/types/utils/chunk.d.ts.map +1 -1
- package/dist/types/utils/copy.d.ts.map +1 -1
- package/dist/types/utils/decodeAbiParameters.d.ts.map +1 -1
- package/dist/types/utils/estimate.d.ts.map +1 -1
- package/dist/types/utils/partition.d.ts.map +1 -1
- package/dist/types/utils/pg.d.ts +1 -1
- package/dist/types/utils/pg.d.ts.map +1 -1
- package/dist/types/utils/pglite.d.ts +1 -1
- package/dist/types/utils/pglite.d.ts.map +1 -1
- package/dist/types/utils/port.d.ts.map +1 -1
- package/dist/types/utils/promiseWithResolvers.d.ts.map +1 -1
- package/dist/types/utils/queue.d.ts.map +1 -1
- package/dist/types/utils/result.d.ts.map +1 -1
- package/dist/types/utils/zipper.d.ts +2 -2
- package/dist/types/utils/zipper.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/bin/commands/codegen.ts +3 -13
- package/src/bin/commands/createViews.ts +3 -6
- package/src/bin/commands/dev.ts +5 -25
- package/src/bin/commands/list.ts +6 -9
- package/src/bin/commands/prune.ts +6 -9
- package/src/bin/commands/serve.ts +5 -21
- package/src/bin/commands/start.ts +5 -22
- package/src/bin/isolatedController.ts +1 -1
- package/src/bin/isolatedWorker.ts +0 -6
- package/src/bin/ponder.ts +1 -1
- package/src/bin/utils/exit.ts +1 -9
- package/src/build/config.ts +22 -16
- package/src/build/factory.ts +2 -2
- package/src/build/index.ts +29 -19
- package/src/build/plugin.ts +1 -1
- package/src/build/pre.ts +2 -2
- package/src/build/schema.ts +20 -14
- package/src/build/stacktrace.ts +5 -5
- package/src/client/index.ts +23 -21
- package/src/config/address.ts +1 -1
- package/src/config/index.ts +1 -1
- package/src/database/actions.ts +18 -20
- package/src/database/index.ts +17 -17
- package/src/database/queryBuilder.ts +12 -14
- package/src/drizzle/bigint.ts +4 -4
- package/src/drizzle/bytes.ts +4 -4
- package/src/drizzle/hex.ts +4 -4
- package/src/drizzle/index.ts +1 -1
- package/src/drizzle/json.ts +6 -6
- package/src/drizzle/kit/index.ts +30 -44
- package/src/drizzle/onchain.ts +27 -23
- package/src/drizzle/text.ts +2 -2
- package/src/graphql/index.ts +16 -14
- package/src/graphql/json.ts +1 -1
- package/src/graphql/middleware.ts +6 -4
- package/src/index.ts +75 -83
- package/src/indexing/addStackTrace.ts +3 -3
- package/src/indexing/client.ts +40 -37
- package/src/indexing/index.ts +8 -6
- package/src/indexing/profile.ts +3 -3
- package/src/indexing-store/cache.ts +15 -15
- package/src/indexing-store/index.ts +26 -25
- package/src/indexing-store/profile.ts +4 -4
- package/src/indexing-store/utils.ts +11 -11
- package/src/internal/common.ts +0 -2
- package/src/internal/logger.ts +12 -9
- package/src/internal/metrics.ts +4 -4
- package/src/internal/options.ts +2 -10
- package/src/internal/types.ts +13 -13
- package/src/rpc/actions.ts +16 -17
- package/src/rpc/http.ts +9 -5
- package/src/rpc/index.ts +20 -16
- package/src/runtime/events.ts +22 -21
- package/src/runtime/filter.ts +9 -3
- package/src/runtime/fragments.ts +1 -1
- package/src/runtime/historical.ts +9 -6
- package/src/runtime/index.ts +6 -4
- package/src/runtime/isolated.ts +26 -20
- package/src/runtime/multichain.ts +24 -18
- package/src/runtime/omnichain.ts +24 -18
- package/src/runtime/realtime.ts +9 -11
- package/src/server/error.ts +2 -2
- package/src/server/index.ts +5 -5
- package/src/sync-historical/index.ts +13 -13
- package/src/sync-realtime/bloom.ts +1 -1
- package/src/sync-realtime/index.ts +7 -7
- package/src/sync-store/encode.ts +2 -2
- package/src/sync-store/index.ts +33 -58
- package/src/sync-store/migrations.ts +1 -1
- package/src/sync-store/schema.ts +1 -1
- package/src/types/db.ts +3 -3
- package/src/types.d.ts +2 -0
- package/src/ui/app.ts +1 -1
- package/src/ui/patch.ts +2 -3
- package/src/utils/abi.ts +7 -4
- package/src/utils/checkpoint.ts +1 -1
- package/src/utils/copy.ts +1 -1
- package/src/utils/decodeAbiParameters.ts +5 -7
- package/src/utils/pg.ts +1 -1
- package/src/utils/pglite.ts +5 -6
- package/src/utils/queue.ts +4 -4
- package/src/utils/result.ts +1 -1
- package/src/utils/sql-parse.ts +6 -6
- package/dist/esm/internal/telemetry.js +0 -200
- package/dist/esm/internal/telemetry.js.map +0 -1
- package/dist/types/internal/telemetry.d.ts +0 -43
- package/dist/types/internal/telemetry.d.ts.map +0 -1
- package/src/internal/telemetry.ts +0 -303
package/src/bin/utils/exit.ts
CHANGED
|
@@ -11,10 +11,7 @@ export const createExit = ({
|
|
|
11
11
|
common,
|
|
12
12
|
options,
|
|
13
13
|
}: {
|
|
14
|
-
common: Pick<
|
|
15
|
-
Common,
|
|
16
|
-
"logger" | "telemetry" | "shutdown" | "buildShutdown" | "apiShutdown"
|
|
17
|
-
>;
|
|
14
|
+
common: Pick<Common, "logger" | "shutdown" | "buildShutdown" | "apiShutdown">;
|
|
18
15
|
options: Options;
|
|
19
16
|
}) => {
|
|
20
17
|
let isShuttingDown = false;
|
|
@@ -34,11 +31,6 @@ export const createExit = ({
|
|
|
34
31
|
msg: "Started shutdown sequence",
|
|
35
32
|
});
|
|
36
33
|
|
|
37
|
-
common.telemetry.record({
|
|
38
|
-
name: "lifecycle:session_end",
|
|
39
|
-
properties: { duration_seconds: process.uptime() },
|
|
40
|
-
});
|
|
41
|
-
|
|
42
34
|
await Promise.all([
|
|
43
35
|
common.shutdown.kill(),
|
|
44
36
|
common.apiShutdown.kill(),
|
package/src/build/config.ts
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type Abi,
|
|
3
|
+
type AbiEvent,
|
|
4
|
+
type AbiFunction,
|
|
5
|
+
type Address,
|
|
6
|
+
BlockNotFoundError,
|
|
7
|
+
type Hex,
|
|
8
|
+
hexToNumber,
|
|
9
|
+
type LogTopic,
|
|
10
|
+
numberToHex,
|
|
11
|
+
toEventSelector,
|
|
12
|
+
toFunctionSelector,
|
|
13
|
+
} from "viem";
|
|
1
14
|
import type { Factory } from "@/config/address.js";
|
|
2
15
|
import type { Config } from "@/config/index.js";
|
|
3
16
|
import type { Common } from "@/internal/common.js";
|
|
@@ -19,7 +32,7 @@ import type {
|
|
|
19
32
|
TransferFilter,
|
|
20
33
|
} from "@/internal/types.js";
|
|
21
34
|
import { eth_getBlockByNumber } from "@/rpc/actions.js";
|
|
22
|
-
import { type Rpc
|
|
35
|
+
import { createRpc, type Rpc } from "@/rpc/index.js";
|
|
23
36
|
import {
|
|
24
37
|
defaultBlockFilterInclude,
|
|
25
38
|
defaultLogFilterInclude,
|
|
@@ -33,19 +46,6 @@ import { hyperliquidEvm, chains as viemChains } from "@/utils/chains.js";
|
|
|
33
46
|
import { dedupe } from "@/utils/dedupe.js";
|
|
34
47
|
import { getFinalityBlockCount } from "@/utils/finality.js";
|
|
35
48
|
import { toLowerCase } from "@/utils/lowercase.js";
|
|
36
|
-
import {
|
|
37
|
-
type Abi,
|
|
38
|
-
type AbiEvent,
|
|
39
|
-
type AbiFunction,
|
|
40
|
-
type Address,
|
|
41
|
-
BlockNotFoundError,
|
|
42
|
-
type Hex,
|
|
43
|
-
type LogTopic,
|
|
44
|
-
hexToNumber,
|
|
45
|
-
numberToHex,
|
|
46
|
-
toEventSelector,
|
|
47
|
-
toFunctionSelector,
|
|
48
|
-
} from "viem";
|
|
49
49
|
import { buildLogFactory } from "./factory.js";
|
|
50
50
|
|
|
51
51
|
const flattenSources = <
|
|
@@ -966,7 +966,10 @@ export async function buildIndexingFunctions({
|
|
|
966
966
|
export function buildConfig({
|
|
967
967
|
common,
|
|
968
968
|
config,
|
|
969
|
-
}: {
|
|
969
|
+
}: {
|
|
970
|
+
common: Common;
|
|
971
|
+
config: Config;
|
|
972
|
+
}): {
|
|
970
973
|
chains: Chain[];
|
|
971
974
|
rpcs: Rpc[];
|
|
972
975
|
logs: ({ level: "warn" | "info" | "debug"; msg: string } & Record<
|
|
@@ -1123,7 +1126,10 @@ export async function safeBuildIndexingFunctions({
|
|
|
1123
1126
|
export function safeBuildConfig({
|
|
1124
1127
|
common,
|
|
1125
1128
|
config,
|
|
1126
|
-
}: {
|
|
1129
|
+
}: {
|
|
1130
|
+
common: Common;
|
|
1131
|
+
config: Config;
|
|
1132
|
+
}) {
|
|
1127
1133
|
try {
|
|
1128
1134
|
const result = buildConfig({ common, config });
|
|
1129
1135
|
|
package/src/build/factory.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import { type Address, toEventSelector } from "viem";
|
|
1
2
|
import type { Factory as FactoryConfig } from "@/config/address.js";
|
|
2
3
|
import type { LogFactory } from "@/internal/types.js";
|
|
3
4
|
import { dedupe } from "@/utils/dedupe.js";
|
|
4
5
|
import { toLowerCase } from "@/utils/lowercase.js";
|
|
5
6
|
import {
|
|
6
|
-
type TupleAbiParameter,
|
|
7
7
|
getBytesConsumedByParam,
|
|
8
8
|
getNestedParamOffset,
|
|
9
|
+
type TupleAbiParameter,
|
|
9
10
|
} from "@/utils/offset.js";
|
|
10
|
-
import { type Address, toEventSelector } from "viem";
|
|
11
11
|
|
|
12
12
|
export function buildLogFactory({
|
|
13
13
|
chainId,
|
package/src/build/index.ts
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
import { drizzle as drizzleNodePostgres } from "drizzle-orm/node-postgres";
|
|
5
|
+
import { drizzle as drizzlePglite } from "drizzle-orm/pglite";
|
|
6
|
+
import { glob } from "glob";
|
|
7
|
+
import { Hono } from "hono";
|
|
8
|
+
import superjson from "superjson";
|
|
9
|
+
import { hexToNumber } from "viem";
|
|
10
|
+
import { createServer } from "vite";
|
|
11
|
+
import { ViteNodeRunner } from "vite-node/client";
|
|
12
|
+
import { ViteNodeServer } from "vite-node/server";
|
|
13
|
+
import { installSourcemapsSupport } from "vite-node/source-map";
|
|
14
|
+
import { normalizeModuleId, toFilePath } from "vite-node/utils";
|
|
15
|
+
import viteTsconfigPathsPlugin from "vite-tsconfig-paths";
|
|
4
16
|
import type { CliOptions } from "@/bin/ponder.js";
|
|
5
17
|
import type { Config } from "@/config/index.js";
|
|
6
18
|
import type { Database } from "@/database/index.js";
|
|
@@ -26,18 +38,6 @@ import { createPglite } from "@/utils/pglite.js";
|
|
|
26
38
|
import { getNextAvailablePort } from "@/utils/port.js";
|
|
27
39
|
import type { Result } from "@/utils/result.js";
|
|
28
40
|
import { startClock } from "@/utils/timer.js";
|
|
29
|
-
import { drizzle as drizzleNodePostgres } from "drizzle-orm/node-postgres";
|
|
30
|
-
import { drizzle as drizzlePglite } from "drizzle-orm/pglite";
|
|
31
|
-
import { glob } from "glob";
|
|
32
|
-
import { Hono } from "hono";
|
|
33
|
-
import superjson from "superjson";
|
|
34
|
-
import { hexToNumber } from "viem";
|
|
35
|
-
import { createServer } from "vite";
|
|
36
|
-
import { ViteNodeRunner } from "vite-node/client";
|
|
37
|
-
import { ViteNodeServer } from "vite-node/server";
|
|
38
|
-
import { installSourcemapsSupport } from "vite-node/source-map";
|
|
39
|
-
import { normalizeModuleId, toFilePath } from "vite-node/utils";
|
|
40
|
-
import viteTsconfigPathsPlugin from "vite-tsconfig-paths";
|
|
41
41
|
import { safeBuildConfig, safeBuildIndexingFunctions } from "./config.js";
|
|
42
42
|
import { vitePluginPonder } from "./plugin.js";
|
|
43
43
|
import { safeBuildPre } from "./pre.js";
|
|
@@ -112,7 +112,9 @@ export const createBuild = async ({
|
|
|
112
112
|
.replace(/\\/g, "/")
|
|
113
113
|
// Escape special characters in the path.
|
|
114
114
|
.replace(escapeRegex, "\\$&");
|
|
115
|
-
const indexingRegex = new RegExp(
|
|
115
|
+
const indexingRegex = new RegExp(
|
|
116
|
+
`^${escapedIndexingDir}/(?!.*\\.(test|spec)\\.).*\\.(ts|js)$`,
|
|
117
|
+
);
|
|
116
118
|
|
|
117
119
|
const indexingPattern = path
|
|
118
120
|
.join(common.options.indexingDir, "**/*.{js,mjs,ts,mts}")
|
|
@@ -122,6 +124,10 @@ export const createBuild = async ({
|
|
|
122
124
|
.join(common.options.apiDir, "**/*.{js,mjs,ts,mts}")
|
|
123
125
|
.replace(/\\/g, "/");
|
|
124
126
|
|
|
127
|
+
const testFilePattern = path
|
|
128
|
+
.join(common.options.indexingDir, "**/*.{test,spec}.{js,mjs,ts,mts}")
|
|
129
|
+
.replace(/\\/g, "/");
|
|
130
|
+
|
|
125
131
|
const viteLogger = {
|
|
126
132
|
warnedMessages: new Set<string>(),
|
|
127
133
|
loggedErrors: new WeakSet<Error>(),
|
|
@@ -175,7 +181,9 @@ export const createBuild = async ({
|
|
|
175
181
|
|
|
176
182
|
const executeFile = async ({
|
|
177
183
|
file,
|
|
178
|
-
}: {
|
|
184
|
+
}: {
|
|
185
|
+
file: string;
|
|
186
|
+
}): Promise<
|
|
179
187
|
{ status: "success"; exports: any } | { status: "error"; error: Error }
|
|
180
188
|
> => {
|
|
181
189
|
try {
|
|
@@ -190,7 +198,9 @@ export const createBuild = async ({
|
|
|
190
198
|
|
|
191
199
|
const executeFileWithTimeout = async ({
|
|
192
200
|
file,
|
|
193
|
-
}: {
|
|
201
|
+
}: {
|
|
202
|
+
file: string;
|
|
203
|
+
}): Promise<
|
|
194
204
|
{ status: "success"; exports: any } | { status: "error"; error: Error }
|
|
195
205
|
> => {
|
|
196
206
|
let timeoutId: ReturnType<typeof setTimeout>;
|
|
@@ -277,7 +287,7 @@ export const createBuild = async ({
|
|
|
277
287
|
},
|
|
278
288
|
async executeIndexingFunctions(): Promise<IndexingResult> {
|
|
279
289
|
const files = glob.sync(indexingPattern, {
|
|
280
|
-
ignore: apiPattern,
|
|
290
|
+
ignore: [apiPattern, testFilePattern],
|
|
281
291
|
});
|
|
282
292
|
|
|
283
293
|
for (const file of files) {
|
|
@@ -300,7 +310,7 @@ export const createBuild = async ({
|
|
|
300
310
|
try {
|
|
301
311
|
const contents = fs.readFileSync(file, "utf-8");
|
|
302
312
|
hash.update(contents);
|
|
303
|
-
} catch (
|
|
313
|
+
} catch (_e) {
|
|
304
314
|
common.logger.warn({
|
|
305
315
|
msg: "Unable to read file",
|
|
306
316
|
file,
|
|
@@ -655,7 +665,7 @@ export const createBuild = async ({
|
|
|
655
665
|
]);
|
|
656
666
|
viteNodeRunner.moduleCache.invalidateDepTree(
|
|
657
667
|
glob.sync(indexingPattern, {
|
|
658
|
-
ignore: apiPattern,
|
|
668
|
+
ignore: [apiPattern, testFilePattern],
|
|
659
669
|
}),
|
|
660
670
|
);
|
|
661
671
|
viteNodeRunner.moduleCache.invalidateDepTree(glob.sync(apiPattern));
|
|
@@ -691,7 +701,7 @@ export const createBuild = async ({
|
|
|
691
701
|
rpc_chain_id: hexToNumber(chainId),
|
|
692
702
|
});
|
|
693
703
|
}
|
|
694
|
-
} catch (
|
|
704
|
+
} catch (_e) {
|
|
695
705
|
const error = new RetryableError("Failed to connect to JSON-RPC");
|
|
696
706
|
error.stack = undefined;
|
|
697
707
|
return { status: "error", error } as const;
|
package/src/build/plugin.ts
CHANGED
package/src/build/pre.ts
CHANGED
|
@@ -30,7 +30,7 @@ export function buildPre({
|
|
|
30
30
|
|
|
31
31
|
if (config.database?.kind) {
|
|
32
32
|
if (config.database.kind === "postgres") {
|
|
33
|
-
let connectionString: string | undefined
|
|
33
|
+
let connectionString: string | undefined;
|
|
34
34
|
|
|
35
35
|
if (config.database.connectionString) {
|
|
36
36
|
connectionString = config.database.connectionString;
|
|
@@ -64,7 +64,7 @@ export function buildPre({
|
|
|
64
64
|
databaseConfig = { kind: "pglite", options: { dataDir: pgliteDir } };
|
|
65
65
|
}
|
|
66
66
|
} else {
|
|
67
|
-
let connectionString: string | undefined
|
|
67
|
+
let connectionString: string | undefined;
|
|
68
68
|
if (process.env.DATABASE_PRIVATE_URL) {
|
|
69
69
|
connectionString = process.env.DATABASE_PRIVATE_URL;
|
|
70
70
|
} else if (process.env.DATABASE_URL) {
|
package/src/build/schema.ts
CHANGED
|
@@ -1,20 +1,13 @@
|
|
|
1
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
2
|
getTableColumns,
|
|
13
3
|
getTableName,
|
|
14
4
|
getViewName,
|
|
15
5
|
is,
|
|
6
|
+
SQL,
|
|
16
7
|
} from "drizzle-orm";
|
|
17
8
|
import {
|
|
9
|
+
getTableConfig,
|
|
10
|
+
getViewConfig,
|
|
18
11
|
PgBigSerial53,
|
|
19
12
|
PgBigSerial64,
|
|
20
13
|
PgColumn,
|
|
@@ -23,14 +16,24 @@ import {
|
|
|
23
16
|
PgSmallSerial,
|
|
24
17
|
PgTable,
|
|
25
18
|
PgView,
|
|
26
|
-
getTableConfig,
|
|
27
|
-
getViewConfig,
|
|
28
19
|
} from "drizzle-orm/pg-core";
|
|
20
|
+
import {
|
|
21
|
+
PONDER_CHECKPOINT_TABLE_NAME,
|
|
22
|
+
PONDER_META_TABLE_NAME,
|
|
23
|
+
} from "@/database/index.js";
|
|
24
|
+
import { getPrimaryKeyColumns } from "@/drizzle/index.js";
|
|
25
|
+
import { getSql } from "@/drizzle/kit/index.js";
|
|
26
|
+
import { MAX_DATABASE_OBJECT_NAME_LENGTH } from "@/drizzle/onchain.js";
|
|
27
|
+
import { BuildError } from "@/internal/errors.js";
|
|
28
|
+
import type { PreBuild, Schema } from "@/internal/types.js";
|
|
29
29
|
|
|
30
30
|
export const buildSchema = ({
|
|
31
31
|
schema,
|
|
32
32
|
preBuild,
|
|
33
|
-
}: {
|
|
33
|
+
}: {
|
|
34
|
+
schema: Schema;
|
|
35
|
+
preBuild: Pick<PreBuild, "ordering">;
|
|
36
|
+
}) => {
|
|
34
37
|
const statements = getSql(schema);
|
|
35
38
|
|
|
36
39
|
const tableNames = new Set<string>();
|
|
@@ -331,7 +334,10 @@ export const buildSchema = ({
|
|
|
331
334
|
export const safeBuildSchema = ({
|
|
332
335
|
schema,
|
|
333
336
|
preBuild,
|
|
334
|
-
}: {
|
|
337
|
+
}: {
|
|
338
|
+
schema: Schema;
|
|
339
|
+
preBuild: Pick<PreBuild, "ordering">;
|
|
340
|
+
}) => {
|
|
335
341
|
try {
|
|
336
342
|
const result = buildSchema({ schema, preBuild });
|
|
337
343
|
|
package/src/build/stacktrace.ts
CHANGED
|
@@ -34,8 +34,8 @@ export function parseViteNodeError(file: string, error: Error): ViteNodeError {
|
|
|
34
34
|
.split("\n")
|
|
35
35
|
.slice(1)
|
|
36
36
|
.map((message) => {
|
|
37
|
-
let location: string | undefined
|
|
38
|
-
let detail: string | undefined
|
|
37
|
+
let location: string | undefined;
|
|
38
|
+
let detail: string | undefined;
|
|
39
39
|
if (message.includes(": ERROR: ")) {
|
|
40
40
|
// /path/to/file.ts:11:9: ERROR: Expected ")" but found ";"
|
|
41
41
|
const s = message.split(": ERROR: ");
|
|
@@ -98,7 +98,7 @@ export function parseViteNodeError(file: string, error: Error): ViteNodeError {
|
|
|
98
98
|
if (resolvedError.stack) {
|
|
99
99
|
const userStackFrames = parseStackTrace(resolvedError.stack);
|
|
100
100
|
|
|
101
|
-
let codeFrame: string | undefined
|
|
101
|
+
let codeFrame: string | undefined;
|
|
102
102
|
for (const { file, lineNumber, column } of userStackFrames) {
|
|
103
103
|
if (file !== null && lineNumber !== null) {
|
|
104
104
|
try {
|
|
@@ -109,7 +109,7 @@ export function parseViteNodeError(file: string, error: Error): ViteNodeError {
|
|
|
109
109
|
{ highlightCode: true },
|
|
110
110
|
);
|
|
111
111
|
break;
|
|
112
|
-
} catch (
|
|
112
|
+
} catch (_err) {
|
|
113
113
|
// No-op.
|
|
114
114
|
}
|
|
115
115
|
}
|
|
@@ -131,7 +131,7 @@ export function parseViteNodeError(file: string, error: Error): ViteNodeError {
|
|
|
131
131
|
// This can throw with "Cannot set property message of [object Object] which has only a getter"
|
|
132
132
|
try {
|
|
133
133
|
resolvedError.message = `Error while ${verb} ${file}: ${resolvedError.message}`;
|
|
134
|
-
} catch (
|
|
134
|
+
} catch (_e) {}
|
|
135
135
|
|
|
136
136
|
return resolvedError;
|
|
137
137
|
}
|
package/src/client/index.ts
CHANGED
|
@@ -1,27 +1,15 @@
|
|
|
1
|
-
import type { PonderApp6 } from "@/database/index.js";
|
|
2
|
-
import { getLiveQueryChannelName } from "@/drizzle/onchain.js";
|
|
3
|
-
import type { Schema } from "@/internal/types.js";
|
|
4
|
-
import type { ReadonlyDrizzle } from "@/types/db.js";
|
|
5
|
-
import {
|
|
6
|
-
type PromiseWithResolvers,
|
|
7
|
-
promiseWithResolvers,
|
|
8
|
-
} from "@/utils/promiseWithResolvers.js";
|
|
9
1
|
import {
|
|
10
|
-
getSQLQueryRelations,
|
|
11
|
-
validateAllowableSQLQuery,
|
|
12
|
-
} from "@/utils/sql-parse.js";
|
|
13
|
-
import {
|
|
14
|
-
type QueryWithTypings,
|
|
15
2
|
getTableName,
|
|
16
3
|
getViewName,
|
|
17
4
|
isTable,
|
|
18
5
|
isView,
|
|
6
|
+
type QueryWithTypings,
|
|
19
7
|
} from "drizzle-orm";
|
|
20
8
|
import {
|
|
9
|
+
getViewConfig,
|
|
21
10
|
type PgDialect,
|
|
22
11
|
type PgSession,
|
|
23
12
|
type PgView,
|
|
24
|
-
getViewConfig,
|
|
25
13
|
pgSchema,
|
|
26
14
|
pgTable,
|
|
27
15
|
} from "drizzle-orm/pg-core";
|
|
@@ -29,6 +17,18 @@ import { createMiddleware } from "hono/factory";
|
|
|
29
17
|
import { streamSSE } from "hono/streaming";
|
|
30
18
|
import type * as pg from "pg";
|
|
31
19
|
import superjson from "superjson";
|
|
20
|
+
import type { PonderApp6 } from "@/database/index.js";
|
|
21
|
+
import { getLiveQueryChannelName } from "@/drizzle/onchain.js";
|
|
22
|
+
import type { Schema } from "@/internal/types.js";
|
|
23
|
+
import type { ReadonlyDrizzle } from "@/types/db.js";
|
|
24
|
+
import {
|
|
25
|
+
type PromiseWithResolvers,
|
|
26
|
+
promiseWithResolvers,
|
|
27
|
+
} from "@/utils/promiseWithResolvers.js";
|
|
28
|
+
import {
|
|
29
|
+
getSQLQueryRelations,
|
|
30
|
+
validateAllowableSQLQuery,
|
|
31
|
+
} from "@/utils/sql-parse.js";
|
|
32
32
|
|
|
33
33
|
type QueryString = string;
|
|
34
34
|
type QueryResult = unknown;
|
|
@@ -75,7 +75,10 @@ const getPonderMetaTable = (schema?: string) => {
|
|
|
75
75
|
export const client = ({
|
|
76
76
|
db,
|
|
77
77
|
schema,
|
|
78
|
-
}: {
|
|
78
|
+
}: {
|
|
79
|
+
db: ReadonlyDrizzle<Schema>;
|
|
80
|
+
schema: Schema;
|
|
81
|
+
}) => {
|
|
79
82
|
if (
|
|
80
83
|
globalThis.PONDER_COMMON === undefined ||
|
|
81
84
|
globalThis.PONDER_DATABASE === undefined ||
|
|
@@ -95,9 +98,9 @@ export const client = ({
|
|
|
95
98
|
// Note: Add system tables to the live query registry.
|
|
96
99
|
tableNames.add("_ponder_checkpoint");
|
|
97
100
|
|
|
98
|
-
// @ts-
|
|
101
|
+
// @ts-expect-error
|
|
99
102
|
const session: PgSession = db._.session;
|
|
100
|
-
// @ts-
|
|
103
|
+
// @ts-expect-error
|
|
101
104
|
const dialect: PgDialect = session.dialect;
|
|
102
105
|
const driver = globalThis.PONDER_DATABASE.driver;
|
|
103
106
|
|
|
@@ -236,7 +239,7 @@ export const client = ({
|
|
|
236
239
|
let hasRegisteredShutdown = false;
|
|
237
240
|
|
|
238
241
|
while (globalThis.PONDER_COMMON.apiShutdown.isKilled === false) {
|
|
239
|
-
// biome-ignore lint/suspicious/noAsyncPromiseExecutor:
|
|
242
|
+
// biome-ignore lint/suspicious/noAsyncPromiseExecutor: This Promise intentionally wraps async connect/retry flow.
|
|
240
243
|
await new Promise<void>(async (resolve) => {
|
|
241
244
|
try {
|
|
242
245
|
client = await driver.admin.connect();
|
|
@@ -487,7 +490,7 @@ export const client = ({
|
|
|
487
490
|
|
|
488
491
|
let resultHash = crypto
|
|
489
492
|
.createHash("MD5")
|
|
490
|
-
// @ts-
|
|
493
|
+
// @ts-expect-error
|
|
491
494
|
.update(JSON.stringify(result.rows))
|
|
492
495
|
.digest("hex")
|
|
493
496
|
.slice(0, 10);
|
|
@@ -529,7 +532,7 @@ export const client = ({
|
|
|
529
532
|
|
|
530
533
|
const _resultHash = crypto
|
|
531
534
|
.createHash("MD5")
|
|
532
|
-
// @ts-
|
|
535
|
+
// @ts-expect-error
|
|
533
536
|
.update(JSON.stringify(result.rows))
|
|
534
537
|
.digest("hex")
|
|
535
538
|
.slice(0, 10);
|
|
@@ -537,7 +540,6 @@ export const client = ({
|
|
|
537
540
|
if (_resultHash === resultHash) continue;
|
|
538
541
|
resultHash = _resultHash;
|
|
539
542
|
|
|
540
|
-
// @ts-ignore
|
|
541
543
|
await stream.writeSSE({ data: JSON.stringify(result) });
|
|
542
544
|
} catch {
|
|
543
545
|
stream.abort();
|
package/src/config/address.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { LogFactory } from "@/internal/types.js";
|
|
2
1
|
import type { AbiEvent, AbiParameter } from "viem";
|
|
2
|
+
import type { LogFactory } from "@/internal/types.js";
|
|
3
3
|
|
|
4
4
|
// Note: Currently limit the depth to 1 level.
|
|
5
5
|
type ParameterNames<T extends AbiParameter> = T extends {
|
package/src/config/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ConnectionOptions } from "node:tls";
|
|
2
|
-
import type { Prettify } from "@/types/utils.js";
|
|
3
2
|
import type { Abi } from "abitype";
|
|
4
3
|
import type { PoolConfig } from "pg";
|
|
5
4
|
import type { Narrow, Transport } from "viem";
|
|
5
|
+
import type { Prettify } from "@/types/utils.js";
|
|
6
6
|
import type { AddressConfig } from "./address.js";
|
|
7
7
|
import type { GetEventFilter } from "./eventFilter.js";
|
|
8
8
|
|
package/src/database/actions.ts
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
and,
|
|
3
|
+
eq,
|
|
4
|
+
getTableColumns,
|
|
5
|
+
getTableName,
|
|
6
|
+
getViewName,
|
|
7
|
+
lte,
|
|
8
|
+
type SQL,
|
|
9
|
+
sql,
|
|
10
|
+
type Table,
|
|
11
|
+
type View,
|
|
12
|
+
} from "drizzle-orm";
|
|
13
|
+
import { getTableConfig } from "drizzle-orm/pg-core";
|
|
1
14
|
import { getPrimaryKeyColumns } from "@/drizzle/index.js";
|
|
2
15
|
import { getColumnCasing, getReorgTable } from "@/drizzle/kit/index.js";
|
|
3
16
|
import {
|
|
@@ -20,24 +33,11 @@ import type {
|
|
|
20
33
|
PreBuild,
|
|
21
34
|
SchemaBuild,
|
|
22
35
|
} from "@/internal/types.js";
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
type SQL,
|
|
26
|
-
type Table,
|
|
27
|
-
type View,
|
|
28
|
-
and,
|
|
29
|
-
eq,
|
|
30
|
-
getTableColumns,
|
|
31
|
-
getTableName,
|
|
32
|
-
getViewName,
|
|
33
|
-
lte,
|
|
34
|
-
sql,
|
|
35
|
-
} from "drizzle-orm";
|
|
36
|
-
import { getTableConfig } from "drizzle-orm/pg-core";
|
|
36
|
+
import { decodeCheckpoint, MAX_CHECKPOINT_STRING } from "@/utils/checkpoint.js";
|
|
37
37
|
import {
|
|
38
|
+
getPonderCheckpointTable,
|
|
38
39
|
PONDER_CHECKPOINT_TABLE_NAME,
|
|
39
40
|
PONDER_META_TABLE_NAME,
|
|
40
|
-
getPonderCheckpointTable,
|
|
41
41
|
} from "./index.js";
|
|
42
42
|
import type { QB } from "./queryBuilder.js";
|
|
43
43
|
|
|
@@ -404,7 +404,7 @@ WITH reverted1 AS (
|
|
|
404
404
|
), ${getRevertSql({ table })};`),
|
|
405
405
|
);
|
|
406
406
|
|
|
407
|
-
// @ts-
|
|
407
|
+
// @ts-expect-error
|
|
408
408
|
counts.push(result.rows[0]!.count);
|
|
409
409
|
}
|
|
410
410
|
|
|
@@ -447,7 +447,6 @@ AND checkpoint > '${checkpoint}'`,
|
|
|
447
447
|
.join(" UNION ALL ")}) AS all_mins;`),
|
|
448
448
|
)
|
|
449
449
|
.then((result) => {
|
|
450
|
-
// @ts-ignore
|
|
451
450
|
return result.rows[0]?.operation_id as string | null;
|
|
452
451
|
});
|
|
453
452
|
|
|
@@ -474,7 +473,7 @@ WITH reverted1 AS (
|
|
|
474
473
|
), ${getRevertSql({ table })};`),
|
|
475
474
|
);
|
|
476
475
|
|
|
477
|
-
// @ts-
|
|
476
|
+
// @ts-expect-error
|
|
478
477
|
counts.push(result.rows[0]!.count);
|
|
479
478
|
}
|
|
480
479
|
|
|
@@ -525,7 +524,7 @@ WITH reverted1 AS (
|
|
|
525
524
|
), ${getRevertSql({ table })};`),
|
|
526
525
|
);
|
|
527
526
|
|
|
528
|
-
// @ts-
|
|
527
|
+
// @ts-expect-error
|
|
529
528
|
counts.push(result.rows[0]!.count);
|
|
530
529
|
}
|
|
531
530
|
|
|
@@ -647,7 +646,6 @@ WHERE checkpoint > (
|
|
|
647
646
|
.join(" UNION ALL ")}) AS all_mins;`),
|
|
648
647
|
)
|
|
649
648
|
.then((result) => {
|
|
650
|
-
// @ts-ignore
|
|
651
649
|
return result.rows[0]?.operation_id as string | null;
|
|
652
650
|
});
|
|
653
651
|
|
package/src/database/index.ts
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
import type { PGlite } from "@electric-sql/pglite";
|
|
2
|
+
import {
|
|
3
|
+
eq,
|
|
4
|
+
getTableName,
|
|
5
|
+
getViewName,
|
|
6
|
+
isTable,
|
|
7
|
+
isView,
|
|
8
|
+
sql,
|
|
9
|
+
} from "drizzle-orm";
|
|
10
|
+
import { drizzle as drizzleNodePg } from "drizzle-orm/node-postgres";
|
|
11
|
+
import { pgSchema, pgTable } from "drizzle-orm/pg-core";
|
|
12
|
+
import { drizzle as drizzlePglite } from "drizzle-orm/pglite";
|
|
13
|
+
import { Kysely, Migrator, PostgresDialect, WithSchemaPlugin } from "kysely";
|
|
14
|
+
import type { Pool } from "pg";
|
|
15
|
+
import prometheus from "prom-client";
|
|
16
|
+
import { hexToBigInt } from "viem";
|
|
1
17
|
import {
|
|
2
18
|
getLiveQueryNotifyProcedureName,
|
|
3
19
|
getLiveQueryProcedureName,
|
|
@@ -26,29 +42,13 @@ import { createPool, createReadonlyPool } from "@/utils/pg.js";
|
|
|
26
42
|
import { createPglite, createPgliteKyselyDialect } from "@/utils/pglite.js";
|
|
27
43
|
import { startClock } from "@/utils/timer.js";
|
|
28
44
|
import { wait } from "@/utils/wait.js";
|
|
29
|
-
import type { PGlite } from "@electric-sql/pglite";
|
|
30
|
-
import {
|
|
31
|
-
eq,
|
|
32
|
-
getTableName,
|
|
33
|
-
getViewName,
|
|
34
|
-
isTable,
|
|
35
|
-
isView,
|
|
36
|
-
sql,
|
|
37
|
-
} from "drizzle-orm";
|
|
38
|
-
import { drizzle as drizzleNodePg } from "drizzle-orm/node-postgres";
|
|
39
|
-
import { pgSchema, pgTable } from "drizzle-orm/pg-core";
|
|
40
|
-
import { drizzle as drizzlePglite } from "drizzle-orm/pglite";
|
|
41
|
-
import { Kysely, Migrator, PostgresDialect, WithSchemaPlugin } from "kysely";
|
|
42
|
-
import type { Pool } from "pg";
|
|
43
|
-
import prometheus from "prom-client";
|
|
44
|
-
import { hexToBigInt } from "viem";
|
|
45
45
|
import {
|
|
46
46
|
crashRecovery,
|
|
47
47
|
createLiveQueryProcedures,
|
|
48
48
|
dropLiveQueryTriggers,
|
|
49
49
|
dropTriggers,
|
|
50
50
|
} from "./actions.js";
|
|
51
|
-
import {
|
|
51
|
+
import { createQB, parseDbError, type QB } from "./queryBuilder.js";
|
|
52
52
|
|
|
53
53
|
export type Database = {
|
|
54
54
|
driver: PostgresDriver | PGliteDriver;
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import crypto from "node:crypto";
|
|
2
|
+
import { PGlite } from "@electric-sql/pglite";
|
|
3
|
+
import type { ExtractTablesWithRelations } from "drizzle-orm";
|
|
4
|
+
import type {
|
|
5
|
+
PgDatabase,
|
|
6
|
+
PgQueryResultHKT,
|
|
7
|
+
PgTransaction,
|
|
8
|
+
PgTransactionConfig,
|
|
9
|
+
} from "drizzle-orm/pg-core";
|
|
10
|
+
import type pg from "pg";
|
|
2
11
|
import type { Common } from "@/internal/common.js";
|
|
3
|
-
import { BaseError } from "@/internal/errors.js";
|
|
4
12
|
import {
|
|
13
|
+
BaseError,
|
|
5
14
|
BigIntSerializationError,
|
|
6
15
|
CheckConstraintError,
|
|
7
16
|
DbConnectionError,
|
|
@@ -15,15 +24,6 @@ import type { Schema } from "@/internal/types.js";
|
|
|
15
24
|
import type { Drizzle } from "@/types/db.js";
|
|
16
25
|
import { startClock } from "@/utils/timer.js";
|
|
17
26
|
import { wait } from "@/utils/wait.js";
|
|
18
|
-
import { PGlite } from "@electric-sql/pglite";
|
|
19
|
-
import type { ExtractTablesWithRelations } from "drizzle-orm";
|
|
20
|
-
import type {
|
|
21
|
-
PgDatabase,
|
|
22
|
-
PgQueryResultHKT,
|
|
23
|
-
PgTransaction,
|
|
24
|
-
PgTransactionConfig,
|
|
25
|
-
} from "drizzle-orm/pg-core";
|
|
26
|
-
import type pg from "pg";
|
|
27
27
|
|
|
28
28
|
const RETRY_COUNT = 9;
|
|
29
29
|
const BASE_DURATION = 125;
|
|
@@ -293,7 +293,7 @@ export const createQB = <
|
|
|
293
293
|
// Add QB methods to the transaction object
|
|
294
294
|
const addQBMethods = (db: PgDatabase<PgQueryResultHKT, TSchema>) => {
|
|
295
295
|
const _transaction = db.transaction.bind(db);
|
|
296
|
-
// @ts-
|
|
296
|
+
// @ts-expect-error
|
|
297
297
|
db.transaction = async (...args) => {
|
|
298
298
|
if (typeof args[0] === "function") {
|
|
299
299
|
const [callback, config, transactionContext] = args as unknown as [
|
|
@@ -324,7 +324,6 @@ export const createQB = <
|
|
|
324
324
|
Object.assign(tx, { $client: tx.session.client });
|
|
325
325
|
|
|
326
326
|
// Note: `tx.wrap` should not retry errors, because the transaction will be aborted
|
|
327
|
-
// @ts-ignore
|
|
328
327
|
(tx as unknown as QB<TSchema, TClient>).wrap = (...args) => {
|
|
329
328
|
if (typeof args[0] === "function") {
|
|
330
329
|
const [query, context] = args as [
|
|
@@ -405,7 +404,6 @@ export const createQB = <
|
|
|
405
404
|
Object.assign(tx, { $client: tx.session.client });
|
|
406
405
|
|
|
407
406
|
// Note: `tx.wrap` should not retry errors, because the transaction will be aborted
|
|
408
|
-
// @ts-ignore
|
|
409
407
|
(tx as unknown as QB<TSchema, TClient>).wrap = (...args) => {
|
|
410
408
|
if (typeof args[0] === "function") {
|
|
411
409
|
const [query, context] = args as [
|
|
@@ -464,7 +462,7 @@ export const createQB = <
|
|
|
464
462
|
if (dialect === "postgres") {
|
|
465
463
|
addQBMethods(db);
|
|
466
464
|
} else {
|
|
467
|
-
// @ts-
|
|
465
|
+
// @ts-expect-error
|
|
468
466
|
db.transaction = async (...args) => {
|
|
469
467
|
if (typeof args[0] === "function") {
|
|
470
468
|
const [callback, context] = args as [
|