turbine-orm 0.93.1 → 0.94.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/README.md +49 -23
- package/dist/adapters/cockroachdb.d.ts +3 -3
- package/dist/adapters/cockroachdb.js +7 -11
- package/dist/adapters/index.d.ts +1 -1
- package/dist/adapters/yugabytedb.js +1 -1
- package/dist/better-sqlite3.d.ts +132 -0
- package/dist/better-sqlite3.js +303 -0
- package/dist/catalog-metadata.d.ts +250 -0
- package/dist/catalog-metadata.js +730 -0
- package/dist/cjs/adapters/cockroachdb.d.ts +3 -3
- package/dist/cjs/adapters/cockroachdb.js +7 -11
- package/dist/cjs/adapters/index.d.ts +1 -1
- package/dist/cjs/adapters/yugabytedb.js +1 -1
- package/dist/cjs/better-sqlite3.d.ts +132 -0
- package/dist/cjs/better-sqlite3.js +311 -0
- package/dist/cjs/catalog-metadata.d.ts +250 -0
- package/dist/cjs/catalog-metadata.js +747 -0
- package/dist/cjs/cli/compile-query.d.ts +6 -3
- package/dist/cjs/cli/compile-query.js +24 -3
- package/dist/cjs/cli/config.d.ts +35 -10
- package/dist/cjs/cli/config.js +173 -42
- package/dist/cjs/cli/d1-config.d.ts +14 -0
- package/dist/cjs/cli/d1-config.js +9 -0
- package/dist/cjs/cli/d1-local.d.ts +31 -0
- package/dist/cjs/cli/d1-local.js +298 -0
- package/dist/cjs/cli/d1-migrations.d.ts +16 -0
- package/dist/cjs/cli/d1-migrations.js +156 -0
- package/dist/cjs/cli/d1-project.d.ts +23 -0
- package/dist/cjs/cli/d1-project.js +314 -0
- package/dist/cjs/cli/d1-seed.d.ts +35 -0
- package/dist/cjs/cli/d1-seed.js +220 -0
- package/dist/cjs/cli/destructive.js +1 -2
- package/dist/cjs/cli/error-catalog.d.ts +3 -3
- package/dist/cjs/cli/error-catalog.js +21 -3
- package/dist/cjs/cli/index.d.ts +13 -8
- package/dist/cjs/cli/index.js +503 -71
- package/dist/cjs/cli/libsql-migrate-command.d.ts +5 -0
- package/dist/cjs/cli/libsql-migrate-command.js +82 -0
- package/dist/cjs/cli/libsql-migrate-status.d.ts +33 -0
- package/dist/cjs/cli/libsql-migrate-status.js +189 -0
- package/dist/cjs/cli/libsql-migrate.d.ts +14 -0
- package/dist/cjs/cli/libsql-migrate.js +522 -0
- package/dist/cjs/cli/libsql-project-config.d.ts +11 -0
- package/dist/cjs/cli/libsql-project-config.js +59 -0
- package/dist/cjs/cli/libsql-project.d.ts +52 -0
- package/dist/cjs/cli/libsql-project.js +409 -0
- package/dist/cjs/cli/libsql-seed-command.d.ts +29 -0
- package/dist/cjs/cli/libsql-seed-command.js +93 -0
- package/dist/cjs/cli/loader.d.ts +6 -5
- package/dist/cjs/cli/loader.js +53 -9
- package/dist/cjs/cli/mcp.d.ts +16 -1
- package/dist/cjs/cli/mcp.js +219 -125
- package/dist/cjs/cli/migrate.d.ts +2 -2
- package/dist/cjs/cli/migrate.js +29 -14
- package/dist/cjs/cli/mssql-doctor.d.ts +44 -0
- package/dist/cjs/cli/mssql-doctor.js +277 -0
- package/dist/cjs/cli/mssql-migrate-command.d.ts +9 -0
- package/dist/cjs/cli/mssql-migrate-command.js +230 -0
- package/dist/cjs/cli/mssql-migrate-connection.d.ts +51 -0
- package/dist/cjs/cli/mssql-migrate-connection.js +255 -0
- package/dist/cjs/cli/mssql-migrate-sql.d.ts +12 -0
- package/dist/cjs/cli/mssql-migrate-sql.js +282 -0
- package/dist/cjs/cli/mssql-migrate.d.ts +45 -0
- package/dist/cjs/cli/mssql-migrate.js +296 -0
- package/dist/cjs/cli/mssql-project.d.ts +34 -0
- package/dist/cjs/cli/mssql-project.js +171 -0
- package/dist/cjs/cli/mssql-seed.d.ts +7 -0
- package/dist/cjs/cli/mssql-seed.js +78 -0
- package/dist/cjs/cli/mssql-tools.d.ts +37 -0
- package/dist/cjs/cli/mssql-tools.js +354 -0
- package/dist/cjs/cli/mysql-doctor.d.ts +48 -0
- package/dist/cjs/cli/mysql-doctor.js +323 -0
- package/dist/cjs/cli/mysql-migrate-command.d.ts +7 -0
- package/dist/cjs/cli/mysql-migrate-command.js +290 -0
- package/dist/cjs/cli/mysql-migrate-sql.d.ts +18 -0
- package/dist/cjs/cli/mysql-migrate-sql.js +166 -0
- package/dist/cjs/cli/mysql-migrate.d.ts +77 -0
- package/dist/cjs/cli/mysql-migrate.js +619 -0
- package/dist/cjs/cli/mysql-project.d.ts +49 -0
- package/dist/cjs/cli/mysql-project.js +284 -0
- package/dist/cjs/cli/mysql-push-command.d.ts +7 -0
- package/dist/cjs/cli/mysql-push-command.js +94 -0
- package/dist/cjs/cli/mysql-push.d.ts +15 -0
- package/dist/cjs/cli/mysql-push.js +98 -0
- package/dist/cjs/cli/mysql-schema-command.d.ts +5 -0
- package/dist/cjs/cli/mysql-schema-command.js +58 -0
- package/dist/cjs/cli/mysql-schema-ddl.d.ts +37 -0
- package/dist/cjs/cli/mysql-schema-ddl.js +234 -0
- package/dist/cjs/cli/mysql-schema-snapshot.d.ts +21 -0
- package/dist/cjs/cli/mysql-schema-snapshot.js +127 -0
- package/dist/cjs/cli/mysql-schema.d.ts +27 -0
- package/dist/cjs/cli/mysql-schema.js +206 -0
- package/dist/cjs/cli/mysql-seed-loader.cjs +58 -0
- package/dist/cjs/cli/mysql-seed-loader.d.cts +3 -0
- package/dist/cjs/cli/mysql-seed.d.ts +6 -0
- package/dist/cjs/cli/mysql-seed.js +83 -0
- package/dist/cjs/cli/mysql-tools.d.ts +44 -0
- package/dist/cjs/cli/mysql-tools.js +336 -0
- package/dist/cjs/cli/no-follow.d.ts +29 -0
- package/dist/cjs/cli/no-follow.js +73 -0
- package/dist/cjs/cli/pii-predicate-guard.d.ts +1 -1
- package/dist/cjs/cli/pii-predicate-guard.js +2 -2
- package/dist/cjs/cli/pii-tags.d.ts +2 -2
- package/dist/cjs/cli/pii-tags.js +1 -1
- package/dist/cjs/cli/prisma-schema.js +2 -2
- package/dist/cjs/cli/sql-statements.d.ts +1 -1
- package/dist/cjs/cli/sql-statements.js +1 -1
- package/dist/cjs/cli/sqlite-doctor.d.ts +35 -0
- package/dist/cjs/cli/sqlite-doctor.js +400 -0
- package/dist/cjs/cli/sqlite-migrate-command.d.ts +4 -0
- package/dist/cjs/cli/sqlite-migrate-command.js +175 -0
- package/dist/cjs/cli/sqlite-migrate.d.ts +61 -0
- package/dist/cjs/cli/sqlite-migrate.js +692 -0
- package/dist/cjs/cli/sqlite-project.d.ts +42 -0
- package/dist/cjs/cli/sqlite-project.js +254 -0
- package/dist/cjs/cli/sqlite-schema-command.d.ts +4 -0
- package/dist/cjs/cli/sqlite-schema-command.js +82 -0
- package/dist/cjs/cli/sqlite-schema-ddl.d.ts +25 -0
- package/dist/cjs/cli/sqlite-schema-ddl.js +252 -0
- package/dist/cjs/cli/sqlite-schema.d.ts +25 -0
- package/dist/cjs/cli/sqlite-schema.js +334 -0
- package/dist/cjs/cli/sqlite-seed.d.ts +4 -0
- package/dist/cjs/cli/sqlite-seed.js +94 -0
- package/dist/cjs/cli/sqlite-tools.d.ts +24 -0
- package/dist/cjs/cli/sqlite-tools.js +169 -0
- package/dist/cjs/cli/studio.js +9 -9
- package/dist/cjs/cli/tool-capabilities.d.ts +72 -0
- package/dist/cjs/cli/tool-capabilities.js +120 -0
- package/dist/cjs/cli/tool-command.d.ts +11 -0
- package/dist/cjs/cli/tool-command.js +49 -0
- package/dist/cjs/cli/ui.d.ts +1 -1
- package/dist/cjs/cli/ui.js +1 -1
- package/dist/cjs/client.d.ts +20 -20
- package/dist/cjs/client.js +65 -344
- package/dist/cjs/connection-url.d.ts +1 -1
- package/dist/cjs/connection-url.js +1 -1
- package/dist/cjs/core.d.ts +58 -0
- package/dist/cjs/core.js +225 -0
- package/dist/cjs/d1/catalog-metadata.d.ts +5 -0
- package/dist/cjs/d1/catalog-metadata.js +230 -0
- package/dist/cjs/d1/catalog.d.ts +15 -0
- package/dist/cjs/d1/catalog.js +88 -0
- package/dist/cjs/d1/generate.d.ts +8 -0
- package/dist/cjs/d1/generate.js +163 -0
- package/dist/cjs/d1/introspect.d.ts +21 -0
- package/dist/cjs/d1/introspect.js +74 -0
- package/dist/cjs/d1/migrate.d.ts +29 -0
- package/dist/cjs/d1/migrate.js +222 -0
- package/dist/cjs/d1/migrations/sql.d.ts +2 -0
- package/dist/cjs/d1/migrations/sql.js +109 -0
- package/dist/cjs/d1/pool.d.ts +14 -0
- package/dist/cjs/d1/pool.js +90 -0
- package/dist/cjs/d1/sql.d.ts +5 -0
- package/dist/cjs/d1/sql.js +140 -0
- package/dist/cjs/d1/sqlite-dialect.d.ts +16 -0
- package/dist/cjs/d1/sqlite-dialect.js +579 -0
- package/dist/cjs/d1/types.d.ts +29 -0
- package/dist/cjs/d1/types.js +2 -0
- package/dist/cjs/d1.d.ts +53 -0
- package/dist/cjs/d1.js +220 -0
- package/dist/cjs/dialect.d.ts +33 -5
- package/dist/cjs/dialect.js +8 -6
- package/dist/cjs/errors.d.ts +38 -1
- package/dist/cjs/errors.js +72 -18
- package/dist/cjs/generate.d.ts +19 -3
- package/dist/cjs/generate.js +330 -97
- package/dist/cjs/global-filters-config.js +4 -4
- package/dist/cjs/index-advisor.js +6 -6
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +3 -2
- package/dist/cjs/introspect.d.ts +59 -356
- package/dist/cjs/introspect.js +158 -984
- package/dist/cjs/libsql/bindings.d.ts +2 -0
- package/dist/cjs/libsql/bindings.js +78 -0
- package/dist/cjs/libsql/dialect.d.ts +3 -0
- package/dist/cjs/libsql/dialect.js +48 -0
- package/dist/cjs/libsql/generate.d.ts +4 -0
- package/dist/cjs/libsql/generate.js +56 -0
- package/dist/cjs/libsql/introspect.d.ts +16 -0
- package/dist/cjs/libsql/introspect.js +295 -0
- package/dist/cjs/libsql/pool.d.ts +42 -0
- package/dist/cjs/libsql/pool.js +275 -0
- package/dist/cjs/libsql/seed-cleanup.d.ts +2 -0
- package/dist/cjs/libsql/seed-cleanup.js +19 -0
- package/dist/cjs/libsql/values.d.ts +20 -0
- package/dist/cjs/libsql/values.js +75 -0
- package/dist/cjs/libsql-seed.d.ts +19 -0
- package/dist/cjs/libsql-seed.js +50 -0
- package/dist/cjs/libsql.d.ts +28 -0
- package/dist/cjs/libsql.js +88 -0
- package/dist/cjs/live-query.d.ts +33 -0
- package/dist/cjs/live-query.js +172 -0
- package/dist/cjs/log-codes.d.ts +1 -1
- package/dist/cjs/log-codes.js +4 -0
- package/dist/cjs/mssql-seed.d.ts +27 -0
- package/dist/cjs/mssql-seed.js +118 -0
- package/dist/cjs/mssql.d.ts +7 -7
- package/dist/cjs/mssql.js +365 -53
- package/dist/cjs/mysql-seed.d.ts +25 -0
- package/dist/cjs/mysql-seed.js +169 -0
- package/dist/cjs/mysql.d.ts +18 -6
- package/dist/cjs/mysql.js +602 -94
- package/dist/cjs/neon-http/client.d.ts +95 -0
- package/dist/cjs/neon-http/client.js +291 -0
- package/dist/cjs/neon-http/sql.d.ts +3 -0
- package/dist/cjs/neon-http/sql.js +116 -0
- package/dist/cjs/neon-http.d.ts +5 -0
- package/dist/cjs/neon-http.js +8 -0
- package/dist/cjs/neon-ws/load-driver.cjs +44 -0
- package/dist/cjs/neon-ws/load-driver.d.cts +9 -0
- package/dist/cjs/neon-ws/recovery.d.ts +14 -0
- package/dist/cjs/neon-ws/recovery.js +69 -0
- package/dist/cjs/neon-ws/snapshot.d.ts +3 -0
- package/dist/cjs/neon-ws/snapshot.js +17 -0
- package/dist/cjs/neon-ws/transport.d.ts +112 -0
- package/dist/cjs/neon-ws/transport.js +290 -0
- package/dist/cjs/neon-ws.d.ts +26 -0
- package/dist/cjs/neon-ws.js +189 -0
- package/dist/cjs/nested-write.d.ts +34 -3
- package/dist/cjs/nested-write.js +117 -24
- package/dist/cjs/notification-hub/consumer.d.ts +22 -0
- package/dist/cjs/notification-hub/consumer.js +111 -0
- package/dist/cjs/notification-hub.d.ts +41 -0
- package/dist/cjs/notification-hub.js +373 -0
- package/dist/cjs/pg-catalog-text.d.ts +96 -0
- package/dist/cjs/pg-catalog-text.js +213 -0
- package/dist/cjs/pg-types.d.ts +46 -2
- package/dist/cjs/pipeline-submittable.d.ts +15 -5
- package/dist/cjs/pipeline-submittable.js +103 -48
- package/dist/cjs/pipeline.d.ts +5 -2
- package/dist/cjs/pipeline.js +111 -41
- package/dist/cjs/plan-divergence.d.ts +1 -1
- package/dist/cjs/plan-divergence.js +1 -1
- package/dist/cjs/powdb-introspect.d.ts +1 -1
- package/dist/cjs/powdb-introspect.js +5 -5
- package/dist/cjs/powdb-shared.d.ts +5 -5
- package/dist/cjs/powdb-shared.js +6 -5
- package/dist/cjs/powdb.d.ts +28 -10
- package/dist/cjs/powdb.js +80 -28
- package/dist/cjs/powql.d.ts +50 -28
- package/dist/cjs/powql.js +47 -33
- package/dist/cjs/prisma-compat.js +4 -5
- package/dist/cjs/prisma-schema-fingerprint.d.ts +1 -1
- package/dist/cjs/prisma-schema-fingerprint.js +1 -1
- package/dist/cjs/query/aggregates.d.ts +0 -13
- package/dist/cjs/query/aggregates.js +105 -238
- package/dist/cjs/query/batched-loader.d.ts +1 -1
- package/dist/cjs/query/batched-loader.js +18 -20
- package/dist/cjs/query/builder.d.ts +108 -144
- package/dist/cjs/query/builder.js +592 -893
- package/dist/cjs/query/compound-unique.d.ts +18 -3
- package/dist/cjs/query/compound-unique.js +110 -43
- package/dist/cjs/query/cursor-tuple.d.ts +17 -0
- package/dist/cjs/query/cursor-tuple.js +121 -0
- package/dist/cjs/query/expr.d.ts +2 -0
- package/dist/cjs/query/expr.js +40 -23
- package/dist/cjs/query/filters.d.ts +39 -7
- package/dist/cjs/query/filters.js +77 -19
- package/dist/cjs/query/normalize-args.d.ts +1 -1
- package/dist/cjs/query/normalize-args.js +7 -5
- package/dist/cjs/query/option-surface.d.ts +1 -1
- package/dist/cjs/query/option-surface.js +5 -3
- package/dist/cjs/query/pg-type-parsers.d.ts +126 -0
- package/dist/cjs/query/pg-type-parsers.js +306 -0
- package/dist/cjs/query/relation-names.d.ts +4 -2
- package/dist/cjs/query/relation-names.js +21 -12
- package/dist/cjs/query/relations.d.ts +19 -7
- package/dist/cjs/query/relations.js +329 -260
- package/dist/cjs/query/row-lock.js +3 -3
- package/dist/cjs/query/sql-comment.js +3 -3
- package/dist/cjs/query/stream-idle.d.ts +11 -1
- package/dist/cjs/query/stream-idle.js +53 -13
- package/dist/cjs/query/stream-signal.d.ts +21 -0
- package/dist/cjs/query/stream-signal.js +132 -0
- package/dist/cjs/query/temporal-parsers.d.ts +101 -0
- package/dist/cjs/query/temporal-parsers.js +362 -0
- package/dist/cjs/query/types.d.ts +67 -20
- package/dist/cjs/query/utils.d.ts +2 -878
- package/dist/cjs/query/utils.js +25 -2058
- package/dist/cjs/query/warn-registry.d.ts +1 -1
- package/dist/cjs/query/warn-registry.js +1 -1
- package/dist/cjs/query/where-compile.d.ts +4 -1
- package/dist/cjs/query/where-compile.js +18 -14
- package/dist/cjs/query/where.d.ts +14 -7
- package/dist/cjs/query/where.js +244 -436
- package/dist/cjs/query/writes.d.ts +33 -2
- package/dist/cjs/query/writes.js +104 -77
- package/dist/cjs/query-utils.d.ts +687 -0
- package/dist/cjs/query-utils.js +1444 -0
- package/dist/cjs/realtime.d.ts +1 -1
- package/dist/cjs/realtime.js +3 -3
- package/dist/cjs/schema-builder.js +2 -2
- package/dist/cjs/schema-metadata.d.ts +13 -3
- package/dist/cjs/schema-metadata.js +33 -5
- package/dist/cjs/schema-sql.d.ts +15 -24
- package/dist/cjs/schema-sql.js +53 -63
- package/dist/cjs/schema.d.ts +37 -2
- package/dist/cjs/schema.js +29 -2
- package/dist/cjs/seed.js +5 -5
- package/dist/cjs/serverless.d.ts +24 -71
- package/dist/cjs/serverless.js +24 -71
- package/dist/cjs/sql.d.ts +111 -0
- package/dist/cjs/sql.js +335 -0
- package/dist/cjs/sqlite-seed.d.ts +17 -0
- package/dist/cjs/sqlite-seed.js +31 -0
- package/dist/cjs/sqlite.d.ts +32 -19
- package/dist/cjs/sqlite.js +865 -652
- package/dist/cjs/supplied-pool-types.js +10 -9
- package/dist/cjs/transaction-control.js +6 -1
- package/dist/cjs/transaction-outcome.d.ts +61 -0
- package/dist/cjs/transaction-outcome.js +239 -0
- package/dist/cjs/transaction-state.d.ts +82 -13
- package/dist/cjs/transaction-state.js +222 -56
- package/dist/cjs/transaction-transport.d.ts +38 -0
- package/dist/cjs/transaction-transport.js +157 -0
- package/dist/cjs/typed-sql.d.ts +1 -1
- package/dist/cjs/typed-sql.js +1 -1
- package/dist/cli/compile-query.d.ts +6 -3
- package/dist/cli/compile-query.js +25 -4
- package/dist/cli/config.d.ts +35 -10
- package/dist/cli/config.js +170 -43
- package/dist/cli/d1-config.d.ts +14 -0
- package/dist/cli/d1-config.js +6 -0
- package/dist/cli/d1-local.d.ts +31 -0
- package/dist/cli/d1-local.js +285 -0
- package/dist/cli/d1-migrations.d.ts +16 -0
- package/dist/cli/d1-migrations.js +151 -0
- package/dist/cli/d1-project.d.ts +23 -0
- package/dist/cli/d1-project.js +304 -0
- package/dist/cli/d1-seed.d.ts +35 -0
- package/dist/cli/d1-seed.js +213 -0
- package/dist/cli/destructive.js +1 -2
- package/dist/cli/error-catalog.d.ts +3 -3
- package/dist/cli/error-catalog.js +21 -3
- package/dist/cli/index.d.ts +13 -8
- package/dist/cli/index.js +500 -71
- package/dist/cli/libsql-migrate-command.d.ts +5 -0
- package/dist/cli/libsql-migrate-command.js +77 -0
- package/dist/cli/libsql-migrate-status.d.ts +33 -0
- package/dist/cli/libsql-migrate-status.js +182 -0
- package/dist/cli/libsql-migrate.d.ts +14 -0
- package/dist/cli/libsql-migrate.js +516 -0
- package/dist/cli/libsql-project-config.d.ts +11 -0
- package/dist/cli/libsql-project-config.js +55 -0
- package/dist/cli/libsql-project.d.ts +52 -0
- package/dist/cli/libsql-project.js +391 -0
- package/dist/cli/libsql-seed-command.d.ts +29 -0
- package/dist/cli/libsql-seed-command.js +85 -0
- package/dist/cli/loader.d.ts +6 -5
- package/dist/cli/loader.js +50 -9
- package/dist/cli/mcp.d.ts +16 -1
- package/dist/cli/mcp.js +220 -127
- package/dist/cli/migrate.d.ts +2 -2
- package/dist/cli/migrate.js +29 -14
- package/dist/cli/mssql-doctor.d.ts +44 -0
- package/dist/cli/mssql-doctor.js +237 -0
- package/dist/cli/mssql-migrate-command.d.ts +9 -0
- package/dist/cli/mssql-migrate-command.js +192 -0
- package/dist/cli/mssql-migrate-connection.d.ts +51 -0
- package/dist/cli/mssql-migrate-connection.js +245 -0
- package/dist/cli/mssql-migrate-sql.d.ts +12 -0
- package/dist/cli/mssql-migrate-sql.js +275 -0
- package/dist/cli/mssql-migrate.d.ts +45 -0
- package/dist/cli/mssql-migrate.js +290 -0
- package/dist/cli/mssql-project.d.ts +34 -0
- package/dist/cli/mssql-project.js +160 -0
- package/dist/cli/mssql-seed.d.ts +7 -0
- package/dist/cli/mssql-seed.js +73 -0
- package/dist/cli/mssql-tools.d.ts +37 -0
- package/dist/cli/mssql-tools.js +341 -0
- package/dist/cli/mysql-doctor.d.ts +48 -0
- package/dist/cli/mysql-doctor.js +316 -0
- package/dist/cli/mysql-migrate-command.d.ts +7 -0
- package/dist/cli/mysql-migrate-command.js +285 -0
- package/dist/cli/mysql-migrate-sql.d.ts +18 -0
- package/dist/cli/mysql-migrate-sql.js +162 -0
- package/dist/cli/mysql-migrate.d.ts +77 -0
- package/dist/cli/mysql-migrate.js +606 -0
- package/dist/cli/mysql-project.d.ts +49 -0
- package/dist/cli/mysql-project.js +272 -0
- package/dist/cli/mysql-push-command.d.ts +7 -0
- package/dist/cli/mysql-push-command.js +89 -0
- package/dist/cli/mysql-push.d.ts +15 -0
- package/dist/cli/mysql-push.js +95 -0
- package/dist/cli/mysql-schema-command.d.ts +5 -0
- package/dist/cli/mysql-schema-command.js +54 -0
- package/dist/cli/mysql-schema-ddl.d.ts +37 -0
- package/dist/cli/mysql-schema-ddl.js +227 -0
- package/dist/cli/mysql-schema-snapshot.d.ts +21 -0
- package/dist/cli/mysql-schema-snapshot.js +119 -0
- package/dist/cli/mysql-schema.d.ts +27 -0
- package/dist/cli/mysql-schema.js +200 -0
- package/dist/cli/mysql-seed-loader.cjs +25 -0
- package/dist/cli/mysql-seed-loader.d.cts +3 -0
- package/dist/cli/mysql-seed.d.ts +6 -0
- package/dist/cli/mysql-seed.js +75 -0
- package/dist/cli/mysql-tools.d.ts +44 -0
- package/dist/cli/mysql-tools.js +290 -0
- package/dist/cli/no-follow.d.ts +29 -0
- package/dist/cli/no-follow.js +67 -0
- package/dist/cli/pii-predicate-guard.d.ts +1 -1
- package/dist/cli/pii-predicate-guard.js +2 -2
- package/dist/cli/pii-tags.d.ts +2 -2
- package/dist/cli/pii-tags.js +1 -1
- package/dist/cli/prisma-schema.js +2 -2
- package/dist/cli/sql-statements.d.ts +1 -1
- package/dist/cli/sql-statements.js +1 -1
- package/dist/cli/sqlite-doctor.d.ts +35 -0
- package/dist/cli/sqlite-doctor.js +392 -0
- package/dist/cli/sqlite-migrate-command.d.ts +4 -0
- package/dist/cli/sqlite-migrate-command.js +171 -0
- package/dist/cli/sqlite-migrate.d.ts +61 -0
- package/dist/cli/sqlite-migrate.js +681 -0
- package/dist/cli/sqlite-project.d.ts +42 -0
- package/dist/cli/sqlite-project.js +244 -0
- package/dist/cli/sqlite-schema-command.d.ts +4 -0
- package/dist/cli/sqlite-schema-command.js +79 -0
- package/dist/cli/sqlite-schema-ddl.d.ts +25 -0
- package/dist/cli/sqlite-schema-ddl.js +248 -0
- package/dist/cli/sqlite-schema.d.ts +25 -0
- package/dist/cli/sqlite-schema.js +330 -0
- package/dist/cli/sqlite-seed.d.ts +4 -0
- package/dist/cli/sqlite-seed.js +57 -0
- package/dist/cli/sqlite-tools.d.ts +24 -0
- package/dist/cli/sqlite-tools.js +163 -0
- package/dist/cli/studio.js +9 -9
- package/dist/cli/tool-capabilities.d.ts +72 -0
- package/dist/cli/tool-capabilities.js +114 -0
- package/dist/cli/tool-command.d.ts +11 -0
- package/dist/cli/tool-command.js +45 -0
- package/dist/cli/ui.d.ts +1 -1
- package/dist/cli/ui.js +1 -1
- package/dist/client.d.ts +20 -20
- package/dist/client.js +62 -341
- package/dist/connection-url.d.ts +1 -1
- package/dist/connection-url.js +1 -1
- package/dist/core.d.ts +58 -0
- package/dist/core.js +220 -0
- package/dist/d1/catalog-metadata.d.ts +5 -0
- package/dist/d1/catalog-metadata.js +227 -0
- package/dist/d1/catalog.d.ts +15 -0
- package/dist/d1/catalog.js +82 -0
- package/dist/d1/generate.d.ts +8 -0
- package/dist/d1/generate.js +160 -0
- package/dist/d1/introspect.d.ts +21 -0
- package/dist/d1/introspect.js +71 -0
- package/dist/d1/migrate.d.ts +29 -0
- package/dist/d1/migrate.js +217 -0
- package/dist/d1/migrations/sql.d.ts +2 -0
- package/dist/d1/migrations/sql.js +106 -0
- package/dist/d1/pool.d.ts +14 -0
- package/dist/d1/pool.js +86 -0
- package/dist/d1/sql.d.ts +5 -0
- package/dist/d1/sql.js +135 -0
- package/dist/d1/sqlite-dialect.d.ts +16 -0
- package/dist/d1/sqlite-dialect.js +572 -0
- package/dist/d1/types.d.ts +29 -0
- package/dist/d1/types.js +1 -0
- package/dist/d1.d.ts +53 -0
- package/dist/d1.js +215 -0
- package/dist/dialect.d.ts +33 -5
- package/dist/dialect.js +6 -4
- package/dist/errors.d.ts +38 -1
- package/dist/errors.js +68 -17
- package/dist/generate.d.ts +19 -3
- package/dist/generate.js +330 -97
- package/dist/global-filters-config.js +2 -2
- package/dist/index-advisor.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/introspect.d.ts +59 -356
- package/dist/introspect.js +116 -943
- package/dist/libsql/bindings.d.ts +2 -0
- package/dist/libsql/bindings.js +75 -0
- package/dist/libsql/dialect.d.ts +3 -0
- package/dist/libsql/dialect.js +45 -0
- package/dist/libsql/generate.d.ts +4 -0
- package/dist/libsql/generate.js +53 -0
- package/dist/libsql/introspect.d.ts +16 -0
- package/dist/libsql/introspect.js +289 -0
- package/dist/libsql/pool.d.ts +42 -0
- package/dist/libsql/pool.js +270 -0
- package/dist/libsql/seed-cleanup.d.ts +2 -0
- package/dist/libsql/seed-cleanup.js +15 -0
- package/dist/libsql/values.d.ts +20 -0
- package/dist/libsql/values.js +68 -0
- package/dist/libsql-seed.d.ts +19 -0
- package/dist/libsql-seed.js +46 -0
- package/dist/libsql.d.ts +28 -0
- package/dist/libsql.js +79 -0
- package/dist/live-query.d.ts +33 -0
- package/dist/live-query.js +169 -0
- package/dist/log-codes.d.ts +1 -1
- package/dist/log-codes.js +4 -0
- package/dist/mssql-seed.d.ts +27 -0
- package/dist/mssql-seed.js +114 -0
- package/dist/mssql.d.ts +7 -7
- package/dist/mssql.js +366 -54
- package/dist/mysql-seed.d.ts +25 -0
- package/dist/mysql-seed.js +165 -0
- package/dist/mysql.d.ts +18 -6
- package/dist/mysql.js +603 -95
- package/dist/neon-http/client.d.ts +95 -0
- package/dist/neon-http/client.js +286 -0
- package/dist/neon-http/sql.d.ts +3 -0
- package/dist/neon-http/sql.js +112 -0
- package/dist/neon-http.d.ts +5 -0
- package/dist/neon-http.js +2 -0
- package/dist/neon-ws/load-driver.cjs +11 -0
- package/dist/neon-ws/load-driver.d.cts +9 -0
- package/dist/neon-ws/recovery.d.ts +14 -0
- package/dist/neon-ws/recovery.js +66 -0
- package/dist/neon-ws/snapshot.d.ts +3 -0
- package/dist/neon-ws/snapshot.js +15 -0
- package/dist/neon-ws/transport.d.ts +112 -0
- package/dist/neon-ws/transport.js +286 -0
- package/dist/neon-ws.d.ts +26 -0
- package/dist/neon-ws.js +182 -0
- package/dist/nested-write.d.ts +34 -3
- package/dist/nested-write.js +114 -22
- package/dist/notification-hub/consumer.d.ts +22 -0
- package/dist/notification-hub/consumer.js +106 -0
- package/dist/notification-hub.d.ts +41 -0
- package/dist/notification-hub.js +370 -0
- package/dist/pg-catalog-text.d.ts +96 -0
- package/dist/pg-catalog-text.js +208 -0
- package/dist/pg-types.d.ts +46 -2
- package/dist/pipeline-submittable.d.ts +15 -5
- package/dist/pipeline-submittable.js +105 -50
- package/dist/pipeline.d.ts +5 -2
- package/dist/pipeline.js +113 -43
- package/dist/plan-divergence.d.ts +1 -1
- package/dist/plan-divergence.js +1 -1
- package/dist/powdb-introspect.d.ts +1 -1
- package/dist/powdb-introspect.js +5 -5
- package/dist/powdb-shared.d.ts +5 -5
- package/dist/powdb-shared.js +6 -5
- package/dist/powdb.d.ts +28 -10
- package/dist/powdb.js +80 -28
- package/dist/powql.d.ts +50 -28
- package/dist/powql.js +49 -35
- package/dist/prisma-compat.js +4 -5
- package/dist/prisma-schema-fingerprint.d.ts +1 -1
- package/dist/prisma-schema-fingerprint.js +1 -1
- package/dist/query/aggregates.d.ts +0 -13
- package/dist/query/aggregates.js +97 -230
- package/dist/query/batched-loader.d.ts +1 -1
- package/dist/query/batched-loader.js +5 -7
- package/dist/query/builder.d.ts +108 -144
- package/dist/query/builder.js +563 -864
- package/dist/query/compound-unique.d.ts +18 -3
- package/dist/query/compound-unique.js +99 -33
- package/dist/query/cursor-tuple.d.ts +17 -0
- package/dist/query/cursor-tuple.js +114 -0
- package/dist/query/expr.d.ts +2 -0
- package/dist/query/expr.js +32 -16
- package/dist/query/filters.d.ts +39 -7
- package/dist/query/filters.js +69 -14
- package/dist/query/normalize-args.d.ts +1 -1
- package/dist/query/normalize-args.js +4 -2
- package/dist/query/option-surface.d.ts +1 -1
- package/dist/query/option-surface.js +4 -2
- package/dist/query/pg-type-parsers.d.ts +126 -0
- package/dist/query/pg-type-parsers.js +296 -0
- package/dist/query/relation-names.d.ts +4 -2
- package/dist/query/relation-names.js +15 -7
- package/dist/query/relations.d.ts +19 -7
- package/dist/query/relations.js +293 -227
- package/dist/query/row-lock.js +1 -1
- package/dist/query/sql-comment.js +1 -1
- package/dist/query/stream-idle.d.ts +11 -1
- package/dist/query/stream-idle.js +51 -13
- package/dist/query/stream-signal.d.ts +21 -0
- package/dist/query/stream-signal.js +125 -0
- package/dist/query/temporal-parsers.d.ts +101 -0
- package/dist/query/temporal-parsers.js +354 -0
- package/dist/query/types.d.ts +67 -20
- package/dist/query/utils.d.ts +2 -878
- package/dist/query/utils.js +5 -2003
- package/dist/query/warn-registry.d.ts +1 -1
- package/dist/query/warn-registry.js +1 -1
- package/dist/query/where-compile.d.ts +4 -1
- package/dist/query/where-compile.js +14 -10
- package/dist/query/where.d.ts +14 -7
- package/dist/query/where.js +236 -430
- package/dist/query/writes.d.ts +33 -2
- package/dist/query/writes.js +90 -65
- package/dist/query-utils.d.ts +687 -0
- package/dist/query-utils.js +1390 -0
- package/dist/realtime.d.ts +1 -1
- package/dist/realtime.js +3 -3
- package/dist/schema-builder.js +2 -2
- package/dist/schema-metadata.d.ts +13 -3
- package/dist/schema-metadata.js +33 -5
- package/dist/schema-sql.d.ts +15 -24
- package/dist/schema-sql.js +50 -60
- package/dist/schema.d.ts +37 -2
- package/dist/schema.js +29 -2
- package/dist/seed.js +5 -5
- package/dist/serverless.d.ts +24 -71
- package/dist/serverless.js +24 -71
- package/dist/sql.d.ts +111 -0
- package/dist/sql.js +321 -0
- package/dist/sqlite-seed.d.ts +17 -0
- package/dist/sqlite-seed.js +27 -0
- package/dist/sqlite.d.ts +32 -19
- package/dist/sqlite.js +859 -648
- package/dist/supplied-pool-types.js +2 -1
- package/dist/transaction-control.js +6 -1
- package/dist/transaction-outcome.d.ts +61 -0
- package/dist/transaction-outcome.js +234 -0
- package/dist/transaction-state.d.ts +82 -13
- package/dist/transaction-state.js +220 -57
- package/dist/transaction-transport.d.ts +38 -0
- package/dist/transaction-transport.js +153 -0
- package/dist/typed-sql.d.ts +1 -1
- package/dist/typed-sql.js +1 -1
- package/package.json +239 -13
- package/skills/turbine-orm/SKILL.md +6 -5
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/** Copy configuration containers synchronously; retain driver/resource identities. */
|
|
4
|
+
function snapshot(value) {
|
|
5
|
+
if (Array.isArray(value))
|
|
6
|
+
return value.map(snapshot);
|
|
7
|
+
if (value instanceof Uint8Array)
|
|
8
|
+
return Uint8Array.prototype.slice.call(value);
|
|
9
|
+
if (value && typeof value === 'object') {
|
|
10
|
+
const prototype = Object.getPrototypeOf(value);
|
|
11
|
+
if (prototype === Object.prototype || prototype === null) {
|
|
12
|
+
return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, snapshot(entry)]));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
exports.default = snapshot;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { PgCompatPool, PgCompatPoolClient, PgCompatQueryResult } from '../pg-types.js';
|
|
2
|
+
import { createRecovery } from './recovery.js';
|
|
3
|
+
/** Only per-client Neon settings. No global-only HTTP or fetch defaults. */
|
|
4
|
+
export interface NeonWsDriverOptions {
|
|
5
|
+
webSocketConstructor?: new (...args: never[]) => unknown;
|
|
6
|
+
wsProxy?: string | ((host: string, port: number | string) => string);
|
|
7
|
+
useSecureWebSocket?: boolean;
|
|
8
|
+
forceDisablePgSSL?: boolean;
|
|
9
|
+
coalesceWrites?: boolean;
|
|
10
|
+
pipelineConnect?: 'password' | false;
|
|
11
|
+
pipelineTLS?: boolean;
|
|
12
|
+
disableSNI?: boolean;
|
|
13
|
+
disableWarningInBrowsers?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface NeonWsPoolConfig {
|
|
16
|
+
connectionString: string;
|
|
17
|
+
max?: number;
|
|
18
|
+
idleTimeoutMillis?: number;
|
|
19
|
+
connectionTimeoutMillis?: number;
|
|
20
|
+
maxLifetimeSeconds?: number;
|
|
21
|
+
application_name?: string;
|
|
22
|
+
ssl?: boolean | Record<string, unknown>;
|
|
23
|
+
}
|
|
24
|
+
/** Structural declarations keep the optional peer out of other consumers' types. */
|
|
25
|
+
export interface NeonWsClient {
|
|
26
|
+
query<R = Record<string, unknown>>(text: string, values?: unknown[]): Promise<PgCompatQueryResult<R>>;
|
|
27
|
+
readonly neonConfig: NeonWsDriverOptions;
|
|
28
|
+
on(event: string, listener: (...args: unknown[]) => void): unknown;
|
|
29
|
+
removeListener(event: string, listener: (...args: unknown[]) => void): unknown;
|
|
30
|
+
}
|
|
31
|
+
export interface NeonWsPool extends PgCompatPool {
|
|
32
|
+
}
|
|
33
|
+
export type NeonWsSource = {
|
|
34
|
+
connection: NeonWsPoolConfig;
|
|
35
|
+
driver?: NeonWsDriverOptions;
|
|
36
|
+
pool?: never;
|
|
37
|
+
client?: never;
|
|
38
|
+
} | {
|
|
39
|
+
pool: NeonWsPool;
|
|
40
|
+
connection?: never;
|
|
41
|
+
client?: never;
|
|
42
|
+
driver?: never;
|
|
43
|
+
} | {
|
|
44
|
+
client: NeonWsClient;
|
|
45
|
+
connection?: never;
|
|
46
|
+
pool?: never;
|
|
47
|
+
driver?: never;
|
|
48
|
+
};
|
|
49
|
+
interface DriverClient extends NeonWsClient {
|
|
50
|
+
connect(): Promise<void>;
|
|
51
|
+
connect(callback: (error?: Error) => void): void;
|
|
52
|
+
connection: {
|
|
53
|
+
stream: {
|
|
54
|
+
destroy(): void;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
connectionTimeoutHandle?: ReturnType<typeof setTimeout>;
|
|
58
|
+
release(error?: Error | boolean): void;
|
|
59
|
+
end(): Promise<void>;
|
|
60
|
+
_types?: unknown;
|
|
61
|
+
_connected?: boolean;
|
|
62
|
+
_ending?: boolean;
|
|
63
|
+
}
|
|
64
|
+
interface DriverPool extends NeonWsPool {
|
|
65
|
+
Client: new (config: unknown) => DriverClient;
|
|
66
|
+
on(event: 'error', listener: (error: Error) => void): this;
|
|
67
|
+
removeListener(event: string, listener: (...args: unknown[]) => void): this;
|
|
68
|
+
options?: unknown;
|
|
69
|
+
_clients?: unknown;
|
|
70
|
+
}
|
|
71
|
+
export interface NeonWsDriver {
|
|
72
|
+
Client: new (config: unknown) => DriverClient;
|
|
73
|
+
Pool: new (config: NeonWsPoolConfig) => DriverPool;
|
|
74
|
+
}
|
|
75
|
+
/** A local lease, never proof of the endpoint's backend session mode. */
|
|
76
|
+
export declare class NeonWsTransport implements PgCompatPool {
|
|
77
|
+
private readonly signal?;
|
|
78
|
+
readonly singleClient: boolean;
|
|
79
|
+
readonly transactionRecovery: ReturnType<typeof createRecovery>;
|
|
80
|
+
readonly Client: NeonWsDriver['Client'];
|
|
81
|
+
private readonly pool?;
|
|
82
|
+
private readonly client?;
|
|
83
|
+
private readonly owned;
|
|
84
|
+
private readonly active;
|
|
85
|
+
private readonly connecting;
|
|
86
|
+
private readonly closingClients;
|
|
87
|
+
private readonly observers;
|
|
88
|
+
private closed;
|
|
89
|
+
private leased;
|
|
90
|
+
private ending?;
|
|
91
|
+
private stopReason;
|
|
92
|
+
private readonly pendingStops;
|
|
93
|
+
private forcedConnections;
|
|
94
|
+
onAbort?: () => void;
|
|
95
|
+
onFailure?: (kind: 'poolError' | 'connectionLost', error: Error) => void;
|
|
96
|
+
private readonly abort;
|
|
97
|
+
private readonly idleError;
|
|
98
|
+
constructor(source: NeonWsSource, driver: NeonWsDriver, signal?: AbortSignal | undefined);
|
|
99
|
+
get options(): unknown;
|
|
100
|
+
get _clients(): unknown;
|
|
101
|
+
get totalCount(): number;
|
|
102
|
+
get idleCount(): number;
|
|
103
|
+
get waitingCount(): number;
|
|
104
|
+
assertOpen(): void;
|
|
105
|
+
private untilStopped;
|
|
106
|
+
connect(): Promise<PgCompatPoolClient>;
|
|
107
|
+
query<R = Record<string, unknown>>(text: string, values?: unknown[]): Promise<PgCompatQueryResult<R>>;
|
|
108
|
+
assertCanStop(): void;
|
|
109
|
+
stop(): number;
|
|
110
|
+
end(): Promise<void>;
|
|
111
|
+
}
|
|
112
|
+
export {};
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NeonWsTransport = void 0;
|
|
4
|
+
const errors_js_1 = require("../errors.js");
|
|
5
|
+
const recovery_js_1 = require("./recovery.js");
|
|
6
|
+
/** A local lease, never proof of the endpoint's backend session mode. */
|
|
7
|
+
class NeonWsTransport {
|
|
8
|
+
signal;
|
|
9
|
+
singleClient;
|
|
10
|
+
transactionRecovery;
|
|
11
|
+
Client;
|
|
12
|
+
pool;
|
|
13
|
+
client;
|
|
14
|
+
owned;
|
|
15
|
+
active = new Set();
|
|
16
|
+
connecting = new Set();
|
|
17
|
+
closingClients = new Set();
|
|
18
|
+
observers = new Set();
|
|
19
|
+
closed = false;
|
|
20
|
+
leased = false;
|
|
21
|
+
ending;
|
|
22
|
+
stopReason = new errors_js_1.ConnectionError('Neon WebSocket binding is disconnected');
|
|
23
|
+
pendingStops = new Set();
|
|
24
|
+
forcedConnections = 0;
|
|
25
|
+
onAbort;
|
|
26
|
+
onFailure;
|
|
27
|
+
abort = () => {
|
|
28
|
+
this.stopReason = this.signal?.reason;
|
|
29
|
+
this.stop();
|
|
30
|
+
this.onAbort?.();
|
|
31
|
+
};
|
|
32
|
+
idleError = (error) => {
|
|
33
|
+
if (this.owned && !this.closed)
|
|
34
|
+
this.onFailure?.('poolError', error);
|
|
35
|
+
};
|
|
36
|
+
constructor(source, driver, signal) {
|
|
37
|
+
this.signal = signal;
|
|
38
|
+
const keys = ['connection', 'pool', 'client'].filter((key) => source[key] !== undefined);
|
|
39
|
+
if (keys.length !== 1)
|
|
40
|
+
throw new errors_js_1.ValidationError('Neon WebSocket source must specify exactly one of connection, pool or client');
|
|
41
|
+
this.owned = source.connection !== undefined;
|
|
42
|
+
this.singleClient = source.client !== undefined;
|
|
43
|
+
this.transactionRecovery = (0, recovery_js_1.createRecovery)(this.singleClient);
|
|
44
|
+
this.Client = driver.Client;
|
|
45
|
+
if (source.connection) {
|
|
46
|
+
const settings = { ...source.driver };
|
|
47
|
+
const BaseClient = driver.Client;
|
|
48
|
+
const connecting = this.connecting;
|
|
49
|
+
class ScopedClient extends BaseClient {
|
|
50
|
+
constructor(config) {
|
|
51
|
+
super(config);
|
|
52
|
+
Object.assign(this.neonConfig, settings);
|
|
53
|
+
}
|
|
54
|
+
connect(callback) {
|
|
55
|
+
connecting.add(this);
|
|
56
|
+
const pending = new Promise((resolve, reject) => {
|
|
57
|
+
let settled = false;
|
|
58
|
+
const done = (error) => {
|
|
59
|
+
if (settled)
|
|
60
|
+
return;
|
|
61
|
+
settled = true;
|
|
62
|
+
connecting.delete(this);
|
|
63
|
+
if (error)
|
|
64
|
+
reject(error);
|
|
65
|
+
else
|
|
66
|
+
resolve();
|
|
67
|
+
};
|
|
68
|
+
try {
|
|
69
|
+
super.connect(done);
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
// Neon can reject configuration before installing its end handler.
|
|
73
|
+
// Do not await end on a stream which never opened a WebSocket.
|
|
74
|
+
done(error);
|
|
75
|
+
clearTimeout(this.connectionTimeoutHandle);
|
|
76
|
+
this.connection.stream.destroy();
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
if (callback)
|
|
80
|
+
void pending.then(() => callback(), callback);
|
|
81
|
+
else
|
|
82
|
+
return pending;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
this.pool = new driver.Pool({ ...source.connection });
|
|
86
|
+
this.pool.Client = ScopedClient;
|
|
87
|
+
}
|
|
88
|
+
else if (source.pool) {
|
|
89
|
+
if (!(source.pool instanceof driver.Pool))
|
|
90
|
+
throw new errors_js_1.ValidationError('pool must be an actual @neondatabase/serverless Pool');
|
|
91
|
+
this.pool = source.pool;
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
if (!(source.client instanceof driver.Client))
|
|
95
|
+
throw new errors_js_1.ValidationError('client must be an actual connected @neondatabase/serverless Client');
|
|
96
|
+
const supplied = source.client;
|
|
97
|
+
if (supplied._connected !== true || supplied._ending) {
|
|
98
|
+
throw new errors_js_1.ValidationError('client must already be connected and queryable before binding');
|
|
99
|
+
}
|
|
100
|
+
this.client = supplied;
|
|
101
|
+
}
|
|
102
|
+
this.pool?.on('error', this.idleError);
|
|
103
|
+
this.signal?.addEventListener('abort', this.abort, { once: true });
|
|
104
|
+
if (this.signal?.aborted)
|
|
105
|
+
this.abort();
|
|
106
|
+
}
|
|
107
|
+
get options() {
|
|
108
|
+
return this.pool?.options;
|
|
109
|
+
}
|
|
110
|
+
get _clients() {
|
|
111
|
+
return this.pool?._clients ?? (this.client ? [this.client] : []);
|
|
112
|
+
}
|
|
113
|
+
get totalCount() {
|
|
114
|
+
return this.pool?.totalCount ?? 0;
|
|
115
|
+
}
|
|
116
|
+
get idleCount() {
|
|
117
|
+
return this.pool?.idleCount ?? 0;
|
|
118
|
+
}
|
|
119
|
+
get waitingCount() {
|
|
120
|
+
return this.pool?.waitingCount ?? 0;
|
|
121
|
+
}
|
|
122
|
+
assertOpen() {
|
|
123
|
+
if (this.closed)
|
|
124
|
+
throw this.stopReason;
|
|
125
|
+
}
|
|
126
|
+
async untilStopped(operation) {
|
|
127
|
+
let rejectStop;
|
|
128
|
+
const stopped = new Promise((_resolve, reject) => {
|
|
129
|
+
rejectStop = reject;
|
|
130
|
+
});
|
|
131
|
+
this.pendingStops.add(rejectStop);
|
|
132
|
+
if (this.closed)
|
|
133
|
+
rejectStop(this.stopReason);
|
|
134
|
+
try {
|
|
135
|
+
return await Promise.race([operation, stopped]);
|
|
136
|
+
}
|
|
137
|
+
finally {
|
|
138
|
+
// A persistent binding must not retain settled query reactions until disconnect.
|
|
139
|
+
this.pendingStops.delete(rejectStop);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
async connect() {
|
|
143
|
+
this.assertOpen();
|
|
144
|
+
if (this.client && this.leased)
|
|
145
|
+
throw new errors_js_1.ConnectionError('The supplied Neon Client is already leased; use a Pool for concurrent work');
|
|
146
|
+
if (this.client)
|
|
147
|
+
this.leased = true;
|
|
148
|
+
const acquire = this.client ? Promise.resolve(this.client) : this.pool.connect();
|
|
149
|
+
let raw;
|
|
150
|
+
try {
|
|
151
|
+
// A stopped acquisition is returned promptly; the eventual checkout is destroyed below.
|
|
152
|
+
raw = await this.untilStopped(acquire);
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
if (this.client)
|
|
156
|
+
this.leased = false;
|
|
157
|
+
if (this.closed && !this.client)
|
|
158
|
+
void acquire.then((late) => late.release(true), () => { });
|
|
159
|
+
throw error;
|
|
160
|
+
}
|
|
161
|
+
if (this.closed) {
|
|
162
|
+
if (this.client)
|
|
163
|
+
this.leased = false;
|
|
164
|
+
else
|
|
165
|
+
raw.release(true);
|
|
166
|
+
throw this.stopReason;
|
|
167
|
+
}
|
|
168
|
+
const recovery = (0, recovery_js_1.createRecovery)(this.singleClient);
|
|
169
|
+
let released = false;
|
|
170
|
+
let lost;
|
|
171
|
+
const onError = (error) => {
|
|
172
|
+
if (lost)
|
|
173
|
+
return;
|
|
174
|
+
lost = error;
|
|
175
|
+
if (this.owned && !this.closed)
|
|
176
|
+
this.onFailure?.('connectionLost', error);
|
|
177
|
+
};
|
|
178
|
+
const detach = () => {
|
|
179
|
+
raw.removeListener('error', onError);
|
|
180
|
+
raw.removeListener('end', detach);
|
|
181
|
+
this.observers.delete(detach);
|
|
182
|
+
};
|
|
183
|
+
this.observers.add(detach);
|
|
184
|
+
raw.on('end', detach);
|
|
185
|
+
raw.on('error', onError);
|
|
186
|
+
const lease = {
|
|
187
|
+
release: (error) => {
|
|
188
|
+
if (released)
|
|
189
|
+
return;
|
|
190
|
+
released = true;
|
|
191
|
+
this.active.delete(lease);
|
|
192
|
+
if (this.client)
|
|
193
|
+
this.leased = false;
|
|
194
|
+
else
|
|
195
|
+
raw.release(error ?? lost);
|
|
196
|
+
// Failed pooled sockets can emit a second error while closing.
|
|
197
|
+
if (this.client || !(error || lost))
|
|
198
|
+
detach();
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
this.active.add(lease);
|
|
202
|
+
// Deliberately expose no native pg cancellation/connection internals. A WS
|
|
203
|
+
// close is not PostgreSQL CancelRequest delivery or proof of rollback.
|
|
204
|
+
return {
|
|
205
|
+
_types: raw._types,
|
|
206
|
+
transactionRecovery: recovery,
|
|
207
|
+
query: async (text, values) => {
|
|
208
|
+
this.assertOpen();
|
|
209
|
+
if (released)
|
|
210
|
+
throw new errors_js_1.ConnectionError('Neon WebSocket checkout has been released');
|
|
211
|
+
// The parser wrapper supplies query configs. Only classify their text;
|
|
212
|
+
// forward the original config (including types) and values untouched.
|
|
213
|
+
const commit = (typeof text === 'string' ? text : text.text) === 'COMMIT';
|
|
214
|
+
if (commit)
|
|
215
|
+
recovery.commitSent();
|
|
216
|
+
const result = await this.untilStopped(raw.query(text, values));
|
|
217
|
+
if (commit && result.command === 'ROLLBACK')
|
|
218
|
+
recovery.commitSent(true);
|
|
219
|
+
return result;
|
|
220
|
+
},
|
|
221
|
+
release: lease.release,
|
|
222
|
+
on: raw.on.bind(raw),
|
|
223
|
+
removeListener: raw.removeListener.bind(raw),
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
async query(text, values) {
|
|
227
|
+
const client = await this.connect();
|
|
228
|
+
try {
|
|
229
|
+
return await client.query(text, values);
|
|
230
|
+
}
|
|
231
|
+
finally {
|
|
232
|
+
client.release();
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
assertCanStop() {
|
|
236
|
+
if (this.client && this.leased)
|
|
237
|
+
throw new errors_js_1.ConnectionError('Cannot disconnect a busy caller-owned Neon Client; await its operation first');
|
|
238
|
+
}
|
|
239
|
+
stop() {
|
|
240
|
+
if (this.closed)
|
|
241
|
+
return this.forcedConnections;
|
|
242
|
+
this.forcedConnections = this.client ? 0 : this.active.size + this.connecting.size;
|
|
243
|
+
this.closed = true;
|
|
244
|
+
for (const reject of this.pendingStops)
|
|
245
|
+
reject(this.stopReason);
|
|
246
|
+
this.pendingStops.clear();
|
|
247
|
+
// Only the owned subclass is tracked here. Destroy the stream before end():
|
|
248
|
+
// a graceful Terminate can itself wait on the unfinished startup handshake.
|
|
249
|
+
// The driver's connect callback removes the failed Client from its Pool.
|
|
250
|
+
for (const raw of this.connecting) {
|
|
251
|
+
const closed = new Promise((resolve) => {
|
|
252
|
+
const done = () => {
|
|
253
|
+
raw.removeListener('end', done);
|
|
254
|
+
resolve();
|
|
255
|
+
};
|
|
256
|
+
raw.on('end', done);
|
|
257
|
+
});
|
|
258
|
+
this.closingClients.add(closed);
|
|
259
|
+
void closed.then(() => this.closingClients.delete(closed));
|
|
260
|
+
raw.connection.stream.destroy();
|
|
261
|
+
}
|
|
262
|
+
// A supplied single Client belongs to the caller and is never terminated.
|
|
263
|
+
for (const lease of [...this.active])
|
|
264
|
+
if (!this.client)
|
|
265
|
+
lease.release(true);
|
|
266
|
+
this.signal?.removeEventListener('abort', this.abort);
|
|
267
|
+
return this.forcedConnections;
|
|
268
|
+
}
|
|
269
|
+
end() {
|
|
270
|
+
this.stop();
|
|
271
|
+
if (!this.ending) {
|
|
272
|
+
this.ending = (async () => {
|
|
273
|
+
try {
|
|
274
|
+
if (this.owned)
|
|
275
|
+
await this.pool.end();
|
|
276
|
+
await Promise.all(this.closingClients);
|
|
277
|
+
}
|
|
278
|
+
finally {
|
|
279
|
+
this.pool?.removeListener('error', this.idleError);
|
|
280
|
+
for (const detach of this.observers)
|
|
281
|
+
detach();
|
|
282
|
+
this.onFailure = undefined;
|
|
283
|
+
this.onAbort = undefined;
|
|
284
|
+
}
|
|
285
|
+
})();
|
|
286
|
+
}
|
|
287
|
+
return this.ending;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
exports.NeonWsTransport = NeonWsTransport;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Optional Neon Pool/Client WebSocket binding. See docs/neon-websocket.md. */
|
|
2
|
+
import { TurbineClient } from './client.js';
|
|
3
|
+
import type { EngineClientConfig } from './engine-config.js';
|
|
4
|
+
import { type NeonWsSource } from './neon-ws/transport.js';
|
|
5
|
+
import type { SchemaMetadata } from './schema.js';
|
|
6
|
+
export type { NeonWsClient, NeonWsDriverOptions, NeonWsPool, NeonWsPoolConfig, NeonWsSource, } from './neon-ws/transport.js';
|
|
7
|
+
export interface NeonWsOptions extends EngineClientConfig {
|
|
8
|
+
/** Explicit assertion about the actual endpoint, not its checked-out logical client. */
|
|
9
|
+
sessionMode: 'persistent' | 'transaction';
|
|
10
|
+
/** Edge connections must be created, used and closed inside one invocation. */
|
|
11
|
+
lifetime: 'persistent' | 'invocation';
|
|
12
|
+
/** Ends this binding and destroys its pooled checkouts. Unsupported for a supplied Client. */
|
|
13
|
+
signal?: AbortSignal;
|
|
14
|
+
/** Names default off; transaction poolers cannot enable them here. */
|
|
15
|
+
preparedStatements?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Bind an owned Pool, a caller-owned Neon Pool, or an already-connected exclusive
|
|
19
|
+
* Neon Client. Supplied resources are never ended. No driver globals are changed.
|
|
20
|
+
* The generated client type adds declarative table accessors, as with turbineHttp.
|
|
21
|
+
*/
|
|
22
|
+
export declare function turbineNeonWs<TClient extends TurbineClient = TurbineClient>(source: NeonWsSource, schema: SchemaMetadata, options: NeonWsOptions): Promise<TClient>;
|
|
23
|
+
/** Own a Pool for exactly one invocation, closing on success, failure or abort. */
|
|
24
|
+
export declare function withNeonWs<T, TClient extends TurbineClient = TurbineClient>(source: Extract<NeonWsSource, {
|
|
25
|
+
connection: unknown;
|
|
26
|
+
}>, schema: SchemaMetadata, options: Omit<NeonWsOptions, 'lifetime'>, run: (db: TClient) => Promise<T>): Promise<T>;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.turbineNeonWs = turbineNeonWs;
|
|
7
|
+
exports.withNeonWs = withNeonWs;
|
|
8
|
+
/** Optional Neon Pool/Client WebSocket binding. See docs/neon-websocket.md. */
|
|
9
|
+
const client_js_1 = require("./client.js");
|
|
10
|
+
const errors_js_1 = require("./errors.js");
|
|
11
|
+
const load_driver_cjs_1 = __importDefault(require("./neon-ws/load-driver.cjs"));
|
|
12
|
+
const snapshot_js_1 = __importDefault(require("./neon-ws/snapshot.js"));
|
|
13
|
+
const transport_js_1 = require("./neon-ws/transport.js");
|
|
14
|
+
// Keep supported inherited accessors exhaustive as the public interfaces evolve.
|
|
15
|
+
// Unknown own enumerable fields still pass through, matching ordinary object spread.
|
|
16
|
+
const optionFields = {
|
|
17
|
+
logging: true,
|
|
18
|
+
logger: true,
|
|
19
|
+
diagnostics: true,
|
|
20
|
+
defaultLimit: true,
|
|
21
|
+
warnOnUnlimited: true,
|
|
22
|
+
utcTimestamps: true,
|
|
23
|
+
temporalInfinity: true,
|
|
24
|
+
planCacheMode: true,
|
|
25
|
+
statementTimeoutMs: true,
|
|
26
|
+
streamIdleTimeoutMs: true,
|
|
27
|
+
sqlComment: true,
|
|
28
|
+
scopedConnect: true,
|
|
29
|
+
relationLoadStrategy: true,
|
|
30
|
+
stableRelationOrder: true,
|
|
31
|
+
implicitPkOrdering: true,
|
|
32
|
+
autoToOneJoinMaxRows: true,
|
|
33
|
+
autoRoundTripMs: true,
|
|
34
|
+
jsonEncoding: true,
|
|
35
|
+
errorMessages: true,
|
|
36
|
+
logQueryParams: true,
|
|
37
|
+
sqlCache: true,
|
|
38
|
+
sqlCacheSize: true,
|
|
39
|
+
globalFilters: true,
|
|
40
|
+
sessionMode: true,
|
|
41
|
+
lifetime: true,
|
|
42
|
+
signal: true,
|
|
43
|
+
preparedStatements: true,
|
|
44
|
+
};
|
|
45
|
+
const connectionFields = {
|
|
46
|
+
connectionString: true,
|
|
47
|
+
max: true,
|
|
48
|
+
idleTimeoutMillis: true,
|
|
49
|
+
connectionTimeoutMillis: true,
|
|
50
|
+
maxLifetimeSeconds: true,
|
|
51
|
+
application_name: true,
|
|
52
|
+
ssl: true,
|
|
53
|
+
};
|
|
54
|
+
const driverFields = {
|
|
55
|
+
webSocketConstructor: true,
|
|
56
|
+
wsProxy: true,
|
|
57
|
+
useSecureWebSocket: true,
|
|
58
|
+
forceDisablePgSSL: true,
|
|
59
|
+
coalesceWrites: true,
|
|
60
|
+
pipelineConnect: true,
|
|
61
|
+
pipelineTLS: true,
|
|
62
|
+
disableSNI: true,
|
|
63
|
+
disableWarningInBrowsers: true,
|
|
64
|
+
};
|
|
65
|
+
/** Capture supported effective fields once, without invoking unrelated class getters. */
|
|
66
|
+
function effective(value, fields) {
|
|
67
|
+
const keys = new Set([...Object.keys(value), ...Object.keys(fields)]);
|
|
68
|
+
return Object.fromEntries([...keys].filter((key) => key in value).map((key) => [key, Reflect.get(value, key)]));
|
|
69
|
+
}
|
|
70
|
+
class NeonWsTurbine extends client_js_1.TurbineClient {
|
|
71
|
+
transport;
|
|
72
|
+
wsOptions;
|
|
73
|
+
closing;
|
|
74
|
+
constructor(transport, schema, wsOptions) {
|
|
75
|
+
const { sessionMode: _mode, lifetime: _lifetime, signal: _signal, ...config } = wsOptions;
|
|
76
|
+
super({ ...config, pool: transport, preparedStatements: config.preparedStatements ?? false }, schema);
|
|
77
|
+
this.transport = transport;
|
|
78
|
+
this.wsOptions = wsOptions;
|
|
79
|
+
transport.onFailure = (kind, error) => this.emitPoolEvent(kind, { error, pool: 'primary' });
|
|
80
|
+
}
|
|
81
|
+
async $listen(channel, handler, options) {
|
|
82
|
+
if (this.wsOptions.sessionMode !== 'persistent' ||
|
|
83
|
+
this.wsOptions.lifetime !== 'persistent' ||
|
|
84
|
+
this.transport.singleClient) {
|
|
85
|
+
throw new errors_js_1.UnsupportedFeatureError('$listen', 'Neon WebSocket', 'Requires an explicitly persistent backend session, persistent lifetime and a Pool with a dedicated listener slot.');
|
|
86
|
+
}
|
|
87
|
+
this.transport.assertOpen();
|
|
88
|
+
return super.$listen(channel, handler, options);
|
|
89
|
+
}
|
|
90
|
+
async disconnect(options) {
|
|
91
|
+
if (options?.timeoutMs !== undefined && (!Number.isSafeInteger(options.timeoutMs) || options.timeoutMs < 0)) {
|
|
92
|
+
throw new errors_js_1.ValidationError('disconnect timeoutMs must be a non-negative safe integer');
|
|
93
|
+
}
|
|
94
|
+
if (!this.closing) {
|
|
95
|
+
// Stop acquisition before subscription teardown, including a reconnect already in flight.
|
|
96
|
+
this.transport.assertCanStop();
|
|
97
|
+
const forcedConnections = this.transport.stop();
|
|
98
|
+
this.closing = (async () => {
|
|
99
|
+
try {
|
|
100
|
+
await super.disconnect();
|
|
101
|
+
}
|
|
102
|
+
finally {
|
|
103
|
+
await this.transport.end();
|
|
104
|
+
}
|
|
105
|
+
return { timedOut: false, forcedConnections };
|
|
106
|
+
})();
|
|
107
|
+
}
|
|
108
|
+
const result = await this.closing;
|
|
109
|
+
return options === undefined ? undefined : result;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Bind an owned Pool, a caller-owned Neon Pool, or an already-connected exclusive
|
|
114
|
+
* Neon Client. Supplied resources are never ended. No driver globals are changed.
|
|
115
|
+
* The generated client type adds declarative table accessors, as with turbineHttp.
|
|
116
|
+
*/
|
|
117
|
+
async function turbineNeonWs(source, schema, options) {
|
|
118
|
+
// Admission and construction must consume the same inputs, including while
|
|
119
|
+
// optional driver resolution yields. Resource and AbortSignal identities stay intact.
|
|
120
|
+
const { logger, ...configuration } = effective(options ?? {}, optionFields);
|
|
121
|
+
options = { ...(0, snapshot_js_1.default)(configuration), logger };
|
|
122
|
+
const { connection, driver: settings, pool, client } = source;
|
|
123
|
+
const connectionConfig = connection === undefined ? undefined : effective(connection, connectionFields);
|
|
124
|
+
const ssl = connectionConfig?.ssl;
|
|
125
|
+
source = {
|
|
126
|
+
connection: connectionConfig === undefined
|
|
127
|
+
? undefined
|
|
128
|
+
: (0, snapshot_js_1.default)({
|
|
129
|
+
...connectionConfig,
|
|
130
|
+
ssl: ssl && typeof ssl === 'object'
|
|
131
|
+
? effective(ssl, { rejectUnauthorized: true, ca: true, key: true, cert: true, servername: true })
|
|
132
|
+
: ssl,
|
|
133
|
+
}),
|
|
134
|
+
driver: settings === undefined ? undefined : (0, snapshot_js_1.default)(effective(settings, driverFields)),
|
|
135
|
+
pool,
|
|
136
|
+
client,
|
|
137
|
+
};
|
|
138
|
+
if (!options ||
|
|
139
|
+
!['persistent', 'transaction'].includes(options.sessionMode) ||
|
|
140
|
+
!['persistent', 'invocation'].includes(options.lifetime)) {
|
|
141
|
+
throw new errors_js_1.ValidationError('Neon WebSocket requires explicit sessionMode and lifetime');
|
|
142
|
+
}
|
|
143
|
+
if (options.sessionMode === 'transaction' && options.preparedStatements === true) {
|
|
144
|
+
throw new errors_js_1.UnsupportedFeatureError('preparedStatements', 'Neon transaction pooler', 'Named statements require an explicitly compatible backend; leave preparedStatements disabled.');
|
|
145
|
+
}
|
|
146
|
+
if (source.client !== undefined && options.signal) {
|
|
147
|
+
throw new errors_js_1.UnsupportedFeatureError('signal', 'caller-owned Neon Client', 'Cancellation would require ending the caller connection. Use an owned Pool or caller-owned Pool instead.');
|
|
148
|
+
}
|
|
149
|
+
options.signal?.throwIfAborted();
|
|
150
|
+
// Optional package resolution is deferred until the optional factory is called.
|
|
151
|
+
let driver;
|
|
152
|
+
try {
|
|
153
|
+
driver = await (0, load_driver_cjs_1.default)();
|
|
154
|
+
}
|
|
155
|
+
catch (cause) {
|
|
156
|
+
throw new errors_js_1.ConnectionError('Neon WebSocket requires the optional @neondatabase/serverless package (1.2 or later). Install @neondatabase/serverless.', { cause });
|
|
157
|
+
}
|
|
158
|
+
const transport = new transport_js_1.NeonWsTransport(source, driver, options.signal);
|
|
159
|
+
try {
|
|
160
|
+
const db = new NeonWsTurbine(transport, schema, { ...options });
|
|
161
|
+
transport.onAbort = () => {
|
|
162
|
+
void db.disconnect().catch(() => { });
|
|
163
|
+
};
|
|
164
|
+
if (options.signal?.aborted) {
|
|
165
|
+
await db.disconnect();
|
|
166
|
+
options.signal.throwIfAborted();
|
|
167
|
+
}
|
|
168
|
+
return db;
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
await transport.end();
|
|
172
|
+
throw error;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/** Own a Pool for exactly one invocation, closing on success, failure or abort. */
|
|
176
|
+
async function withNeonWs(source, schema, options, run) {
|
|
177
|
+
if (!('connection' in source))
|
|
178
|
+
throw new errors_js_1.ValidationError('withNeonWs requires an owned connection configuration');
|
|
179
|
+
const db = await turbineNeonWs(source, schema, {
|
|
180
|
+
...effective(options, optionFields),
|
|
181
|
+
lifetime: 'invocation',
|
|
182
|
+
});
|
|
183
|
+
try {
|
|
184
|
+
return await run(db);
|
|
185
|
+
}
|
|
186
|
+
finally {
|
|
187
|
+
await db.disconnect();
|
|
188
|
+
}
|
|
189
|
+
}
|