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
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
* `SET transaction_timeout` (v23.1+) for per-transaction time limits.
|
|
12
12
|
*
|
|
13
13
|
* 3. **`pg_indexes` view**, CockroachDB supports `pg_indexes` since v22.1
|
|
14
|
-
*
|
|
15
|
-
*
|
|
14
|
+
* with `tablename`, `indexname`, and `indexdef` columns consumed by the
|
|
15
|
+
* standard introspection flow.
|
|
16
16
|
*
|
|
17
|
-
* 4. **`pg_class.reltuples`**, Not reliable in CockroachDB.
|
|
17
|
+
* 4. **`pg_class.reltuples`**, Not reliable in CockroachDB. The adapter uses
|
|
18
18
|
* `crdb_internal.table_row_statistics` for row estimates.
|
|
19
19
|
*
|
|
20
20
|
* Known limitations with Turbine on CockroachDB:
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
* `SET transaction_timeout` (v23.1+) for per-transaction time limits.
|
|
13
13
|
*
|
|
14
14
|
* 3. **`pg_indexes` view**, CockroachDB supports `pg_indexes` since v22.1
|
|
15
|
-
*
|
|
16
|
-
*
|
|
15
|
+
* with `tablename`, `indexname`, and `indexdef` columns consumed by the
|
|
16
|
+
* standard introspection flow.
|
|
17
17
|
*
|
|
18
|
-
* 4. **`pg_class.reltuples`**, Not reliable in CockroachDB.
|
|
18
|
+
* 4. **`pg_class.reltuples`**, Not reliable in CockroachDB. The adapter uses
|
|
19
19
|
* `crdb_internal.table_row_statistics` for row estimates.
|
|
20
20
|
*
|
|
21
21
|
* Known limitations with Turbine on CockroachDB:
|
|
@@ -71,8 +71,8 @@ const SQL_INDEXES_CRDB = `
|
|
|
71
71
|
WHERE schemaname = $1
|
|
72
72
|
`;
|
|
73
73
|
/**
|
|
74
|
-
* Row
|
|
75
|
-
*
|
|
74
|
+
* Row-estimates override query using crdb_internal, with zero for tables
|
|
75
|
+
* lacking statistics.
|
|
76
76
|
*/
|
|
77
77
|
const SQL_ROW_ESTIMATES_CRDB = `
|
|
78
78
|
SELECT
|
|
@@ -86,8 +86,7 @@ const SQL_ROW_ESTIMATES_CRDB = `
|
|
|
86
86
|
`;
|
|
87
87
|
/**
|
|
88
88
|
* Enum introspection, CockroachDB supports pg_type/pg_enum since v20.2.
|
|
89
|
-
* The
|
|
90
|
-
* mechanism is complete.
|
|
89
|
+
* The override uses the same catalog columns as PostgreSQL.
|
|
91
90
|
*/
|
|
92
91
|
const SQL_ENUMS_CRDB = `
|
|
93
92
|
SELECT t.typname, e.enumlabel
|
|
@@ -122,7 +121,6 @@ exports.cockroachdb = {
|
|
|
122
121
|
return CREATE_LOCK_TABLE_SQL;
|
|
123
122
|
},
|
|
124
123
|
async acquireLock(client, lockId) {
|
|
125
|
-
// Ensure the lock table exists
|
|
126
124
|
await client.query(CREATE_LOCK_TABLE_SQL);
|
|
127
125
|
// Insert the lock row if it doesn't exist (idempotent)
|
|
128
126
|
await client.query(`INSERT INTO "${LOCK_TABLE}" (lock_id) VALUES ($1) ON CONFLICT (lock_id) DO NOTHING`, [lockId]);
|
|
@@ -130,9 +128,8 @@ exports.cockroachdb = {
|
|
|
130
128
|
try {
|
|
131
129
|
await client.query('BEGIN');
|
|
132
130
|
await client.query(`SELECT lock_id FROM "${LOCK_TABLE}" WHERE lock_id = $1 FOR UPDATE NOWAIT`, [lockId]);
|
|
133
|
-
// Update the acquired metadata
|
|
134
131
|
await client.query(`UPDATE "${LOCK_TABLE}" SET acquired_at = now(), acquired_by = current_user WHERE lock_id = $1`, [lockId]);
|
|
135
|
-
//
|
|
132
|
+
// The transaction stays OPEN: the lock is held until
|
|
136
133
|
// releaseLock() commits or rolls back. That is why this adapter sets
|
|
137
134
|
// `lockHoldsOpenTransaction` and the runner hands it its own connection:
|
|
138
135
|
// on a shared one, the first migration's COMMIT would end this.
|
|
@@ -150,7 +147,6 @@ exports.cockroachdb = {
|
|
|
150
147
|
}
|
|
151
148
|
return false;
|
|
152
149
|
}
|
|
153
|
-
// Any other error, rollback and re-throw
|
|
154
150
|
try {
|
|
155
151
|
await client.query('ROLLBACK');
|
|
156
152
|
}
|
|
@@ -20,7 +20,7 @@ import type { PgCompatPoolClient } from '../client.js';
|
|
|
20
20
|
* pg_catalog or information_schema behaves differently.
|
|
21
21
|
*/
|
|
22
22
|
export interface IntrospectionOverrides {
|
|
23
|
-
/** Override the pg_indexes query
|
|
23
|
+
/** Override the pg_indexes query. CockroachDB supplies a pg_indexes compatibility query. */
|
|
24
24
|
indexes: string;
|
|
25
25
|
/** Override the pg_enum query */
|
|
26
26
|
enums: string;
|
|
@@ -71,7 +71,7 @@ const CREATE_LOCK_TABLE_SQL = `
|
|
|
71
71
|
// ---------------------------------------------------------------------------
|
|
72
72
|
/**
|
|
73
73
|
* Row estimates override. YugabyteDB's pg_class.reltuples can be stale or
|
|
74
|
-
* zero.
|
|
74
|
+
* zero. The query still returns estimates, but they may lag behind actual
|
|
75
75
|
* row counts. This query matches the PostgreSQL format so the introspection
|
|
76
76
|
* consumer doesn't need special handling.
|
|
77
77
|
*
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type { SchemaMetadata } from './schema.js';
|
|
2
|
+
import { introspectSqliteDatabase, type TurbineSqliteOptions } from './sqlite.js';
|
|
3
|
+
/** Structural peer types: consumers do not need @types/better-sqlite3. */
|
|
4
|
+
interface BetterStatement {
|
|
5
|
+
readonly source: string;
|
|
6
|
+
readonly reader: boolean;
|
|
7
|
+
all(...params: unknown[]): Record<string, unknown>[];
|
|
8
|
+
get(...params: unknown[]): Record<string, unknown> | undefined;
|
|
9
|
+
run(...params: unknown[]): {
|
|
10
|
+
changes: number | bigint;
|
|
11
|
+
lastInsertRowid: number | bigint;
|
|
12
|
+
};
|
|
13
|
+
iterate(...params: unknown[]): IterableIterator<Record<string, unknown>>;
|
|
14
|
+
columns(): {
|
|
15
|
+
name: string;
|
|
16
|
+
column: string | null;
|
|
17
|
+
table: string | null;
|
|
18
|
+
database: string | null;
|
|
19
|
+
type: string | null;
|
|
20
|
+
}[];
|
|
21
|
+
safeIntegers(enabled?: boolean): unknown;
|
|
22
|
+
raw(enabled?: boolean): unknown;
|
|
23
|
+
}
|
|
24
|
+
export interface BetterSqlite3Database {
|
|
25
|
+
readonly open: boolean;
|
|
26
|
+
readonly inTransaction: boolean;
|
|
27
|
+
prepare(sql: string): BetterStatement;
|
|
28
|
+
exec(sql: string): unknown;
|
|
29
|
+
close(): unknown;
|
|
30
|
+
}
|
|
31
|
+
export type TurbineBetterSqlite3Options = TurbineSqliteOptions;
|
|
32
|
+
/** SQLite wire decoding depends on this binding, including on Node without node:sqlite. */
|
|
33
|
+
export declare const betterSqlite3Dialect: {
|
|
34
|
+
name: import("./dialect.js").DialectName;
|
|
35
|
+
capabilities: import("./dialect.js").EngineCapabilities;
|
|
36
|
+
resultStrategy: import("./dialect.js").ResultStrategy;
|
|
37
|
+
paramPlaceholder(index: number): string;
|
|
38
|
+
quoteIdentifier(name: string): string;
|
|
39
|
+
escapeStringLiteral(value: string): string;
|
|
40
|
+
emptyJsonArrayLiteral: string;
|
|
41
|
+
nullJsonLiteral: string;
|
|
42
|
+
buildJsonObject(pairs: [key: string, expr: string][]): string;
|
|
43
|
+
buildJsonArray?(exprs: string[]): string;
|
|
44
|
+
buildJsonArrayAgg(jsonObjectExpr: string, orderBy?: string): string;
|
|
45
|
+
aggSupportsInlineOrderBy: boolean;
|
|
46
|
+
inlineLimitOffset?: boolean;
|
|
47
|
+
wrapJsonSubresult(subquery: string, fallback: string): string;
|
|
48
|
+
supportsReturning: boolean;
|
|
49
|
+
supportsUpsertUpdateWhere?: boolean;
|
|
50
|
+
supportsVector: boolean;
|
|
51
|
+
supportsJsonContains: boolean;
|
|
52
|
+
supportsFullTextSearch?: boolean;
|
|
53
|
+
supportsArrayColumns?: boolean;
|
|
54
|
+
supportsListenNotify: boolean;
|
|
55
|
+
supportsRLS: boolean;
|
|
56
|
+
supportsAdvisoryLock: boolean;
|
|
57
|
+
supportsPlanCacheMode?: boolean;
|
|
58
|
+
supportsLateralJoin?: boolean;
|
|
59
|
+
rowLockModes?: readonly import("./index.js").RowLockMode[];
|
|
60
|
+
supportsPercentileAggregates?: boolean;
|
|
61
|
+
supportsBulkUpsert?: boolean;
|
|
62
|
+
upsertTargetAlias?: string;
|
|
63
|
+
explainQuery?: {
|
|
64
|
+
prefix: string;
|
|
65
|
+
};
|
|
66
|
+
buildReturningClause(selection?: import("./dialect.js").ReturningSelection): string;
|
|
67
|
+
buildInsertStatement(input: import("./dialect.js").InsertStatementInput): string;
|
|
68
|
+
buildBulkInsertStatement(input: import("./dialect.js").BulkInsertStatementInput): import("./dialect.js").BuiltStatement;
|
|
69
|
+
buildDefaultValuesInsertStatement?(input: import("./dialect.js").DefaultValuesInsertStatementInput): string;
|
|
70
|
+
buildUpsertStatement(input: import("./dialect.js").UpsertStatementInput): string;
|
|
71
|
+
buildBulkUpsertStatement?(input: import("./dialect.js").BulkUpsertStatementInput): import("./dialect.js").BuiltStatement;
|
|
72
|
+
supportsILike: boolean;
|
|
73
|
+
buildInsensitiveLike(column: string, paramRef: string): string;
|
|
74
|
+
escapeLikePattern?(value: string): string;
|
|
75
|
+
likeEscapeCharacter?: string;
|
|
76
|
+
jsonPathSupport: "native" | "function" | "limited";
|
|
77
|
+
buildJsonContains(column: string, paramRef: string): string;
|
|
78
|
+
buildJsonPathExtract(column: string, pathParamRef: string): string;
|
|
79
|
+
buildJsonPathEquals?(input: import("./dialect.js").JsonPathEqualsInput): string;
|
|
80
|
+
buildCorrelation(leftRef: string, leftColumns: string | string[], rightRef: string, rightColumns: string | string[]): string;
|
|
81
|
+
jsonWireRule?(columnType: string): import("./dialect.js").JsonWireRule | undefined;
|
|
82
|
+
decodeColumnValue?(columnType: string): ((value: unknown) => unknown) | undefined;
|
|
83
|
+
typeToTypeScript?(dialectType: string, nullable: boolean): string;
|
|
84
|
+
castAggregate?(expr: string, target: "int" | "float"): string;
|
|
85
|
+
averageArgument?(columnRef: string, columnType: string): string | undefined;
|
|
86
|
+
buildInClause?(expr: string, paramRef: string, negated: boolean): string;
|
|
87
|
+
inClauseParam?(values: unknown[]): unknown;
|
|
88
|
+
checkTextWrite?(table: string, column: string, columnType: string, value: string): string | undefined;
|
|
89
|
+
buildEnumColumn?(column: string, labels: readonly string[]): {
|
|
90
|
+
type: string;
|
|
91
|
+
maxLength?: number | null;
|
|
92
|
+
check?: string;
|
|
93
|
+
};
|
|
94
|
+
arrayType?(baseType: string): string;
|
|
95
|
+
buildColumnType(input: import("./dialect.js").ColumnTypeInput): string;
|
|
96
|
+
buildColumnDefinition(input: import("./dialect.js").ColumnDefinitionInput): string;
|
|
97
|
+
buildPrimaryKeyConstraint(columns: string[]): string;
|
|
98
|
+
buildCreateTableStatement(input: import("./dialect.js").CreateTableStatementInput): string;
|
|
99
|
+
buildCreateIndexStatement(input: import("./dialect.js").CreateIndexStatementInput): string;
|
|
100
|
+
buildMigrationTrackingTable(table: string): string;
|
|
101
|
+
buildMigrationSelectApplied(table: string): string;
|
|
102
|
+
buildMigrationUpdateChecksum(table: string): string;
|
|
103
|
+
buildMigrationInsertApplied(table: string): string;
|
|
104
|
+
buildMigrationDeleteApplied(table: string): string;
|
|
105
|
+
beginStatement(isolationLevel?: string): string;
|
|
106
|
+
commitStatement(): string;
|
|
107
|
+
rollbackStatement(): string;
|
|
108
|
+
savepointStatement(name: string): string;
|
|
109
|
+
releaseSavepointStatement(name: string): string;
|
|
110
|
+
rollbackToSavepointStatement(name: string): string;
|
|
111
|
+
buildSetSessionConfig(name: string, value: string): import("./dialect.js").BuiltStatement;
|
|
112
|
+
openStream(connection: import("./dialect.js").StreamableConnection, sql: string, params: unknown[], batchSize: number, opts?: import("./dialect.js").OpenStreamOptions): AsyncGenerator<Record<string, unknown>[], void, undefined>;
|
|
113
|
+
introspector?: import("./dialect.js").DialectIntrospector;
|
|
114
|
+
buildLimitOffset?(input: import("./dialect.js").LimitOffsetInput): string;
|
|
115
|
+
buildUpdateStatement?(input: import("./dialect.js").UpdateStatementInput): string;
|
|
116
|
+
buildDeleteStatement?(input: import("./dialect.js").DeleteStatementInput): string;
|
|
117
|
+
buildRelationSubquery?(ctx: import("./dialect.js").RelationSubqueryContext): string;
|
|
118
|
+
buildPartitionLimit?(input: import("./dialect.js").PartitionLimitInput): string;
|
|
119
|
+
};
|
|
120
|
+
/** Introspect a supplied handle without closing or changing it. */
|
|
121
|
+
export declare function introspectBetterSqlite3Database(handle: BetterSqlite3Database, options?: Parameters<typeof introspectSqliteDatabase>[1]): {
|
|
122
|
+
tables: Record<string, import("./schema.js").TableMetadata>;
|
|
123
|
+
enums: {};
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Create a typed client with the optional better-sqlite3 peer. Paths are client
|
|
127
|
+
* owned; supplied handles remain caller owned. The same pool enforces FIFO
|
|
128
|
+
* transaction/iterator ownership, rollback on release and incremental streaming.
|
|
129
|
+
* Synchronous SQLite work can observe cancellation only between pulls.
|
|
130
|
+
*/
|
|
131
|
+
export declare function turbineBetterSqlite3(target: string | BetterSqlite3Database, schema: SchemaMetadata, options?: TurbineBetterSqlite3Options): Promise<import("./client.js").TurbineClient>;
|
|
132
|
+
export {};
|
|
@@ -0,0 +1,311 @@
|
|
|
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.betterSqlite3Dialect = void 0;
|
|
7
|
+
exports.introspectBetterSqlite3Database = introspectBetterSqlite3Database;
|
|
8
|
+
exports.turbineBetterSqlite3 = turbineBetterSqlite3;
|
|
9
|
+
const sqlite_dialect_js_1 = require("./d1/sqlite-dialect.js");
|
|
10
|
+
const errors_js_1 = require("./errors.js");
|
|
11
|
+
const optional_peer_import_cjs_1 = __importDefault(require("./optional-peer-import.cjs"));
|
|
12
|
+
const sql_placeholders_js_1 = require("./sql-placeholders.js");
|
|
13
|
+
const sqlite_js_1 = require("./sqlite.js");
|
|
14
|
+
// The peer's Node 20 object-row path drops a result column named __proto__.
|
|
15
|
+
// Read arrays on that runtime and define own fields before shared decoding.
|
|
16
|
+
const arrayRows = Number(process.versions.node.split('.')[0]) < 22;
|
|
17
|
+
// The existing SQLite error translator consumes the real extended result code.
|
|
18
|
+
// Do not infer constraint kinds from user-controlled error text.
|
|
19
|
+
const codes = {
|
|
20
|
+
SQLITE_ERROR: 1,
|
|
21
|
+
SQLITE_BUSY: 5,
|
|
22
|
+
SQLITE_LOCKED: 6,
|
|
23
|
+
SQLITE_BUSY_RECOVERY: 261,
|
|
24
|
+
SQLITE_BUSY_SNAPSHOT: 517,
|
|
25
|
+
SQLITE_BUSY_TIMEOUT: 773,
|
|
26
|
+
SQLITE_LOCKED_SHAREDCACHE: 262,
|
|
27
|
+
SQLITE_LOCKED_VTAB: 518,
|
|
28
|
+
SQLITE_CONSTRAINT_CHECK: 275,
|
|
29
|
+
SQLITE_CONSTRAINT_FOREIGNKEY: 787,
|
|
30
|
+
SQLITE_CONSTRAINT_NOTNULL: 1299,
|
|
31
|
+
SQLITE_CONSTRAINT_PRIMARYKEY: 1555,
|
|
32
|
+
SQLITE_CONSTRAINT_UNIQUE: 2067,
|
|
33
|
+
};
|
|
34
|
+
function nativeCall(fn) {
|
|
35
|
+
try {
|
|
36
|
+
return fn();
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
if (error && typeof error === 'object' && 'code' in error && typeof error.code === 'string') {
|
|
40
|
+
const code = codes[error.code];
|
|
41
|
+
if (code !== undefined)
|
|
42
|
+
Object.assign(error, { errcode: code });
|
|
43
|
+
}
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** SQL-only analysis. Values and their accessors are read afresh on every call. */
|
|
48
|
+
function bindingPlan(sql) {
|
|
49
|
+
// Canonicalize native names to equal-width positional tokens for the existing
|
|
50
|
+
// lexer. Quotes, comments and identifier boundaries still determine which
|
|
51
|
+
// matches are code; the SQL given to the native engine is never rewritten.
|
|
52
|
+
const tokens = (0, sql_placeholders_js_1.scanPlaceholders)(sql.replace(/[:@$][\w$\u0080-]+/g, (name) => `$${'0'.repeat(name.length - 1)}`), 'sqlite');
|
|
53
|
+
const names = new Map();
|
|
54
|
+
const slots = new Map();
|
|
55
|
+
let last = 0;
|
|
56
|
+
for (const token of tokens) {
|
|
57
|
+
if (token.kind === 'question') {
|
|
58
|
+
const digits = /^\d+/.exec(sql.slice(token.end))?.[0];
|
|
59
|
+
if (digits) {
|
|
60
|
+
const index = Number(digits);
|
|
61
|
+
if (!slots.has(index))
|
|
62
|
+
slots.set(index, digits);
|
|
63
|
+
names.set(digits, index);
|
|
64
|
+
last = Math.max(last, index);
|
|
65
|
+
}
|
|
66
|
+
else
|
|
67
|
+
last++;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
const full = sql.slice(token.start, token.end);
|
|
71
|
+
if (!names.has(full)) {
|
|
72
|
+
names.set(full, ++last);
|
|
73
|
+
slots.set(last, full.slice(1));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return { slots, last };
|
|
78
|
+
}
|
|
79
|
+
/** Adapt named bindings, including SQLite's NULL defaults for omitted values. */
|
|
80
|
+
function binding(params, { slots, last }) {
|
|
81
|
+
// Numbered ?N can leave anonymous holes. Missing named and anonymous slots
|
|
82
|
+
// retain SQLite's NULL value even when another parameter was supplied.
|
|
83
|
+
if (params.length === 0) {
|
|
84
|
+
const named = Object.fromEntries([...slots.values()].map((name) => [name, null]));
|
|
85
|
+
const anonymous = Array.from({ length: last - slots.size }, () => null);
|
|
86
|
+
return slots.size ? [named, ...anonymous] : anonymous;
|
|
87
|
+
}
|
|
88
|
+
const first = params[0];
|
|
89
|
+
if (params.length !== 1 || !first || typeof first !== 'object' || ArrayBuffer.isView(first))
|
|
90
|
+
return params;
|
|
91
|
+
const values = first;
|
|
92
|
+
const keys = Object.keys(values);
|
|
93
|
+
const allowed = new Set(slots.values());
|
|
94
|
+
if (allowed.size !== slots.size)
|
|
95
|
+
throw new errors_js_1.ValidationError('Conflicting SQLite parameter prefixes prevent bare named binding.');
|
|
96
|
+
for (const key of keys) {
|
|
97
|
+
if (!allowed.has(key.startsWith(':') ? key.slice(1) : key))
|
|
98
|
+
throw new errors_js_1.ValidationError(`Unknown SQLite binding "${key}"; no corresponding parameter occurs in the statement.`);
|
|
99
|
+
}
|
|
100
|
+
if (keys.length === allowed.size && last === slots.size)
|
|
101
|
+
return keys.some((key) => key.startsWith(':'))
|
|
102
|
+
? [Object.fromEntries(keys.map((key) => [key.startsWith(':') ? key.slice(1) : key, values[key]]))]
|
|
103
|
+
: params;
|
|
104
|
+
const named = Object.fromEntries([...slots.values()].map((name) => [name, null]));
|
|
105
|
+
for (const key of keys)
|
|
106
|
+
Object.defineProperty(named, key.startsWith(':') ? key.slice(1) : key, {
|
|
107
|
+
enumerable: true,
|
|
108
|
+
configurable: true,
|
|
109
|
+
get: () => values[key],
|
|
110
|
+
});
|
|
111
|
+
return [named, ...Array.from({ length: last - slots.size }, () => null)];
|
|
112
|
+
}
|
|
113
|
+
/** Only the SQLite methods the shared pool/introspector use are adapted. No statement cache. */
|
|
114
|
+
function adapt(handle, arrays) {
|
|
115
|
+
// Retain only bounded SQL analysis, never a native statement, row or binding.
|
|
116
|
+
const plans = new Map();
|
|
117
|
+
let planBytes = 0;
|
|
118
|
+
const planFor = (sql) => {
|
|
119
|
+
const previous = sql.length <= 32768 ? plans.get(sql) : undefined;
|
|
120
|
+
if (previous)
|
|
121
|
+
return previous;
|
|
122
|
+
const plan = bindingPlan(sql);
|
|
123
|
+
const bytes = sql.length * 2;
|
|
124
|
+
if (sql.length <= 32768 && plans.size < 128 && planBytes + bytes <= 131072) {
|
|
125
|
+
plans.set(sql, plan);
|
|
126
|
+
planBytes += bytes;
|
|
127
|
+
}
|
|
128
|
+
return plan;
|
|
129
|
+
};
|
|
130
|
+
const unsupported = (feature) => {
|
|
131
|
+
throw new errors_js_1.UnsupportedFeatureError(feature, 'better-sqlite3', 'This binding adapts typed queries, transactions and iterators. Use the original native handle for peer-specific APIs; node:sqlite migration/session APIs are unavailable.');
|
|
132
|
+
};
|
|
133
|
+
const db = {
|
|
134
|
+
get isOpen() {
|
|
135
|
+
return handle.open;
|
|
136
|
+
},
|
|
137
|
+
get isTransaction() {
|
|
138
|
+
return handle.inTransaction;
|
|
139
|
+
},
|
|
140
|
+
createSession: () => unsupported('node:sqlite sessions'),
|
|
141
|
+
applyChangeset: () => unsupported('node:sqlite changesets'),
|
|
142
|
+
setAuthorizer: () => unsupported('node:sqlite authorizer'),
|
|
143
|
+
close: () => {
|
|
144
|
+
plans.clear();
|
|
145
|
+
planBytes = 0;
|
|
146
|
+
return handle.close();
|
|
147
|
+
},
|
|
148
|
+
exec: (sql) => nativeCall(() => handle.exec(sql)),
|
|
149
|
+
prepare: (sql) => {
|
|
150
|
+
const stmt = nativeCall(() => handle.prepare(sql));
|
|
151
|
+
let plan;
|
|
152
|
+
const bind = (params) => {
|
|
153
|
+
plan ??= planFor(sql);
|
|
154
|
+
return binding(params, plan);
|
|
155
|
+
};
|
|
156
|
+
// Only unwrapped native peer methods opt into positional extraction.
|
|
157
|
+
// Supplied compatible statements keep their own object-row behavior.
|
|
158
|
+
const nativeArrays = arrays &&
|
|
159
|
+
stmt.reader &&
|
|
160
|
+
['all', 'columns', 'raw', 'safeIntegers'].every((key) => {
|
|
161
|
+
if (Object.hasOwn(stmt, key))
|
|
162
|
+
return false;
|
|
163
|
+
const fn = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(stmt), key)?.value;
|
|
164
|
+
return (typeof fn === 'function' &&
|
|
165
|
+
Reflect.get(stmt, key) === fn &&
|
|
166
|
+
Function.prototype.toString.call(fn) === `function ${key}() { [native code] }`);
|
|
167
|
+
});
|
|
168
|
+
const nativeColumns = nativeArrays ? stmt.columns : undefined;
|
|
169
|
+
let positional = false;
|
|
170
|
+
let columns;
|
|
171
|
+
const materialize = arrayRows && stmt.reader
|
|
172
|
+
? (row) => {
|
|
173
|
+
columns ??= stmt.columns();
|
|
174
|
+
return Object.fromEntries(columns.map((column, i) => [column.name, row[i]]));
|
|
175
|
+
}
|
|
176
|
+
: undefined;
|
|
177
|
+
if (materialize)
|
|
178
|
+
nativeCall(() => stmt.raw(true));
|
|
179
|
+
const adapted = {
|
|
180
|
+
get sourceSQL() {
|
|
181
|
+
return stmt.source;
|
|
182
|
+
},
|
|
183
|
+
all: (...params) => nativeCall(() => {
|
|
184
|
+
columns = undefined;
|
|
185
|
+
const values = bind(params);
|
|
186
|
+
if (stmt.reader) {
|
|
187
|
+
const rows = stmt.all(...values);
|
|
188
|
+
return materialize && !positional ? rows.map(materialize) : rows;
|
|
189
|
+
}
|
|
190
|
+
// node:sqlite permits all()/get() on rowless statements. This matters
|
|
191
|
+
// for WITH writes and SQL whose quoted text contains RETURNING.
|
|
192
|
+
stmt.run(...values);
|
|
193
|
+
return [];
|
|
194
|
+
}),
|
|
195
|
+
get: (...params) => nativeCall(() => {
|
|
196
|
+
columns = undefined;
|
|
197
|
+
const values = bind(params);
|
|
198
|
+
if (stmt.reader) {
|
|
199
|
+
const row = stmt.get(...values);
|
|
200
|
+
return row && materialize && !positional ? materialize(row) : row;
|
|
201
|
+
}
|
|
202
|
+
stmt.run(...values);
|
|
203
|
+
return undefined;
|
|
204
|
+
}),
|
|
205
|
+
run: (...params) => nativeCall(() => stmt.run(...bind(params))),
|
|
206
|
+
iterate: (...params) => {
|
|
207
|
+
columns = undefined;
|
|
208
|
+
if (!stmt.reader)
|
|
209
|
+
return (function* () {
|
|
210
|
+
nativeCall(() => stmt.run(...bind(params)));
|
|
211
|
+
})();
|
|
212
|
+
const iterator = nativeCall(() => stmt.iterate(...bind(params)));
|
|
213
|
+
return {
|
|
214
|
+
next: () => nativeCall(() => {
|
|
215
|
+
const result = iterator.next();
|
|
216
|
+
if (!result.done && materialize && !positional)
|
|
217
|
+
result.value = materialize(result.value);
|
|
218
|
+
return result;
|
|
219
|
+
}),
|
|
220
|
+
return: () => nativeCall(() => iterator.return()),
|
|
221
|
+
[Symbol.iterator]() {
|
|
222
|
+
return this;
|
|
223
|
+
},
|
|
224
|
+
};
|
|
225
|
+
},
|
|
226
|
+
columns: () => nativeCall(() => (positional ? nativeColumns.call(stmt) : stmt.columns())),
|
|
227
|
+
setReadBigInts: (enabled) => {
|
|
228
|
+
stmt.safeIntegers(enabled);
|
|
229
|
+
},
|
|
230
|
+
setAllowBareNamedParameters: () => { },
|
|
231
|
+
};
|
|
232
|
+
if (nativeArrays) {
|
|
233
|
+
adapted.setReturnArrays = (enabled) => {
|
|
234
|
+
nativeCall(() => stmt.raw(arrayRows || enabled));
|
|
235
|
+
positional = enabled;
|
|
236
|
+
};
|
|
237
|
+
arrays.set(adapted, { all: adapted.all, columns: adapted.columns, setReturnArrays: adapted.setReturnArrays });
|
|
238
|
+
}
|
|
239
|
+
return adapted;
|
|
240
|
+
},
|
|
241
|
+
};
|
|
242
|
+
// Deliberately narrow bridge to the existing pool, not a claim that the peer
|
|
243
|
+
// implements unused node:sqlite functions, sessions or backup APIs.
|
|
244
|
+
return db;
|
|
245
|
+
}
|
|
246
|
+
/** SQLite wire decoding depends on this binding, including on Node without node:sqlite. */
|
|
247
|
+
exports.betterSqlite3Dialect = {
|
|
248
|
+
...(0, sqlite_dialect_js_1.createPortableSqliteDialect)({
|
|
249
|
+
declaredTypes: () => true,
|
|
250
|
+
decodeBlob: (hex) => Uint8Array.from(Buffer.from(hex, 'hex')),
|
|
251
|
+
// Record generated bulk inserts so an owned handle may bind them
|
|
252
|
+
// positionally; the shared pool decides per handle. `false`: this
|
|
253
|
+
// dialect never bound qualified `:pN` keys, so a handle that cannot
|
|
254
|
+
// bind positionally keeps the plain `{ p1 }` binding it has always
|
|
255
|
+
// received (qualified keys make the adapter above copy the object).
|
|
256
|
+
recordBulkInsert: (params, sql) => (0, sqlite_js_1.recordSqliteBulkInsert)(params, sql, false),
|
|
257
|
+
}),
|
|
258
|
+
};
|
|
259
|
+
/** Introspect a supplied handle without closing or changing it. */
|
|
260
|
+
function introspectBetterSqlite3Database(handle, options = {}) {
|
|
261
|
+
return (0, sqlite_js_1.introspectSqliteDatabase)(adapt(handle), options);
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Create a typed client with the optional better-sqlite3 peer. Paths are client
|
|
265
|
+
* owned; supplied handles remain caller owned. The same pool enforces FIFO
|
|
266
|
+
* transaction/iterator ownership, rollback on release and incremental streaming.
|
|
267
|
+
* Synchronous SQLite work can observe cancellation only between pulls.
|
|
268
|
+
*/
|
|
269
|
+
async function turbineBetterSqlite3(target, schema, options = {}) {
|
|
270
|
+
const owns = typeof target === 'string';
|
|
271
|
+
let handle;
|
|
272
|
+
if (owns) {
|
|
273
|
+
let Constructor;
|
|
274
|
+
try {
|
|
275
|
+
const peer = (await (0, optional_peer_import_cjs_1.default)('better-sqlite3'));
|
|
276
|
+
Constructor = peer.default;
|
|
277
|
+
}
|
|
278
|
+
catch (cause) {
|
|
279
|
+
throw new errors_js_1.ConnectionError('The optional better-sqlite3 binding requires better-sqlite3. Install the peer in this application.', { cause });
|
|
280
|
+
}
|
|
281
|
+
try {
|
|
282
|
+
handle = new Constructor(target);
|
|
283
|
+
}
|
|
284
|
+
catch (cause) {
|
|
285
|
+
throw new errors_js_1.ConnectionError(`Failed to open better-sqlite3 database "${target}".`, { cause });
|
|
286
|
+
}
|
|
287
|
+
try {
|
|
288
|
+
handle.exec(`PRAGMA busy_timeout = ${Number(options.busyTimeoutMs ?? 5000)}`);
|
|
289
|
+
if (options.foreignKeys !== false)
|
|
290
|
+
handle.exec('PRAGMA foreign_keys = ON');
|
|
291
|
+
// Match node:sqlite's durable default for handles this factory owns.
|
|
292
|
+
handle.exec('PRAGMA synchronous = FULL');
|
|
293
|
+
if (target !== ':memory:' && options.wal !== false) {
|
|
294
|
+
try {
|
|
295
|
+
handle.exec('PRAGMA journal_mode = WAL');
|
|
296
|
+
}
|
|
297
|
+
catch {
|
|
298
|
+
/* Same filesystem fallback as node:sqlite. */
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
catch (error) {
|
|
303
|
+
handle.close();
|
|
304
|
+
throw error;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
else
|
|
308
|
+
handle = target;
|
|
309
|
+
const arrays = owns ? new WeakMap() : undefined;
|
|
310
|
+
return (0, sqlite_js_1.createSqliteBindingClient)(adapt(handle, arrays), schema, options, owns, exports.betterSqlite3Dialect, arrays);
|
|
311
|
+
}
|