ts-prorm-orm 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +83 -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 +711 -0
- package/dist/index.js +19 -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,1653 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base dialect interface for the ORM
|
|
3
|
+
* Each database dialect implements this interface
|
|
4
|
+
*/
|
|
5
|
+
import { Transaction, TransactionOptions, QueryResult, QueryOptions, DataType, WhereOptions, Order, IncludeOptions, PartitionBound, CreatePartitionOptions, AttachPartitionOptions, DetachPartitionOptions, RefreshOptions, MaterializedViewOptions, DropMaterializedViewOptions, StoredProcedureOptions, DropStoredProcedureOptions, ExecuteStoredProcedureOptions, TriggerOptions, DropTriggerOptions, SequenceOptions, DropSequenceOptions, PolicyOptions, DropPolicyOptions, StreamOptions } from '../types';
|
|
6
|
+
import type { Readable } from 'stream';
|
|
7
|
+
export interface Dialect {
|
|
8
|
+
/**
|
|
9
|
+
* The name of the dialect
|
|
10
|
+
*/
|
|
11
|
+
readonly name: string;
|
|
12
|
+
/**
|
|
13
|
+
* The database library or driver being used
|
|
14
|
+
*/
|
|
15
|
+
readonly library: string;
|
|
16
|
+
/**
|
|
17
|
+
* Connect to the database
|
|
18
|
+
*/
|
|
19
|
+
connect(): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Disconnect from the database
|
|
22
|
+
*/
|
|
23
|
+
disconnect(): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Get the current connection
|
|
26
|
+
*/
|
|
27
|
+
getConnection(): any;
|
|
28
|
+
/**
|
|
29
|
+
* Check if connected
|
|
30
|
+
*/
|
|
31
|
+
isConnected(): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Execute a raw query
|
|
34
|
+
* @param sql - The SQL query string
|
|
35
|
+
* @param options - Query options
|
|
36
|
+
*/
|
|
37
|
+
query(sql: string, options?: QueryOptions): Promise<QueryResult>;
|
|
38
|
+
/**
|
|
39
|
+
* Execute a query and stream the results back as a Node.js Readable
|
|
40
|
+
* (object mode — one row, or one model instance when `options.mapToModel`
|
|
41
|
+
* is set, per chunk) instead of buffering the whole result set in memory.
|
|
42
|
+
* Used by `Model.findAllStream()`/`findAllIterate()` for processing large
|
|
43
|
+
* tables without loading them all into memory at once.
|
|
44
|
+
*
|
|
45
|
+
* Native server-side cursor support (postgres/mysql/cockroachdb) is used
|
|
46
|
+
* where the driver has it; other dialects fall back to LIMIT/OFFSET-paged
|
|
47
|
+
* queries — correct and dialect-agnostic, though it does more round trips
|
|
48
|
+
* than a real cursor for very large result sets.
|
|
49
|
+
* @param sql - The SQL query string to stream results for
|
|
50
|
+
* @param options - Streaming options (batch size, backpressure watermark, model mapping)
|
|
51
|
+
* @example
|
|
52
|
+
* const stream = dialect.queryStream('SELECT * FROM users', { batchSize: 500 });
|
|
53
|
+
* for await (const row of stream) { console.log(row); }
|
|
54
|
+
*/
|
|
55
|
+
queryStream(sql: string, options?: StreamOptions): Readable;
|
|
56
|
+
/**
|
|
57
|
+
* Escape a value for use in a query
|
|
58
|
+
* @param value - The value to escape
|
|
59
|
+
*/
|
|
60
|
+
escape(value: any): string;
|
|
61
|
+
/**
|
|
62
|
+
* Escape an identifier (table name, column name, etc.)
|
|
63
|
+
* @param identifier - The identifier to escape
|
|
64
|
+
*/
|
|
65
|
+
escapeId(identifier: string): string;
|
|
66
|
+
/**
|
|
67
|
+
* Quote an identifier (column name, table name)
|
|
68
|
+
* @param identifier - The identifier to quote
|
|
69
|
+
*/
|
|
70
|
+
quoteIdentifier(identifier: string): string;
|
|
71
|
+
/**
|
|
72
|
+
* Quote a table name
|
|
73
|
+
* @param tableName - The table name to quote
|
|
74
|
+
* @param schema - Optional schema to prefix the table with
|
|
75
|
+
*/
|
|
76
|
+
quoteTable(tableName: string, schema?: string): string;
|
|
77
|
+
/**
|
|
78
|
+
* Create a schema
|
|
79
|
+
* @param schema - The schema name to create
|
|
80
|
+
*/
|
|
81
|
+
createSchema(schema: string): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Drop a schema
|
|
84
|
+
* @param schema - The schema name to drop
|
|
85
|
+
* @param options - Drop options (e.g., cascade)
|
|
86
|
+
*/
|
|
87
|
+
dropSchema(schema: string, options?: DropSchemaOptions): Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Show all schemas in the database
|
|
90
|
+
*/
|
|
91
|
+
showAllSchemas(): Promise<string[]>;
|
|
92
|
+
/**
|
|
93
|
+
* List all schemas in the database
|
|
94
|
+
*/
|
|
95
|
+
listSchemas(): Promise<string[]>;
|
|
96
|
+
/**
|
|
97
|
+
* Generate SQL for creating a database
|
|
98
|
+
* @param options - Database creation options
|
|
99
|
+
*/
|
|
100
|
+
createDatabaseSQL(options: {
|
|
101
|
+
name: string;
|
|
102
|
+
encoding?: string;
|
|
103
|
+
lcCollate?: string;
|
|
104
|
+
lcCtype?: string;
|
|
105
|
+
template?: string;
|
|
106
|
+
tablespace?: string;
|
|
107
|
+
collate?: string;
|
|
108
|
+
isTemplate?: boolean;
|
|
109
|
+
}): string;
|
|
110
|
+
/**
|
|
111
|
+
* Generate SQL for dropping a database
|
|
112
|
+
* @param name - Database name to drop
|
|
113
|
+
*/
|
|
114
|
+
dropDatabaseSQL(name: string): string;
|
|
115
|
+
/**
|
|
116
|
+
* Generate SQL for creating a savepoint
|
|
117
|
+
* @param name - Savepoint name (optional, will be generated if not provided)
|
|
118
|
+
*/
|
|
119
|
+
createSavepointSQL(name?: string): string;
|
|
120
|
+
/**
|
|
121
|
+
* Generate SQL for releasing a savepoint
|
|
122
|
+
* @param name - Savepoint name to release
|
|
123
|
+
*/
|
|
124
|
+
releaseSavepointSQL(name: string): string;
|
|
125
|
+
/**
|
|
126
|
+
* Generate SQL for rolling back to a savepoint
|
|
127
|
+
* @param name - Savepoint name to rollback to
|
|
128
|
+
*/
|
|
129
|
+
rollbackToSavepointSQL(name: string): string;
|
|
130
|
+
/**
|
|
131
|
+
* Create a PostgreSQL extension
|
|
132
|
+
* @param extensionName - Name of the extension to create
|
|
133
|
+
* @param options - Extension options
|
|
134
|
+
*/
|
|
135
|
+
createExtension(extensionName: string, options?: CreateExtensionOptions): Promise<void>;
|
|
136
|
+
/**
|
|
137
|
+
* Drop a PostgreSQL extension
|
|
138
|
+
* @param extensionName - Name of the extension to drop
|
|
139
|
+
* @param options - Drop options
|
|
140
|
+
*/
|
|
141
|
+
dropExtension(extensionName: string, options?: DropExtensionOptions): Promise<void>;
|
|
142
|
+
/**
|
|
143
|
+
* Get all installed PostgreSQL extensions
|
|
144
|
+
* @returns Array of extension information
|
|
145
|
+
*/
|
|
146
|
+
getExtensions(): Promise<ExtensionInfo[]>;
|
|
147
|
+
/**
|
|
148
|
+
* Check if a PostgreSQL extension is installed
|
|
149
|
+
* @param extensionName - Name of the extension
|
|
150
|
+
* @returns True if the extension is installed
|
|
151
|
+
*/
|
|
152
|
+
hasExtension(extensionName: string): Promise<boolean>;
|
|
153
|
+
/**
|
|
154
|
+
* Get database version
|
|
155
|
+
*/
|
|
156
|
+
getDatabaseVersion(): Promise<string>;
|
|
157
|
+
/**
|
|
158
|
+
* Create a new table
|
|
159
|
+
* @param tableName - Name of the table
|
|
160
|
+
* @param columns - Column definitions
|
|
161
|
+
* @param options - Additional options
|
|
162
|
+
*/
|
|
163
|
+
createTable(tableName: string, columns: Record<string, ColumnDefinition>, options?: TableOptions): Promise<void>;
|
|
164
|
+
/**
|
|
165
|
+
* Drop a table
|
|
166
|
+
* @param tableName - Name of the table
|
|
167
|
+
* @param options - Additional options
|
|
168
|
+
*/
|
|
169
|
+
dropTable(tableName: string, options?: DropTableOptions): Promise<void>;
|
|
170
|
+
/**
|
|
171
|
+
* Create a partitioned table (PostgreSQL 10+)
|
|
172
|
+
* @param tableName - Name of the table to create
|
|
173
|
+
* @param columns - Column definitions
|
|
174
|
+
* @param options - Table options including partition configuration
|
|
175
|
+
*/
|
|
176
|
+
createPartitionedTable(tableName: string, columns: Record<string, ColumnDefinition>, options?: TableOptions & {
|
|
177
|
+
partitionBy: {
|
|
178
|
+
type: 'range' | 'list' | 'hash';
|
|
179
|
+
column: string | string[];
|
|
180
|
+
};
|
|
181
|
+
partitions?: {
|
|
182
|
+
name: string;
|
|
183
|
+
bound?: PartitionBound;
|
|
184
|
+
tablespace?: string;
|
|
185
|
+
storageParameters?: Record<string, string | number>;
|
|
186
|
+
}[];
|
|
187
|
+
}): Promise<void>;
|
|
188
|
+
/**
|
|
189
|
+
* Create a partition for an existing partitioned table (PostgreSQL 10+)
|
|
190
|
+
* @param options - Partition creation options
|
|
191
|
+
*/
|
|
192
|
+
createPartition(options: CreatePartitionOptions): Promise<void>;
|
|
193
|
+
/**
|
|
194
|
+
* Attach a partition to a partitioned table (PostgreSQL 11+)
|
|
195
|
+
* @param options - Partition attachment options
|
|
196
|
+
*/
|
|
197
|
+
attachPartition(options: AttachPartitionOptions): Promise<void>;
|
|
198
|
+
/**
|
|
199
|
+
* Detach a partition from a partitioned table (PostgreSQL 11+)
|
|
200
|
+
* @param options - Partition detachment options
|
|
201
|
+
*/
|
|
202
|
+
detachPartition(options: DetachPartitionOptions): Promise<void>;
|
|
203
|
+
/**
|
|
204
|
+
* Drop a partition (PostgreSQL 10+)
|
|
205
|
+
* @param partitionName - Name of the partition to drop
|
|
206
|
+
* @param options - Drop options
|
|
207
|
+
*/
|
|
208
|
+
dropPartition(partitionName: string, options?: {
|
|
209
|
+
ifExists?: boolean;
|
|
210
|
+
cascade?: boolean;
|
|
211
|
+
}): Promise<void>;
|
|
212
|
+
/**
|
|
213
|
+
* Create a database view
|
|
214
|
+
* @param viewName - Name of the view to create
|
|
215
|
+
* @param query - The SELECT query for the view
|
|
216
|
+
* @param options - View options (e.g., replace if exists)
|
|
217
|
+
*/
|
|
218
|
+
createView(viewName: string, query: string, options?: ViewOptions): Promise<void>;
|
|
219
|
+
/**
|
|
220
|
+
* Drop a database view
|
|
221
|
+
* @param viewName - Name of the view to drop
|
|
222
|
+
* @param options - Drop options
|
|
223
|
+
*/
|
|
224
|
+
dropView(viewName: string, options?: DropViewOptions): Promise<void>;
|
|
225
|
+
/**
|
|
226
|
+
* Add a column to a table
|
|
227
|
+
* @param tableName - Name of the table
|
|
228
|
+
* @param columnName - Name of the new column
|
|
229
|
+
* @param definition - Column definition
|
|
230
|
+
*/
|
|
231
|
+
addColumn(tableName: string, columnName: string, definition: ColumnDefinition): Promise<void>;
|
|
232
|
+
/**
|
|
233
|
+
* Remove a column from a table
|
|
234
|
+
* @param tableName - Name of the table
|
|
235
|
+
* @param columnName - Name of the column to remove
|
|
236
|
+
*/
|
|
237
|
+
removeColumn(tableName: string, columnName: string): Promise<void>;
|
|
238
|
+
/**
|
|
239
|
+
* Change a column definition
|
|
240
|
+
* @param tableName - Name of the table
|
|
241
|
+
* @param columnName - Name of the column to change
|
|
242
|
+
* @param definition - New column definition
|
|
243
|
+
*/
|
|
244
|
+
changeColumn(tableName: string, columnName: string, definition: ColumnDefinition): Promise<void>;
|
|
245
|
+
/**
|
|
246
|
+
* Rename a column
|
|
247
|
+
* @param tableName - Name of the table
|
|
248
|
+
* @param oldColumnName - Current column name
|
|
249
|
+
* @param newColumnName - New column name
|
|
250
|
+
*/
|
|
251
|
+
renameColumn(tableName: string, oldColumnName: string, newColumnName: string): Promise<void>;
|
|
252
|
+
/**
|
|
253
|
+
* Add a foreign key to a table
|
|
254
|
+
* @param tableName - Name of the table
|
|
255
|
+
* @param columnName - Name of the column
|
|
256
|
+
* @param referencedTableName - Name of the referenced table
|
|
257
|
+
* @param referencedColumnName - Name of the referenced column
|
|
258
|
+
* @param options - Foreign key options
|
|
259
|
+
*/
|
|
260
|
+
addForeignKey(tableName: string, columnName: string, referencedTableName: string, referencedColumnName: string, options?: any): Promise<void>;
|
|
261
|
+
/**
|
|
262
|
+
* Bulk insert records into a table
|
|
263
|
+
* @param tableName - Name of the table
|
|
264
|
+
* @param records - Array of records to insert
|
|
265
|
+
* @param options - Insert options
|
|
266
|
+
*/
|
|
267
|
+
bulkInsert(tableName: string, records: Record<string, any>[], options?: any): Promise<QueryResult>;
|
|
268
|
+
/**
|
|
269
|
+
* Show all tables in the database
|
|
270
|
+
*/
|
|
271
|
+
showTables(): Promise<string[]>;
|
|
272
|
+
/**
|
|
273
|
+
* Show all views in the database
|
|
274
|
+
*/
|
|
275
|
+
showViews(): Promise<string[]>;
|
|
276
|
+
/**
|
|
277
|
+
* Show constraints for a table
|
|
278
|
+
*/
|
|
279
|
+
showConstraints(tableName: string): Promise<any[]>;
|
|
280
|
+
/**
|
|
281
|
+
* Add a constraint to a table
|
|
282
|
+
*/
|
|
283
|
+
addConstraint(tableName: string, options: {
|
|
284
|
+
type: 'UNIQUE' | 'CHECK' | 'PRIMARY KEY' | 'FOREIGN KEY';
|
|
285
|
+
fields: string[];
|
|
286
|
+
name?: string;
|
|
287
|
+
references?: {
|
|
288
|
+
table: string;
|
|
289
|
+
fields: string[];
|
|
290
|
+
};
|
|
291
|
+
check?: string;
|
|
292
|
+
}): Promise<void>;
|
|
293
|
+
/**
|
|
294
|
+
* Remove a constraint from a table
|
|
295
|
+
*/
|
|
296
|
+
removeConstraint(tableName: string, constraintName: string): Promise<void>;
|
|
297
|
+
/**
|
|
298
|
+
* Show indexes for a table
|
|
299
|
+
*/
|
|
300
|
+
showIndexes(tableName: string): Promise<any[]>;
|
|
301
|
+
/**
|
|
302
|
+
* Describe a table (get column information)
|
|
303
|
+
* @param tableName - Name of the table
|
|
304
|
+
*/
|
|
305
|
+
describeTable(tableName: string): Promise<TableDescription>;
|
|
306
|
+
/**
|
|
307
|
+
* Rename a table
|
|
308
|
+
* @param oldName - Current table name
|
|
309
|
+
* @param newName - New table name
|
|
310
|
+
*/
|
|
311
|
+
renameTable(oldName: string, newName: string): Promise<void>;
|
|
312
|
+
/**
|
|
313
|
+
* Add an index to a table
|
|
314
|
+
* @param tableName - Name of the table
|
|
315
|
+
* @param indexName - Name of the index
|
|
316
|
+
* @param fields - Fields to index
|
|
317
|
+
* @param options - Index options
|
|
318
|
+
*/
|
|
319
|
+
addIndex(tableName: string, indexName: string, fields: string[], options?: IndexOptions): Promise<void>;
|
|
320
|
+
/**
|
|
321
|
+
* Remove an index from a table
|
|
322
|
+
* @param tableName - Name of the table
|
|
323
|
+
* @param indexName - Name of the index
|
|
324
|
+
*/
|
|
325
|
+
removeIndex(tableName: string, indexName: string): Promise<void>;
|
|
326
|
+
/**
|
|
327
|
+
* Create an index on a table with full options support
|
|
328
|
+
* @param tableName - Name of the table
|
|
329
|
+
* @param indexDef - Index definition
|
|
330
|
+
*/
|
|
331
|
+
createIndex(tableName: string, indexDef: IndexDefinition): Promise<void>;
|
|
332
|
+
/**
|
|
333
|
+
* Create a fulltext index on a table
|
|
334
|
+
* @param tableName - Name of the table
|
|
335
|
+
* @param indexName - Name of the index
|
|
336
|
+
* @param fields - Fields to index
|
|
337
|
+
* @param options - Fulltext index options
|
|
338
|
+
*/
|
|
339
|
+
createFulltextIndex(tableName: string, indexName: string, fields: string[], options?: {
|
|
340
|
+
parser?: string;
|
|
341
|
+
comment?: string;
|
|
342
|
+
}): Promise<void>;
|
|
343
|
+
/**
|
|
344
|
+
* Create a spatial index on a table
|
|
345
|
+
* @param tableName - Name of the table
|
|
346
|
+
* @param indexName - Name of the index
|
|
347
|
+
* @param fields - Fields to index
|
|
348
|
+
* @param options - Spatial index options
|
|
349
|
+
*/
|
|
350
|
+
createSpatialIndex(tableName: string, indexName: string, fields: string[], options?: {
|
|
351
|
+
storage?: string;
|
|
352
|
+
srid?: number;
|
|
353
|
+
}): Promise<void>;
|
|
354
|
+
/**
|
|
355
|
+
* Drop an index from a table
|
|
356
|
+
* @param tableName - Name of the table
|
|
357
|
+
* @param indexName - Name of the index
|
|
358
|
+
* @param options - Drop options
|
|
359
|
+
*/
|
|
360
|
+
dropIndex(tableName: string, indexName: string, options?: DropIndexOptions): Promise<void>;
|
|
361
|
+
/**
|
|
362
|
+
* Create a constraint on a table
|
|
363
|
+
* @param tableName - Name of the table
|
|
364
|
+
* @param constraintDef - Constraint definition
|
|
365
|
+
*/
|
|
366
|
+
createConstraint(tableName: string, constraintDef: ConstraintDefinition): Promise<void>;
|
|
367
|
+
/**
|
|
368
|
+
* Drop a constraint from a table
|
|
369
|
+
* @param tableName - Name of the table
|
|
370
|
+
* @param constraintName - Name of the constraint
|
|
371
|
+
* @param options - Drop options
|
|
372
|
+
*/
|
|
373
|
+
dropConstraint(tableName: string, constraintName: string, options?: DropConstraintOptions): Promise<void>;
|
|
374
|
+
/**
|
|
375
|
+
* Change owner of a table or view
|
|
376
|
+
*/
|
|
377
|
+
changeOwner(newOwner: string, tableName: string): Promise<void>;
|
|
378
|
+
/**
|
|
379
|
+
* Create a foreign data wrapper (PostgreSQL)
|
|
380
|
+
*/
|
|
381
|
+
createForeignDataWrapper(fdwName: string, options?: {
|
|
382
|
+
handler?: string;
|
|
383
|
+
}): Promise<void>;
|
|
384
|
+
/**
|
|
385
|
+
* Drop a foreign data wrapper (PostgreSQL)
|
|
386
|
+
*/
|
|
387
|
+
dropForeignDataWrapper(fdwName: string, options?: {
|
|
388
|
+
ifExists?: boolean;
|
|
389
|
+
}): Promise<void>;
|
|
390
|
+
/**
|
|
391
|
+
* Create a foreign server (PostgreSQL)
|
|
392
|
+
*/
|
|
393
|
+
createForeignServer(serverName: string, fdwName: string, options?: {
|
|
394
|
+
options?: Record<string, string>;
|
|
395
|
+
ifNotExists?: boolean;
|
|
396
|
+
}): Promise<void>;
|
|
397
|
+
/**
|
|
398
|
+
* Drop a foreign server (PostgreSQL)
|
|
399
|
+
*/
|
|
400
|
+
dropForeignServer(serverName: string, options?: {
|
|
401
|
+
ifExists?: boolean;
|
|
402
|
+
cascade?: boolean;
|
|
403
|
+
}): Promise<void>;
|
|
404
|
+
/**
|
|
405
|
+
* Create a foreign table (PostgreSQL)
|
|
406
|
+
*/
|
|
407
|
+
createForeignTable(tableName: string, columns: Record<string, {
|
|
408
|
+
type: string;
|
|
409
|
+
}>, options?: {
|
|
410
|
+
serverName?: string;
|
|
411
|
+
ifNotExists?: boolean;
|
|
412
|
+
}): Promise<void>;
|
|
413
|
+
/**
|
|
414
|
+
* Create a security policy (MSSQL Row-Level Security)
|
|
415
|
+
*/
|
|
416
|
+
createSecurityPolicy(policyName: string, tableName: string, options?: {
|
|
417
|
+
predicate?: string;
|
|
418
|
+
}): Promise<void>;
|
|
419
|
+
/**
|
|
420
|
+
* Drop a security policy (MSSQL Row-Level Security)
|
|
421
|
+
*/
|
|
422
|
+
dropSecurityPolicy(policyName: string, tableName: string): Promise<void>;
|
|
423
|
+
/**
|
|
424
|
+
* Begin a new transaction
|
|
425
|
+
* @param options - Transaction options
|
|
426
|
+
*/
|
|
427
|
+
startTransaction(options?: TransactionOptions): Promise<Transaction>;
|
|
428
|
+
/**
|
|
429
|
+
* Commit a transaction
|
|
430
|
+
* @param transaction - The transaction to commit
|
|
431
|
+
*/
|
|
432
|
+
commitTransaction(transaction: Transaction): Promise<void>;
|
|
433
|
+
/**
|
|
434
|
+
* Rollback a transaction
|
|
435
|
+
* @param transaction - The transaction to rollback
|
|
436
|
+
*/
|
|
437
|
+
rollbackTransaction(transaction: Transaction): Promise<void>;
|
|
438
|
+
/**
|
|
439
|
+
* Get the SQL for a data type
|
|
440
|
+
* @param dataType - The data type
|
|
441
|
+
*/
|
|
442
|
+
getDataTypeSql(dataType: DataType): string;
|
|
443
|
+
/**
|
|
444
|
+
* Build a WHERE clause from a WhereOptions object
|
|
445
|
+
* @param where - The where options
|
|
446
|
+
* @param options - Build options
|
|
447
|
+
*/
|
|
448
|
+
buildWhereClause(where: WhereOptions, options?: BuildOptions): {
|
|
449
|
+
sql: string;
|
|
450
|
+
values: any[];
|
|
451
|
+
};
|
|
452
|
+
/**
|
|
453
|
+
* Build an ORDER BY clause
|
|
454
|
+
* @param order - The order options
|
|
455
|
+
* @param options - Build options
|
|
456
|
+
*/
|
|
457
|
+
buildOrderClause(order: Order, options?: BuildOptions): string;
|
|
458
|
+
/**
|
|
459
|
+
* Build a LIMIT/OFFSET clause
|
|
460
|
+
* @param limit - Limit value
|
|
461
|
+
* @param offset - Offset value
|
|
462
|
+
*/
|
|
463
|
+
buildLimitOffset(limit?: number | string, offset?: number | string): string;
|
|
464
|
+
/**
|
|
465
|
+
* Build an INSERT query
|
|
466
|
+
* @param tableName - Table name
|
|
467
|
+
* @param values - Values to insert
|
|
468
|
+
* @param options - Query options
|
|
469
|
+
*/
|
|
470
|
+
buildInsertQuery(tableName: string, values: Record<string, any>, options?: InsertOptions): {
|
|
471
|
+
sql: string;
|
|
472
|
+
values: any[];
|
|
473
|
+
};
|
|
474
|
+
/**
|
|
475
|
+
* Build an UPDATE query
|
|
476
|
+
* @param tableName - Table name
|
|
477
|
+
* @param values - Values to update
|
|
478
|
+
* @param where - Where clause
|
|
479
|
+
* @param options - Query options
|
|
480
|
+
*/
|
|
481
|
+
buildUpdateQuery(tableName: string, values: Record<string, any>, where: WhereOptions, options?: UpdateOptions): {
|
|
482
|
+
sql: string;
|
|
483
|
+
values: any[];
|
|
484
|
+
};
|
|
485
|
+
/**
|
|
486
|
+
* Build a DELETE query
|
|
487
|
+
* @param tableName - Table name
|
|
488
|
+
* @param where - Where clause
|
|
489
|
+
* @param options - Query options
|
|
490
|
+
*/
|
|
491
|
+
buildDeleteQuery(tableName: string, where: WhereOptions, options?: DeleteOptions): {
|
|
492
|
+
sql: string;
|
|
493
|
+
values: any[];
|
|
494
|
+
};
|
|
495
|
+
/**
|
|
496
|
+
* Build a SELECT query
|
|
497
|
+
* @param options - Select options
|
|
498
|
+
*/
|
|
499
|
+
buildSelectQuery(options: SelectOptions): {
|
|
500
|
+
sql: string;
|
|
501
|
+
values: any[];
|
|
502
|
+
};
|
|
503
|
+
/**
|
|
504
|
+
* Build an UPSERT query (insert or update on conflict)
|
|
505
|
+
* @param tableName - Table name
|
|
506
|
+
* @param values - Values to insert/update
|
|
507
|
+
* @param options - Upsert options
|
|
508
|
+
*/
|
|
509
|
+
buildUpsertQuery(tableName: string, values: Record<string, any>, options?: UpsertQueryOptions): {
|
|
510
|
+
sql: string;
|
|
511
|
+
values: any[];
|
|
512
|
+
};
|
|
513
|
+
/**
|
|
514
|
+
* Build an increment query
|
|
515
|
+
* @param tableName - Table name
|
|
516
|
+
* @param fields - Fields to increment (field name or array of field names, or object with values)
|
|
517
|
+
* @param where - Where clause
|
|
518
|
+
* @param options - Query options (by: number)
|
|
519
|
+
*/
|
|
520
|
+
buildIncrementQuery(tableName: string, fields: string | string[] | Record<string, number>, where: WhereOptions, options?: {
|
|
521
|
+
by?: number;
|
|
522
|
+
}): {
|
|
523
|
+
sql: string;
|
|
524
|
+
values: any[];
|
|
525
|
+
};
|
|
526
|
+
/**
|
|
527
|
+
* Replace placeholders in SQL with actual values
|
|
528
|
+
* Supports both named (:param) and positional (?) placeholders
|
|
529
|
+
* @param sql - SQL string with placeholders
|
|
530
|
+
* @param replacements - Values to replace (object for named, array for positional)
|
|
531
|
+
* @returns SQL with placeholders replaced with escaped values
|
|
532
|
+
*/
|
|
533
|
+
replaceReplacements(sql: string, replacements?: Record<string, unknown> | unknown[]): string;
|
|
534
|
+
buildCreateServerQuery(name: string, opts: FdwForeignServerOptions): string;
|
|
535
|
+
buildAlterServerQuery(name: string, opts: FdwAlterForeignServerOptions): string;
|
|
536
|
+
buildDropServerQuery(name: string, opts?: {
|
|
537
|
+
ifExists?: boolean;
|
|
538
|
+
cascade?: boolean;
|
|
539
|
+
}): string;
|
|
540
|
+
buildCreateUserMappingQuery(opts: FdwUserMappingOptions): string;
|
|
541
|
+
buildAlterUserMappingQuery(opts: FdwUserMappingOptions): string;
|
|
542
|
+
buildDropUserMappingQuery(serverName: string, user: string, opts?: {
|
|
543
|
+
ifExists?: boolean;
|
|
544
|
+
}): string;
|
|
545
|
+
/**
|
|
546
|
+
* Create a user mapping for a foreign server
|
|
547
|
+
* @param userName - User name
|
|
548
|
+
* @param serverName - Foreign server name
|
|
549
|
+
* @param options - User mapping options
|
|
550
|
+
*/
|
|
551
|
+
createUserMapping(userName: string, serverName: string, options?: any): Promise<void>;
|
|
552
|
+
/**
|
|
553
|
+
* Drop a user mapping for a foreign server
|
|
554
|
+
* @param userName - User name
|
|
555
|
+
* @param serverName - Foreign server name
|
|
556
|
+
*/
|
|
557
|
+
dropUserMapping(userName: string, serverName: string, options?: any): Promise<void>;
|
|
558
|
+
buildCreateForeignTableQuery(tableName: string, opts: FdwForeignTableOptions): string;
|
|
559
|
+
buildDropForeignTableQuery(tableName: string, opts?: {
|
|
560
|
+
ifExists?: boolean;
|
|
561
|
+
cascade?: boolean;
|
|
562
|
+
}): string;
|
|
563
|
+
buildImportForeignSchemaQuery(remoteSchema: string, serverName: string, opts?: FdwImportForeignSchemaOptions): string;
|
|
564
|
+
getServersQuery(): string;
|
|
565
|
+
buildCreateUserQuery(username: string, options?: any): string;
|
|
566
|
+
buildAlterUserQuery(username: string, options: any): string;
|
|
567
|
+
buildDropUserQuery(username: string, options?: any): string;
|
|
568
|
+
getUsersQuery(): string;
|
|
569
|
+
buildGrantQuery(options: any): string;
|
|
570
|
+
buildRevokeQuery(options: any): string;
|
|
571
|
+
buildShowGrantsQuery(username: string, host?: string): string;
|
|
572
|
+
buildFlushPrivilegesQuery(): string;
|
|
573
|
+
buildCreateRoleQuery(roleName: string, options?: any): string;
|
|
574
|
+
buildDropRoleQuery(roleName: string, options?: any): string;
|
|
575
|
+
buildGrantRoleQuery(role: string, to: any, options?: any): string;
|
|
576
|
+
buildRevokeRoleQuery(role: string, from: any, options?: any): string;
|
|
577
|
+
getRolesQuery(): string;
|
|
578
|
+
createStoredProcedure(options: StoredProcedureOptions): Promise<void>;
|
|
579
|
+
createProcedure(options: StoredProcedureOptions): Promise<void>;
|
|
580
|
+
dropStoredProcedure(procedureName: string, options?: DropStoredProcedureOptions): Promise<void>;
|
|
581
|
+
dropProcedure(procedureName: string, options?: DropStoredProcedureOptions): Promise<void>;
|
|
582
|
+
executeStoredProcedure(options: ExecuteStoredProcedureOptions): Promise<QueryResult>;
|
|
583
|
+
hasStoredProcedure(procedureName: string, schema?: string): Promise<boolean>;
|
|
584
|
+
}
|
|
585
|
+
export interface ColumnDefinition {
|
|
586
|
+
type: DataType;
|
|
587
|
+
allowNull?: boolean;
|
|
588
|
+
defaultValue?: any;
|
|
589
|
+
primaryKey?: boolean;
|
|
590
|
+
autoIncrement?: boolean;
|
|
591
|
+
unique?: boolean | string;
|
|
592
|
+
references?: {
|
|
593
|
+
table: string;
|
|
594
|
+
field: string | string[];
|
|
595
|
+
onDelete?: string;
|
|
596
|
+
onUpdate?: string;
|
|
597
|
+
};
|
|
598
|
+
comment?: string;
|
|
599
|
+
/** Column-level character set (MySQL/MariaDB, e.g. 'utf8mb4') */
|
|
600
|
+
charset?: string;
|
|
601
|
+
/** Column-level collation (MySQL/MariaDB, e.g. 'utf8mb4_unicode_ci') */
|
|
602
|
+
collate?: string;
|
|
603
|
+
/**
|
|
604
|
+
* SQL Server: mark the column as `SPARSE`. Sparse columns optimize storage
|
|
605
|
+
* for columns whose values are NULL most of the time, at the cost of extra
|
|
606
|
+
* storage overhead for non-NULL values. Only valid on nullable columns —
|
|
607
|
+
* SQL Server requires `SPARSE` columns to allow NULL.
|
|
608
|
+
*/
|
|
609
|
+
sparse?: boolean;
|
|
610
|
+
/**
|
|
611
|
+
* Marks the column INVISIBLE (MySQL 8.0+ / MariaDB 10.3+). Invisible
|
|
612
|
+
* columns are hidden from `SELECT *` and don't require a value on
|
|
613
|
+
* INSERT, which makes them useful for zero-downtime column rollout: add
|
|
614
|
+
* the column invisible, backfill it, then flip it visible once ready.
|
|
615
|
+
* Columns are visible by default (false/undefined).
|
|
616
|
+
*/
|
|
617
|
+
invisible?: boolean;
|
|
618
|
+
}
|
|
619
|
+
export interface TableOptions {
|
|
620
|
+
ifNotExists?: boolean;
|
|
621
|
+
engine?: string;
|
|
622
|
+
charset?: string;
|
|
623
|
+
collate?: string;
|
|
624
|
+
comment?: string;
|
|
625
|
+
initialAutoIncrement?: number;
|
|
626
|
+
/** Row format for MySQL/MariaDB (e.g., 'DYNAMIC', 'FIXED', 'COMPRESSED') */
|
|
627
|
+
rowFormat?: string;
|
|
628
|
+
indexes?: TableIndex[];
|
|
629
|
+
constraints?: TableConstraint[];
|
|
630
|
+
/** Unique keys to create with the table */
|
|
631
|
+
uniqueKeys?: Record<string, string[]>;
|
|
632
|
+
/** PostgreSQL tablespace */
|
|
633
|
+
tablespace?: string;
|
|
634
|
+
/** PostgreSQL: inherit from parent table */
|
|
635
|
+
inherit?: string;
|
|
636
|
+
/** PostgreSQL: partition by clause */
|
|
637
|
+
partitionBy?: string;
|
|
638
|
+
/**
|
|
639
|
+
* System-versioned (temporal/bitemporal history) table support, e.g.
|
|
640
|
+
* MariaDB/SQL Server `SYSTEM_VERSIONING = ON` (plain `boolean`) or SAP
|
|
641
|
+
* HANA `PERIOD FOR SYSTEM_TIME (...) WITH SYSTEM VERSIONING`, which also
|
|
642
|
+
* accepts a config object naming the history table and period columns.
|
|
643
|
+
* Dialects that don't support system-versioned tables should ignore this
|
|
644
|
+
* option.
|
|
645
|
+
*/
|
|
646
|
+
systemVersioning?: boolean | {
|
|
647
|
+
/** Name of the history table that stores prior row versions. When
|
|
648
|
+
* omitted, the dialect's default/implicit history table naming
|
|
649
|
+
* applies (e.g. HANA auto-generates one when no `HISTORY TABLE`
|
|
650
|
+
* clause is given). */
|
|
651
|
+
historyTable?: string;
|
|
652
|
+
/** Name of the "row start"/valid-from period column. Defaults to
|
|
653
|
+
* `valid_from` when omitted. */
|
|
654
|
+
validFromColumn?: string;
|
|
655
|
+
/** Name of the "row end"/valid-to period column. Defaults to
|
|
656
|
+
* `valid_to` when omitted. */
|
|
657
|
+
validToColumn?: string;
|
|
658
|
+
};
|
|
659
|
+
}
|
|
660
|
+
export interface TableIndex {
|
|
661
|
+
name?: string;
|
|
662
|
+
unique?: boolean;
|
|
663
|
+
type?: string;
|
|
664
|
+
using?: string;
|
|
665
|
+
fields: string[];
|
|
666
|
+
where?: WhereOptions;
|
|
667
|
+
/** Expression for expression-based indexes (e.g., LOWER(column)) */
|
|
668
|
+
expression?: string;
|
|
669
|
+
/** Include columns for covering index (PostgreSQL 11+, MySQL 8.0.17+) */
|
|
670
|
+
include?: string[];
|
|
671
|
+
}
|
|
672
|
+
export interface TableConstraint {
|
|
673
|
+
name?: string;
|
|
674
|
+
type: 'PRIMARY KEY' | 'UNIQUE' | 'FOREIGN KEY' | 'CHECK';
|
|
675
|
+
fields?: string[];
|
|
676
|
+
references?: {
|
|
677
|
+
table: string;
|
|
678
|
+
field: string | string[];
|
|
679
|
+
onDelete?: string;
|
|
680
|
+
onUpdate?: string;
|
|
681
|
+
};
|
|
682
|
+
check?: string;
|
|
683
|
+
}
|
|
684
|
+
export interface DropTableOptions {
|
|
685
|
+
ifExists?: boolean;
|
|
686
|
+
cascade?: boolean;
|
|
687
|
+
}
|
|
688
|
+
export interface TableDescription {
|
|
689
|
+
[columnName: string]: {
|
|
690
|
+
type: string;
|
|
691
|
+
allowNull: boolean;
|
|
692
|
+
defaultValue: any;
|
|
693
|
+
primaryKey: boolean;
|
|
694
|
+
autoIncrement: boolean;
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
export interface IndexOptions {
|
|
698
|
+
/** Explicit index name (used by the `(tableName, fields, options)` addIndex shorthand) */
|
|
699
|
+
name?: string;
|
|
700
|
+
unique?: boolean;
|
|
701
|
+
type?: string;
|
|
702
|
+
using?: string;
|
|
703
|
+
where?: WhereOptions;
|
|
704
|
+
/** Expression for expression-based indexes (e.g., LOWER(column)) */
|
|
705
|
+
expression?: string;
|
|
706
|
+
/** Include columns for covering index (PostgreSQL 11+, MySQL 8.0.17+) */
|
|
707
|
+
include?: string[];
|
|
708
|
+
/** If true, does not throw error if index already exists */
|
|
709
|
+
ifNotExists?: boolean;
|
|
710
|
+
/** Oracle: tablespace for the index */
|
|
711
|
+
tablespace?: string;
|
|
712
|
+
/** Oracle: compress index storage */
|
|
713
|
+
compress?: boolean | number;
|
|
714
|
+
/**
|
|
715
|
+
* Create the index as invisible/ignored to the query optimizer (MySQL
|
|
716
|
+
* 8.0+ uses `INVISIBLE`; MariaDB 10.6+ uses `IGNORED` — the keyword
|
|
717
|
+
* differs between the two dialects even though the concept is the
|
|
718
|
+
* same). Useful for zero-downtime index rollout: add the index
|
|
719
|
+
* invisible, let it build and backfill, then flip it visible once
|
|
720
|
+
* verified. Indexes are visible/not-ignored by default.
|
|
721
|
+
*/
|
|
722
|
+
invisible?: boolean;
|
|
723
|
+
}
|
|
724
|
+
export interface IndexDefinition {
|
|
725
|
+
name: string;
|
|
726
|
+
unique?: boolean;
|
|
727
|
+
type?: string;
|
|
728
|
+
using?: string;
|
|
729
|
+
fields: string[];
|
|
730
|
+
where?: WhereOptions;
|
|
731
|
+
/** See {@link IndexOptions.invisible}. */
|
|
732
|
+
invisible?: boolean;
|
|
733
|
+
}
|
|
734
|
+
export interface DropIndexOptions {
|
|
735
|
+
ifExists?: boolean;
|
|
736
|
+
cascade?: boolean;
|
|
737
|
+
}
|
|
738
|
+
export interface ConstraintDefinition {
|
|
739
|
+
name: string;
|
|
740
|
+
type: 'PRIMARY KEY' | 'UNIQUE' | 'FOREIGN KEY' | 'CHECK';
|
|
741
|
+
fields?: string[];
|
|
742
|
+
references?: {
|
|
743
|
+
table: string;
|
|
744
|
+
field: string;
|
|
745
|
+
onDelete?: string;
|
|
746
|
+
onUpdate?: string;
|
|
747
|
+
};
|
|
748
|
+
check?: string;
|
|
749
|
+
deferrable?: 'INITIALLY DEFERRED' | 'INITIALLY IMMEDIATE';
|
|
750
|
+
}
|
|
751
|
+
export interface DropConstraintOptions {
|
|
752
|
+
ifExists?: boolean;
|
|
753
|
+
cascade?: boolean;
|
|
754
|
+
}
|
|
755
|
+
/**
|
|
756
|
+
* Options for creating a view
|
|
757
|
+
*/
|
|
758
|
+
export interface ViewOptions {
|
|
759
|
+
/** If true, replaces an existing view with the same name */
|
|
760
|
+
replace?: boolean;
|
|
761
|
+
/** Optional comment for the view */
|
|
762
|
+
comment?: string;
|
|
763
|
+
/** Schema to create the view in (PostgreSQL) */
|
|
764
|
+
schema?: string;
|
|
765
|
+
}
|
|
766
|
+
/**
|
|
767
|
+
* Options for dropping a view
|
|
768
|
+
*/
|
|
769
|
+
export interface DropViewOptions {
|
|
770
|
+
/** If true, does not throw error if view does not exist */
|
|
771
|
+
ifExists?: boolean;
|
|
772
|
+
/** If true, also drops dependent views (PostgreSQL) */
|
|
773
|
+
cascade?: boolean;
|
|
774
|
+
}
|
|
775
|
+
export interface DropSchemaOptions {
|
|
776
|
+
ifExists?: boolean;
|
|
777
|
+
cascade?: boolean;
|
|
778
|
+
}
|
|
779
|
+
/**
|
|
780
|
+
* Options for creating a PostgreSQL extension
|
|
781
|
+
*/
|
|
782
|
+
export interface CreateExtensionOptions {
|
|
783
|
+
/** If true, uses CREATE EXTENSION IF NOT EXISTS */
|
|
784
|
+
ifNotExists?: boolean;
|
|
785
|
+
/** Schema to install the extension into */
|
|
786
|
+
schema?: string;
|
|
787
|
+
/** Version of the extension to install */
|
|
788
|
+
version?: string;
|
|
789
|
+
}
|
|
790
|
+
/**
|
|
791
|
+
* Options for dropping a PostgreSQL extension
|
|
792
|
+
*/
|
|
793
|
+
export interface DropExtensionOptions {
|
|
794
|
+
/** If true, uses DROP EXTENSION IF EXISTS */
|
|
795
|
+
ifExists?: boolean;
|
|
796
|
+
/** If true, uses CASCADE to drop dependent objects */
|
|
797
|
+
cascade?: boolean;
|
|
798
|
+
}
|
|
799
|
+
/**
|
|
800
|
+
* Extension information returned by getExtensions
|
|
801
|
+
*/
|
|
802
|
+
export interface ExtensionInfo {
|
|
803
|
+
name: string;
|
|
804
|
+
defaultVersion: string | null;
|
|
805
|
+
installedVersion: string | null;
|
|
806
|
+
comment: string | null;
|
|
807
|
+
}
|
|
808
|
+
/**
|
|
809
|
+
* Options for creating a PostgreSQL enum type (`CREATE TYPE name AS ENUM (...)`)
|
|
810
|
+
*/
|
|
811
|
+
export interface CreateEnumTypeOptions {
|
|
812
|
+
/** Schema to create the type in */
|
|
813
|
+
schema?: string;
|
|
814
|
+
/**
|
|
815
|
+
* If true, checks whether the type already exists first (via `pg_type`) and
|
|
816
|
+
* skips creation if so. Postgres has no native `CREATE TYPE IF NOT EXISTS`.
|
|
817
|
+
*/
|
|
818
|
+
ifNotExists?: boolean;
|
|
819
|
+
}
|
|
820
|
+
/**
|
|
821
|
+
* Options for dropping a PostgreSQL type (`DROP TYPE ...`)
|
|
822
|
+
*/
|
|
823
|
+
export interface DropTypeOptions {
|
|
824
|
+
/** If true, uses DROP TYPE IF EXISTS */
|
|
825
|
+
ifExists?: boolean;
|
|
826
|
+
/** If true, uses CASCADE to drop dependent objects */
|
|
827
|
+
cascade?: boolean;
|
|
828
|
+
/** Schema the type lives in */
|
|
829
|
+
schema?: string;
|
|
830
|
+
}
|
|
831
|
+
/**
|
|
832
|
+
* Options for creating a PostgreSQL domain (`CREATE DOMAIN name AS base_type ...`)
|
|
833
|
+
*/
|
|
834
|
+
export interface CreateDomainOptions {
|
|
835
|
+
/** Schema to create the domain in */
|
|
836
|
+
schema?: string;
|
|
837
|
+
/**
|
|
838
|
+
* Optional default value. Strings are single-quoted and escaped unless they
|
|
839
|
+
* look like a raw SQL expression (wrapped in the caller's own quoting is
|
|
840
|
+
* not performed automatically for anything other than plain strings).
|
|
841
|
+
*/
|
|
842
|
+
default?: string | number | boolean;
|
|
843
|
+
/** Emits `COLLATE collation` */
|
|
844
|
+
collation?: string;
|
|
845
|
+
/** Emits `NOT NULL` (mutually exclusive in intent with allowing NULL, but Postgres allows either) */
|
|
846
|
+
notNull?: boolean;
|
|
847
|
+
/**
|
|
848
|
+
* One or more `CHECK` expressions, e.g. `['VALUE > 0']`, each emitted as
|
|
849
|
+
* `CONSTRAINT name CHECK (expression)` when a corresponding name is given,
|
|
850
|
+
* or a bare `CHECK (expression)` otherwise.
|
|
851
|
+
*/
|
|
852
|
+
checks?: Array<{
|
|
853
|
+
name?: string;
|
|
854
|
+
expression: string;
|
|
855
|
+
}>;
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* Options for dropping a PostgreSQL domain (`DROP DOMAIN ...`)
|
|
859
|
+
*/
|
|
860
|
+
export interface DropDomainOptions {
|
|
861
|
+
/** If true, uses DROP DOMAIN IF EXISTS */
|
|
862
|
+
ifExists?: boolean;
|
|
863
|
+
/** If true, uses CASCADE to drop dependent objects */
|
|
864
|
+
cascade?: boolean;
|
|
865
|
+
/** Schema the domain lives in */
|
|
866
|
+
schema?: string;
|
|
867
|
+
}
|
|
868
|
+
export interface ViewOptions {
|
|
869
|
+
/** Replace the view if it already exists (CREATE OR REPLACE) */
|
|
870
|
+
replace?: boolean;
|
|
871
|
+
/** Materialized view (PostgreSQL) */
|
|
872
|
+
materialized?: boolean;
|
|
873
|
+
/** View comment */
|
|
874
|
+
comment?: string;
|
|
875
|
+
}
|
|
876
|
+
export interface FdwForeignServerOptions {
|
|
877
|
+
fdw: string;
|
|
878
|
+
options?: Record<string, string>;
|
|
879
|
+
version?: string;
|
|
880
|
+
ifNotExists?: boolean;
|
|
881
|
+
}
|
|
882
|
+
export interface FdwAlterForeignServerOptions {
|
|
883
|
+
options?: Record<string, string>;
|
|
884
|
+
addOptions?: Record<string, string>;
|
|
885
|
+
setOptions?: Record<string, string>;
|
|
886
|
+
dropOptions?: string[];
|
|
887
|
+
version?: string;
|
|
888
|
+
}
|
|
889
|
+
export interface FdwUserMappingOptions {
|
|
890
|
+
serverName: string;
|
|
891
|
+
user: string;
|
|
892
|
+
options?: Record<string, string>;
|
|
893
|
+
ifNotExists?: boolean;
|
|
894
|
+
}
|
|
895
|
+
export interface FdwForeignTableColumnDef {
|
|
896
|
+
type: string;
|
|
897
|
+
options?: string;
|
|
898
|
+
}
|
|
899
|
+
export interface FdwForeignTableOptions {
|
|
900
|
+
serverName: string;
|
|
901
|
+
schema?: string;
|
|
902
|
+
columns: Record<string, FdwForeignTableColumnDef>;
|
|
903
|
+
options?: Record<string, string>;
|
|
904
|
+
ifNotExists?: boolean;
|
|
905
|
+
}
|
|
906
|
+
export interface FdwImportForeignSchemaOptions {
|
|
907
|
+
localSchema?: string;
|
|
908
|
+
limitTo?: string[];
|
|
909
|
+
except?: string[];
|
|
910
|
+
options?: Record<string, string>;
|
|
911
|
+
}
|
|
912
|
+
export interface DropViewOptions {
|
|
913
|
+
ifExists?: boolean;
|
|
914
|
+
cascade?: boolean;
|
|
915
|
+
}
|
|
916
|
+
export interface BuildOptions {
|
|
917
|
+
replacements?: Record<string, any>;
|
|
918
|
+
model?: any;
|
|
919
|
+
include?: IncludeOptions[];
|
|
920
|
+
}
|
|
921
|
+
export interface InsertOptions {
|
|
922
|
+
/** Schema to use for the table */
|
|
923
|
+
schema?: string;
|
|
924
|
+
returning?: boolean | string[];
|
|
925
|
+
upsert?: boolean;
|
|
926
|
+
conflictFields?: string[];
|
|
927
|
+
/** Fields to update on conflict (MySQL: ON DUPLICATE KEY UPDATE, PostgreSQL/SQLite: ON CONFLICT DO UPDATE, MariaDB: ON DUPLICATE KEY UPDATE) */
|
|
928
|
+
updateOnDuplicate?: string[];
|
|
929
|
+
}
|
|
930
|
+
export interface UpsertQueryOptions {
|
|
931
|
+
/** Fields to use for conflict resolution (ON CONFLICT for PostgreSQL/SQLite, ON DUPLICATE KEY for MySQL/MariaDB) */
|
|
932
|
+
conflictFields?: string[];
|
|
933
|
+
/** Schema to use for the table */
|
|
934
|
+
schema?: string;
|
|
935
|
+
/** Fields to update on conflict. If not specified, all fields will be updated */
|
|
936
|
+
updateOnDuplicate?: string[];
|
|
937
|
+
/** Whether to return the record after upsert */
|
|
938
|
+
returning?: boolean | string[];
|
|
939
|
+
/** Model raw attributes for type casting */
|
|
940
|
+
model?: any;
|
|
941
|
+
}
|
|
942
|
+
export interface UpdateOptions {
|
|
943
|
+
limit?: number;
|
|
944
|
+
returning?: boolean | string[];
|
|
945
|
+
}
|
|
946
|
+
export interface DeleteOptions {
|
|
947
|
+
limit?: number;
|
|
948
|
+
returning?: boolean | string[];
|
|
949
|
+
truncate?: boolean;
|
|
950
|
+
}
|
|
951
|
+
export interface SelectOptions {
|
|
952
|
+
tableName: string;
|
|
953
|
+
/** Schema to use for the table */
|
|
954
|
+
schema?: string;
|
|
955
|
+
attributes?: string[] | {
|
|
956
|
+
include?: string[];
|
|
957
|
+
exclude?: string[];
|
|
958
|
+
};
|
|
959
|
+
where?: WhereOptions;
|
|
960
|
+
include?: IncludeOptions[];
|
|
961
|
+
order?: Order;
|
|
962
|
+
limit?: number | string;
|
|
963
|
+
offset?: number | string;
|
|
964
|
+
group?: string | string[];
|
|
965
|
+
having?: WhereOptions;
|
|
966
|
+
raw?: boolean;
|
|
967
|
+
lock?: any;
|
|
968
|
+
subQuery?: boolean;
|
|
969
|
+
benchmark?: boolean;
|
|
970
|
+
distinct?: boolean;
|
|
971
|
+
/** Column to use with DISTINCT for count queries (e.g., COUNT(DISTINCT col)) */
|
|
972
|
+
col?: string;
|
|
973
|
+
distinctOn?: string[];
|
|
974
|
+
/**
|
|
975
|
+
* When true, uses table aliases to distinguish duplicate column names
|
|
976
|
+
* This is needed when including multiple tables that have columns with the same name
|
|
977
|
+
*/
|
|
978
|
+
duplicate?: boolean;
|
|
979
|
+
/**
|
|
980
|
+
* UNION type for combining multiple queries
|
|
981
|
+
*/
|
|
982
|
+
unionType?: 'UNION' | 'UNION ALL' | 'EXCEPT' | 'INTERSECT';
|
|
983
|
+
/**
|
|
984
|
+
* Array of union queries to combine with the main query
|
|
985
|
+
*/
|
|
986
|
+
union?: Array<{
|
|
987
|
+
model: any;
|
|
988
|
+
where?: WhereOptions;
|
|
989
|
+
attributes?: string[] | {
|
|
990
|
+
include?: string[];
|
|
991
|
+
exclude?: string[];
|
|
992
|
+
};
|
|
993
|
+
order?: Order;
|
|
994
|
+
limit?: number | string;
|
|
995
|
+
offset?: number | string;
|
|
996
|
+
include?: IncludeOptions[];
|
|
997
|
+
as?: string;
|
|
998
|
+
}>;
|
|
999
|
+
/**
|
|
1000
|
+
* Common Table Expressions (CTEs) to prepend to the query as a `WITH` clause.
|
|
1001
|
+
* Each entry becomes `name [(columns)] AS (query)`. If any entry sets
|
|
1002
|
+
* `recursive: true`, the whole clause is emitted as `WITH RECURSIVE`.
|
|
1003
|
+
*/
|
|
1004
|
+
cte?: CTEOption[];
|
|
1005
|
+
/**
|
|
1006
|
+
* PostgreSQL `TABLESAMPLE` clause, appended right after the `FROM` table:
|
|
1007
|
+
* `FROM table TABLESAMPLE BERNOULLI(10) REPEATABLE(seed)`. `percent` is the
|
|
1008
|
+
* sampling percentage (0-100). `seed`, if provided, produces a repeatable
|
|
1009
|
+
* sample via `REPEATABLE(seed)`.
|
|
1010
|
+
*/
|
|
1011
|
+
sample?: {
|
|
1012
|
+
method: 'BERNOULLI' | 'SYSTEM';
|
|
1013
|
+
percent: number;
|
|
1014
|
+
seed?: number;
|
|
1015
|
+
};
|
|
1016
|
+
}
|
|
1017
|
+
/**
|
|
1018
|
+
* A single Common Table Expression definition used by `SelectOptions.cte`.
|
|
1019
|
+
*/
|
|
1020
|
+
export interface CTEOption {
|
|
1021
|
+
/** Name the CTE is referenced by in the main query (and in itself, for recursive CTEs). */
|
|
1022
|
+
name: string;
|
|
1023
|
+
/** The CTE body: either a raw SQL string or a nested SelectOptions to be compiled. */
|
|
1024
|
+
query: string | SelectOptions;
|
|
1025
|
+
/** Marks this CTE as recursive, causing `WITH RECURSIVE` to be used. */
|
|
1026
|
+
recursive?: boolean;
|
|
1027
|
+
/** Optional explicit column list: `name (col1, col2, ...) AS (...)`. */
|
|
1028
|
+
columns?: string[];
|
|
1029
|
+
}
|
|
1030
|
+
export interface DialectOptions {
|
|
1031
|
+
host?: string;
|
|
1032
|
+
port?: number;
|
|
1033
|
+
database?: string;
|
|
1034
|
+
username?: string;
|
|
1035
|
+
password?: string;
|
|
1036
|
+
storage?: string;
|
|
1037
|
+
timezone?: string;
|
|
1038
|
+
isolationLevel?: string;
|
|
1039
|
+
}
|
|
1040
|
+
/**
|
|
1041
|
+
* Abstract base class for database dialects
|
|
1042
|
+
* Provides common functionality for all dialect implementations
|
|
1043
|
+
*/
|
|
1044
|
+
export declare abstract class BaseDialect implements Dialect {
|
|
1045
|
+
abstract readonly name: string;
|
|
1046
|
+
abstract readonly library: string;
|
|
1047
|
+
protected _connection: any;
|
|
1048
|
+
protected _connected: boolean;
|
|
1049
|
+
protected dialectName: string;
|
|
1050
|
+
abstract connect(): Promise<void>;
|
|
1051
|
+
abstract disconnect(): Promise<void>;
|
|
1052
|
+
abstract getConnection(): any;
|
|
1053
|
+
abstract isConnected(): boolean;
|
|
1054
|
+
abstract query(sql: string, options?: QueryOptions): Promise<QueryResult>;
|
|
1055
|
+
abstract queryStream(sql: string, options?: StreamOptions): Readable;
|
|
1056
|
+
abstract escape(value: any): string;
|
|
1057
|
+
abstract escapeId(identifier: string): string;
|
|
1058
|
+
abstract quoteIdentifier(identifier: string): string;
|
|
1059
|
+
abstract quoteTable(tableName: string, schema?: string): string;
|
|
1060
|
+
abstract getDatabaseVersion(): Promise<string>;
|
|
1061
|
+
abstract createTable(tableName: string, columns: Record<string, ColumnDefinition>, options?: TableOptions): Promise<void>;
|
|
1062
|
+
abstract dropTable(tableName: string, options?: DropTableOptions): Promise<void>;
|
|
1063
|
+
/**
|
|
1064
|
+
* Create a partitioned table (PostgreSQL 10+)
|
|
1065
|
+
*/
|
|
1066
|
+
abstract createPartitionedTable(tableName: string, columns: Record<string, ColumnDefinition>, options?: TableOptions & {
|
|
1067
|
+
partitionBy: {
|
|
1068
|
+
type: 'range' | 'list' | 'hash';
|
|
1069
|
+
column: string | string[];
|
|
1070
|
+
};
|
|
1071
|
+
partitions?: {
|
|
1072
|
+
name: string;
|
|
1073
|
+
bound?: PartitionBound;
|
|
1074
|
+
tablespace?: string;
|
|
1075
|
+
storageParameters?: Record<string, string | number>;
|
|
1076
|
+
}[];
|
|
1077
|
+
}): Promise<void>;
|
|
1078
|
+
/**
|
|
1079
|
+
* Create a partition for an existing partitioned table (PostgreSQL 10+)
|
|
1080
|
+
*/
|
|
1081
|
+
abstract createPartition(options: CreatePartitionOptions): Promise<void>;
|
|
1082
|
+
/**
|
|
1083
|
+
* Attach a partition to a partitioned table (PostgreSQL 11+)
|
|
1084
|
+
*/
|
|
1085
|
+
abstract attachPartition(options: AttachPartitionOptions): Promise<void>;
|
|
1086
|
+
/**
|
|
1087
|
+
* Detach a partition from a partitioned table (PostgreSQL 11+)
|
|
1088
|
+
*/
|
|
1089
|
+
abstract detachPartition(options: DetachPartitionOptions): Promise<void>;
|
|
1090
|
+
/**
|
|
1091
|
+
* Drop a partition (PostgreSQL 10+)
|
|
1092
|
+
*/
|
|
1093
|
+
abstract dropPartition(partitionName: string, options?: {
|
|
1094
|
+
ifExists?: boolean;
|
|
1095
|
+
cascade?: boolean;
|
|
1096
|
+
}): Promise<void>;
|
|
1097
|
+
/**
|
|
1098
|
+
* Create a database view
|
|
1099
|
+
* @param viewName - Name of the view to create
|
|
1100
|
+
* @param query - The SELECT query for the view
|
|
1101
|
+
* @param options - View options
|
|
1102
|
+
*/
|
|
1103
|
+
abstract createView(viewName: string, query: string, options?: ViewOptions): Promise<void>;
|
|
1104
|
+
/**
|
|
1105
|
+
* Drop a database view
|
|
1106
|
+
* @param viewName - Name of the view to drop
|
|
1107
|
+
* @param options - Drop options
|
|
1108
|
+
*/
|
|
1109
|
+
abstract dropView(viewName: string, options?: DropViewOptions): Promise<void>;
|
|
1110
|
+
/**
|
|
1111
|
+
* Create a materialized view (PostgreSQL only)
|
|
1112
|
+
* @param options - Materialized view options
|
|
1113
|
+
*/
|
|
1114
|
+
abstract createMaterializedView(options: MaterializedViewOptions): Promise<void>;
|
|
1115
|
+
/**
|
|
1116
|
+
* Refresh a materialized view (PostgreSQL only)
|
|
1117
|
+
* @param viewName - Name of the materialized view to refresh
|
|
1118
|
+
* @param options - Refresh options
|
|
1119
|
+
*/
|
|
1120
|
+
abstract refreshMaterializedView(viewName: string, options?: RefreshOptions): Promise<void>;
|
|
1121
|
+
/**
|
|
1122
|
+
* Drop a materialized view (PostgreSQL only)
|
|
1123
|
+
* @param viewName - Name of the materialized view to drop
|
|
1124
|
+
* @param options - Drop options
|
|
1125
|
+
*/
|
|
1126
|
+
abstract dropMaterializedView(viewName: string, options?: DropMaterializedViewOptions): Promise<void>;
|
|
1127
|
+
/**
|
|
1128
|
+
* Check if a materialized view exists (PostgreSQL only)
|
|
1129
|
+
* @param viewName - Name of the materialized view
|
|
1130
|
+
* @returns True if the materialized view exists
|
|
1131
|
+
*/
|
|
1132
|
+
abstract hasMaterializedView(viewName: string): Promise<boolean>;
|
|
1133
|
+
/**
|
|
1134
|
+
* Create a stored procedure
|
|
1135
|
+
* @param options - Stored procedure options
|
|
1136
|
+
*/
|
|
1137
|
+
abstract createStoredProcedure(options: StoredProcedureOptions): Promise<void>;
|
|
1138
|
+
/**
|
|
1139
|
+
* Create a stored procedure (alias for createStoredProcedure)
|
|
1140
|
+
* @param options - Stored procedure options
|
|
1141
|
+
*/
|
|
1142
|
+
createProcedure(options: StoredProcedureOptions): Promise<void>;
|
|
1143
|
+
/**
|
|
1144
|
+
* Drop a stored procedure
|
|
1145
|
+
* @param procedureName - Name of the stored procedure
|
|
1146
|
+
* @param options - Drop options
|
|
1147
|
+
*/
|
|
1148
|
+
abstract dropStoredProcedure(procedureName: string, options?: DropStoredProcedureOptions): Promise<void>;
|
|
1149
|
+
/**
|
|
1150
|
+
* Drop a stored procedure (alias for dropStoredProcedure)
|
|
1151
|
+
* @param procedureName - Name of the stored procedure
|
|
1152
|
+
* @param options - Drop options
|
|
1153
|
+
*/
|
|
1154
|
+
dropProcedure(procedureName: string, options?: DropStoredProcedureOptions): Promise<void>;
|
|
1155
|
+
/**
|
|
1156
|
+
* Execute a stored procedure
|
|
1157
|
+
* @param options - Execute options
|
|
1158
|
+
* @returns Query result
|
|
1159
|
+
*/
|
|
1160
|
+
abstract executeStoredProcedure(options: ExecuteStoredProcedureOptions): Promise<QueryResult>;
|
|
1161
|
+
/**
|
|
1162
|
+
* Check if a stored procedure exists
|
|
1163
|
+
* @param procedureName - Name of the stored procedure
|
|
1164
|
+
* @param schema - Schema name (PostgreSQL)
|
|
1165
|
+
* @returns True if the stored procedure exists
|
|
1166
|
+
*/
|
|
1167
|
+
abstract hasStoredProcedure(procedureName: string, schema?: string): Promise<boolean>;
|
|
1168
|
+
/**
|
|
1169
|
+
* Create a trigger
|
|
1170
|
+
* @param options - Trigger options
|
|
1171
|
+
*/
|
|
1172
|
+
abstract createTrigger(options: TriggerOptions): Promise<void>;
|
|
1173
|
+
/**
|
|
1174
|
+
* Drop a trigger
|
|
1175
|
+
* @param triggerName - Name of the trigger
|
|
1176
|
+
* @param tableName - Table the trigger is attached to
|
|
1177
|
+
* @param options - Drop options
|
|
1178
|
+
*/
|
|
1179
|
+
abstract dropTrigger(triggerName: string, tableName: string, options?: DropTriggerOptions): Promise<void>;
|
|
1180
|
+
/**
|
|
1181
|
+
* Check if a trigger exists
|
|
1182
|
+
* @param triggerName - Name of the trigger
|
|
1183
|
+
* @param tableName - Table the trigger is attached to
|
|
1184
|
+
* @returns True if the trigger exists
|
|
1185
|
+
*/
|
|
1186
|
+
abstract hasTrigger(triggerName: string, tableName: string): Promise<boolean>;
|
|
1187
|
+
/**
|
|
1188
|
+
* Create a sequence (PostgreSQL)
|
|
1189
|
+
* @param options - Sequence options
|
|
1190
|
+
*/
|
|
1191
|
+
abstract createSequence(options: SequenceOptions): Promise<void>;
|
|
1192
|
+
/**
|
|
1193
|
+
* Drop a sequence (PostgreSQL)
|
|
1194
|
+
* @param sequenceName - Name of the sequence
|
|
1195
|
+
* @param options - Drop options
|
|
1196
|
+
*/
|
|
1197
|
+
abstract dropSequence(sequenceName: string, options?: DropSequenceOptions): Promise<void>;
|
|
1198
|
+
/**
|
|
1199
|
+
* Get next value from a sequence (PostgreSQL)
|
|
1200
|
+
* @param sequenceName - Name of the sequence
|
|
1201
|
+
* @returns Next sequence value
|
|
1202
|
+
*/
|
|
1203
|
+
abstract nextSequenceValue(sequenceName: string): Promise<number>;
|
|
1204
|
+
/**
|
|
1205
|
+
* Check if a sequence exists (PostgreSQL)
|
|
1206
|
+
* @param sequenceName - Name of the sequence
|
|
1207
|
+
* @returns True if the sequence exists
|
|
1208
|
+
*/
|
|
1209
|
+
abstract hasSequence(sequenceName: string): Promise<boolean>;
|
|
1210
|
+
/**
|
|
1211
|
+
* Create a policy (PostgreSQL RLS)
|
|
1212
|
+
* @param options - Policy options
|
|
1213
|
+
*/
|
|
1214
|
+
abstract createPolicy(options: PolicyOptions): Promise<void>;
|
|
1215
|
+
/**
|
|
1216
|
+
* Drop a policy (PostgreSQL RLS)
|
|
1217
|
+
* @param policyName - Name of the policy
|
|
1218
|
+
* @param tableName - Table name
|
|
1219
|
+
* @param options - Drop options
|
|
1220
|
+
*/
|
|
1221
|
+
abstract dropPolicy(policyName: string, tableName: string, options?: DropPolicyOptions): Promise<void>;
|
|
1222
|
+
/**
|
|
1223
|
+
* Enable row-level security on a table (PostgreSQL)
|
|
1224
|
+
* @param tableName - Table name
|
|
1225
|
+
* @param schema - Schema name
|
|
1226
|
+
*/
|
|
1227
|
+
abstract enableRLS(tableName: string, schema?: string): Promise<void>;
|
|
1228
|
+
/**
|
|
1229
|
+
* Disable row-level security on a table (PostgreSQL)
|
|
1230
|
+
* @param tableName - Table name
|
|
1231
|
+
* @param schema - Schema name
|
|
1232
|
+
*/
|
|
1233
|
+
abstract disableRLS(tableName: string, schema?: string): Promise<void>;
|
|
1234
|
+
/**
|
|
1235
|
+
* Check if a policy exists (PostgreSQL RLS)
|
|
1236
|
+
* @param policyName - Name of the policy
|
|
1237
|
+
* @param tableName - Table name
|
|
1238
|
+
* @returns True if the policy exists
|
|
1239
|
+
*/
|
|
1240
|
+
abstract hasPolicy(policyName: string, tableName: string): Promise<boolean>;
|
|
1241
|
+
/**
|
|
1242
|
+
* Add comment to a table
|
|
1243
|
+
* @param tableName - Table name
|
|
1244
|
+
* @param comment - Comment text
|
|
1245
|
+
*/
|
|
1246
|
+
abstract commentTable(tableName: string, comment: string): Promise<void>;
|
|
1247
|
+
/**
|
|
1248
|
+
* Add comment to a column
|
|
1249
|
+
* @param tableName - Table name
|
|
1250
|
+
* @param columnName - Column name
|
|
1251
|
+
* @param comment - Comment text
|
|
1252
|
+
*/
|
|
1253
|
+
abstract commentColumn(tableName: string, columnName: string, comment: string): Promise<void>;
|
|
1254
|
+
/**
|
|
1255
|
+
* Create a partial index (index with WHERE clause)
|
|
1256
|
+
* @param tableName - Table name
|
|
1257
|
+
* @param indexName - Index name
|
|
1258
|
+
* @param fields - Fields to index
|
|
1259
|
+
* @param where - WHERE clause for partial index
|
|
1260
|
+
* @param options - Additional index options
|
|
1261
|
+
*/
|
|
1262
|
+
abstract createPartialIndex(tableName: string, indexName: string, fields: string[], where: string, options?: IndexOptions): Promise<void>;
|
|
1263
|
+
/**
|
|
1264
|
+
* Create an expression index
|
|
1265
|
+
* @param tableName - Table name
|
|
1266
|
+
* @param indexName - Index name
|
|
1267
|
+
* @param expression - Expression for the index
|
|
1268
|
+
* @param options - Additional index options
|
|
1269
|
+
*/
|
|
1270
|
+
abstract createExpressionIndex(tableName: string, indexName: string, expression: string, options?: IndexOptions): Promise<void>;
|
|
1271
|
+
/**
|
|
1272
|
+
* Create an identity column
|
|
1273
|
+
* @param tableName - Table name
|
|
1274
|
+
* @param columnName - Column name
|
|
1275
|
+
* @param options - Identity options
|
|
1276
|
+
*/
|
|
1277
|
+
abstract createIdentityColumn(tableName: string, columnName: string, options?: {
|
|
1278
|
+
startWith?: number;
|
|
1279
|
+
incrementBy?: number;
|
|
1280
|
+
minvalue?: number;
|
|
1281
|
+
maxvalue?: number;
|
|
1282
|
+
cycle?: boolean;
|
|
1283
|
+
}): Promise<void>;
|
|
1284
|
+
/**
|
|
1285
|
+
* Create a computed column
|
|
1286
|
+
* @param tableName - Table name
|
|
1287
|
+
* @param columnName - Column name
|
|
1288
|
+
* @param expression - Expression for computed column
|
|
1289
|
+
* @param options - Computed column options
|
|
1290
|
+
*/
|
|
1291
|
+
abstract createComputedColumn(tableName: string, columnName: string, expression: string, options?: {
|
|
1292
|
+
persisted?: boolean;
|
|
1293
|
+
type?: string;
|
|
1294
|
+
}): Promise<void>;
|
|
1295
|
+
abstract addColumn(tableName: string, columnName: string, definition: ColumnDefinition): Promise<void>;
|
|
1296
|
+
abstract removeColumn(tableName: string, columnName: string): Promise<void>;
|
|
1297
|
+
abstract changeColumn(tableName: string, columnName: string, definition: ColumnDefinition): Promise<void>;
|
|
1298
|
+
/**
|
|
1299
|
+
* Rename a column (default throws error)
|
|
1300
|
+
*/
|
|
1301
|
+
renameColumn(_tableName: string, _oldColumnName: string, _newColumnName: string): Promise<void>;
|
|
1302
|
+
/**
|
|
1303
|
+
* Add a foreign key (default throws error)
|
|
1304
|
+
*/
|
|
1305
|
+
addForeignKey(_tableName: string, _columnName: string, _referencedTableName: string, _referencedColumnName: string, _options?: any): Promise<void>;
|
|
1306
|
+
/**
|
|
1307
|
+
* Bulk insert records (default implementation)
|
|
1308
|
+
*/
|
|
1309
|
+
bulkInsert(tableName: string, records: Record<string, any>[], _options?: any): Promise<QueryResult>;
|
|
1310
|
+
abstract showTables(): Promise<string[]>;
|
|
1311
|
+
abstract showViews(): Promise<string[]>;
|
|
1312
|
+
abstract showMaterializedViews(): Promise<string[]>;
|
|
1313
|
+
abstract showConstraints(tableName: string): Promise<any[]>;
|
|
1314
|
+
abstract addConstraint(tableName: string, options: {
|
|
1315
|
+
type: 'UNIQUE' | 'CHECK' | 'PRIMARY KEY' | 'FOREIGN KEY';
|
|
1316
|
+
fields: string[];
|
|
1317
|
+
name?: string;
|
|
1318
|
+
references?: {
|
|
1319
|
+
table: string;
|
|
1320
|
+
fields: string[];
|
|
1321
|
+
};
|
|
1322
|
+
check?: string;
|
|
1323
|
+
}): Promise<void>;
|
|
1324
|
+
abstract removeConstraint(tableName: string, constraintName: string): Promise<void>;
|
|
1325
|
+
abstract showIndexes(tableName: string): Promise<any[]>;
|
|
1326
|
+
abstract describeTable(tableName: string): Promise<TableDescription>;
|
|
1327
|
+
abstract renameTable(oldName: string, newName: string): Promise<void>;
|
|
1328
|
+
abstract addIndex(tableName: string, indexName: string, fields: string[], options?: IndexOptions): Promise<void>;
|
|
1329
|
+
abstract removeIndex(tableName: string, indexName: string): Promise<void>;
|
|
1330
|
+
abstract createIndex(tableName: string, indexDef: IndexDefinition): Promise<void>;
|
|
1331
|
+
/**
|
|
1332
|
+
* Create a fulltext index (default throws error)
|
|
1333
|
+
*/
|
|
1334
|
+
createFulltextIndex(_tableName: string, _indexName: string, _fields: string[], _options?: {
|
|
1335
|
+
parser?: string;
|
|
1336
|
+
comment?: string;
|
|
1337
|
+
}): Promise<void>;
|
|
1338
|
+
/**
|
|
1339
|
+
* Create a spatial index (default throws error)
|
|
1340
|
+
*/
|
|
1341
|
+
createSpatialIndex(_tableName: string, _indexName: string, _fields: string[], _options?: {
|
|
1342
|
+
storage?: string;
|
|
1343
|
+
srid?: number;
|
|
1344
|
+
}): Promise<void>;
|
|
1345
|
+
abstract dropIndex(tableName: string, indexName: string, options?: DropIndexOptions): Promise<void>;
|
|
1346
|
+
abstract createConstraint(tableName: string, constraintDef: ConstraintDefinition): Promise<void>;
|
|
1347
|
+
abstract dropConstraint(tableName: string, constraintName: string, options?: DropConstraintOptions): Promise<void>;
|
|
1348
|
+
abstract changeOwner(newOwner: string, tableName: string): Promise<void>;
|
|
1349
|
+
abstract createForeignDataWrapper(fdwName: string, options?: {
|
|
1350
|
+
handler?: string;
|
|
1351
|
+
}): Promise<void>;
|
|
1352
|
+
abstract dropForeignDataWrapper(fdwName: string, options?: {
|
|
1353
|
+
ifExists?: boolean;
|
|
1354
|
+
}): Promise<void>;
|
|
1355
|
+
abstract createForeignServer(serverName: string, fdwName: string, options?: {
|
|
1356
|
+
options?: Record<string, string>;
|
|
1357
|
+
ifNotExists?: boolean;
|
|
1358
|
+
}): Promise<void>;
|
|
1359
|
+
abstract dropForeignServer(serverName: string, options?: {
|
|
1360
|
+
ifExists?: boolean;
|
|
1361
|
+
cascade?: boolean;
|
|
1362
|
+
}): Promise<void>;
|
|
1363
|
+
abstract createForeignTable(tableName: string, columns: Record<string, {
|
|
1364
|
+
type: string;
|
|
1365
|
+
}>, options?: {
|
|
1366
|
+
serverName?: string;
|
|
1367
|
+
ifNotExists?: boolean;
|
|
1368
|
+
}): Promise<void>;
|
|
1369
|
+
abstract createSecurityPolicy(policyName: string, tableName: string, options?: {
|
|
1370
|
+
predicate?: string;
|
|
1371
|
+
}): Promise<void>;
|
|
1372
|
+
abstract dropSecurityPolicy(policyName: string, tableName: string): Promise<void>;
|
|
1373
|
+
abstract startTransaction(options?: TransactionOptions): Promise<Transaction>;
|
|
1374
|
+
abstract commitTransaction(transaction: Transaction): Promise<void>;
|
|
1375
|
+
abstract rollbackTransaction(transaction: Transaction): Promise<void>;
|
|
1376
|
+
abstract getDataTypeSql(dataType: DataType): string;
|
|
1377
|
+
abstract buildWhereClause(where: WhereOptions, options?: BuildOptions): {
|
|
1378
|
+
sql: string;
|
|
1379
|
+
values: any[];
|
|
1380
|
+
};
|
|
1381
|
+
abstract buildOrderClause(order: Order, options?: BuildOptions): string;
|
|
1382
|
+
abstract buildLimitOffset(limit?: number | string, offset?: number | string): string;
|
|
1383
|
+
abstract buildInsertQuery(tableName: string, values: Record<string, any>, options?: InsertOptions): {
|
|
1384
|
+
sql: string;
|
|
1385
|
+
values: any[];
|
|
1386
|
+
};
|
|
1387
|
+
abstract buildUpdateQuery(tableName: string, values: Record<string, any>, where: WhereOptions, options?: UpdateOptions): {
|
|
1388
|
+
sql: string;
|
|
1389
|
+
values: any[];
|
|
1390
|
+
};
|
|
1391
|
+
abstract buildDeleteQuery(tableName: string, where: WhereOptions, options?: DeleteOptions): {
|
|
1392
|
+
sql: string;
|
|
1393
|
+
values: any[];
|
|
1394
|
+
};
|
|
1395
|
+
abstract buildSelectQuery(options: SelectOptions): {
|
|
1396
|
+
sql: string;
|
|
1397
|
+
values: any[];
|
|
1398
|
+
};
|
|
1399
|
+
/**
|
|
1400
|
+
* Create a schema
|
|
1401
|
+
* @param schema - The schema name to create
|
|
1402
|
+
*/
|
|
1403
|
+
abstract createSchema(schema: string): Promise<void>;
|
|
1404
|
+
/**
|
|
1405
|
+
* Drop a schema
|
|
1406
|
+
* @param schema - The schema name to drop
|
|
1407
|
+
* @param options - Drop options
|
|
1408
|
+
*/
|
|
1409
|
+
abstract dropSchema(schema: string, options?: DropSchemaOptions): Promise<void>;
|
|
1410
|
+
/**
|
|
1411
|
+
* Show all schemas in the database
|
|
1412
|
+
*/
|
|
1413
|
+
abstract showAllSchemas(): Promise<string[]>;
|
|
1414
|
+
/**
|
|
1415
|
+
* List all schemas in the database
|
|
1416
|
+
*/
|
|
1417
|
+
listSchemas(): Promise<string[]>;
|
|
1418
|
+
/**
|
|
1419
|
+
* Generate SQL for creating a database (default implementation)
|
|
1420
|
+
* @param options - Database creation options
|
|
1421
|
+
*/
|
|
1422
|
+
createDatabaseSQL(options: {
|
|
1423
|
+
name: string;
|
|
1424
|
+
encoding?: string;
|
|
1425
|
+
lcCollate?: string;
|
|
1426
|
+
lcCtype?: string;
|
|
1427
|
+
template?: string;
|
|
1428
|
+
tablespace?: string;
|
|
1429
|
+
collate?: string;
|
|
1430
|
+
isTemplate?: boolean;
|
|
1431
|
+
}): string;
|
|
1432
|
+
/**
|
|
1433
|
+
* Generate SQL for dropping a database
|
|
1434
|
+
* @param name - Database name to drop
|
|
1435
|
+
*/
|
|
1436
|
+
dropDatabaseSQL(name: string): string;
|
|
1437
|
+
/**
|
|
1438
|
+
* Generate SQL for creating a savepoint
|
|
1439
|
+
* @param name - Savepoint name (optional, will be generated if not provided)
|
|
1440
|
+
*/
|
|
1441
|
+
createSavepointSQL(name?: string): string;
|
|
1442
|
+
/**
|
|
1443
|
+
* Generate SQL for releasing a savepoint
|
|
1444
|
+
* @param name - Savepoint name to release
|
|
1445
|
+
*/
|
|
1446
|
+
releaseSavepointSQL(name: string): string;
|
|
1447
|
+
/**
|
|
1448
|
+
* Generate SQL for rolling back to a savepoint
|
|
1449
|
+
* @param name - Savepoint name to rollback to
|
|
1450
|
+
*/
|
|
1451
|
+
rollbackToSavepointSQL(name: string): string;
|
|
1452
|
+
/**
|
|
1453
|
+
* Create a PostgreSQL extension (only supported in PostgreSQL)
|
|
1454
|
+
* @param extensionName - Name of the extension to create
|
|
1455
|
+
* @param options - Extension options
|
|
1456
|
+
*/
|
|
1457
|
+
createExtension(_extensionName: string, _options?: CreateExtensionOptions): Promise<void>;
|
|
1458
|
+
/**
|
|
1459
|
+
* Drop a PostgreSQL extension (only supported in PostgreSQL)
|
|
1460
|
+
* @param extensionName - Name of the extension to drop
|
|
1461
|
+
* @param options - Drop options
|
|
1462
|
+
*/
|
|
1463
|
+
dropExtension(_extensionName: string, _options?: DropExtensionOptions): Promise<void>;
|
|
1464
|
+
/**
|
|
1465
|
+
* Get all installed PostgreSQL extensions (only supported in PostgreSQL)
|
|
1466
|
+
* @returns Array of extension information
|
|
1467
|
+
*/
|
|
1468
|
+
getExtensions(): Promise<ExtensionInfo[]>;
|
|
1469
|
+
/**
|
|
1470
|
+
* Check if a PostgreSQL extension is installed (only supported in PostgreSQL)
|
|
1471
|
+
* @param extensionName - Name of the extension
|
|
1472
|
+
* @returns True if the extension is installed
|
|
1473
|
+
*/
|
|
1474
|
+
hasExtension(_extensionName: string): Promise<boolean>;
|
|
1475
|
+
/**
|
|
1476
|
+
* Create a PostgreSQL enum type (only supported in PostgreSQL)
|
|
1477
|
+
*/
|
|
1478
|
+
createEnumType(_name: string, _values: string[], _options?: CreateEnumTypeOptions): Promise<void>;
|
|
1479
|
+
/**
|
|
1480
|
+
* Drop a PostgreSQL type (only supported in PostgreSQL)
|
|
1481
|
+
*/
|
|
1482
|
+
dropType(_name: string, _options?: DropTypeOptions): Promise<void>;
|
|
1483
|
+
/**
|
|
1484
|
+
* Create a PostgreSQL domain (only supported in PostgreSQL)
|
|
1485
|
+
*/
|
|
1486
|
+
createDomain(_name: string, _baseType: string, _options?: CreateDomainOptions): Promise<void>;
|
|
1487
|
+
/**
|
|
1488
|
+
* Drop a PostgreSQL domain (only supported in PostgreSQL)
|
|
1489
|
+
*/
|
|
1490
|
+
dropDomain(_name: string, _options?: DropDomainOptions): Promise<void>;
|
|
1491
|
+
buildCreateServerQuery(_name: string, _opts: FdwForeignServerOptions): string;
|
|
1492
|
+
buildAlterServerQuery(_name: string, _opts: FdwAlterForeignServerOptions): string;
|
|
1493
|
+
buildDropServerQuery(_name: string, _opts?: {
|
|
1494
|
+
ifExists?: boolean;
|
|
1495
|
+
cascade?: boolean;
|
|
1496
|
+
}): string;
|
|
1497
|
+
buildCreateUserMappingQuery(_opts: FdwUserMappingOptions): string;
|
|
1498
|
+
buildAlterUserMappingQuery(_opts: FdwUserMappingOptions): string;
|
|
1499
|
+
buildDropUserMappingQuery(_serverName: string, _user: string, _opts?: {
|
|
1500
|
+
ifExists?: boolean;
|
|
1501
|
+
}): string;
|
|
1502
|
+
/**
|
|
1503
|
+
* Create a user mapping (default throws error)
|
|
1504
|
+
*/
|
|
1505
|
+
createUserMapping(_userName: string, _serverName: string, _options?: any): Promise<void>;
|
|
1506
|
+
/**
|
|
1507
|
+
* Drop a user mapping (default throws error)
|
|
1508
|
+
*/
|
|
1509
|
+
dropUserMapping(_userName: string, _serverName: string, _options?: any): Promise<void>;
|
|
1510
|
+
buildCreateForeignTableQuery(_tableName: string, _opts: FdwForeignTableOptions): string;
|
|
1511
|
+
buildDropForeignTableQuery(_tableName: string, _opts?: {
|
|
1512
|
+
ifExists?: boolean;
|
|
1513
|
+
cascade?: boolean;
|
|
1514
|
+
}): string;
|
|
1515
|
+
buildImportForeignSchemaQuery(_remoteSchema: string, _serverName: string, _opts?: FdwImportForeignSchemaOptions): string;
|
|
1516
|
+
getServersQuery(): string;
|
|
1517
|
+
buildCreateUserQuery(_username: string, _options?: any): string;
|
|
1518
|
+
buildAlterUserQuery(_username: string, _options: any): string;
|
|
1519
|
+
buildDropUserQuery(_username: string, _options?: any): string;
|
|
1520
|
+
getUsersQuery(): string;
|
|
1521
|
+
buildGrantQuery(_options: any): string;
|
|
1522
|
+
buildRevokeQuery(_options: any): string;
|
|
1523
|
+
buildShowGrantsQuery(_username: string, _host?: string): string;
|
|
1524
|
+
buildFlushPrivilegesQuery(): string;
|
|
1525
|
+
buildCreateRoleQuery(_roleName: string, _options?: any): string;
|
|
1526
|
+
buildDropRoleQuery(_roleName: string, _options?: any): string;
|
|
1527
|
+
buildGrantRoleQuery(_role: string, _to: any, _options?: any): string;
|
|
1528
|
+
buildRevokeRoleQuery(_role: string, _from: any, _options?: any): string;
|
|
1529
|
+
getRolesQuery(): string;
|
|
1530
|
+
/**
|
|
1531
|
+
* Build an UPSERT query (insert or update on conflict)
|
|
1532
|
+
* @param tableName - Table name
|
|
1533
|
+
* @param values - Values to insert/update
|
|
1534
|
+
* @param options - Upsert options
|
|
1535
|
+
*/
|
|
1536
|
+
abstract buildUpsertQuery(tableName: string, values: Record<string, any>, options?: UpsertQueryOptions): {
|
|
1537
|
+
sql: string;
|
|
1538
|
+
values: any[];
|
|
1539
|
+
};
|
|
1540
|
+
/**
|
|
1541
|
+
* Build an UPSERT query (insert or update on conflict)
|
|
1542
|
+
* @param tableName - Table name
|
|
1543
|
+
* @param values - Values to insert/update
|
|
1544
|
+
* @param options - Upsert options
|
|
1545
|
+
*/
|
|
1546
|
+
abstract buildUpsertQuery(tableName: string, values: Record<string, any>, options?: UpsertQueryOptions): {
|
|
1547
|
+
sql: string;
|
|
1548
|
+
values: any[];
|
|
1549
|
+
};
|
|
1550
|
+
/**
|
|
1551
|
+
* Build an increment query
|
|
1552
|
+
* @param tableName - Table name
|
|
1553
|
+
* @param fields - Fields to increment
|
|
1554
|
+
* @param where - Where clause
|
|
1555
|
+
* @param options - Query options (by: number)
|
|
1556
|
+
*/
|
|
1557
|
+
abstract buildIncrementQuery(tableName: string, fields: string | string[] | Record<string, number>, where: WhereOptions, options?: {
|
|
1558
|
+
by?: number;
|
|
1559
|
+
}): {
|
|
1560
|
+
sql: string;
|
|
1561
|
+
values: any[];
|
|
1562
|
+
};
|
|
1563
|
+
/**
|
|
1564
|
+
* Build a JSON/JSONB path query
|
|
1565
|
+
* Default implementation using common JSON extraction syntax
|
|
1566
|
+
*
|
|
1567
|
+
* @param column - The JSON/JSONB column name
|
|
1568
|
+
* @param path - The JSON path to access (e.g., 'key' or 'key.subkey')
|
|
1569
|
+
* @param value - The value to compare against (optional)
|
|
1570
|
+
* @param operator - The comparison operator to use (defaults to =)
|
|
1571
|
+
* @returns SQL fragment and values for the JSON query
|
|
1572
|
+
*/
|
|
1573
|
+
buildJsonQuery(column: string, path: string, value?: unknown, operator?: string): {
|
|
1574
|
+
sql: string;
|
|
1575
|
+
values: unknown[];
|
|
1576
|
+
};
|
|
1577
|
+
/**
|
|
1578
|
+
* Format a value for SQL based on its type
|
|
1579
|
+
*/
|
|
1580
|
+
protected formatValue(value: any): string;
|
|
1581
|
+
/**
|
|
1582
|
+
* Format a date for SQL
|
|
1583
|
+
*/
|
|
1584
|
+
protected formatDate(date: Date): string;
|
|
1585
|
+
/**
|
|
1586
|
+
* Replace placeholders in SQL with actual values
|
|
1587
|
+
* Supports both named (:param) and positional (?) placeholders
|
|
1588
|
+
* Properly escapes values to prevent SQL injection
|
|
1589
|
+
*/
|
|
1590
|
+
replaceReplacements(sql: string, replacements?: Record<string, unknown> | unknown[]): string;
|
|
1591
|
+
/**
|
|
1592
|
+
* Replace positional (?) placeholders with escaped values
|
|
1593
|
+
*/
|
|
1594
|
+
protected replacePositionalReplacements(sql: string, replacements: unknown[]): string;
|
|
1595
|
+
/**
|
|
1596
|
+
* Replace named (:param) placeholders with escaped values
|
|
1597
|
+
*/
|
|
1598
|
+
protected replaceNamedReplacements(sql: string, replacements: Record<string, unknown>): string;
|
|
1599
|
+
/**
|
|
1600
|
+
* Escape a replacement value for safe inclusion in SQL
|
|
1601
|
+
*/
|
|
1602
|
+
protected escapeReplacement(value: unknown): string;
|
|
1603
|
+
/**
|
|
1604
|
+
* Parse a value from the database
|
|
1605
|
+
*/
|
|
1606
|
+
protected parseValue(value: any, type: DataType): any;
|
|
1607
|
+
/**
|
|
1608
|
+
* Get the isolation level SQL
|
|
1609
|
+
*/
|
|
1610
|
+
protected getIsolationLevelSql(isolationLevel?: string): string;
|
|
1611
|
+
/**
|
|
1612
|
+
* Resolve the 'all' include option to actual include configurations
|
|
1613
|
+
*/
|
|
1614
|
+
protected resolveAllInclude(include: IncludeOptions, parentAlias: string, depth: number): IncludeOptions[];
|
|
1615
|
+
/**
|
|
1616
|
+
* Generate column list with proper aliasing to avoid duplicates
|
|
1617
|
+
*/
|
|
1618
|
+
protected generateSelectColumns(mainTableName: string, mainTableAlias: string, attributes?: string[] | {
|
|
1619
|
+
include?: string[];
|
|
1620
|
+
exclude?: string[];
|
|
1621
|
+
}, includes?: Array<{
|
|
1622
|
+
tableName: string;
|
|
1623
|
+
alias: string;
|
|
1624
|
+
}>): string;
|
|
1625
|
+
/**
|
|
1626
|
+
* Flatten nested includes to handle 'all' option
|
|
1627
|
+
*/
|
|
1628
|
+
protected flattenIncludesWithAll(includes: IncludeOptions[], parentAlias?: string, depth?: number): IncludeOptions[];
|
|
1629
|
+
}
|
|
1630
|
+
/**
|
|
1631
|
+
* Dialect registry for managing available dialects
|
|
1632
|
+
*/
|
|
1633
|
+
export declare class DialectRegistry {
|
|
1634
|
+
private static dialects;
|
|
1635
|
+
/**
|
|
1636
|
+
* Register a new dialect
|
|
1637
|
+
*/
|
|
1638
|
+
static register(name: string, factory: new (options: DialectOptions) => Dialect): void;
|
|
1639
|
+
/**
|
|
1640
|
+
* Get a dialect by name
|
|
1641
|
+
*/
|
|
1642
|
+
static get(name: string): new (options: DialectOptions) => Dialect;
|
|
1643
|
+
/**
|
|
1644
|
+
* Check if a dialect is registered
|
|
1645
|
+
*/
|
|
1646
|
+
static has(name: string): boolean;
|
|
1647
|
+
/**
|
|
1648
|
+
* Get all registered dialect names
|
|
1649
|
+
*/
|
|
1650
|
+
static getAvailable(): string[];
|
|
1651
|
+
}
|
|
1652
|
+
export type { RefreshOptions, MaterializedViewOptions, DropMaterializedViewOptions, RefreshMethod, BuildMode, RefreshOn, } from '../types';
|
|
1653
|
+
export type { RefreshStrategy as ViewRefreshStrategy } from '../decorators/view';
|