ts-prorm-orm 1.1.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +95 -0
- package/README.md +194 -72
- package/dist/audit/history-query.d.ts +35 -0
- package/dist/audit/index.d.ts +16 -0
- package/dist/audit/logger.d.ts +126 -0
- package/dist/cache/cache-manager.d.ts +341 -0
- package/dist/cache/index.d.ts +8 -0
- package/dist/cache/redis-cluster-cache.d.ts +164 -0
- package/dist/cache/redis-cluster-cache.js +19 -36
- package/dist/cli/cloud.d.ts +55 -0
- package/dist/cli/cloud.js +318 -0
- package/dist/cli/commands/auth.d.ts +2 -0
- package/dist/cli/commands/auth.js +345 -0
- package/dist/cli/commands/billing.d.ts +2 -0
- package/dist/cli/commands/billing.js +135 -0
- package/dist/cli/commands/code.d.ts +2 -0
- package/dist/cli/commands/code.js +168 -0
- package/dist/cli/commands/config.d.ts +2 -0
- package/dist/cli/commands/config.js +154 -0
- package/dist/cli/commands/db.d.ts +2 -0
- package/dist/cli/commands/db.js +189 -0
- package/dist/cli/commands/index.d.ts +1 -0
- package/dist/cli/commands/index.js +22 -0
- package/dist/cli/commands/keys.d.ts +2 -0
- package/dist/cli/commands/keys.js +100 -0
- package/dist/cli/commands/misc.d.ts +2 -0
- package/dist/cli/commands/misc.js +282 -0
- package/dist/cli/commands/pull.d.ts +2 -0
- package/dist/cli/commands/pull.js +306 -0
- package/dist/cli/commands/runners.d.ts +2 -0
- package/dist/cli/commands/runners.js +218 -0
- package/dist/cli/commands/scaffold.d.ts +2 -0
- package/dist/cli/commands/scaffold.js +383 -0
- package/dist/cli/commands/secrets.d.ts +2 -0
- package/dist/cli/commands/secrets.js +162 -0
- package/dist/cli/commands/store.d.ts +2 -0
- package/dist/cli/commands/store.js +274 -0
- package/dist/cli/commands/system.d.ts +10 -0
- package/dist/cli/commands/system.js +169 -0
- package/dist/cli/commands/teams.d.ts +2 -0
- package/dist/cli/commands/teams.js +189 -0
- package/dist/cli/commands/user.d.ts +2 -0
- package/dist/cli/commands/user.js +171 -0
- package/dist/cli/framework.d.ts +103 -0
- package/dist/cli/framework.js +436 -0
- package/dist/cli/io.d.ts +26 -0
- package/dist/cli/io.js +181 -0
- package/dist/cli/keychain.d.ts +10 -0
- package/dist/cli/keychain.js +101 -0
- package/dist/cli/prompt.d.ts +20 -0
- package/dist/cli/prompt.js +111 -0
- package/dist/cli.d.ts +214 -0
- package/dist/cli.js +72 -5
- package/dist/compliance/audit-trail.d.ts +66 -0
- package/dist/compliance/backup-verification.d.ts +279 -0
- package/dist/compliance/breach-detector.d.ts +197 -0
- package/dist/compliance/consent-record.d.ts +107 -0
- package/dist/compliance/consent-versioning.d.ts +169 -0
- package/dist/compliance/cross-border-log.d.ts +254 -0
- package/dist/compliance/data-classifier.d.ts +127 -0
- package/dist/compliance/data-lineage.d.ts +268 -0
- package/dist/compliance/data-masker.d.ts +110 -0
- package/dist/compliance/data-portability.d.ts +98 -0
- package/dist/compliance/data-retention.d.ts +108 -0
- package/dist/compliance/dsar-workflow.d.ts +175 -0
- package/dist/compliance/field-encryption.d.ts +84 -0
- package/dist/compliance/immutable-record.d.ts +84 -0
- package/dist/compliance/index.d.ts +93 -0
- package/dist/compliance/privacy-impact-assessment.d.ts +196 -0
- package/dist/compliance/pseudonymization.d.ts +96 -0
- package/dist/compliance/query-firewall.d.ts +661 -0
- package/dist/compliance/rate-limiter.d.ts +203 -0
- package/dist/compliance/right-to-erasure.d.ts +96 -0
- package/dist/compliance/row-level-security.d.ts +152 -0
- package/dist/compliance/security-decorator.d.ts +388 -0
- package/dist/compliance/security-monitor.d.ts +170 -0
- package/dist/compliance/sensitive-data-discovery.d.ts +151 -0
- package/dist/compliance/session-isolation.d.ts +286 -0
- package/dist/compliance/tls-enforcer.d.ts +51 -0
- package/dist/compliance/worm-storage.d.ts +225 -0
- package/dist/connection-manager.d.ts +130 -0
- package/dist/connection-pool.d.ts +311 -0
- package/dist/decorators/audit.d.ts +49 -0
- package/dist/decorators/check.d.ts +218 -0
- package/dist/decorators/collate.d.ts +346 -0
- package/dist/decorators/comment.d.ts +51 -0
- package/dist/decorators/database-settings.d.ts +193 -0
- package/dist/decorators/default.d.ts +148 -0
- package/dist/decorators/encryption.d.ts +175 -0
- package/dist/decorators/engine.d.ts +97 -0
- package/dist/decorators/fk-constraints.d.ts +387 -0
- package/dist/decorators/foreign-table.d.ts +57 -0
- package/dist/decorators/generated.d.ts +232 -0
- package/dist/decorators/hstore.d.ts +96 -0
- package/dist/decorators/index.d.ts +57 -0
- package/dist/decorators/index.js +14 -30
- package/dist/decorators/json-column.d.ts +47 -0
- package/dist/decorators/jsonb.d.ts +83 -0
- package/dist/decorators/orm-decorators.d.ts +274 -0
- package/dist/decorators/permissions.d.ts +192 -0
- package/dist/decorators/procedure.d.ts +168 -0
- package/dist/decorators/procedure.js +31 -7
- package/dist/decorators/query-options.d.ts +527 -0
- package/dist/decorators/range.d.ts +122 -0
- package/dist/decorators/set-column.d.ts +43 -0
- package/dist/decorators/spatial.d.ts +60 -0
- package/dist/decorators/storage.d.ts +561 -0
- package/dist/decorators/timezone.d.ts +319 -0
- package/dist/decorators/trigger.d.ts +50 -0
- package/dist/decorators/uuid.d.ts +102 -0
- package/dist/decorators/view.d.ts +213 -0
- package/dist/diagrams/chen-diagram.d.ts +70 -0
- package/dist/diagrams/chen-diagram.js +33 -31
- package/dist/diagrams/class-diagram.d.ts +78 -0
- package/dist/diagrams/class-diagram.js +23 -27
- package/dist/diagrams/dependency-diagram.d.ts +82 -0
- package/dist/diagrams/dependency-diagram.js +18 -9
- package/dist/diagrams/er-diagram.d.ts +82 -0
- package/dist/diagrams/er-diagram.js +174 -231
- package/dist/diagrams/flow-diagram.d.ts +70 -0
- package/dist/diagrams/flow-diagram.js +23 -18
- package/dist/diagrams/gantt-diagram.d.ts +67 -0
- package/dist/diagrams/gantt-diagram.js +20 -18
- package/dist/diagrams/index-diagram.d.ts +61 -0
- package/dist/diagrams/index-diagram.js +36 -31
- package/dist/diagrams/index.d.ts +155 -0
- package/dist/diagrams/index.js +7 -1
- package/dist/diagrams/migration-diagram.d.ts +67 -0
- package/dist/diagrams/migration-diagram.js +45 -57
- package/dist/diagrams/model-diagram.d.ts +85 -0
- package/dist/diagrams/model-diagram.js +225 -287
- package/dist/diagrams/package-diagram.d.ts +69 -0
- package/dist/diagrams/package-diagram.js +30 -32
- package/dist/diagrams/palette.d.ts +138 -0
- package/dist/diagrams/palette.js +134 -25
- package/dist/diagrams/relational-diagram.d.ts +82 -0
- package/dist/diagrams/relational-diagram.js +51 -59
- package/dist/diagrams/schemadoc-diagram.d.ts +57 -0
- package/dist/diagrams/schemadoc-diagram.js +36 -28
- package/dist/diagrams/sequence-diagram.d.ts +61 -0
- package/dist/diagrams/sequence-diagram.js +20 -11
- package/dist/diagrams/state-diagram.d.ts +85 -0
- package/dist/diagrams/state-diagram.js +21 -17
- package/dist/diagrams/svg-dom.d.ts +62 -0
- package/dist/diagrams/svg-dom.js +11 -0
- package/dist/diagrams/tree-diagram.d.ts +47 -0
- package/dist/diagrams/tree-diagram.js +19 -10
- package/dist/dialects/clickhouse/index.d.ts +660 -0
- package/dist/dialects/clickhouse/index.js +107 -2
- package/dist/dialects/cockroachdb/index.d.ts +1708 -0
- package/dist/dialects/cockroachdb/index.js +139 -10
- package/dist/dialects/cratedb/index.d.ts +262 -0
- package/dist/dialects/cratedb/index.js +148 -0
- package/dist/dialects/databricks/index.d.ts +397 -0
- package/dist/dialects/databricks/index.js +233 -11
- package/dist/dialects/db2/index.d.ts +729 -0
- package/dist/dialects/db2/index.js +152 -2
- package/dist/dialects/dialect.d.ts +1653 -0
- package/dist/dialects/duckdb/index.d.ts +440 -0
- package/dist/dialects/duckdb/index.js +21 -37
- package/dist/dialects/exasol/index.d.ts +197 -0
- package/dist/dialects/exasol/index.js +14 -0
- package/dist/dialects/firebird/index.d.ts +286 -0
- package/dist/dialects/firebird/index.js +135 -0
- package/dist/dialects/greenplum/index.d.ts +336 -0
- package/dist/dialects/greenplum/index.js +168 -0
- package/dist/dialects/hana/index.d.ts +512 -0
- package/dist/dialects/hana/index.js +17 -35
- package/dist/dialects/mariadb/index.d.ts +1241 -0
- package/dist/dialects/mariadb/index.js +181 -43
- package/dist/dialects/mssql/index.d.ts +729 -0
- package/dist/dialects/mssql/index.js +76 -7
- package/dist/dialects/mysql/index.d.ts +1233 -0
- package/dist/dialects/mysql/index.js +87 -19
- package/dist/dialects/oracle/index.d.ts +1222 -0
- package/dist/dialects/oracle/index.js +210 -9
- package/dist/dialects/postgres/index.d.ts +1598 -0
- package/dist/dialects/postgres/index.js +34 -13
- package/dist/dialects/query-stream-helper.d.ts +58 -0
- package/dist/dialects/questdb/index.d.ts +430 -0
- package/dist/dialects/questdb/index.js +292 -0
- package/dist/dialects/redshift/index.d.ts +933 -0
- package/dist/dialects/redshift/index.js +17 -5
- package/dist/dialects/singlestore/index.d.ts +233 -0
- package/dist/dialects/singlestore/index.js +53 -0
- package/dist/dialects/snowflake/index.d.ts +727 -0
- package/dist/dialects/snowflake/index.js +154 -5
- package/dist/dialects/spanner/index.d.ts +660 -0
- package/dist/dialects/spanner/index.js +43 -21
- package/dist/dialects/sqlite/index.d.ts +1133 -0
- package/dist/dialects/sqlite/index.js +168 -30
- package/dist/dialects/tidb/index.d.ts +226 -0
- package/dist/dialects/tidb/index.js +10 -0
- package/dist/dialects/timescaledb/index.d.ts +286 -0
- package/dist/dialects/timescaledb/index.js +179 -0
- package/dist/dialects/trino/index.d.ts +230 -0
- package/dist/dialects/trino/index.js +85 -10
- package/dist/dialects/turso/index.d.ts +98 -0
- package/dist/dialects/turso/index.js +10 -0
- package/dist/dialects/vertica/index.d.ts +321 -0
- package/dist/dialects/vertica/index.js +161 -0
- package/dist/dialects/yugabytedb/index.d.ts +276 -0
- package/dist/dialects/yugabytedb/index.js +121 -0
- package/dist/errors/index.d.ts +378 -0
- package/dist/errors/index.js +29 -1
- package/dist/errors/utils.d.ts +53 -0
- package/dist/errors.d.ts +5 -0
- package/dist/extensions/catalog/cloud-warehouse-features.d.ts +27 -0
- package/dist/extensions/catalog/mssql-features.d.ts +20 -0
- package/dist/extensions/catalog/mysql-mariadb-plugins.d.ts +18 -0
- package/dist/extensions/catalog/oracle-db2-features.d.ts +17 -0
- package/dist/extensions/catalog/postgres-extensions.d.ts +15 -0
- package/dist/extensions/index.d.ts +34 -0
- package/dist/extensions/types.d.ts +43 -0
- package/dist/external-fields/adapters.d.ts +50 -0
- package/dist/external-fields/adapters.js +227 -0
- package/dist/external-fields/decorator.d.ts +77 -0
- package/dist/external-fields/decorator.js +80 -0
- package/dist/external-fields/index.d.ts +10 -0
- package/dist/external-fields/index.js +19 -0
- package/dist/external-fields/runtime.d.ts +39 -0
- package/dist/external-fields/runtime.js +221 -0
- package/dist/foreign-data.d.ts +168 -0
- package/dist/graph/base-graph-dialect.d.ts +250 -0
- package/dist/graph/base-graph-dialect.js +539 -0
- package/dist/graph/dgraph/index.d.ts +65 -0
- package/dist/graph/dgraph/index.js +559 -0
- package/dist/graph/gremlin/index.d.ts +59 -0
- package/dist/graph/gremlin/index.js +378 -0
- package/dist/graph/index.d.ts +60 -0
- package/dist/graph/index.js +67 -0
- package/dist/graph/neo4j/index.d.ts +50 -0
- package/dist/graph/neo4j/index.js +462 -0
- package/dist/graph/types.d.ts +213 -0
- package/dist/graph/types.js +234 -0
- package/dist/hooks/hooks-manager.d.ts +189 -0
- package/dist/hooks/index.d.ts +8 -0
- package/dist/index.d.ts +713 -0
- package/dist/index.js +36 -4
- package/dist/logging.d.ts +183 -0
- package/dist/migrations/index.d.ts +9 -0
- package/dist/migrations/migration.d.ts +143 -0
- package/dist/migrations/migrator.d.ts +199 -0
- package/dist/migrations/prormmigration.d.ts +131 -0
- package/dist/migrations/query-interface.d.ts +335 -0
- package/dist/migrations/seeder.d.ts +167 -0
- package/dist/models/associations.d.ts +131 -0
- package/dist/models/associations.js +7 -2
- package/dist/models/constraints.d.ts +175 -0
- package/dist/models/data-types.d.ts +1656 -0
- package/dist/models/decorators.d.ts +328 -0
- package/dist/models/decorators.js +61 -82
- package/dist/models/eager-load.d.ts +86 -0
- package/dist/models/eager-load.js +369 -0
- package/dist/models/index.d.ts +13 -0
- package/dist/models/indexes.d.ts +325 -0
- package/dist/models/methods.d.ts +419 -0
- package/dist/models/model-manager.d.ts +76 -0
- package/dist/models/model.d.ts +820 -0
- package/dist/models/model.js +15 -101
- package/dist/models/operators.d.ts +29 -0
- package/dist/models/scopes.d.ts +71 -0
- package/dist/models/typescript-types.d.ts +177 -0
- package/dist/nosql/aerospike/index.d.ts +126 -0
- package/dist/nosql/allegrograph/index.d.ts +86 -0
- package/dist/nosql/arangodb/index.d.ts +285 -0
- package/dist/nosql/arangodb/index.js +274 -2
- package/dist/nosql/arangodb/where.d.ts +38 -0
- package/dist/nosql/arangodb/where.js +94 -0
- package/dist/nosql/azure-blob/index.d.ts +104 -0
- package/dist/nosql/beanstalkd/index.d.ts +88 -0
- package/dist/nosql/beequeue/index.d.ts +99 -0
- package/dist/nosql/bigchaindb/index.d.ts +113 -0
- package/dist/nosql/bigtable/index.d.ts +144 -0
- package/dist/nosql/blazegraph/index.d.ts +88 -0
- package/dist/nosql/bullmq/index.d.ts +83 -0
- package/dist/nosql/cassandra/index.d.ts +119 -0
- package/dist/nosql/chroma/index.d.ts +151 -0
- package/dist/nosql/cloudflare-kv/index.d.ts +120 -0
- package/dist/nosql/coherence/index.d.ts +91 -0
- package/dist/nosql/cosmosdb/index.d.ts +78 -0
- package/dist/nosql/couchbase/index.d.ts +103 -0
- package/dist/nosql/dax/index.d.ts +118 -0
- package/dist/nosql/deno-kv/index.d.ts +109 -0
- package/dist/nosql/dgraph/index.d.ts +80 -0
- package/dist/nosql/doris/index.d.ts +88 -0
- package/dist/nosql/druid/index.d.ts +95 -0
- package/dist/nosql/dynamodb/index.d.ts +643 -0
- package/dist/nosql/dynamodb/index.js +423 -0
- package/dist/nosql/elasticsearch/index.d.ts +239 -0
- package/dist/nosql/etcd/index.d.ts +243 -0
- package/dist/nosql/eventhubs/index.d.ts +89 -0
- package/dist/nosql/eventstore/index.d.ts +102 -0
- package/dist/nosql/faunadb/index.d.ts +141 -0
- package/dist/nosql/faunadb/index.js +329 -0
- package/dist/nosql/firestore/index.d.ts +67 -0
- package/dist/nosql/fluree/index.d.ts +88 -0
- package/dist/nosql/fuseki/index.d.ts +94 -0
- package/dist/nosql/gcs/index.d.ts +62 -0
- package/dist/nosql/gearman/index.d.ts +77 -0
- package/dist/nosql/geode/index.d.ts +93 -0
- package/dist/nosql/graphdb/index.d.ts +86 -0
- package/dist/nosql/graylog/index.d.ts +118 -0
- package/dist/nosql/gridgain/index.d.ts +78 -0
- package/dist/nosql/hazelcast/index.d.ts +73 -0
- package/dist/nosql/hbase/index.d.ts +123 -0
- package/dist/nosql/ignite/index.d.ts +80 -0
- package/dist/nosql/immudb/index.d.ts +131 -0
- package/dist/nosql/index.d.ts +215 -0
- package/dist/nosql/infinispan/index.d.ts +95 -0
- package/dist/nosql/influxdb/flux-compiler.d.ts +23 -0
- package/dist/nosql/influxdb/flux-compiler.js +170 -0
- package/dist/nosql/influxdb/index.d.ts +300 -0
- package/dist/nosql/influxdb/index.js +0 -0
- package/dist/nosql/kafka/index.d.ts +113 -0
- package/dist/nosql/keyspaces/index.d.ts +122 -0
- package/dist/nosql/kinesis/index.d.ts +121 -0
- package/dist/nosql/leveldb/index.d.ts +112 -0
- package/dist/nosql/leveldb/index.js +103 -1
- package/dist/nosql/lmdb/index.d.ts +76 -0
- package/dist/nosql/loki/index.d.ts +126 -0
- package/dist/nosql/marklogic/index.d.ts +76 -0
- package/dist/nosql/materialize/index.d.ts +91 -0
- package/dist/nosql/meilisearch/index.d.ts +76 -0
- package/dist/nosql/memcached/index.d.ts +138 -0
- package/dist/nosql/milvus/index.d.ts +167 -0
- package/dist/nosql/minio/index.d.ts +122 -0
- package/dist/nosql/momento/index.d.ts +99 -0
- package/dist/nosql/mongodb/index.d.ts +265 -0
- package/dist/nosql/mongodb/index.js +139 -0
- package/dist/nosql/mongodb/where.d.ts +8 -0
- package/dist/nosql/mongodb/where.js +181 -0
- package/dist/nosql/nats/index.d.ts +139 -0
- package/dist/nosql/nedb/index.d.ts +79 -0
- package/dist/nosql/neo4j/index.d.ts +217 -0
- package/dist/nosql/neo4j/index.js +26 -14
- package/dist/nosql/neptune/index.d.ts +234 -0
- package/dist/nosql/neptune/index.js +23 -9
- package/dist/nosql/nsq/index.d.ts +93 -0
- package/dist/nosql/opensearch/index.d.ts +97 -0
- package/dist/nosql/orientdb/index.d.ts +72 -0
- package/dist/nosql/papertrail/index.d.ts +120 -0
- package/dist/nosql/pinecone/index.d.ts +148 -0
- package/dist/nosql/pinot/index.d.ts +90 -0
- package/dist/nosql/pouchdb/index.d.ts +95 -0
- package/dist/nosql/prometheus/index.d.ts +112 -0
- package/dist/nosql/provendb/index.d.ts +143 -0
- package/dist/nosql/provendb/index.js +262 -0
- package/dist/nosql/pubsub/index.d.ts +83 -0
- package/dist/nosql/pulsar/index.d.ts +105 -0
- package/dist/nosql/qdrant/index.d.ts +231 -0
- package/dist/nosql/qldb/index.d.ts +182 -0
- package/dist/nosql/qldb/index.js +302 -1
- package/dist/nosql/r2/index.d.ts +160 -0
- package/dist/nosql/rabbitmq/index.d.ts +131 -0
- package/dist/nosql/ravendb/index.d.ts +138 -0
- package/dist/nosql/ravendb/index.js +323 -9
- package/dist/nosql/ravendb/where.d.ts +38 -0
- package/dist/nosql/ravendb/where.js +94 -0
- package/dist/nosql/redis/index.d.ts +267 -0
- package/dist/nosql/redis/index.js +19 -5
- package/dist/nosql/redpanda/index.d.ts +117 -0
- package/dist/nosql/resque/index.d.ts +91 -0
- package/dist/nosql/rethinkdb/index.d.ts +194 -0
- package/dist/nosql/rethinkdb/index.js +290 -0
- package/dist/nosql/rethinkdb/where.d.ts +38 -0
- package/dist/nosql/rethinkdb/where.js +94 -0
- package/dist/nosql/rocksdb/document-layer.d.ts +162 -0
- package/dist/nosql/rocksdb/document-layer.js +338 -0
- package/dist/nosql/rocksdb/index.d.ts +112 -0
- package/dist/nosql/rocksdb/index.js +103 -1
- package/dist/nosql/rocksdb/where-match.d.ts +21 -0
- package/dist/nosql/rocksdb/where-match.js +238 -0
- package/dist/nosql/rockset/index.d.ts +84 -0
- package/dist/nosql/s3/index.d.ts +170 -0
- package/dist/nosql/scylladb/index.d.ts +117 -0
- package/dist/nosql/signoz/index.d.ts +116 -0
- package/dist/nosql/sns/index.d.ts +99 -0
- package/dist/nosql/solr/index.d.ts +129 -0
- package/dist/nosql/splunk/index.d.ts +125 -0
- package/dist/nosql/sqs/index.d.ts +116 -0
- package/dist/nosql/stardog/index.d.ts +86 -0
- package/dist/nosql/starrocks/index.d.ts +89 -0
- package/dist/nosql/store.d.ts +23 -0
- package/dist/nosql/sumologic/index.d.ts +119 -0
- package/dist/nosql/surrealdb/index.d.ts +156 -0
- package/dist/nosql/surrealdb/index.js +174 -1
- package/dist/nosql/surrealdb/query-compiler.d.ts +26 -0
- package/dist/nosql/surrealdb/query-compiler.js +193 -0
- package/dist/nosql/terminusdb/index.d.ts +95 -0
- package/dist/nosql/tigergraph/index.d.ts +314 -0
- package/dist/nosql/typesense/index.d.ts +82 -0
- package/dist/nosql/unqlite/index.d.ts +68 -0
- package/dist/nosql/upstash/index.d.ts +80 -0
- package/dist/nosql/vercel-kv/index.d.ts +82 -0
- package/dist/nosql/victoriametrics/index.d.ts +129 -0
- package/dist/nosql/virtuoso/index.d.ts +87 -0
- package/dist/nosql/weaviate/index.d.ts +196 -0
- package/dist/operators/index.d.ts +7 -0
- package/dist/operators.d.ts +2947 -0
- package/dist/operators.js +46 -1
- package/dist/prisma-migrate/index.d.ts +28 -0
- package/dist/prisma-migrate/migration-generator.d.ts +21 -0
- package/dist/prisma-migrate/model-generator.d.ts +12 -0
- package/dist/prisma-migrate/relations.d.ts +28 -0
- package/dist/prisma-migrate/schema-parser.d.ts +42 -0
- package/dist/prisma-migrate/type-mapper.d.ts +20 -0
- package/dist/prorm.d.ts +2093 -0
- package/dist/prorm.js +721 -302
- package/dist/query-builders/cte-builder.d.ts +104 -0
- package/dist/query-builders/functions/aggregate.d.ts +199 -0
- package/dist/query-builders/functions/conditional.d.ts +195 -0
- package/dist/query-builders/functions/datetime.d.ts +202 -0
- package/dist/query-builders/functions/fulltext.d.ts +220 -0
- package/dist/query-builders/functions/index.d.ts +17 -0
- package/dist/query-builders/functions/json.d.ts +157 -0
- package/dist/query-builders/functions/math.d.ts +215 -0
- package/dist/query-builders/functions/string.d.ts +233 -0
- package/dist/query-builders/functions/window.d.ts +209 -0
- package/dist/query-builders/include-builder.d.ts +85 -0
- package/dist/query-builders/index-expression-builder.d.ts +153 -0
- package/dist/query-builders/index.d.ts +121 -0
- package/dist/query-builders/index.js +10 -0
- package/dist/query-builders/insert-builder.d.ts +62 -0
- package/dist/query-builders/model-helpers.d.ts +28 -0
- package/dist/query-builders/order-limit-builder.d.ts +84 -0
- package/dist/query-builders/sql-compiler.d.ts +562 -0
- package/dist/query-builders/subquery-builder.d.ts +133 -0
- package/dist/query-builders/update-builder.d.ts +71 -0
- package/dist/query-builders/view-builder.d.ts +189 -0
- package/dist/query-builders/where-builder.d.ts +124 -0
- package/dist/query-interface.d.ts +407 -0
- package/dist/query-interface.js +84 -0
- package/dist/query-optimizers/batch-optimizer.d.ts +175 -0
- package/dist/query-optimizers/explain-plans.d.ts +187 -0
- package/dist/query-optimizers/index.d.ts +27 -0
- package/dist/query-optimizers/prepared-statement-cache.d.ts +252 -0
- package/dist/query-optimizers/query-hints.d.ts +201 -0
- package/dist/query-optimizers/query-optimizer.d.ts +162 -0
- package/dist/query-optimizers/slow-query-logger.d.ts +186 -0
- package/dist/replica-manager.d.ts +235 -0
- package/dist/schema/index.d.ts +7 -0
- package/dist/schema/migration-generator.d.ts +74 -0
- package/dist/schema/schema-differ.d.ts +114 -0
- package/dist/schema/types.d.ts +246 -0
- package/dist/schema-objects.d.ts +78 -0
- package/dist/schema-objects.js +203 -0
- package/dist/sql-constants.d.ts +240 -0
- package/dist/sqlite-advanced.d.ts +572 -0
- package/dist/streams/index.d.ts +5 -0
- package/dist/streams/transforms.d.ts +120 -0
- package/dist/transaction.d.ts +221 -0
- package/dist/types/index.d.ts +3123 -0
- package/dist/user-management.d.ts +141 -0
- package/dist/utils/date.d.ts +149 -0
- package/dist/utils/index.d.ts +359 -0
- package/dist/utils/string.d.ts +88 -0
- package/dist/validators/index.d.ts +7 -0
- package/dist/validators/validator.d.ts +306 -0
- package/package.json +20 -5
|
@@ -0,0 +1,1133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQLite dialect implementation
|
|
3
|
+
*/
|
|
4
|
+
import type Database from 'better-sqlite3';
|
|
5
|
+
import { Dialect, DialectOptions, ColumnDefinition, TableOptions, DropTableOptions, TableDescription, IndexOptions, InsertOptions, UpdateOptions as DUpdateOptions, DeleteOptions, SelectOptions, UpsertQueryOptions, CreateExtensionOptions, DropExtensionOptions, ExtensionInfo, MaterializedViewOptions, RefreshOptions, DropMaterializedViewOptions, FdwForeignServerOptions, FdwAlterForeignServerOptions, FdwUserMappingOptions, FdwForeignTableOptions, FdwImportForeignSchemaOptions, CTEOption } from '../dialect';
|
|
6
|
+
import { Transaction, TransactionOptions, QueryResult, QueryOptions, DataType, WhereOptions, Order, CreatePartitionOptions, AttachPartitionOptions, DetachPartitionOptions, StoredProcedureOptions, DropStoredProcedureOptions, ExecuteStoredProcedureOptions, SequenceOptions, DropSequenceOptions, PolicyOptions, DropPolicyOptions, StreamOptions } from '../../types';
|
|
7
|
+
import { Readable } from 'stream';
|
|
8
|
+
import { SQLiteAdvanced } from '../../sqlite-advanced';
|
|
9
|
+
/**
|
|
10
|
+
* A single `ON CONFLICT (...) DO ...` target for multi-target upserts. SQLite
|
|
11
|
+
* allows chaining several of these in one INSERT, each naming a different
|
|
12
|
+
* PRIMARY KEY/UNIQUE constraint, evaluated in order until one matches.
|
|
13
|
+
*/
|
|
14
|
+
export interface ConflictTarget {
|
|
15
|
+
/** Columns identifying the PRIMARY KEY/UNIQUE constraint to match. */
|
|
16
|
+
fields: string[];
|
|
17
|
+
/** Action to take when this target's constraint is violated. Defaults to 'DO UPDATE'. */
|
|
18
|
+
action?: 'DO NOTHING' | 'DO UPDATE';
|
|
19
|
+
/** Columns to update (defaults to all inserted columns) when action is 'DO UPDATE'. */
|
|
20
|
+
updateColumns?: string[];
|
|
21
|
+
/** Optional raw SQL WHERE clause restricting when the DO UPDATE applies. */
|
|
22
|
+
where?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* SQLite dialect class that implements the Dialect interface
|
|
26
|
+
*/
|
|
27
|
+
export declare class SQLiteDialect implements Dialect {
|
|
28
|
+
readonly name: string;
|
|
29
|
+
readonly library: string;
|
|
30
|
+
private connection;
|
|
31
|
+
private _isConnected;
|
|
32
|
+
private config;
|
|
33
|
+
private transactionDepth;
|
|
34
|
+
private _advanced;
|
|
35
|
+
constructor(config: SQLiteDialectOptions);
|
|
36
|
+
/**
|
|
37
|
+
* Connect to the SQLite database
|
|
38
|
+
*/
|
|
39
|
+
connect(): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Disconnect from the SQLite database
|
|
42
|
+
*/
|
|
43
|
+
disconnect(): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Get the current database connection
|
|
46
|
+
*/
|
|
47
|
+
getConnection(): any;
|
|
48
|
+
/**
|
|
49
|
+
* Check if connected
|
|
50
|
+
*/
|
|
51
|
+
isConnected(): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Get SQLite advanced features instance
|
|
54
|
+
*/
|
|
55
|
+
get advanced(): SQLiteAdvanced;
|
|
56
|
+
/**
|
|
57
|
+
* Replace placeholders in SQL with actual values
|
|
58
|
+
* Supports both named (:param) and positional (?) placeholders
|
|
59
|
+
*/
|
|
60
|
+
replaceReplacements(sql: string, replacements?: Record<string, unknown> | unknown[]): string;
|
|
61
|
+
/**
|
|
62
|
+
* Execute a raw SQL query with retry support
|
|
63
|
+
*/
|
|
64
|
+
query(sql: string, options?: QueryOptions): Promise<QueryResult>;
|
|
65
|
+
/**
|
|
66
|
+
* Stream query results using better-sqlite3's native `Statement#iterate()`
|
|
67
|
+
* — a real in-process cursor (no round trips at all, since sqlite is
|
|
68
|
+
* embedded), so this is more efficient than the generic paginated
|
|
69
|
+
* LIMIT/OFFSET fallback other dialects use.
|
|
70
|
+
* @param sql - The SELECT statement to stream
|
|
71
|
+
* @param options - Streaming options (batch size only affects backpressure batching, not fetch round trips)
|
|
72
|
+
*/
|
|
73
|
+
queryStream(sql: string, options?: StreamOptions): Readable;
|
|
74
|
+
/**
|
|
75
|
+
* Execute a function with retry logic for query execution
|
|
76
|
+
*/
|
|
77
|
+
private executeWithRetry;
|
|
78
|
+
/**
|
|
79
|
+
* Escape a value for use in a query
|
|
80
|
+
*/
|
|
81
|
+
escape(value: unknown): string;
|
|
82
|
+
/**
|
|
83
|
+
* Build a JSON extraction query for SQLite
|
|
84
|
+
* SQLite: json_extract(column, '$.path')
|
|
85
|
+
*/
|
|
86
|
+
buildJsonExtract(column: string, path: string, asText?: boolean): string;
|
|
87
|
+
/**
|
|
88
|
+
* Build a JSON contains query for SQLite
|
|
89
|
+
* SQLite: uses json_each and json_extract for containment checks
|
|
90
|
+
*/
|
|
91
|
+
buildJsonContains(column: string, value: unknown, path?: string): {
|
|
92
|
+
sql: string;
|
|
93
|
+
values: unknown[];
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Build a JSON has key query for SQLite
|
|
97
|
+
* SQLite: json_each or json_extract for key existence
|
|
98
|
+
*/
|
|
99
|
+
buildJsonHasKey(column: string, key: string, type?: 'one' | 'all'): string;
|
|
100
|
+
/**
|
|
101
|
+
* Build a JSON path query for SQLite
|
|
102
|
+
*/
|
|
103
|
+
buildJsonPathQuery(column: string, path: string, value?: unknown, operator?: string): {
|
|
104
|
+
sql: string;
|
|
105
|
+
values: unknown[];
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Build a `json_group_array()` aggregate expression for SQLite.
|
|
109
|
+
*
|
|
110
|
+
* `json_group_array()` is SQLite's JSON1 aggregate for collecting the
|
|
111
|
+
* values of `valueExpr` (evaluated once per row in the current group) into
|
|
112
|
+
* a single JSON array. Commonly used for "hasMany as nested JSON" style
|
|
113
|
+
* queries, e.g. rolling up child rows into a JSON array column of a
|
|
114
|
+
* grouped parent query.
|
|
115
|
+
*
|
|
116
|
+
* @param valueExpr - a column name or SQL expression to collect per row.
|
|
117
|
+
* Bare identifiers are escaped as columns; anything containing SQL
|
|
118
|
+
* syntax (parens, function calls, `.`) is passed through as-is so
|
|
119
|
+
* callers can pass expressions like `json_object('id', id)`.
|
|
120
|
+
* @param options.distinct - emit `json_group_array(DISTINCT ...)`
|
|
121
|
+
*/
|
|
122
|
+
buildJsonGroupArray(valueExpr: string, options?: {
|
|
123
|
+
distinct?: boolean;
|
|
124
|
+
}): string;
|
|
125
|
+
/**
|
|
126
|
+
* Build a `json_group_object()` aggregate expression for SQLite.
|
|
127
|
+
*
|
|
128
|
+
* `json_group_object()` collects `(keyExpr, valueExpr)` pairs from the
|
|
129
|
+
* rows of the current group into a single JSON object, keyed by
|
|
130
|
+
* `keyExpr`. Useful for building a JSON map of `{ [key]: value }` from
|
|
131
|
+
* grouped rows (e.g. nested-relation queries keyed by id).
|
|
132
|
+
*/
|
|
133
|
+
buildJsonGroupObject(keyExpr: string, valueExpr: string): string;
|
|
134
|
+
/**
|
|
135
|
+
* Escape a column/expression argument passed to an aggregate builder.
|
|
136
|
+
* Bare identifiers (letters, digits, underscore, dot for table.column)
|
|
137
|
+
* are quoted as an identifier; anything else (function calls, literals,
|
|
138
|
+
* `*`, etc.) is passed through untouched so callers can supply arbitrary
|
|
139
|
+
* SQL expressions.
|
|
140
|
+
*/
|
|
141
|
+
private escapeAggregateExpr;
|
|
142
|
+
/**
|
|
143
|
+
* Build a `json_patch()` expression for SQLite (RFC 7396 JSON Merge Patch).
|
|
144
|
+
*
|
|
145
|
+
* `json_patch(target, patch)` applies an RFC 7396 merge patch to the JSON
|
|
146
|
+
* stored in `column`, returning the patched JSON document. Unlike
|
|
147
|
+
* `json_set()` (which sets a single path) this can add, replace, and
|
|
148
|
+
* remove multiple keys in one call - keys in `patch` set to `null` are
|
|
149
|
+
* removed from the result.
|
|
150
|
+
*
|
|
151
|
+
* @param column - the JSON column to patch
|
|
152
|
+
* @param patch - a JS object/value to be JSON-stringified and applied as
|
|
153
|
+
* the merge patch; passed as a bound parameter, not interpolated.
|
|
154
|
+
*/
|
|
155
|
+
buildJsonPatch(column: string, patch: unknown): {
|
|
156
|
+
sql: string;
|
|
157
|
+
values: unknown[];
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* Escape a string for SQL
|
|
161
|
+
*/
|
|
162
|
+
private escapeString;
|
|
163
|
+
/**
|
|
164
|
+
* Escape an identifier (table name, column name, etc.)
|
|
165
|
+
*/
|
|
166
|
+
escapeId(identifier: unknown): string;
|
|
167
|
+
/**
|
|
168
|
+
* Quote an identifier (column name, table name)
|
|
169
|
+
* Same as escapeId for SQLite
|
|
170
|
+
*/
|
|
171
|
+
quoteIdentifier(identifier: string): string;
|
|
172
|
+
/**
|
|
173
|
+
* Quote a table name
|
|
174
|
+
* Same as escapeId for SQLite
|
|
175
|
+
* If schema is provided, returns schema.tableName (SQLite treats schemas as prefixes)
|
|
176
|
+
*/
|
|
177
|
+
quoteTable(tableName: string, schema?: string): string;
|
|
178
|
+
/**
|
|
179
|
+
* Get the database version
|
|
180
|
+
*/
|
|
181
|
+
getDatabaseVersion(): Promise<string>;
|
|
182
|
+
/**
|
|
183
|
+
* Generate SQL for creating a database
|
|
184
|
+
* SQLite uses ATTACH DATABASE for creating new database files
|
|
185
|
+
*/
|
|
186
|
+
createDatabaseSQL(options: {
|
|
187
|
+
name: string;
|
|
188
|
+
encoding?: string;
|
|
189
|
+
lcCollate?: string;
|
|
190
|
+
lcCtype?: string;
|
|
191
|
+
template?: string;
|
|
192
|
+
tablespace?: string;
|
|
193
|
+
collate?: string;
|
|
194
|
+
isTemplate?: boolean;
|
|
195
|
+
}): string;
|
|
196
|
+
/**
|
|
197
|
+
* Generate SQL for dropping a database
|
|
198
|
+
* SQLite uses DETACH DATABASE for dropping database files
|
|
199
|
+
*/
|
|
200
|
+
dropDatabaseSQL(name: string): string;
|
|
201
|
+
/**
|
|
202
|
+
* Attach an external SQLite database file to the current connection under
|
|
203
|
+
* `alias`, making its tables reachable as `alias.tableName` in subsequent
|
|
204
|
+
* queries (cross-database queries/joins). Executes a real
|
|
205
|
+
* `ATTACH DATABASE ? AS <alias>` statement rather than just documenting the
|
|
206
|
+
* capability.
|
|
207
|
+
*
|
|
208
|
+
* @param path - filesystem path to the database file to attach (or
|
|
209
|
+
* `:memory:` for an attached in-memory database)
|
|
210
|
+
* @param alias - schema name subsequent SQL will use to refer to the
|
|
211
|
+
* attached database (e.g. `alias.users`)
|
|
212
|
+
*/
|
|
213
|
+
attachDatabase(path: string, alias: string): Promise<void>;
|
|
214
|
+
/**
|
|
215
|
+
* Detach a previously-attached database from the current connection.
|
|
216
|
+
* Executes a real `DETACH DATABASE <alias>` statement.
|
|
217
|
+
*
|
|
218
|
+
* @param alias - the schema name the database was attached under via
|
|
219
|
+
* `attachDatabase()`
|
|
220
|
+
*/
|
|
221
|
+
detachDatabase(alias: string): Promise<void>;
|
|
222
|
+
/**
|
|
223
|
+
* Generate SQL for creating a savepoint
|
|
224
|
+
*/
|
|
225
|
+
createSavepointSQL(name?: string): string;
|
|
226
|
+
/**
|
|
227
|
+
* Generate SQL for releasing a savepoint
|
|
228
|
+
*/
|
|
229
|
+
releaseSavepointSQL(name: string): string;
|
|
230
|
+
/**
|
|
231
|
+
* Generate SQL for rolling back to a savepoint
|
|
232
|
+
*/
|
|
233
|
+
rollbackToSavepointSQL(name: string): string;
|
|
234
|
+
/**
|
|
235
|
+
* Create a new table
|
|
236
|
+
*/
|
|
237
|
+
createTable(tableName: string, columns: Record<string, ColumnDefinition>, options?: TableOptions & {
|
|
238
|
+
/**
|
|
239
|
+
* SQLite 3.37+ STRICT tables - enforces column type affinity strictly
|
|
240
|
+
* instead of SQLite's normally-flexible type system.
|
|
241
|
+
*/
|
|
242
|
+
strict?: boolean;
|
|
243
|
+
/**
|
|
244
|
+
* WITHOUT ROWID tables - opts a table out of the implicit rowid, storing
|
|
245
|
+
* rows in the order of the PRIMARY KEY instead. Useful for tables with a
|
|
246
|
+
* natural composite/text primary key.
|
|
247
|
+
*/
|
|
248
|
+
withoutRowid?: boolean;
|
|
249
|
+
}): Promise<void>;
|
|
250
|
+
/**
|
|
251
|
+
* Build constraint SQL for table creation
|
|
252
|
+
*/
|
|
253
|
+
private buildConstraintSql;
|
|
254
|
+
/**
|
|
255
|
+
* Generate column definition SQL
|
|
256
|
+
*/
|
|
257
|
+
private getColumnDefinitionSql;
|
|
258
|
+
/**
|
|
259
|
+
* Get default value SQL
|
|
260
|
+
*/
|
|
261
|
+
private getDefaultValue;
|
|
262
|
+
/**
|
|
263
|
+
* Drop a table
|
|
264
|
+
*/
|
|
265
|
+
dropTable(tableName: string, options?: DropTableOptions): Promise<void>;
|
|
266
|
+
/**
|
|
267
|
+
* Create a partitioned table (SQLite emulation)
|
|
268
|
+
* Creates base table + child partition tables + union view
|
|
269
|
+
*/
|
|
270
|
+
createPartitionedTable(tableName: string, columns: Record<string, ColumnDefinition>, options?: TableOptions & {
|
|
271
|
+
partitionBy: {
|
|
272
|
+
type: 'range' | 'list' | 'hash' | 'key';
|
|
273
|
+
column: string | string[];
|
|
274
|
+
};
|
|
275
|
+
partitions?: {
|
|
276
|
+
name: string;
|
|
277
|
+
bound?: any;
|
|
278
|
+
tablespace?: string;
|
|
279
|
+
storageParameters?: Record<string, string | number>;
|
|
280
|
+
}[] | number;
|
|
281
|
+
}): Promise<void>;
|
|
282
|
+
/**
|
|
283
|
+
* Create a partition for an existing partitioned table (SQLite emulation)
|
|
284
|
+
*/
|
|
285
|
+
createPartition(options: CreatePartitionOptions): Promise<void>;
|
|
286
|
+
/**
|
|
287
|
+
* Attach a partition to a partitioned table (SQLite emulation)
|
|
288
|
+
*/
|
|
289
|
+
attachPartition(options: AttachPartitionOptions): Promise<void>;
|
|
290
|
+
/**
|
|
291
|
+
* Detach a partition from a partitioned table (SQLite emulation)
|
|
292
|
+
* Marks the partition as detached but keeps the table
|
|
293
|
+
*/
|
|
294
|
+
detachPartition(options: DetachPartitionOptions): Promise<void>;
|
|
295
|
+
/**
|
|
296
|
+
* Drop a partition (SQLite emulation)
|
|
297
|
+
*/
|
|
298
|
+
dropPartition(partitionName: string, options?: {
|
|
299
|
+
ifExists?: boolean;
|
|
300
|
+
cascade?: boolean;
|
|
301
|
+
}): Promise<void>;
|
|
302
|
+
/**
|
|
303
|
+
* Add a partition to an existing partitioned table (SQLite emulation)
|
|
304
|
+
* @param tableName - Name of the partitioned table
|
|
305
|
+
* @param partitionName - Name for the new partition
|
|
306
|
+
* @param partitionSpec - Partition specification
|
|
307
|
+
*/
|
|
308
|
+
addPartition(tableName: string, partitionName: string, partitionSpec: {
|
|
309
|
+
values?: string;
|
|
310
|
+
forValues?: string;
|
|
311
|
+
}): Promise<void>;
|
|
312
|
+
/**
|
|
313
|
+
* List partitions for a table (SQLite emulation)
|
|
314
|
+
*/
|
|
315
|
+
listPartitions(tableName: string): Promise<Array<{
|
|
316
|
+
name: string;
|
|
317
|
+
parent_table: string;
|
|
318
|
+
bound: string | null;
|
|
319
|
+
is_detached: number;
|
|
320
|
+
}>>;
|
|
321
|
+
/**
|
|
322
|
+
* Check if a table has partitions (SQLite emulation)
|
|
323
|
+
*/
|
|
324
|
+
hasPartition(tableName: string): Promise<boolean>;
|
|
325
|
+
/**
|
|
326
|
+
* Create a user (stub - not supported by SQLite)
|
|
327
|
+
*/
|
|
328
|
+
createUser(_username: string, _options?: any): Promise<void>;
|
|
329
|
+
/**
|
|
330
|
+
* Drop a user (stub - not supported by SQLite)
|
|
331
|
+
*/
|
|
332
|
+
dropUser(_username: string, _options?: any): Promise<void>;
|
|
333
|
+
/**
|
|
334
|
+
* List users (stub - not supported by SQLite)
|
|
335
|
+
*/
|
|
336
|
+
listUsers(): Promise<Array<{
|
|
337
|
+
username: string;
|
|
338
|
+
host: string;
|
|
339
|
+
}>>;
|
|
340
|
+
/**
|
|
341
|
+
* Create a role (stub - not supported by SQLite)
|
|
342
|
+
*/
|
|
343
|
+
createRole(_roleName: string, _options?: any): Promise<void>;
|
|
344
|
+
/**
|
|
345
|
+
* Drop a role (stub - not supported by SQLite)
|
|
346
|
+
*/
|
|
347
|
+
dropRole(_roleName: string, _options?: any): Promise<void>;
|
|
348
|
+
/**
|
|
349
|
+
* List roles (stub - not supported by SQLite)
|
|
350
|
+
*/
|
|
351
|
+
listRoles(): Promise<string[]>;
|
|
352
|
+
/**
|
|
353
|
+
* Grant privileges (stub - not supported by SQLite)
|
|
354
|
+
*/
|
|
355
|
+
grant(_privilege: string, _on: string, _to: string): Promise<void>;
|
|
356
|
+
/**
|
|
357
|
+
* Revoke privileges (stub - not supported by SQLite)
|
|
358
|
+
*/
|
|
359
|
+
revoke(_privilege: string, _on: string, _from: string): Promise<void>;
|
|
360
|
+
/**
|
|
361
|
+
* Add a column to a table
|
|
362
|
+
*/
|
|
363
|
+
addColumn(tableName: string, columnName: string, definition: ColumnDefinition): Promise<void>;
|
|
364
|
+
/**
|
|
365
|
+
* Remove a column from a table
|
|
366
|
+
*/
|
|
367
|
+
removeColumn(tableName: string, columnName: string): Promise<void>;
|
|
368
|
+
/**
|
|
369
|
+
* Change a column definition
|
|
370
|
+
*/
|
|
371
|
+
changeColumn(tableName: string, columnName: string, definition: ColumnDefinition): Promise<void>;
|
|
372
|
+
/**
|
|
373
|
+
* Show all tables in the database
|
|
374
|
+
*/
|
|
375
|
+
showTables(): Promise<string[]>;
|
|
376
|
+
/**
|
|
377
|
+
* Get table status (SQLite implementation)
|
|
378
|
+
*/
|
|
379
|
+
getTableStatus(tableName?: string): Promise<Record<string, any>[]>;
|
|
380
|
+
/**
|
|
381
|
+
* Get table create statement (SQLite implementation)
|
|
382
|
+
*/
|
|
383
|
+
getCreateTable(tableName: string): Promise<string>;
|
|
384
|
+
/**
|
|
385
|
+
* Get MariaDB-specific version info (not supported in SQLite)
|
|
386
|
+
* This method exists for compatibility when tests fall back to SQLite
|
|
387
|
+
*/
|
|
388
|
+
getMariaDBVersionInfo(): Promise<{
|
|
389
|
+
version: string;
|
|
390
|
+
versionNumber: number;
|
|
391
|
+
storageEngine: string;
|
|
392
|
+
}>;
|
|
393
|
+
/**
|
|
394
|
+
* Show constraints for a table (SQLite)
|
|
395
|
+
*/
|
|
396
|
+
showConstraints(tableName: string): Promise<any[]>;
|
|
397
|
+
/**
|
|
398
|
+
* Show indexes for a table
|
|
399
|
+
*/
|
|
400
|
+
showIndexes(tableName: string): Promise<any[]>;
|
|
401
|
+
/**
|
|
402
|
+
* Create a schema
|
|
403
|
+
* SQLite doesn't have native schema support, but we can use ATTACH DATABASE
|
|
404
|
+
* For now, this is a no-op for compatibility with other dialects
|
|
405
|
+
* @param schema - The schema name to create
|
|
406
|
+
*/
|
|
407
|
+
createSchema(_schema: string): Promise<void>;
|
|
408
|
+
/**
|
|
409
|
+
* Drop a schema
|
|
410
|
+
* SQLite doesn't have native schema support
|
|
411
|
+
* For now, this is a no-op for compatibility with other dialects
|
|
412
|
+
* @param schema - The schema name to drop
|
|
413
|
+
* @param options - Drop options
|
|
414
|
+
*/
|
|
415
|
+
dropSchema(_schema: string, _options?: {
|
|
416
|
+
ifExists?: boolean;
|
|
417
|
+
cascade?: boolean;
|
|
418
|
+
}): Promise<void>;
|
|
419
|
+
/**
|
|
420
|
+
* Show all schemas in the database
|
|
421
|
+
* SQLite doesn't have native schema support, returns default schema
|
|
422
|
+
*/
|
|
423
|
+
showAllSchemas(): Promise<string[]>;
|
|
424
|
+
/**
|
|
425
|
+
* List all schemas (SQLite only has main)
|
|
426
|
+
*/
|
|
427
|
+
listSchemas(): Promise<string[]>;
|
|
428
|
+
/**
|
|
429
|
+
* VACUUM the database - reclaims disk space and defragments
|
|
430
|
+
* @param options - VACUUM options
|
|
431
|
+
*/
|
|
432
|
+
vacuum(options?: {
|
|
433
|
+
schema?: string;
|
|
434
|
+
shrinkTo?: number;
|
|
435
|
+
analyze?: boolean;
|
|
436
|
+
}): Promise<void>;
|
|
437
|
+
/**
|
|
438
|
+
* ANALYZE the database - updates statistics for query optimizer
|
|
439
|
+
* @param target - Optional table or index name
|
|
440
|
+
*/
|
|
441
|
+
analyze(target?: string): Promise<void>;
|
|
442
|
+
/**
|
|
443
|
+
* Get database information using PRAGMA
|
|
444
|
+
*/
|
|
445
|
+
getDatabaseInfo(): Promise<{
|
|
446
|
+
schemaVersion: number;
|
|
447
|
+
userVersion: number;
|
|
448
|
+
foreignKeys: boolean;
|
|
449
|
+
journalingMode: string;
|
|
450
|
+
synchronous: string;
|
|
451
|
+
cacheSize: number;
|
|
452
|
+
pageSize: number;
|
|
453
|
+
}>;
|
|
454
|
+
/**
|
|
455
|
+
* Create an FTS5 virtual table for full-text search
|
|
456
|
+
*/
|
|
457
|
+
createFTS5Table(tableName: string, columns: {
|
|
458
|
+
name: string;
|
|
459
|
+
type?: string;
|
|
460
|
+
notindexed?: boolean;
|
|
461
|
+
}[], options?: {
|
|
462
|
+
tokenizer?: 'porter' | 'unicode61' | 'trigram' | 'ascii';
|
|
463
|
+
content?: string;
|
|
464
|
+
contentRowId?: string;
|
|
465
|
+
prefix?: number[] | 'all';
|
|
466
|
+
}): Promise<void>;
|
|
467
|
+
/**
|
|
468
|
+
* Perform full-text search
|
|
469
|
+
*/
|
|
470
|
+
fullTextSearch(ftsTable: string, searchQuery: string, options?: {
|
|
471
|
+
columns?: string[];
|
|
472
|
+
orderBy?: {
|
|
473
|
+
column: string;
|
|
474
|
+
desc?: boolean;
|
|
475
|
+
}[];
|
|
476
|
+
limit?: number;
|
|
477
|
+
offset?: number;
|
|
478
|
+
highlight?: {
|
|
479
|
+
before?: string;
|
|
480
|
+
after?: string;
|
|
481
|
+
column?: string;
|
|
482
|
+
};
|
|
483
|
+
bm25?: boolean;
|
|
484
|
+
}): Promise<QueryResult>;
|
|
485
|
+
/**
|
|
486
|
+
* Create a stored procedure (SQLite - Not Supported)
|
|
487
|
+
*
|
|
488
|
+
* SQLite does not support stored procedures natively. However, you can achieve
|
|
489
|
+
* similar functionality using:
|
|
490
|
+
*
|
|
491
|
+
* 1. Application-level code: Move business logic into your application code
|
|
492
|
+
* 2. Views: For read-only operations
|
|
493
|
+
* 3. Triggers: For automated responses to data changes
|
|
494
|
+
* 4. FTS5 virtual tables: For full-text search operations
|
|
495
|
+
* 5. SQLite ATTACH: Connect to another database that supports stored procedures
|
|
496
|
+
*
|
|
497
|
+
* Example workaround using application code:
|
|
498
|
+
* ```typescript
|
|
499
|
+
* // Instead of:
|
|
500
|
+
* await db.executeStoredProcedure({ procedureName: 'calculateTotal', params: { orderId: 1 } });
|
|
501
|
+
*
|
|
502
|
+
* // Use application-level code:
|
|
503
|
+
* const total = await calculateTotal(orderId);
|
|
504
|
+
* ```
|
|
505
|
+
*/
|
|
506
|
+
createStoredProcedure(options: StoredProcedureOptions): Promise<void>;
|
|
507
|
+
/**
|
|
508
|
+
* Drop a stored procedure (SQLite - Not Supported)
|
|
509
|
+
*
|
|
510
|
+
* Since SQLite does not support stored procedures, there is nothing to drop.
|
|
511
|
+
* If you previously created a stored procedure in an attached database,
|
|
512
|
+
* drop it from that database instead.
|
|
513
|
+
*/
|
|
514
|
+
dropStoredProcedure(procedureName: string, _options?: DropStoredProcedureOptions): Promise<void>;
|
|
515
|
+
/**
|
|
516
|
+
* Drop a stored procedure (alias for dropStoredProcedure)
|
|
517
|
+
* SQLite does not support stored procedures - use application code instead.
|
|
518
|
+
*/
|
|
519
|
+
dropProcedure(procedureName: string, options?: DropStoredProcedureOptions): Promise<void>;
|
|
520
|
+
/**
|
|
521
|
+
* Execute a stored procedure (SQLite - Not Supported)
|
|
522
|
+
*
|
|
523
|
+
* SQLite does not support stored procedures. To execute the equivalent logic,
|
|
524
|
+
* move the procedure's SQL statements into your application code.
|
|
525
|
+
*
|
|
526
|
+
* Example:
|
|
527
|
+
* ```typescript
|
|
528
|
+
* // Instead of:
|
|
529
|
+
* const result = await db.executeStoredProcedure({
|
|
530
|
+
* procedureName: 'getUserOrders',
|
|
531
|
+
* params: { userId: 123 }
|
|
532
|
+
* });
|
|
533
|
+
*
|
|
534
|
+
* // Use a query directly:
|
|
535
|
+
* const result = await db.query(
|
|
536
|
+
* 'SELECT * FROM orders WHERE user_id = ?',
|
|
537
|
+
* [123]
|
|
538
|
+
* );
|
|
539
|
+
* ```
|
|
540
|
+
*/
|
|
541
|
+
executeStoredProcedure(options: ExecuteStoredProcedureOptions): Promise<QueryResult>;
|
|
542
|
+
/**
|
|
543
|
+
* Check if a stored procedure exists (SQLite - Always Returns False)
|
|
544
|
+
*
|
|
545
|
+
* Since SQLite does not support stored procedures, this always returns false.
|
|
546
|
+
* If you are checking for a procedure in an attached database, use that
|
|
547
|
+
* database's native method instead.
|
|
548
|
+
*/
|
|
549
|
+
hasStoredProcedure(_procedureName: string, _schema?: string): Promise<boolean>;
|
|
550
|
+
/**
|
|
551
|
+
* Create a stored procedure (alias for createStoredProcedure)
|
|
552
|
+
* SQLite does not support stored procedures - use application code instead.
|
|
553
|
+
*/
|
|
554
|
+
createProcedure(options: StoredProcedureOptions): Promise<void>;
|
|
555
|
+
/**
|
|
556
|
+
* Create a foreign data wrapper (SQLite - not supported)
|
|
557
|
+
* @param fdwName - Foreign data wrapper name
|
|
558
|
+
* @param options - Options including handler function
|
|
559
|
+
*/
|
|
560
|
+
createForeignDataWrapper(_fdwName: string, _options?: {
|
|
561
|
+
handler?: string;
|
|
562
|
+
}): Promise<void>;
|
|
563
|
+
dropForeignDataWrapper(_fdwName: string, _options?: {
|
|
564
|
+
ifExists?: boolean;
|
|
565
|
+
}): Promise<void>;
|
|
566
|
+
createForeignServer(_serverName: string, _fdwName: string, _options?: {
|
|
567
|
+
options?: Record<string, string>;
|
|
568
|
+
ifNotExists?: boolean;
|
|
569
|
+
}): Promise<void>;
|
|
570
|
+
dropForeignServer(_serverName: string, _options?: {
|
|
571
|
+
ifExists?: boolean;
|
|
572
|
+
cascade?: boolean;
|
|
573
|
+
}): Promise<void>;
|
|
574
|
+
createForeignTable(_tableName: string, _columns: Record<string, {
|
|
575
|
+
type: string;
|
|
576
|
+
}>, _options?: {
|
|
577
|
+
serverName?: string;
|
|
578
|
+
ifNotExists?: boolean;
|
|
579
|
+
}): Promise<void>;
|
|
580
|
+
changeOwner(_newOwner: string, _tableName: string): Promise<void>;
|
|
581
|
+
addConstraint(_tableName: string, _options: {
|
|
582
|
+
type: 'UNIQUE' | 'CHECK' | 'PRIMARY KEY' | 'FOREIGN KEY';
|
|
583
|
+
fields: string[];
|
|
584
|
+
name?: string;
|
|
585
|
+
references?: {
|
|
586
|
+
table: string;
|
|
587
|
+
fields: string[];
|
|
588
|
+
};
|
|
589
|
+
check?: string;
|
|
590
|
+
}): Promise<void>;
|
|
591
|
+
removeConstraint(_tableName: string, _constraintName: string): Promise<void>;
|
|
592
|
+
createSecurityPolicy(_policyName: string, _tableName: string, _options?: {
|
|
593
|
+
predicate?: string;
|
|
594
|
+
}): Promise<void>;
|
|
595
|
+
dropSecurityPolicy(_policyName: string, _tableName: string): Promise<void>;
|
|
596
|
+
/**
|
|
597
|
+
* Create a trigger
|
|
598
|
+
*/
|
|
599
|
+
createTrigger(triggerName: string, timing: 'BEFORE' | 'AFTER' | 'INSTEAD OF', events: ('INSERT' | 'UPDATE' | 'DELETE')[], tableName: string, body: string, options?: {
|
|
600
|
+
replace?: boolean;
|
|
601
|
+
forEachRow?: boolean;
|
|
602
|
+
whenCondition?: string;
|
|
603
|
+
}): Promise<void>;
|
|
604
|
+
/**
|
|
605
|
+
* Drop a trigger
|
|
606
|
+
*/
|
|
607
|
+
dropTrigger(triggerName: string, options?: {
|
|
608
|
+
ifExists?: boolean;
|
|
609
|
+
}): Promise<void>;
|
|
610
|
+
hasTrigger(triggerName: string, tableName?: string): Promise<boolean>;
|
|
611
|
+
/**
|
|
612
|
+
* Create a sequence (simulated using AUTOINCREMENT table)
|
|
613
|
+
*/
|
|
614
|
+
createSequence(options: SequenceOptions): Promise<void>;
|
|
615
|
+
/**
|
|
616
|
+
* Drop a sequence (simulated by dropping the sequence table)
|
|
617
|
+
*/
|
|
618
|
+
dropSequence(sequenceName: string, options?: DropSequenceOptions): Promise<void>;
|
|
619
|
+
/**
|
|
620
|
+
* Get next value from a sequence
|
|
621
|
+
* (simulated by inserting and getting last_insert_rowid)
|
|
622
|
+
*/
|
|
623
|
+
nextSequenceValue(sequenceName: string, schema?: string): Promise<number>;
|
|
624
|
+
/**
|
|
625
|
+
* Check if a sequence exists
|
|
626
|
+
* (simulated by checking if the sequence table exists)
|
|
627
|
+
*/
|
|
628
|
+
hasSequence(sequenceName: string, schema?: string): Promise<boolean>;
|
|
629
|
+
/**
|
|
630
|
+
* List all sequences in the database (SQLite - simulated via tables)
|
|
631
|
+
* @returns Array of sequence names
|
|
632
|
+
*/
|
|
633
|
+
listSequences(): Promise<string[]>;
|
|
634
|
+
/**
|
|
635
|
+
* Get the internal table name for a sequence
|
|
636
|
+
*/
|
|
637
|
+
private _getSequenceTableName;
|
|
638
|
+
createPolicy(_options: PolicyOptions): Promise<void>;
|
|
639
|
+
dropPolicy(_policyName: string, _tableName: string, _options?: DropPolicyOptions): Promise<void>;
|
|
640
|
+
enableRLS(_tableName: string, _schema?: string): Promise<void>;
|
|
641
|
+
enableRowLevelSecurity(_tableName: string, _schema?: string): Promise<void>;
|
|
642
|
+
disableRLS(_tableName: string, _schema?: string): Promise<void>;
|
|
643
|
+
hasPolicy(_policyName: string, _tableName: string): Promise<boolean>;
|
|
644
|
+
commentTable(_tableName: string, _comment: string): Promise<void>;
|
|
645
|
+
commentColumn(_tableName: string, _columnName: string, _comment: string): Promise<void>;
|
|
646
|
+
createPartialIndex(tableName: string, indexName: string, fields: string[], where: string, options?: IndexOptions): Promise<void>;
|
|
647
|
+
createExpressionIndex(tableName: string, indexName: string, expression: string, options?: IndexOptions): Promise<void>;
|
|
648
|
+
createIdentityColumn(_tableName: string, _columnName: string, _options?: {
|
|
649
|
+
startWith?: number;
|
|
650
|
+
incrementBy?: number;
|
|
651
|
+
minvalue?: number;
|
|
652
|
+
maxvalue?: number;
|
|
653
|
+
cycle?: boolean;
|
|
654
|
+
}): Promise<void>;
|
|
655
|
+
createComputedColumn(tableName: string, columnName: string, expression: string, options?: {
|
|
656
|
+
persisted?: boolean;
|
|
657
|
+
type?: string;
|
|
658
|
+
}): Promise<void>;
|
|
659
|
+
/**
|
|
660
|
+
* Create a PostgreSQL extension (not supported in SQLite)
|
|
661
|
+
*/
|
|
662
|
+
createExtension(_extensionName: string, _options?: CreateExtensionOptions): Promise<void>;
|
|
663
|
+
/**
|
|
664
|
+
* Drop a PostgreSQL extension (not supported in SQLite)
|
|
665
|
+
*/
|
|
666
|
+
dropExtension(_extensionName: string, _options?: DropExtensionOptions): Promise<void>;
|
|
667
|
+
/**
|
|
668
|
+
* Get all installed PostgreSQL extensions (not supported in SQLite)
|
|
669
|
+
*/
|
|
670
|
+
getExtensions(): Promise<ExtensionInfo[]>;
|
|
671
|
+
/**
|
|
672
|
+
* Check if a PostgreSQL extension is installed (not supported in SQLite)
|
|
673
|
+
*/
|
|
674
|
+
hasExtension(_extensionName: string): Promise<boolean>;
|
|
675
|
+
buildCreateServerQuery(_name: string, _opts: FdwForeignServerOptions): string;
|
|
676
|
+
buildAlterServerQuery(_name: string, _opts: FdwAlterForeignServerOptions): string;
|
|
677
|
+
buildDropServerQuery(_name: string, _opts?: {
|
|
678
|
+
ifExists?: boolean;
|
|
679
|
+
cascade?: boolean;
|
|
680
|
+
}): string;
|
|
681
|
+
buildCreateUserMappingQuery(_opts: FdwUserMappingOptions): string;
|
|
682
|
+
buildAlterUserMappingQuery(_opts: FdwUserMappingOptions): string;
|
|
683
|
+
buildDropUserMappingQuery(_serverName: string, _user: string, _opts?: {
|
|
684
|
+
ifExists?: boolean;
|
|
685
|
+
}): string;
|
|
686
|
+
buildCreateForeignTableQuery(_tableName: string, _opts: FdwForeignTableOptions): string;
|
|
687
|
+
buildDropForeignTableQuery(_tableName: string, _opts?: {
|
|
688
|
+
ifExists?: boolean;
|
|
689
|
+
cascade?: boolean;
|
|
690
|
+
}): string;
|
|
691
|
+
buildImportForeignSchemaQuery(_remoteSchema: string, _serverName: string, _opts?: FdwImportForeignSchemaOptions): string;
|
|
692
|
+
getServersQuery(): string;
|
|
693
|
+
/**
|
|
694
|
+
* Create a database view (SQLite uses CREATE VIEW)
|
|
695
|
+
* @param viewName - Name of the view to create
|
|
696
|
+
* @param query - The SELECT query for the view
|
|
697
|
+
* @param options - View options
|
|
698
|
+
*/
|
|
699
|
+
createView(viewName: string, query: string, options?: {
|
|
700
|
+
replace?: boolean;
|
|
701
|
+
}): Promise<void>;
|
|
702
|
+
/**
|
|
703
|
+
* Drop a database view
|
|
704
|
+
* @param viewName - Name of the view to drop
|
|
705
|
+
* @param options - Drop options
|
|
706
|
+
*/
|
|
707
|
+
dropView(viewName: string, options?: {
|
|
708
|
+
ifExists?: boolean;
|
|
709
|
+
}): Promise<void>;
|
|
710
|
+
/**
|
|
711
|
+
* Show all views in the database
|
|
712
|
+
*/
|
|
713
|
+
showViews(): Promise<string[]>;
|
|
714
|
+
/**
|
|
715
|
+
* Create a materialized view - Not supported by SQLite
|
|
716
|
+
*/
|
|
717
|
+
createMaterializedView(_options: MaterializedViewOptions): Promise<void>;
|
|
718
|
+
/**
|
|
719
|
+
* Refresh a materialized view - Not supported by SQLite
|
|
720
|
+
*/
|
|
721
|
+
refreshMaterializedView(_viewName: string, _options?: RefreshOptions): Promise<void>;
|
|
722
|
+
/**
|
|
723
|
+
* Drop a materialized view - Not supported by SQLite
|
|
724
|
+
*/
|
|
725
|
+
dropMaterializedView(_viewName: string, _options?: DropMaterializedViewOptions): Promise<void>;
|
|
726
|
+
/**
|
|
727
|
+
* Check if a materialized view exists - Not supported by SQLite
|
|
728
|
+
*/
|
|
729
|
+
hasMaterializedView(_viewName: string): Promise<boolean>;
|
|
730
|
+
/**
|
|
731
|
+
* Show all materialized views - Not supported by SQLite
|
|
732
|
+
*/
|
|
733
|
+
showMaterializedViews(): Promise<string[]>;
|
|
734
|
+
/**
|
|
735
|
+
* Describe a table (get column information)
|
|
736
|
+
*/
|
|
737
|
+
describeTable(tableName: string): Promise<TableDescription>;
|
|
738
|
+
/**
|
|
739
|
+
* Convert a column description (as returned by describeTable, sourced from
|
|
740
|
+
* PRAGMA table_info) into a ColumnDefinition suitable for getColumnDefinitionSql.
|
|
741
|
+
*
|
|
742
|
+
* PRAGMA table_info's `dflt_value` is already a raw SQL literal exactly as SQLite
|
|
743
|
+
* stored it (e.g. the string column default `'foo'` comes back as the 3-character
|
|
744
|
+
* string `'foo'`, quotes included). It must be wrapped in a Literal so it is
|
|
745
|
+
* emitted verbatim instead of being re-escaped and quoted a second time.
|
|
746
|
+
*/
|
|
747
|
+
private toColumnDefinition;
|
|
748
|
+
/**
|
|
749
|
+
* Rename a table
|
|
750
|
+
*/
|
|
751
|
+
renameTable(oldName: string, newName: string): Promise<void>;
|
|
752
|
+
/**
|
|
753
|
+
* Add an index to a table
|
|
754
|
+
* Supports partial indexes (WHERE) and expression indexes (SQLite 3.9.0+)
|
|
755
|
+
*/
|
|
756
|
+
addIndex(tableName: string, indexName: string, fields?: string[], options?: IndexOptions): Promise<void>;
|
|
757
|
+
/**
|
|
758
|
+
* Remove an index from a table
|
|
759
|
+
*/
|
|
760
|
+
removeIndex(tableName: string, indexName: string): Promise<void>;
|
|
761
|
+
/**
|
|
762
|
+
* Create an index on a table with full options support
|
|
763
|
+
* Supports partial indexes (WHERE) and expression indexes (SQLite 3.9.0+)
|
|
764
|
+
*/
|
|
765
|
+
createIndex(tableName: string, indexDef: {
|
|
766
|
+
name: string;
|
|
767
|
+
unique?: boolean;
|
|
768
|
+
type?: string;
|
|
769
|
+
using?: string;
|
|
770
|
+
fields: string[];
|
|
771
|
+
where?: WhereOptions;
|
|
772
|
+
expression?: string;
|
|
773
|
+
}): Promise<void>;
|
|
774
|
+
/**
|
|
775
|
+
* Drop an index from a table
|
|
776
|
+
*/
|
|
777
|
+
dropIndex(tableName: string, indexName: string, _options?: {
|
|
778
|
+
ifExists?: boolean;
|
|
779
|
+
cascade?: boolean;
|
|
780
|
+
}): Promise<void>;
|
|
781
|
+
/**
|
|
782
|
+
* Create a constraint on a table
|
|
783
|
+
* Note: SQLite has limited ALTER TABLE support for constraints
|
|
784
|
+
*/
|
|
785
|
+
createConstraint(tableName: string, constraintDef: {
|
|
786
|
+
name: string;
|
|
787
|
+
type: 'PRIMARY KEY' | 'UNIQUE' | 'FOREIGN KEY' | 'CHECK';
|
|
788
|
+
fields?: string[];
|
|
789
|
+
references?: {
|
|
790
|
+
table: string;
|
|
791
|
+
field: string;
|
|
792
|
+
onDelete?: string;
|
|
793
|
+
onUpdate?: string;
|
|
794
|
+
};
|
|
795
|
+
check?: string;
|
|
796
|
+
}): Promise<void>;
|
|
797
|
+
/**
|
|
798
|
+
* Drop a constraint from a table
|
|
799
|
+
* Note: SQLite has limited ALTER TABLE support for constraints
|
|
800
|
+
*/
|
|
801
|
+
dropConstraint(tableName: string, constraintName: string, _options?: {
|
|
802
|
+
ifExists?: boolean;
|
|
803
|
+
cascade?: boolean;
|
|
804
|
+
}): Promise<void>;
|
|
805
|
+
/**
|
|
806
|
+
* Recreate table with a new constraint (for createConstraint)
|
|
807
|
+
*/
|
|
808
|
+
private recreateTableWithConstraint;
|
|
809
|
+
/**
|
|
810
|
+
* Begin a new transaction
|
|
811
|
+
*/
|
|
812
|
+
startTransaction(options?: TransactionOptions): Promise<Transaction>;
|
|
813
|
+
/**
|
|
814
|
+
* Commit a transaction
|
|
815
|
+
*/
|
|
816
|
+
commitTransaction(transaction: Transaction): Promise<void>;
|
|
817
|
+
/**
|
|
818
|
+
* Rollback a transaction
|
|
819
|
+
*/
|
|
820
|
+
rollbackTransaction(transaction: Transaction): Promise<void>;
|
|
821
|
+
/**
|
|
822
|
+
* Get the SQL for a data type
|
|
823
|
+
*/
|
|
824
|
+
getDataTypeSql(dataType: DataType, columnName?: string): string;
|
|
825
|
+
/**
|
|
826
|
+
* Build a WHERE clause from a WhereOptions object
|
|
827
|
+
*/
|
|
828
|
+
buildWhereClause(where: WhereOptions, options?: {
|
|
829
|
+
replacements?: Record<string, unknown>;
|
|
830
|
+
}): {
|
|
831
|
+
sql: string;
|
|
832
|
+
values: unknown[];
|
|
833
|
+
};
|
|
834
|
+
/**
|
|
835
|
+
* Build an ORDER BY clause
|
|
836
|
+
*/
|
|
837
|
+
buildOrderClause(order: Order, options?: {
|
|
838
|
+
replacements?: Record<string, unknown>;
|
|
839
|
+
}): string;
|
|
840
|
+
/**
|
|
841
|
+
* Build a LIMIT/OFFSET clause
|
|
842
|
+
*/
|
|
843
|
+
buildLimitOffset(limit?: number | string, offset?: number | string): string;
|
|
844
|
+
/**
|
|
845
|
+
* Build an INSERT query
|
|
846
|
+
*/
|
|
847
|
+
buildInsertQuery(tableName: string, values: Record<string, unknown>, options?: InsertOptions & {
|
|
848
|
+
/** Emit `ON CONFLICT (...) DO NOTHING` instead of `DO UPDATE`. */
|
|
849
|
+
doNothing?: boolean;
|
|
850
|
+
/**
|
|
851
|
+
* Multiple chained `ON CONFLICT` clauses targeting different unique
|
|
852
|
+
* constraints, e.g. `ON CONFLICT(a) DO NOTHING ON CONFLICT(b) DO UPDATE ...`.
|
|
853
|
+
* When provided, this takes precedence over `conflictFields`/`doNothing`.
|
|
854
|
+
*/
|
|
855
|
+
conflictTargets?: ConflictTarget[];
|
|
856
|
+
}): {
|
|
857
|
+
sql: string;
|
|
858
|
+
values: unknown[];
|
|
859
|
+
};
|
|
860
|
+
/**
|
|
861
|
+
* Build one or more chained `ON CONFLICT (...) DO ...` clauses. SQLite allows
|
|
862
|
+
* multiple `ON CONFLICT` clauses in a single INSERT, each targeting a
|
|
863
|
+
* different PRIMARY KEY/UNIQUE constraint and evaluated in order until one
|
|
864
|
+
* matches, e.g.:
|
|
865
|
+
* INSERT INTO t (...) VALUES (...)
|
|
866
|
+
* ON CONFLICT (a) DO NOTHING
|
|
867
|
+
* ON CONFLICT (b) DO UPDATE SET ...
|
|
868
|
+
*/
|
|
869
|
+
private buildConflictClausesSql;
|
|
870
|
+
/**
|
|
871
|
+
* Build an UPSERT query (INSERT ... ON CONFLICT DO UPDATE)
|
|
872
|
+
* SQLite supports: INSERT OR REPLACE, INSERT OR IGNORE, and ON CONFLICT DO UPDATE
|
|
873
|
+
*/
|
|
874
|
+
buildUpsertQuery(tableName: string, values: Record<string, unknown>, options?: UpsertQueryOptions & {
|
|
875
|
+
/** Emit `ON CONFLICT (...) DO NOTHING` instead of `DO UPDATE`. */
|
|
876
|
+
doNothing?: boolean;
|
|
877
|
+
/**
|
|
878
|
+
* Multiple chained `ON CONFLICT` clauses targeting different unique
|
|
879
|
+
* constraints, e.g. `ON CONFLICT(a) DO NOTHING ON CONFLICT(b) DO UPDATE ...`.
|
|
880
|
+
* When provided, this takes precedence over `conflictFields`/`doNothing`.
|
|
881
|
+
*/
|
|
882
|
+
conflictTargets?: ConflictTarget[];
|
|
883
|
+
}): {
|
|
884
|
+
sql: string;
|
|
885
|
+
values: unknown[];
|
|
886
|
+
};
|
|
887
|
+
/**
|
|
888
|
+
* Build an increment query
|
|
889
|
+
* @param tableName - Table name
|
|
890
|
+
* @param fields - Fields to increment
|
|
891
|
+
* @param where - Where clause
|
|
892
|
+
* @param options - Query options (by: number)
|
|
893
|
+
*/
|
|
894
|
+
buildIncrementQuery(tableName: string, fields: string | string[] | Record<string, number>, where: WhereOptions, options?: {
|
|
895
|
+
by?: number;
|
|
896
|
+
}): {
|
|
897
|
+
sql: string;
|
|
898
|
+
values: unknown[];
|
|
899
|
+
};
|
|
900
|
+
/**
|
|
901
|
+
* Build an UPDATE query
|
|
902
|
+
*/
|
|
903
|
+
buildUpdateQuery(tableName: string, values: Record<string, unknown>, where: WhereOptions, options?: DUpdateOptions): {
|
|
904
|
+
sql: string;
|
|
905
|
+
values: unknown[];
|
|
906
|
+
};
|
|
907
|
+
/**
|
|
908
|
+
* Build a DELETE query
|
|
909
|
+
*/
|
|
910
|
+
buildDeleteQuery(tableName: string, where: WhereOptions, options?: DeleteOptions): {
|
|
911
|
+
sql: string;
|
|
912
|
+
values: unknown[];
|
|
913
|
+
};
|
|
914
|
+
/**
|
|
915
|
+
* Check if a value is a function expression (fn('COUNT', ...))
|
|
916
|
+
*/
|
|
917
|
+
private isFnExpression;
|
|
918
|
+
/**
|
|
919
|
+
* Check if a value is a column expression (col('name'))
|
|
920
|
+
*/
|
|
921
|
+
private isColExpression;
|
|
922
|
+
/**
|
|
923
|
+
* Check if a value is a literal expression (literal('sql'))
|
|
924
|
+
*/
|
|
925
|
+
/**
|
|
926
|
+
* Render a literal expression, substituting any `bindings` into its `?`
|
|
927
|
+
* placeholders with dialect-correct escaping. `literalExpr(sql)` with no
|
|
928
|
+
* bindings is unchanged; `literalExpr('x > ?', [v])` no longer requires the
|
|
929
|
+
* caller to concatenate the value into the string themselves.
|
|
930
|
+
*/
|
|
931
|
+
private literalSql;
|
|
932
|
+
private isLiteralExpression;
|
|
933
|
+
/**
|
|
934
|
+
* Compile a function expression to SQL
|
|
935
|
+
*/
|
|
936
|
+
private compileFnExpression;
|
|
937
|
+
/**
|
|
938
|
+
* Build SELECT clause with support for function expressions and aliases
|
|
939
|
+
* Handles: 'field', ['field'], ['field', 'alias'], [fn('COUNT', 'id'), 'count']
|
|
940
|
+
*/
|
|
941
|
+
private buildSelectClause;
|
|
942
|
+
/**
|
|
943
|
+
* Build GROUP BY clause with support for function expressions and aliases
|
|
944
|
+
* Handles: 'field', ['field1', 'field2'], [[fn('COUNT', 'id'), 'count']]
|
|
945
|
+
*/
|
|
946
|
+
private buildGroupByClause;
|
|
947
|
+
/**
|
|
948
|
+
* Build a WHERE clause condition using standard operators (Op.gt, Op.eq, etc.)
|
|
949
|
+
* Uses SQLite ? placeholders
|
|
950
|
+
*/
|
|
951
|
+
private buildCondition;
|
|
952
|
+
/**
|
|
953
|
+
* Build a HAVING clause with support for standard Op operators
|
|
954
|
+
*/
|
|
955
|
+
private buildHavingClause;
|
|
956
|
+
/**
|
|
957
|
+
* Build a `WITH [RECURSIVE] name [(cols)] AS (query), ...` clause from
|
|
958
|
+
* `SelectOptions.cte`. Nested `SelectOptions` queries are compiled via a
|
|
959
|
+
* recursive call to `buildSelectQuery`; raw SQL strings are used verbatim.
|
|
960
|
+
*
|
|
961
|
+
* SQLite uses unnumbered `?` placeholders (unlike Postgres/MSSQL's
|
|
962
|
+
* numbered `$n`/`@pN`), so no placeholder renumbering is needed here -
|
|
963
|
+
* each CTE's `values` are simply concatenated in the order their `?`
|
|
964
|
+
* markers appear in the rendered SQL, and the caller prepends the whole
|
|
965
|
+
* batch ahead of the main query's own values.
|
|
966
|
+
*/
|
|
967
|
+
buildWithClause(ctes: CTEOption[]): {
|
|
968
|
+
sql: string;
|
|
969
|
+
values: unknown[];
|
|
970
|
+
};
|
|
971
|
+
/**
|
|
972
|
+
* Build a SELECT query
|
|
973
|
+
*/
|
|
974
|
+
buildSelectQuery(options: SelectOptions): {
|
|
975
|
+
sql: string;
|
|
976
|
+
values: unknown[];
|
|
977
|
+
};
|
|
978
|
+
/**
|
|
979
|
+
* Recreate table without a column (for removeColumn)
|
|
980
|
+
*/
|
|
981
|
+
private recreateTableWithoutColumn;
|
|
982
|
+
/**
|
|
983
|
+
* Recreate table to modify a column
|
|
984
|
+
*/
|
|
985
|
+
private recreateTableModifyColumn;
|
|
986
|
+
buildCreateUserQuery(_username: string, _options?: any): string;
|
|
987
|
+
buildAlterUserQuery(_username: string, _options?: any): string;
|
|
988
|
+
buildDropUserQuery(_username: string, _options?: any): string;
|
|
989
|
+
getUsersQuery(): string;
|
|
990
|
+
buildGrantQuery(_options: any): string;
|
|
991
|
+
buildRevokeQuery(_options: any): string;
|
|
992
|
+
buildShowGrantsQuery(_username: string, _host?: string): string;
|
|
993
|
+
buildFlushPrivilegesQuery(): string;
|
|
994
|
+
buildCreateRoleQuery(_roleName: string, _options?: any): string;
|
|
995
|
+
buildDropRoleQuery(_roleName: string, _options?: any): string;
|
|
996
|
+
buildGrantRoleQuery(_role: string, _to: any, _options?: any): string;
|
|
997
|
+
buildRevokeRoleQuery(_role: string, _from: any, _options?: any): string;
|
|
998
|
+
getRolesQuery(): string;
|
|
999
|
+
/**
|
|
1000
|
+
* Bulk insert records into a table
|
|
1001
|
+
*/
|
|
1002
|
+
bulkInsert(tableName: string, records: Record<string, any>[], _options?: any): Promise<QueryResult>;
|
|
1003
|
+
/**
|
|
1004
|
+
* Update every row matching `where` with `values` in a single statement.
|
|
1005
|
+
*/
|
|
1006
|
+
bulkUpdate(tableName: string, values: Record<string, unknown>, where?: WhereOptions): Promise<unknown>;
|
|
1007
|
+
/**
|
|
1008
|
+
* Delete every row matching `where` (deletes all rows when `where` is empty).
|
|
1009
|
+
*/
|
|
1010
|
+
bulkDelete(tableName: string, where?: WhereOptions): Promise<unknown>;
|
|
1011
|
+
/**
|
|
1012
|
+
* Add a foreign key to a table
|
|
1013
|
+
* Note: SQLite does not support ALTER TABLE ADD CONSTRAINT.
|
|
1014
|
+
* Foreign keys must be defined when the table is created.
|
|
1015
|
+
*/
|
|
1016
|
+
addForeignKey(tableName: string, columnName: string, referencedTableName: string, referencedColumnName: string, options?: {
|
|
1017
|
+
name?: string;
|
|
1018
|
+
onDelete?: 'CASCADE' | 'RESTRICT' | 'SET NULL' | 'NO ACTION';
|
|
1019
|
+
onUpdate?: 'CASCADE' | 'RESTRICT' | 'SET NULL' | 'NO ACTION';
|
|
1020
|
+
}): Promise<void>;
|
|
1021
|
+
/**
|
|
1022
|
+
* Run a setter PRAGMA (one that returns no rows).
|
|
1023
|
+
*
|
|
1024
|
+
* On better-sqlite3 this must go through the synchronous `exec()` API:
|
|
1025
|
+
* routing it through `query()` would call `stmt.all()` and throw
|
|
1026
|
+
* "statement does not return data". Subclasses that don't have a
|
|
1027
|
+
* synchronous connection (e.g. TursoDialect over the libSQL wire) override
|
|
1028
|
+
* this to run the PRAGMA through their async driver instead.
|
|
1029
|
+
*/
|
|
1030
|
+
protected setPragma(pragma: string): Promise<void>;
|
|
1031
|
+
/**
|
|
1032
|
+
* Rename a column
|
|
1033
|
+
*/
|
|
1034
|
+
renameColumn(tableName: string, oldColumnName: string, newColumnName: string): Promise<void>;
|
|
1035
|
+
/**
|
|
1036
|
+
* Create a fulltext index (SQLite supports FTS5)
|
|
1037
|
+
*/
|
|
1038
|
+
createFulltextIndex(_tableName: string, indexName: string, fields: string[], _options?: {
|
|
1039
|
+
parser?: string;
|
|
1040
|
+
comment?: string;
|
|
1041
|
+
}): Promise<void>;
|
|
1042
|
+
/**
|
|
1043
|
+
* Create a spatial index (SQLite supports spatial indexing via RTree)
|
|
1044
|
+
*/
|
|
1045
|
+
createSpatialIndex(_tableName: string, indexName: string, fields: string[], _options?: {
|
|
1046
|
+
storage?: string;
|
|
1047
|
+
srid?: number;
|
|
1048
|
+
}): Promise<void>;
|
|
1049
|
+
/**
|
|
1050
|
+
* Create user mapping (SQLite doesn't support user mappings)
|
|
1051
|
+
*/
|
|
1052
|
+
createUserMapping(_userName: string, _serverName: string, _options?: any): Promise<void>;
|
|
1053
|
+
/**
|
|
1054
|
+
* Drop user mapping (SQLite doesn't support user mappings)
|
|
1055
|
+
*/
|
|
1056
|
+
dropUserMapping(_userName: string, _serverName: string, _options?: any): Promise<void>;
|
|
1057
|
+
/**
|
|
1058
|
+
* ST_Distance - calculate distance between two geometries
|
|
1059
|
+
* SQLite uses SpatiaLite extension or custom implementation
|
|
1060
|
+
*/
|
|
1061
|
+
stDistance(geom1: string, geom2: string, _srid?: number): string;
|
|
1062
|
+
/**
|
|
1063
|
+
* ST_DWithin - check if geometries are within a given distance
|
|
1064
|
+
*/
|
|
1065
|
+
stDWithin(geom1: string, geom2: string, distance: number, _srid?: number): string;
|
|
1066
|
+
/**
|
|
1067
|
+
* ST_Within - check if geometry A is within geometry B
|
|
1068
|
+
*/
|
|
1069
|
+
stWithin(geom1: string, geom2: string, _srid?: number): string;
|
|
1070
|
+
/**
|
|
1071
|
+
* ST_Contains - check if geometry A contains geometry B
|
|
1072
|
+
*/
|
|
1073
|
+
stContains(geom1: string, geom2: string, _srid?: number): string;
|
|
1074
|
+
/**
|
|
1075
|
+
* ST_Intersects - check if geometries intersect
|
|
1076
|
+
*/
|
|
1077
|
+
stIntersects(geom1: string, geom2: string, _srid?: number): string;
|
|
1078
|
+
/**
|
|
1079
|
+
* ST_AsText - convert geometry to text representation
|
|
1080
|
+
*/
|
|
1081
|
+
stAsText(geom: string): string;
|
|
1082
|
+
/**
|
|
1083
|
+
* ST_GeomFromText - create geometry from text
|
|
1084
|
+
*/
|
|
1085
|
+
stGeomFromText(wkt: string, srid?: number): string;
|
|
1086
|
+
/**
|
|
1087
|
+
* Build an expression to shred a JSON document/array into relational rows.
|
|
1088
|
+
* SQLite has no `JSON_TABLE` function; its real equivalent is the `json_each`
|
|
1089
|
+
* table-valued function, which yields fixed columns (key, value, type, atom, id,
|
|
1090
|
+
* parent, fullkey, path). To project those into named/typed columns (matching the
|
|
1091
|
+
* other dialects' JSON_TABLE/OPENJSON shape), this wraps json_each in a derived table
|
|
1092
|
+
* that applies `json_extract` per requested column.
|
|
1093
|
+
* SQLite: (SELECT json_extract(je.value, '$.path') AS name, ... FROM
|
|
1094
|
+
* json_each(expr, '$.rowPath') AS je) AS alias
|
|
1095
|
+
*/
|
|
1096
|
+
buildJsonTable(jsonExpression: string, rowPath: string, columns: Array<{
|
|
1097
|
+
name: string;
|
|
1098
|
+
type?: string;
|
|
1099
|
+
path?: string;
|
|
1100
|
+
forOrdinality?: boolean;
|
|
1101
|
+
}>, alias: string): string;
|
|
1102
|
+
}
|
|
1103
|
+
/**
|
|
1104
|
+
* SQLite-specific transaction class
|
|
1105
|
+
*/
|
|
1106
|
+
export declare class SQLiteTransaction implements Transaction {
|
|
1107
|
+
private connection;
|
|
1108
|
+
private dialect?;
|
|
1109
|
+
id: string;
|
|
1110
|
+
finished: boolean;
|
|
1111
|
+
options: TransactionOptions;
|
|
1112
|
+
parent: Transaction | null;
|
|
1113
|
+
savepoints: string[];
|
|
1114
|
+
isOuter: boolean;
|
|
1115
|
+
constructor(connection: Database.Database, depth: number, options?: TransactionOptions, dialect?: {
|
|
1116
|
+
commitTransaction(tx: Transaction): Promise<void>;
|
|
1117
|
+
rollbackTransaction(tx: Transaction): Promise<void>;
|
|
1118
|
+
} | undefined);
|
|
1119
|
+
commit(): Promise<void>;
|
|
1120
|
+
rollback(): Promise<void>;
|
|
1121
|
+
}
|
|
1122
|
+
export interface SQLiteDialectOptions extends DialectOptions {
|
|
1123
|
+
storage?: string;
|
|
1124
|
+
readonly?: boolean;
|
|
1125
|
+
fileMustExist?: boolean;
|
|
1126
|
+
timeout?: number;
|
|
1127
|
+
verbose?: (message?: unknown, ...additionalArgs: unknown[]) => void;
|
|
1128
|
+
}
|
|
1129
|
+
/**
|
|
1130
|
+
* Create a new SQLite dialect instance
|
|
1131
|
+
*/
|
|
1132
|
+
export declare function createSQLiteDialect(options?: SQLiteDialectOptions): SQLiteDialect;
|
|
1133
|
+
export default SQLiteDialect;
|