ts-prorm-orm 1.1.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +95 -0
- package/README.md +194 -72
- package/dist/audit/history-query.d.ts +35 -0
- package/dist/audit/index.d.ts +16 -0
- package/dist/audit/logger.d.ts +126 -0
- package/dist/cache/cache-manager.d.ts +341 -0
- package/dist/cache/index.d.ts +8 -0
- package/dist/cache/redis-cluster-cache.d.ts +164 -0
- package/dist/cache/redis-cluster-cache.js +19 -36
- package/dist/cli/cloud.d.ts +55 -0
- package/dist/cli/cloud.js +318 -0
- package/dist/cli/commands/auth.d.ts +2 -0
- package/dist/cli/commands/auth.js +345 -0
- package/dist/cli/commands/billing.d.ts +2 -0
- package/dist/cli/commands/billing.js +135 -0
- package/dist/cli/commands/code.d.ts +2 -0
- package/dist/cli/commands/code.js +168 -0
- package/dist/cli/commands/config.d.ts +2 -0
- package/dist/cli/commands/config.js +154 -0
- package/dist/cli/commands/db.d.ts +2 -0
- package/dist/cli/commands/db.js +189 -0
- package/dist/cli/commands/index.d.ts +1 -0
- package/dist/cli/commands/index.js +22 -0
- package/dist/cli/commands/keys.d.ts +2 -0
- package/dist/cli/commands/keys.js +100 -0
- package/dist/cli/commands/misc.d.ts +2 -0
- package/dist/cli/commands/misc.js +282 -0
- package/dist/cli/commands/pull.d.ts +2 -0
- package/dist/cli/commands/pull.js +306 -0
- package/dist/cli/commands/runners.d.ts +2 -0
- package/dist/cli/commands/runners.js +218 -0
- package/dist/cli/commands/scaffold.d.ts +2 -0
- package/dist/cli/commands/scaffold.js +383 -0
- package/dist/cli/commands/secrets.d.ts +2 -0
- package/dist/cli/commands/secrets.js +162 -0
- package/dist/cli/commands/store.d.ts +2 -0
- package/dist/cli/commands/store.js +274 -0
- package/dist/cli/commands/system.d.ts +10 -0
- package/dist/cli/commands/system.js +169 -0
- package/dist/cli/commands/teams.d.ts +2 -0
- package/dist/cli/commands/teams.js +189 -0
- package/dist/cli/commands/user.d.ts +2 -0
- package/dist/cli/commands/user.js +171 -0
- package/dist/cli/framework.d.ts +103 -0
- package/dist/cli/framework.js +436 -0
- package/dist/cli/io.d.ts +26 -0
- package/dist/cli/io.js +181 -0
- package/dist/cli/keychain.d.ts +10 -0
- package/dist/cli/keychain.js +101 -0
- package/dist/cli/prompt.d.ts +20 -0
- package/dist/cli/prompt.js +111 -0
- package/dist/cli.d.ts +214 -0
- package/dist/cli.js +72 -5
- package/dist/compliance/audit-trail.d.ts +66 -0
- package/dist/compliance/backup-verification.d.ts +279 -0
- package/dist/compliance/breach-detector.d.ts +197 -0
- package/dist/compliance/consent-record.d.ts +107 -0
- package/dist/compliance/consent-versioning.d.ts +169 -0
- package/dist/compliance/cross-border-log.d.ts +254 -0
- package/dist/compliance/data-classifier.d.ts +127 -0
- package/dist/compliance/data-lineage.d.ts +268 -0
- package/dist/compliance/data-masker.d.ts +110 -0
- package/dist/compliance/data-portability.d.ts +98 -0
- package/dist/compliance/data-retention.d.ts +108 -0
- package/dist/compliance/dsar-workflow.d.ts +175 -0
- package/dist/compliance/field-encryption.d.ts +84 -0
- package/dist/compliance/immutable-record.d.ts +84 -0
- package/dist/compliance/index.d.ts +93 -0
- package/dist/compliance/privacy-impact-assessment.d.ts +196 -0
- package/dist/compliance/pseudonymization.d.ts +96 -0
- package/dist/compliance/query-firewall.d.ts +661 -0
- package/dist/compliance/rate-limiter.d.ts +203 -0
- package/dist/compliance/right-to-erasure.d.ts +96 -0
- package/dist/compliance/row-level-security.d.ts +152 -0
- package/dist/compliance/security-decorator.d.ts +388 -0
- package/dist/compliance/security-monitor.d.ts +170 -0
- package/dist/compliance/sensitive-data-discovery.d.ts +151 -0
- package/dist/compliance/session-isolation.d.ts +286 -0
- package/dist/compliance/tls-enforcer.d.ts +51 -0
- package/dist/compliance/worm-storage.d.ts +225 -0
- package/dist/connection-manager.d.ts +130 -0
- package/dist/connection-pool.d.ts +311 -0
- package/dist/decorators/audit.d.ts +49 -0
- package/dist/decorators/check.d.ts +218 -0
- package/dist/decorators/collate.d.ts +346 -0
- package/dist/decorators/comment.d.ts +51 -0
- package/dist/decorators/database-settings.d.ts +193 -0
- package/dist/decorators/default.d.ts +148 -0
- package/dist/decorators/encryption.d.ts +175 -0
- package/dist/decorators/engine.d.ts +97 -0
- package/dist/decorators/fk-constraints.d.ts +387 -0
- package/dist/decorators/foreign-table.d.ts +57 -0
- package/dist/decorators/generated.d.ts +232 -0
- package/dist/decorators/hstore.d.ts +96 -0
- package/dist/decorators/index.d.ts +57 -0
- package/dist/decorators/index.js +14 -30
- package/dist/decorators/json-column.d.ts +47 -0
- package/dist/decorators/jsonb.d.ts +83 -0
- package/dist/decorators/orm-decorators.d.ts +274 -0
- package/dist/decorators/permissions.d.ts +192 -0
- package/dist/decorators/procedure.d.ts +168 -0
- package/dist/decorators/procedure.js +31 -7
- package/dist/decorators/query-options.d.ts +527 -0
- package/dist/decorators/range.d.ts +122 -0
- package/dist/decorators/set-column.d.ts +43 -0
- package/dist/decorators/spatial.d.ts +60 -0
- package/dist/decorators/storage.d.ts +561 -0
- package/dist/decorators/timezone.d.ts +319 -0
- package/dist/decorators/trigger.d.ts +50 -0
- package/dist/decorators/uuid.d.ts +102 -0
- package/dist/decorators/view.d.ts +213 -0
- package/dist/diagrams/chen-diagram.d.ts +70 -0
- package/dist/diagrams/chen-diagram.js +33 -31
- package/dist/diagrams/class-diagram.d.ts +78 -0
- package/dist/diagrams/class-diagram.js +23 -27
- package/dist/diagrams/dependency-diagram.d.ts +82 -0
- package/dist/diagrams/dependency-diagram.js +18 -9
- package/dist/diagrams/er-diagram.d.ts +82 -0
- package/dist/diagrams/er-diagram.js +174 -231
- package/dist/diagrams/flow-diagram.d.ts +70 -0
- package/dist/diagrams/flow-diagram.js +23 -18
- package/dist/diagrams/gantt-diagram.d.ts +67 -0
- package/dist/diagrams/gantt-diagram.js +20 -18
- package/dist/diagrams/index-diagram.d.ts +61 -0
- package/dist/diagrams/index-diagram.js +36 -31
- package/dist/diagrams/index.d.ts +155 -0
- package/dist/diagrams/index.js +7 -1
- package/dist/diagrams/migration-diagram.d.ts +67 -0
- package/dist/diagrams/migration-diagram.js +45 -57
- package/dist/diagrams/model-diagram.d.ts +85 -0
- package/dist/diagrams/model-diagram.js +225 -287
- package/dist/diagrams/package-diagram.d.ts +69 -0
- package/dist/diagrams/package-diagram.js +30 -32
- package/dist/diagrams/palette.d.ts +138 -0
- package/dist/diagrams/palette.js +134 -25
- package/dist/diagrams/relational-diagram.d.ts +82 -0
- package/dist/diagrams/relational-diagram.js +51 -59
- package/dist/diagrams/schemadoc-diagram.d.ts +57 -0
- package/dist/diagrams/schemadoc-diagram.js +36 -28
- package/dist/diagrams/sequence-diagram.d.ts +61 -0
- package/dist/diagrams/sequence-diagram.js +20 -11
- package/dist/diagrams/state-diagram.d.ts +85 -0
- package/dist/diagrams/state-diagram.js +21 -17
- package/dist/diagrams/svg-dom.d.ts +62 -0
- package/dist/diagrams/svg-dom.js +11 -0
- package/dist/diagrams/tree-diagram.d.ts +47 -0
- package/dist/diagrams/tree-diagram.js +19 -10
- package/dist/dialects/clickhouse/index.d.ts +660 -0
- package/dist/dialects/clickhouse/index.js +107 -2
- package/dist/dialects/cockroachdb/index.d.ts +1708 -0
- package/dist/dialects/cockroachdb/index.js +139 -10
- package/dist/dialects/cratedb/index.d.ts +262 -0
- package/dist/dialects/cratedb/index.js +148 -0
- package/dist/dialects/databricks/index.d.ts +397 -0
- package/dist/dialects/databricks/index.js +233 -11
- package/dist/dialects/db2/index.d.ts +729 -0
- package/dist/dialects/db2/index.js +152 -2
- package/dist/dialects/dialect.d.ts +1653 -0
- package/dist/dialects/duckdb/index.d.ts +440 -0
- package/dist/dialects/duckdb/index.js +21 -37
- package/dist/dialects/exasol/index.d.ts +197 -0
- package/dist/dialects/exasol/index.js +14 -0
- package/dist/dialects/firebird/index.d.ts +286 -0
- package/dist/dialects/firebird/index.js +135 -0
- package/dist/dialects/greenplum/index.d.ts +336 -0
- package/dist/dialects/greenplum/index.js +168 -0
- package/dist/dialects/hana/index.d.ts +512 -0
- package/dist/dialects/hana/index.js +17 -35
- package/dist/dialects/mariadb/index.d.ts +1241 -0
- package/dist/dialects/mariadb/index.js +181 -43
- package/dist/dialects/mssql/index.d.ts +729 -0
- package/dist/dialects/mssql/index.js +76 -7
- package/dist/dialects/mysql/index.d.ts +1233 -0
- package/dist/dialects/mysql/index.js +87 -19
- package/dist/dialects/oracle/index.d.ts +1222 -0
- package/dist/dialects/oracle/index.js +210 -9
- package/dist/dialects/postgres/index.d.ts +1598 -0
- package/dist/dialects/postgres/index.js +34 -13
- package/dist/dialects/query-stream-helper.d.ts +58 -0
- package/dist/dialects/questdb/index.d.ts +430 -0
- package/dist/dialects/questdb/index.js +292 -0
- package/dist/dialects/redshift/index.d.ts +933 -0
- package/dist/dialects/redshift/index.js +17 -5
- package/dist/dialects/singlestore/index.d.ts +233 -0
- package/dist/dialects/singlestore/index.js +53 -0
- package/dist/dialects/snowflake/index.d.ts +727 -0
- package/dist/dialects/snowflake/index.js +154 -5
- package/dist/dialects/spanner/index.d.ts +660 -0
- package/dist/dialects/spanner/index.js +43 -21
- package/dist/dialects/sqlite/index.d.ts +1133 -0
- package/dist/dialects/sqlite/index.js +168 -30
- package/dist/dialects/tidb/index.d.ts +226 -0
- package/dist/dialects/tidb/index.js +10 -0
- package/dist/dialects/timescaledb/index.d.ts +286 -0
- package/dist/dialects/timescaledb/index.js +179 -0
- package/dist/dialects/trino/index.d.ts +230 -0
- package/dist/dialects/trino/index.js +85 -10
- package/dist/dialects/turso/index.d.ts +98 -0
- package/dist/dialects/turso/index.js +10 -0
- package/dist/dialects/vertica/index.d.ts +321 -0
- package/dist/dialects/vertica/index.js +161 -0
- package/dist/dialects/yugabytedb/index.d.ts +276 -0
- package/dist/dialects/yugabytedb/index.js +121 -0
- package/dist/errors/index.d.ts +378 -0
- package/dist/errors/index.js +29 -1
- package/dist/errors/utils.d.ts +53 -0
- package/dist/errors.d.ts +5 -0
- package/dist/extensions/catalog/cloud-warehouse-features.d.ts +27 -0
- package/dist/extensions/catalog/mssql-features.d.ts +20 -0
- package/dist/extensions/catalog/mysql-mariadb-plugins.d.ts +18 -0
- package/dist/extensions/catalog/oracle-db2-features.d.ts +17 -0
- package/dist/extensions/catalog/postgres-extensions.d.ts +15 -0
- package/dist/extensions/index.d.ts +34 -0
- package/dist/extensions/types.d.ts +43 -0
- package/dist/external-fields/adapters.d.ts +50 -0
- package/dist/external-fields/adapters.js +227 -0
- package/dist/external-fields/decorator.d.ts +77 -0
- package/dist/external-fields/decorator.js +80 -0
- package/dist/external-fields/index.d.ts +10 -0
- package/dist/external-fields/index.js +19 -0
- package/dist/external-fields/runtime.d.ts +39 -0
- package/dist/external-fields/runtime.js +221 -0
- package/dist/foreign-data.d.ts +168 -0
- package/dist/graph/base-graph-dialect.d.ts +250 -0
- package/dist/graph/base-graph-dialect.js +539 -0
- package/dist/graph/dgraph/index.d.ts +65 -0
- package/dist/graph/dgraph/index.js +559 -0
- package/dist/graph/gremlin/index.d.ts +59 -0
- package/dist/graph/gremlin/index.js +378 -0
- package/dist/graph/index.d.ts +60 -0
- package/dist/graph/index.js +67 -0
- package/dist/graph/neo4j/index.d.ts +50 -0
- package/dist/graph/neo4j/index.js +462 -0
- package/dist/graph/types.d.ts +213 -0
- package/dist/graph/types.js +234 -0
- package/dist/hooks/hooks-manager.d.ts +189 -0
- package/dist/hooks/index.d.ts +8 -0
- package/dist/index.d.ts +713 -0
- package/dist/index.js +36 -4
- package/dist/logging.d.ts +183 -0
- package/dist/migrations/index.d.ts +9 -0
- package/dist/migrations/migration.d.ts +143 -0
- package/dist/migrations/migrator.d.ts +199 -0
- package/dist/migrations/prormmigration.d.ts +131 -0
- package/dist/migrations/query-interface.d.ts +335 -0
- package/dist/migrations/seeder.d.ts +167 -0
- package/dist/models/associations.d.ts +131 -0
- package/dist/models/associations.js +7 -2
- package/dist/models/constraints.d.ts +175 -0
- package/dist/models/data-types.d.ts +1656 -0
- package/dist/models/decorators.d.ts +328 -0
- package/dist/models/decorators.js +61 -82
- package/dist/models/eager-load.d.ts +86 -0
- package/dist/models/eager-load.js +369 -0
- package/dist/models/index.d.ts +13 -0
- package/dist/models/indexes.d.ts +325 -0
- package/dist/models/methods.d.ts +419 -0
- package/dist/models/model-manager.d.ts +76 -0
- package/dist/models/model.d.ts +820 -0
- package/dist/models/model.js +15 -101
- package/dist/models/operators.d.ts +29 -0
- package/dist/models/scopes.d.ts +71 -0
- package/dist/models/typescript-types.d.ts +177 -0
- package/dist/nosql/aerospike/index.d.ts +126 -0
- package/dist/nosql/allegrograph/index.d.ts +86 -0
- package/dist/nosql/arangodb/index.d.ts +285 -0
- package/dist/nosql/arangodb/index.js +274 -2
- package/dist/nosql/arangodb/where.d.ts +38 -0
- package/dist/nosql/arangodb/where.js +94 -0
- package/dist/nosql/azure-blob/index.d.ts +104 -0
- package/dist/nosql/beanstalkd/index.d.ts +88 -0
- package/dist/nosql/beequeue/index.d.ts +99 -0
- package/dist/nosql/bigchaindb/index.d.ts +113 -0
- package/dist/nosql/bigtable/index.d.ts +144 -0
- package/dist/nosql/blazegraph/index.d.ts +88 -0
- package/dist/nosql/bullmq/index.d.ts +83 -0
- package/dist/nosql/cassandra/index.d.ts +119 -0
- package/dist/nosql/chroma/index.d.ts +151 -0
- package/dist/nosql/cloudflare-kv/index.d.ts +120 -0
- package/dist/nosql/coherence/index.d.ts +91 -0
- package/dist/nosql/cosmosdb/index.d.ts +78 -0
- package/dist/nosql/couchbase/index.d.ts +103 -0
- package/dist/nosql/dax/index.d.ts +118 -0
- package/dist/nosql/deno-kv/index.d.ts +109 -0
- package/dist/nosql/dgraph/index.d.ts +80 -0
- package/dist/nosql/doris/index.d.ts +88 -0
- package/dist/nosql/druid/index.d.ts +95 -0
- package/dist/nosql/dynamodb/index.d.ts +643 -0
- package/dist/nosql/dynamodb/index.js +423 -0
- package/dist/nosql/elasticsearch/index.d.ts +239 -0
- package/dist/nosql/etcd/index.d.ts +243 -0
- package/dist/nosql/eventhubs/index.d.ts +89 -0
- package/dist/nosql/eventstore/index.d.ts +102 -0
- package/dist/nosql/faunadb/index.d.ts +141 -0
- package/dist/nosql/faunadb/index.js +329 -0
- package/dist/nosql/firestore/index.d.ts +67 -0
- package/dist/nosql/fluree/index.d.ts +88 -0
- package/dist/nosql/fuseki/index.d.ts +94 -0
- package/dist/nosql/gcs/index.d.ts +62 -0
- package/dist/nosql/gearman/index.d.ts +77 -0
- package/dist/nosql/geode/index.d.ts +93 -0
- package/dist/nosql/graphdb/index.d.ts +86 -0
- package/dist/nosql/graylog/index.d.ts +118 -0
- package/dist/nosql/gridgain/index.d.ts +78 -0
- package/dist/nosql/hazelcast/index.d.ts +73 -0
- package/dist/nosql/hbase/index.d.ts +123 -0
- package/dist/nosql/ignite/index.d.ts +80 -0
- package/dist/nosql/immudb/index.d.ts +131 -0
- package/dist/nosql/index.d.ts +215 -0
- package/dist/nosql/infinispan/index.d.ts +95 -0
- package/dist/nosql/influxdb/flux-compiler.d.ts +23 -0
- package/dist/nosql/influxdb/flux-compiler.js +170 -0
- package/dist/nosql/influxdb/index.d.ts +300 -0
- package/dist/nosql/influxdb/index.js +0 -0
- package/dist/nosql/kafka/index.d.ts +113 -0
- package/dist/nosql/keyspaces/index.d.ts +122 -0
- package/dist/nosql/kinesis/index.d.ts +121 -0
- package/dist/nosql/leveldb/index.d.ts +112 -0
- package/dist/nosql/leveldb/index.js +103 -1
- package/dist/nosql/lmdb/index.d.ts +76 -0
- package/dist/nosql/loki/index.d.ts +126 -0
- package/dist/nosql/marklogic/index.d.ts +76 -0
- package/dist/nosql/materialize/index.d.ts +91 -0
- package/dist/nosql/meilisearch/index.d.ts +76 -0
- package/dist/nosql/memcached/index.d.ts +138 -0
- package/dist/nosql/milvus/index.d.ts +167 -0
- package/dist/nosql/minio/index.d.ts +122 -0
- package/dist/nosql/momento/index.d.ts +99 -0
- package/dist/nosql/mongodb/index.d.ts +265 -0
- package/dist/nosql/mongodb/index.js +139 -0
- package/dist/nosql/mongodb/where.d.ts +8 -0
- package/dist/nosql/mongodb/where.js +181 -0
- package/dist/nosql/nats/index.d.ts +139 -0
- package/dist/nosql/nedb/index.d.ts +79 -0
- package/dist/nosql/neo4j/index.d.ts +217 -0
- package/dist/nosql/neo4j/index.js +26 -14
- package/dist/nosql/neptune/index.d.ts +234 -0
- package/dist/nosql/neptune/index.js +23 -9
- package/dist/nosql/nsq/index.d.ts +93 -0
- package/dist/nosql/opensearch/index.d.ts +97 -0
- package/dist/nosql/orientdb/index.d.ts +72 -0
- package/dist/nosql/papertrail/index.d.ts +120 -0
- package/dist/nosql/pinecone/index.d.ts +148 -0
- package/dist/nosql/pinot/index.d.ts +90 -0
- package/dist/nosql/pouchdb/index.d.ts +95 -0
- package/dist/nosql/prometheus/index.d.ts +112 -0
- package/dist/nosql/provendb/index.d.ts +143 -0
- package/dist/nosql/provendb/index.js +262 -0
- package/dist/nosql/pubsub/index.d.ts +83 -0
- package/dist/nosql/pulsar/index.d.ts +105 -0
- package/dist/nosql/qdrant/index.d.ts +231 -0
- package/dist/nosql/qldb/index.d.ts +182 -0
- package/dist/nosql/qldb/index.js +302 -1
- package/dist/nosql/r2/index.d.ts +160 -0
- package/dist/nosql/rabbitmq/index.d.ts +131 -0
- package/dist/nosql/ravendb/index.d.ts +138 -0
- package/dist/nosql/ravendb/index.js +323 -9
- package/dist/nosql/ravendb/where.d.ts +38 -0
- package/dist/nosql/ravendb/where.js +94 -0
- package/dist/nosql/redis/index.d.ts +267 -0
- package/dist/nosql/redis/index.js +19 -5
- package/dist/nosql/redpanda/index.d.ts +117 -0
- package/dist/nosql/resque/index.d.ts +91 -0
- package/dist/nosql/rethinkdb/index.d.ts +194 -0
- package/dist/nosql/rethinkdb/index.js +290 -0
- package/dist/nosql/rethinkdb/where.d.ts +38 -0
- package/dist/nosql/rethinkdb/where.js +94 -0
- package/dist/nosql/rocksdb/document-layer.d.ts +162 -0
- package/dist/nosql/rocksdb/document-layer.js +338 -0
- package/dist/nosql/rocksdb/index.d.ts +112 -0
- package/dist/nosql/rocksdb/index.js +103 -1
- package/dist/nosql/rocksdb/where-match.d.ts +21 -0
- package/dist/nosql/rocksdb/where-match.js +238 -0
- package/dist/nosql/rockset/index.d.ts +84 -0
- package/dist/nosql/s3/index.d.ts +170 -0
- package/dist/nosql/scylladb/index.d.ts +117 -0
- package/dist/nosql/signoz/index.d.ts +116 -0
- package/dist/nosql/sns/index.d.ts +99 -0
- package/dist/nosql/solr/index.d.ts +129 -0
- package/dist/nosql/splunk/index.d.ts +125 -0
- package/dist/nosql/sqs/index.d.ts +116 -0
- package/dist/nosql/stardog/index.d.ts +86 -0
- package/dist/nosql/starrocks/index.d.ts +89 -0
- package/dist/nosql/store.d.ts +23 -0
- package/dist/nosql/sumologic/index.d.ts +119 -0
- package/dist/nosql/surrealdb/index.d.ts +156 -0
- package/dist/nosql/surrealdb/index.js +174 -1
- package/dist/nosql/surrealdb/query-compiler.d.ts +26 -0
- package/dist/nosql/surrealdb/query-compiler.js +193 -0
- package/dist/nosql/terminusdb/index.d.ts +95 -0
- package/dist/nosql/tigergraph/index.d.ts +314 -0
- package/dist/nosql/typesense/index.d.ts +82 -0
- package/dist/nosql/unqlite/index.d.ts +68 -0
- package/dist/nosql/upstash/index.d.ts +80 -0
- package/dist/nosql/vercel-kv/index.d.ts +82 -0
- package/dist/nosql/victoriametrics/index.d.ts +129 -0
- package/dist/nosql/virtuoso/index.d.ts +87 -0
- package/dist/nosql/weaviate/index.d.ts +196 -0
- package/dist/operators/index.d.ts +7 -0
- package/dist/operators.d.ts +2947 -0
- package/dist/operators.js +46 -1
- package/dist/prisma-migrate/index.d.ts +28 -0
- package/dist/prisma-migrate/migration-generator.d.ts +21 -0
- package/dist/prisma-migrate/model-generator.d.ts +12 -0
- package/dist/prisma-migrate/relations.d.ts +28 -0
- package/dist/prisma-migrate/schema-parser.d.ts +42 -0
- package/dist/prisma-migrate/type-mapper.d.ts +20 -0
- package/dist/prorm.d.ts +2093 -0
- package/dist/prorm.js +721 -302
- package/dist/query-builders/cte-builder.d.ts +104 -0
- package/dist/query-builders/functions/aggregate.d.ts +199 -0
- package/dist/query-builders/functions/conditional.d.ts +195 -0
- package/dist/query-builders/functions/datetime.d.ts +202 -0
- package/dist/query-builders/functions/fulltext.d.ts +220 -0
- package/dist/query-builders/functions/index.d.ts +17 -0
- package/dist/query-builders/functions/json.d.ts +157 -0
- package/dist/query-builders/functions/math.d.ts +215 -0
- package/dist/query-builders/functions/string.d.ts +233 -0
- package/dist/query-builders/functions/window.d.ts +209 -0
- package/dist/query-builders/include-builder.d.ts +85 -0
- package/dist/query-builders/index-expression-builder.d.ts +153 -0
- package/dist/query-builders/index.d.ts +121 -0
- package/dist/query-builders/index.js +10 -0
- package/dist/query-builders/insert-builder.d.ts +62 -0
- package/dist/query-builders/model-helpers.d.ts +28 -0
- package/dist/query-builders/order-limit-builder.d.ts +84 -0
- package/dist/query-builders/sql-compiler.d.ts +562 -0
- package/dist/query-builders/subquery-builder.d.ts +133 -0
- package/dist/query-builders/update-builder.d.ts +71 -0
- package/dist/query-builders/view-builder.d.ts +189 -0
- package/dist/query-builders/where-builder.d.ts +124 -0
- package/dist/query-interface.d.ts +407 -0
- package/dist/query-interface.js +84 -0
- package/dist/query-optimizers/batch-optimizer.d.ts +175 -0
- package/dist/query-optimizers/explain-plans.d.ts +187 -0
- package/dist/query-optimizers/index.d.ts +27 -0
- package/dist/query-optimizers/prepared-statement-cache.d.ts +252 -0
- package/dist/query-optimizers/query-hints.d.ts +201 -0
- package/dist/query-optimizers/query-optimizer.d.ts +162 -0
- package/dist/query-optimizers/slow-query-logger.d.ts +186 -0
- package/dist/replica-manager.d.ts +235 -0
- package/dist/schema/index.d.ts +7 -0
- package/dist/schema/migration-generator.d.ts +74 -0
- package/dist/schema/schema-differ.d.ts +114 -0
- package/dist/schema/types.d.ts +246 -0
- package/dist/schema-objects.d.ts +78 -0
- package/dist/schema-objects.js +203 -0
- package/dist/sql-constants.d.ts +240 -0
- package/dist/sqlite-advanced.d.ts +572 -0
- package/dist/streams/index.d.ts +5 -0
- package/dist/streams/transforms.d.ts +120 -0
- package/dist/transaction.d.ts +221 -0
- package/dist/types/index.d.ts +3123 -0
- package/dist/user-management.d.ts +141 -0
- package/dist/utils/date.d.ts +149 -0
- package/dist/utils/index.d.ts +359 -0
- package/dist/utils/string.d.ts +88 -0
- package/dist/validators/index.d.ts +7 -0
- package/dist/validators/validator.d.ts +306 -0
- package/package.json +20 -5
|
@@ -32,15 +32,27 @@
|
|
|
32
32
|
* folded into the default query-retry match lists so single-statement
|
|
33
33
|
* retries cover it too.
|
|
34
34
|
*/
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
36
|
exports.CockroachDBTransaction = exports.CockroachDBDialect = void 0;
|
|
40
37
|
exports.createCockroachDBDialect = createCockroachDBDialect;
|
|
41
|
-
const
|
|
38
|
+
const operators_1 = require("../../operators");
|
|
42
39
|
const prorm_1 = require("../../prorm");
|
|
43
|
-
|
|
40
|
+
// Lazily-loaded `pg` driver. Required only when a connection is opened, so
|
|
41
|
+
// importing this ORM never loads the pg driver.
|
|
42
|
+
let pgModule = null;
|
|
43
|
+
function loadPg() {
|
|
44
|
+
if (!pgModule) {
|
|
45
|
+
try {
|
|
46
|
+
pgModule = require('pg');
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
throw new Error("The 'pg' package is required to use the CockroachDB dialect but could not be loaded. " +
|
|
50
|
+
'Install it with `npm install pg`. Original error: ' +
|
|
51
|
+
(err instanceof Error ? err.message : String(err)));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return pgModule;
|
|
55
|
+
}
|
|
44
56
|
/**
|
|
45
57
|
* Build a CockroachDB OPTIONS (...) clause from a plain object.
|
|
46
58
|
* Single-quotes each value and escapes existing single-quotes.
|
|
@@ -153,7 +165,7 @@ class CockroachDBDialect {
|
|
|
153
165
|
*/
|
|
154
166
|
async connect() {
|
|
155
167
|
try {
|
|
156
|
-
this.pool = new
|
|
168
|
+
this.pool = new (loadPg().Pool)({
|
|
157
169
|
host: this.config.host,
|
|
158
170
|
port: this.config.port,
|
|
159
171
|
user: this.config.username,
|
|
@@ -2140,6 +2152,62 @@ class CockroachDBDialect {
|
|
|
2140
2152
|
const result = await this.query(sql);
|
|
2141
2153
|
return result.rows;
|
|
2142
2154
|
}
|
|
2155
|
+
/**
|
|
2156
|
+
* Inspect the range (shard) distribution of a table or index via
|
|
2157
|
+
* CockroachDB's `SHOW RANGES FROM TABLE|INDEX ...`. Each row describes one
|
|
2158
|
+
* range: its start/end keys, lease holder, and replica placement. Useful for
|
|
2159
|
+
* diagnosing hotspots and verifying `splitAt()`/`configureZone()` results
|
|
2160
|
+
* without dropping to raw SQL.
|
|
2161
|
+
*
|
|
2162
|
+
* @param target - `{ kind: 'table', name }` or `{ kind: 'index', table,
|
|
2163
|
+
* index }` naming what to inspect (same target shape as
|
|
2164
|
+
* {@link configureZone}/{@link splitAt}).
|
|
2165
|
+
* @see https://www.cockroachlabs.com/docs/stable/show-ranges
|
|
2166
|
+
*/
|
|
2167
|
+
async showRanges(target) {
|
|
2168
|
+
const sql = `SHOW RANGES FROM ${this.resolveZoneTarget(target)}`;
|
|
2169
|
+
const result = await this.query(sql);
|
|
2170
|
+
return result.rows;
|
|
2171
|
+
}
|
|
2172
|
+
/**
|
|
2173
|
+
* Show the single range that would contain a given primary-key row
|
|
2174
|
+
* (`SHOW RANGE FROM TABLE <t> FOR ROW (val, ...)`), reporting its lease
|
|
2175
|
+
* holder and replica placement. Handy for pinpointing which node owns a
|
|
2176
|
+
* specific hot key.
|
|
2177
|
+
*
|
|
2178
|
+
* @param tableName - Table to look up the row's range in.
|
|
2179
|
+
* @param rowValues - The row's primary-key column value(s), in key order.
|
|
2180
|
+
* @see https://www.cockroachlabs.com/docs/stable/show-range-for-row
|
|
2181
|
+
*/
|
|
2182
|
+
async showRangeForRow(tableName, rowValues) {
|
|
2183
|
+
const tuple = rowValues.map((v) => this.formatSplitValue(v)).join(', ');
|
|
2184
|
+
const sql = `SHOW RANGE FROM TABLE ${this.escapeId(tableName)} FOR ROW (${tuple})`;
|
|
2185
|
+
const result = await this.query(sql);
|
|
2186
|
+
return result.rows;
|
|
2187
|
+
}
|
|
2188
|
+
/**
|
|
2189
|
+
* Return the cost-based optimizer's table statistics
|
|
2190
|
+
* (`SHOW STATISTICS FOR TABLE <t>`): column sets, row counts, distinct
|
|
2191
|
+
* counts, null counts and histogram ids the planner uses for cardinality
|
|
2192
|
+
* estimation.
|
|
2193
|
+
*
|
|
2194
|
+
* @see https://www.cockroachlabs.com/docs/stable/show-statistics
|
|
2195
|
+
*/
|
|
2196
|
+
async showStatistics(tableName) {
|
|
2197
|
+
const sql = `SHOW STATISTICS FOR TABLE ${this.escapeId(tableName)}`;
|
|
2198
|
+
const result = await this.query(sql);
|
|
2199
|
+
return result.rows;
|
|
2200
|
+
}
|
|
2201
|
+
/**
|
|
2202
|
+
* Trigger a fresh collection of table statistics for the optimizer
|
|
2203
|
+
* (`ANALYZE <t>`, an alias of `CREATE STATISTICS ... FROM <t>`). Run after a
|
|
2204
|
+
* large bulk load/mutation so the planner has accurate cardinality estimates.
|
|
2205
|
+
*
|
|
2206
|
+
* @see https://www.cockroachlabs.com/docs/stable/create-statistics
|
|
2207
|
+
*/
|
|
2208
|
+
async analyzeTable(tableName) {
|
|
2209
|
+
await this.query(`ANALYZE ${this.escapeId(tableName)}`);
|
|
2210
|
+
}
|
|
2143
2211
|
/**
|
|
2144
2212
|
* Describe a table (get column information)
|
|
2145
2213
|
*
|
|
@@ -2338,6 +2406,35 @@ class CockroachDBDialect {
|
|
|
2338
2406
|
: ''}`;
|
|
2339
2407
|
await this.query(sql);
|
|
2340
2408
|
}
|
|
2409
|
+
/**
|
|
2410
|
+
* Create an inverted (GIN) index over a JSONB column so containment/path
|
|
2411
|
+
* queries (`@>`, `->`, `->>`) on it can be index-accelerated. Unlike
|
|
2412
|
+
* {@link createGINIndex} (which wraps the column in `to_tsvector(...)` for
|
|
2413
|
+
* full-text search), this indexes the raw JSONB value directly:
|
|
2414
|
+
* `CREATE [UNIQUE] INVERTED INDEX <name> ON <table> (<column>)`.
|
|
2415
|
+
*
|
|
2416
|
+
* CockroachDB spells inverted indexes as `INVERTED INDEX ... (col)`
|
|
2417
|
+
* (equivalent to Postgres's `USING GIN (col)`); this helper emits the
|
|
2418
|
+
* CockroachDB-native form. Also usable for `ARRAY` columns.
|
|
2419
|
+
*
|
|
2420
|
+
* @see https://www.cockroachlabs.com/docs/stable/inverted-indexes
|
|
2421
|
+
*/
|
|
2422
|
+
async createInvertedIndex(tableName, indexName, column, options) {
|
|
2423
|
+
let sql = 'CREATE INVERTED INDEX';
|
|
2424
|
+
if (options?.ifNotExists) {
|
|
2425
|
+
sql += ' IF NOT EXISTS';
|
|
2426
|
+
}
|
|
2427
|
+
sql += ` ${this.escapeId(indexName)} ON ${this.escapeId(tableName)} (${this.escapeId(column)})`;
|
|
2428
|
+
if (options?.storageParameters && Object.keys(options.storageParameters).length > 0) {
|
|
2429
|
+
sql +=
|
|
2430
|
+
' WITH (' +
|
|
2431
|
+
Object.entries(options.storageParameters)
|
|
2432
|
+
.map(([k, v]) => `${k} = ${v}`)
|
|
2433
|
+
.join(', ') +
|
|
2434
|
+
')';
|
|
2435
|
+
}
|
|
2436
|
+
await this.query(sql);
|
|
2437
|
+
}
|
|
2341
2438
|
/**
|
|
2342
2439
|
* Build a to_tsvector expression
|
|
2343
2440
|
* SQL: to_tsvector([config,] document)
|
|
@@ -2706,9 +2803,32 @@ class CockroachDBDialect {
|
|
|
2706
2803
|
else {
|
|
2707
2804
|
await client.query('BEGIN');
|
|
2708
2805
|
}
|
|
2806
|
+
// Apply transaction priority (SET TRANSACTION PRIORITY LOW|NORMAL|HIGH)
|
|
2807
|
+
// right after BEGIN, if requested. The priority keyword is from a fixed
|
|
2808
|
+
// enum (not user input), so it is safe to interpolate directly.
|
|
2809
|
+
if (options?.priority) {
|
|
2810
|
+
await client.query(`SET TRANSACTION PRIORITY ${options.priority}`);
|
|
2811
|
+
}
|
|
2709
2812
|
const transaction = new CockroachDBTransaction(client, this.transactionDepth++, options);
|
|
2710
2813
|
return transaction;
|
|
2711
2814
|
}
|
|
2815
|
+
/**
|
|
2816
|
+
* Set the priority of the *current* transaction
|
|
2817
|
+
* (`SET TRANSACTION PRIORITY {LOW|NORMAL|HIGH}`). Must be called on a
|
|
2818
|
+
* transaction's own client, before any statement in the transaction reads or
|
|
2819
|
+
* writes data. Prefer passing `priority` to {@link startTransaction} /
|
|
2820
|
+
* {@link runTransaction}; this helper is for adjusting an already-open
|
|
2821
|
+
* transaction created elsewhere.
|
|
2822
|
+
*
|
|
2823
|
+
* @see https://www.cockroachlabs.com/docs/stable/set-transaction
|
|
2824
|
+
*/
|
|
2825
|
+
async setTransactionPriority(transaction, priority) {
|
|
2826
|
+
const tx = transaction;
|
|
2827
|
+
if (!tx.client) {
|
|
2828
|
+
throw new Error('Transaction has no active client');
|
|
2829
|
+
}
|
|
2830
|
+
await tx.client.query(`SET TRANSACTION PRIORITY ${priority}`);
|
|
2831
|
+
}
|
|
2712
2832
|
/**
|
|
2713
2833
|
* Run a function inside a CockroachDB transaction, automatically retrying
|
|
2714
2834
|
* the *entire transaction body* when it fails with a serialization failure
|
|
@@ -3393,6 +3513,15 @@ class CockroachDBDialect {
|
|
|
3393
3513
|
/**
|
|
3394
3514
|
* Check if a value is a literal expression (literal('sql'))
|
|
3395
3515
|
*/
|
|
3516
|
+
/**
|
|
3517
|
+
* Render a literal expression, substituting any `bindings` into its `?`
|
|
3518
|
+
* placeholders with dialect-correct escaping. `literalExpr(sql)` with no
|
|
3519
|
+
* bindings is unchanged; `literalExpr('x > ?', [v])` no longer requires the
|
|
3520
|
+
* caller to concatenate the value into the string themselves.
|
|
3521
|
+
*/
|
|
3522
|
+
literalSql(expr) {
|
|
3523
|
+
return (0, operators_1.expandLiteralBindings)(expr, (v) => this.escape(v));
|
|
3524
|
+
}
|
|
3396
3525
|
isLiteralExpression(value) {
|
|
3397
3526
|
return value !== null && typeof value === 'object' && value.__type === 'literal';
|
|
3398
3527
|
}
|
|
@@ -3436,7 +3565,7 @@ class CockroachDBDialect {
|
|
|
3436
3565
|
sql = this.escapeId(expr.col);
|
|
3437
3566
|
}
|
|
3438
3567
|
else if (this.isLiteralExpression(expr)) {
|
|
3439
|
-
sql = expr
|
|
3568
|
+
sql = this.literalSql(expr);
|
|
3440
3569
|
}
|
|
3441
3570
|
else if (typeof expr === 'string') {
|
|
3442
3571
|
// Check if it's a column reference or literal SQL
|
|
@@ -3460,7 +3589,7 @@ class CockroachDBDialect {
|
|
|
3460
3589
|
return this.escapeId(attr.col);
|
|
3461
3590
|
}
|
|
3462
3591
|
else if (this.isLiteralExpression(attr)) {
|
|
3463
|
-
return attr
|
|
3592
|
+
return this.literalSql(attr);
|
|
3464
3593
|
}
|
|
3465
3594
|
else if (typeof attr === 'string') {
|
|
3466
3595
|
// Plain column name
|
|
@@ -3501,7 +3630,7 @@ class CockroachDBDialect {
|
|
|
3501
3630
|
sql = this.escapeId(expr.col);
|
|
3502
3631
|
}
|
|
3503
3632
|
else if (this.isLiteralExpression(expr)) {
|
|
3504
|
-
sql = expr
|
|
3633
|
+
sql = this.literalSql(expr);
|
|
3505
3634
|
}
|
|
3506
3635
|
else if (typeof expr === 'string') {
|
|
3507
3636
|
sql = this.escapeId(expr);
|
|
@@ -3522,7 +3651,7 @@ class CockroachDBDialect {
|
|
|
3522
3651
|
return this.escapeId(field.col);
|
|
3523
3652
|
}
|
|
3524
3653
|
else if (this.isLiteralExpression(field)) {
|
|
3525
|
-
return field
|
|
3654
|
+
return this.literalSql(field);
|
|
3526
3655
|
}
|
|
3527
3656
|
else if (typeof field === 'string') {
|
|
3528
3657
|
if (field.includes('.')) {
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CrateDB dialect implementation for the TypeScript ORM
|
|
3
|
+
*
|
|
4
|
+
* CrateDB is a distributed SQL database that speaks the PostgreSQL wire protocol
|
|
5
|
+
* (default port 5432) and is largely PG-compatible on the client side, so this
|
|
6
|
+
* dialect extends `PostgresDialect` and reuses the `pg` driver for connectivity
|
|
7
|
+
* and most query building. It overrides the schema-generation surface (CREATE
|
|
8
|
+
* TABLE + type mapping) to emit CrateDB-native SQL. Notable differences from the
|
|
9
|
+
* Postgres dialect:
|
|
10
|
+
*
|
|
11
|
+
* - Default port stays 5432 (PG-wire-compatible), so the constructor forwards
|
|
12
|
+
* `{ port: 5432, ...config }` to the Postgres base.
|
|
13
|
+
* - CREATE TABLE supports CrateDB's distribution/partitioning clauses, emitted in
|
|
14
|
+
* CrateDB's required order: `PARTITIONED BY (col)`, then
|
|
15
|
+
* `CLUSTERED [BY (col)] INTO n SHARDS`, then a `WITH ( ... )` settings block.
|
|
16
|
+
* Example:
|
|
17
|
+
* CREATE TABLE "t" (...) PARTITIONED BY ("day")
|
|
18
|
+
* CLUSTERED BY ("id") INTO 6 SHARDS
|
|
19
|
+
* WITH (number_of_replicas = '1', "refresh_interval" = 1000)
|
|
20
|
+
* - Type mapping is CrateDB-specific: TEXT, INTEGER, BIGINT, DOUBLE PRECISION,
|
|
21
|
+
* BOOLEAN, TIMESTAMP, OBJECT and GEO_POINT (rather than Postgres VARCHAR/SERIAL/
|
|
22
|
+
* JSONB/etc). Composite/semi-structured types use CrateDB syntax:
|
|
23
|
+
* * OBJECT columns emit `OBJECT(DYNAMIC) AS (col type, ...)` (or bare `OBJECT`
|
|
24
|
+
* when no sub-columns are declared). The column policy defaults to DYNAMIC.
|
|
25
|
+
* * ARRAY columns emit `ARRAY(type)` (CrateDB's array syntax) rather than
|
|
26
|
+
* Postgres's `type[]`.
|
|
27
|
+
* - PRIMARY KEY is preserved. NOTE: in CrateDB a PRIMARY KEY must include every
|
|
28
|
+
* routing/clustered/partitioned column (CrateDB requires routing columns to be
|
|
29
|
+
* part of the primary key). The dialect does not attempt to validate or rewrite
|
|
30
|
+
* the PRIMARY KEY to enforce this — it is the caller's responsibility.
|
|
31
|
+
* - FOREIGN KEYs are OMITTED. CrateDB has no foreign-key support, so both
|
|
32
|
+
* column-level `references` and any `FOREIGN KEY` table constraints are dropped
|
|
33
|
+
* from generated DDL rather than emitted.
|
|
34
|
+
*/
|
|
35
|
+
import { PostgresDialect, PostgresDialectOptions } from '../postgres';
|
|
36
|
+
import { ColumnDefinition, TableOptions, InsertOptions, IndexOptions, IndexDefinition, DropIndexOptions, ConstraintDefinition, CreateEnumTypeOptions, DropTypeOptions, CreateDomainOptions, DropDomainOptions } from '../dialect';
|
|
37
|
+
import { DataType, SequenceOptions, DropSequenceOptions, MaterializedViewOptions, RefreshOptions, DropMaterializedViewOptions, StoredProcedureOptions, DropStoredProcedureOptions, ExecuteStoredProcedureOptions, QueryResult, TriggerOptions, DropTriggerOptions, PolicyOptions, DropPolicyOptions, CreatePartitionOptions, AttachPartitionOptions, DetachPartitionOptions } from '../../types';
|
|
38
|
+
/**
|
|
39
|
+
* CrateDB connection options. CrateDB is PG-wire-compatible, so this is just the
|
|
40
|
+
* Postgres option set (the default port is 5432, set in the constructor).
|
|
41
|
+
*/
|
|
42
|
+
export interface CrateDBDialectOptions extends PostgresDialectOptions {
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* CrateDB-specific CREATE TABLE options: sharding/routing (`CLUSTERED`),
|
|
46
|
+
* partitioning (`PARTITIONED BY`) and table settings (`WITH ( ... )`). Not part
|
|
47
|
+
* of the shared `TableOptions` type (used by every dialect), so callers targeting
|
|
48
|
+
* CrateDB pass these alongside the common options via an intersection type.
|
|
49
|
+
*
|
|
50
|
+
* @see https://cratedb.com/docs/crate/reference/en/latest/sql/statements/create-table.html
|
|
51
|
+
*/
|
|
52
|
+
export interface CrateDBTableOptions {
|
|
53
|
+
/** `CLUSTERED INTO n SHARDS` — number of shards to distribute the table into. */
|
|
54
|
+
clusteredInto?: number;
|
|
55
|
+
/** Alias for {@link CrateDBTableOptions.clusteredInto}. */
|
|
56
|
+
shards?: number;
|
|
57
|
+
/** `CLUSTERED BY (col)` — the routing column used to co-locate rows. */
|
|
58
|
+
clusteredBy?: string;
|
|
59
|
+
/** `PARTITIONED BY (col, ...)` — one or more partition (routing) columns. */
|
|
60
|
+
partitionedBy?: string | string[];
|
|
61
|
+
/**
|
|
62
|
+
* `WITH ( key = value, ... )` — CrateDB table settings, e.g.
|
|
63
|
+
* `{ number_of_replicas: '1', '"refresh_interval"': 1000 }`. String values are
|
|
64
|
+
* single-quoted; numeric/boolean values are emitted bare. Keys are emitted
|
|
65
|
+
* verbatim, so a quoted key (`'"refresh_interval"'`) is preserved as-is.
|
|
66
|
+
*/
|
|
67
|
+
with?: Record<string, string | number | boolean>;
|
|
68
|
+
/**
|
|
69
|
+
* Fulltext (`INDEX name USING FULLTEXT (col, ...) [WITH (analyzer = '...')]`)
|
|
70
|
+
* indexes declared inside the column list. CrateDB has no standalone
|
|
71
|
+
* `CREATE INDEX` statement — the only user-defined indexes are fulltext
|
|
72
|
+
* indexes, and they must be declared at `CREATE TABLE` time as named index
|
|
73
|
+
* columns. Each entry emits one such index column.
|
|
74
|
+
*
|
|
75
|
+
* @see https://cratedb.com/docs/crate/reference/en/latest/general/ddl/fulltext-indices.html
|
|
76
|
+
*/
|
|
77
|
+
fulltextIndexes?: Array<{
|
|
78
|
+
/** The index column name. */
|
|
79
|
+
name: string;
|
|
80
|
+
/** Source column(s) the fulltext index covers. */
|
|
81
|
+
fields: string[];
|
|
82
|
+
/** Optional analyzer, e.g. `'english'`, emitted as `WITH (analyzer = '...')`. */
|
|
83
|
+
analyzer?: string;
|
|
84
|
+
}>;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* CrateDB INSERT options: the shared {@link InsertOptions} plus CrateDB's
|
|
88
|
+
* `ON CONFLICT ... DO NOTHING` variant (CrateDB supports both `DO UPDATE SET`
|
|
89
|
+
* and `DO NOTHING`, and — unlike `DO UPDATE` — `DO NOTHING` may omit the
|
|
90
|
+
* conflict target).
|
|
91
|
+
*/
|
|
92
|
+
export interface CrateDBInsertOptions extends InsertOptions {
|
|
93
|
+
/** Emit `ON CONFLICT [(fields)] DO NOTHING` instead of an upsert/plain insert. */
|
|
94
|
+
onConflictDoNothing?: boolean;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* CrateDB dialect class. Extends the PostgreSQL dialect (PG-wire compatible) and
|
|
98
|
+
* overrides CREATE TABLE generation and type mapping for CrateDB.
|
|
99
|
+
*/
|
|
100
|
+
export declare class CrateDBDialect extends PostgresDialect {
|
|
101
|
+
readonly name = "cratedb";
|
|
102
|
+
constructor(config: CrateDBDialectOptions);
|
|
103
|
+
/**
|
|
104
|
+
* Map an ORM data type to its CrateDB SQL type. Overrides the Postgres mapping
|
|
105
|
+
* to emit CrateDB-native types (TEXT, INTEGER, BIGINT, DOUBLE PRECISION,
|
|
106
|
+
* BOOLEAN, TIMESTAMP, OBJECT, GEO_POINT) and CrateDB's `OBJECT(...)`/`ARRAY(...)`
|
|
107
|
+
* syntax for semi-structured/collection types.
|
|
108
|
+
*/
|
|
109
|
+
getDataTypeSql(dataType: DataType): string;
|
|
110
|
+
/**
|
|
111
|
+
* Build the CrateDB `OBJECT` type SQL. Emits `OBJECT(POLICY) AS (col type, ...)`
|
|
112
|
+
* when sub-columns are declared, otherwise a bare `OBJECT`. The column policy
|
|
113
|
+
* defaults to DYNAMIC (CrateDB's default).
|
|
114
|
+
*/
|
|
115
|
+
private buildObjectTypeSql;
|
|
116
|
+
/**
|
|
117
|
+
* Format a value for a `WITH ( key = value )` table setting: strings are
|
|
118
|
+
* single-quoted (with embedded quotes escaped), numbers/booleans are bare.
|
|
119
|
+
*/
|
|
120
|
+
private formatSettingValue;
|
|
121
|
+
/**
|
|
122
|
+
* Format a CrateDB column DEFAULT value.
|
|
123
|
+
*/
|
|
124
|
+
private formatDefaultValue;
|
|
125
|
+
/**
|
|
126
|
+
* Build a single CrateDB column definition. FOREIGN KEY references are omitted
|
|
127
|
+
* (CrateDB has no FK support).
|
|
128
|
+
*/
|
|
129
|
+
private getCrateColumnDefinitionSql;
|
|
130
|
+
/**
|
|
131
|
+
* Build a CrateDB table constraint. FOREIGN KEY constraints are omitted
|
|
132
|
+
* (CrateDB has no FK support); PRIMARY KEY / UNIQUE / CHECK are passed through.
|
|
133
|
+
*/
|
|
134
|
+
private buildCrateConstraintSql;
|
|
135
|
+
/**
|
|
136
|
+
* Build the CrateDB `CREATE TABLE` statement (synchronous, no execution).
|
|
137
|
+
*
|
|
138
|
+
* Emits clauses in CrateDB's required order after the column list:
|
|
139
|
+
* 1. `PARTITIONED BY (col, ...)`
|
|
140
|
+
* 2. `CLUSTERED [BY (col)] INTO n SHARDS`
|
|
141
|
+
* 3. `WITH ( key = value, ... )`
|
|
142
|
+
*
|
|
143
|
+
* FOREIGN KEY references/constraints are omitted (unsupported by CrateDB).
|
|
144
|
+
*/
|
|
145
|
+
buildCreateTableSQL(tableName: string, columns: Record<string, ColumnDefinition>, options?: TableOptions & CrateDBTableOptions): string;
|
|
146
|
+
/**
|
|
147
|
+
* Create a new table in CrateDB.
|
|
148
|
+
*
|
|
149
|
+
* Overrides the Postgres implementation to emit CrateDB's CREATE TABLE syntax
|
|
150
|
+
* (CLUSTERED / PARTITIONED BY / WITH, CrateDB type mapping, no foreign keys).
|
|
151
|
+
*/
|
|
152
|
+
createTable(tableName: string, columns: Record<string, ColumnDefinition>, options?: TableOptions & CrateDBTableOptions): Promise<void>;
|
|
153
|
+
private static readonly NO_CREATE_INDEX;
|
|
154
|
+
addIndex(_tableName: string, _indexName: string, _fields?: string[], _options?: IndexOptions): Promise<void>;
|
|
155
|
+
createIndex(_tableName: string, _indexDef: IndexDefinition): Promise<void>;
|
|
156
|
+
createFulltextIndex(_tableName: string, _indexName: string, _fields: string[], _options?: {
|
|
157
|
+
parser?: string;
|
|
158
|
+
comment?: string;
|
|
159
|
+
}): Promise<void>;
|
|
160
|
+
createSpatialIndex(_tableName: string, _indexName: string, _fields: string[], _options?: {
|
|
161
|
+
storage?: string;
|
|
162
|
+
srid?: number;
|
|
163
|
+
}): Promise<void>;
|
|
164
|
+
removeIndex(_tableName: string, _indexName: string): Promise<void>;
|
|
165
|
+
dropIndex(_tableName: string, _indexName: string, _options?: DropIndexOptions): Promise<void>;
|
|
166
|
+
addForeignKey(_tableName: string, _columnName: string, _referencedTableName: string, _referencedColumnName: string, _options?: unknown): Promise<void>;
|
|
167
|
+
addConstraint(tableName: string, options: {
|
|
168
|
+
type: 'UNIQUE' | 'CHECK' | 'PRIMARY KEY' | 'FOREIGN KEY';
|
|
169
|
+
fields: string[];
|
|
170
|
+
name?: string;
|
|
171
|
+
references?: {
|
|
172
|
+
table: string;
|
|
173
|
+
fields: string[];
|
|
174
|
+
};
|
|
175
|
+
check?: string;
|
|
176
|
+
}): Promise<void>;
|
|
177
|
+
createConstraint(tableName: string, constraintDef: ConstraintDefinition): Promise<void>;
|
|
178
|
+
/**
|
|
179
|
+
* Add a column via `ALTER TABLE t ADD COLUMN ...`. Overrides the Postgres
|
|
180
|
+
* implementation so the column uses CrateDB's type mapping and drops any FK
|
|
181
|
+
* reference (CrateDB supports ADD COLUMN but not SERIAL/REFERENCES).
|
|
182
|
+
*/
|
|
183
|
+
addColumn(tableName: string, columnName: string, definition: ColumnDefinition): Promise<void>;
|
|
184
|
+
/**
|
|
185
|
+
* CrateDB cannot rename columns via ALTER TABLE (no `RENAME COLUMN`).
|
|
186
|
+
*/
|
|
187
|
+
renameColumn(_tableName: string, _oldColumnName: string, _newColumnName: string): Promise<void>;
|
|
188
|
+
/**
|
|
189
|
+
* CrateDB cannot rename tables via ALTER TABLE (no `RENAME TO`).
|
|
190
|
+
*/
|
|
191
|
+
renameTable(_oldName: string, _newName: string): Promise<void>;
|
|
192
|
+
buildInsertQuery(tableName: string, values: Record<string, unknown>, options?: CrateDBInsertOptions): {
|
|
193
|
+
sql: string;
|
|
194
|
+
values: unknown[];
|
|
195
|
+
};
|
|
196
|
+
private static unsupported;
|
|
197
|
+
createSequence(_options: SequenceOptions): Promise<void>;
|
|
198
|
+
dropSequence(_sequenceName: string, _options?: DropSequenceOptions): Promise<void>;
|
|
199
|
+
nextSequenceValue(_sequenceName: string): Promise<number>;
|
|
200
|
+
hasSequence(_sequenceName: string): Promise<boolean>;
|
|
201
|
+
createMaterializedView(_options: MaterializedViewOptions): Promise<void>;
|
|
202
|
+
refreshMaterializedView(_viewName: string, _options?: RefreshOptions): Promise<void>;
|
|
203
|
+
dropMaterializedView(_viewName: string, _options?: DropMaterializedViewOptions): Promise<void>;
|
|
204
|
+
hasMaterializedView(_viewName: string): Promise<boolean>;
|
|
205
|
+
showMaterializedViews(): Promise<string[]>;
|
|
206
|
+
createStoredProcedure(_options: StoredProcedureOptions): Promise<void>;
|
|
207
|
+
dropStoredProcedure(_procedureName: string, _options?: DropStoredProcedureOptions): Promise<void>;
|
|
208
|
+
executeStoredProcedure(_options: ExecuteStoredProcedureOptions): Promise<QueryResult>;
|
|
209
|
+
hasStoredProcedure(_procedureName: string, _schema?: string): Promise<boolean>;
|
|
210
|
+
createTrigger(_options: TriggerOptions): Promise<void>;
|
|
211
|
+
dropTrigger(_triggerName: string, _tableName: string, _options?: DropTriggerOptions): Promise<void>;
|
|
212
|
+
hasTrigger(_triggerName: string, _tableName: string): Promise<boolean>;
|
|
213
|
+
createPolicy(_options: PolicyOptions): Promise<void>;
|
|
214
|
+
dropPolicy(_policyName: string, _tableName: string, _options?: DropPolicyOptions): Promise<void>;
|
|
215
|
+
enableRLS(_tableName: string, _schema?: string): Promise<void>;
|
|
216
|
+
disableRLS(_tableName: string, _schema?: string): Promise<void>;
|
|
217
|
+
hasPolicy(_policyName: string, _tableName: string): Promise<boolean>;
|
|
218
|
+
createEnumType(_name: string, _values: string[], _options?: CreateEnumTypeOptions): Promise<void>;
|
|
219
|
+
dropType(_name: string, _options?: DropTypeOptions): Promise<void>;
|
|
220
|
+
createDomain(_name: string, _baseType: string, _options?: CreateDomainOptions): Promise<void>;
|
|
221
|
+
dropDomain(_name: string, _options?: DropDomainOptions): Promise<void>;
|
|
222
|
+
createPartitionedTable(tableName: string, columns: Record<string, ColumnDefinition>, options: TableOptions & CrateDBTableOptions & {
|
|
223
|
+
partitionBy: {
|
|
224
|
+
type: 'range' | 'list' | 'hash';
|
|
225
|
+
column: string | string[];
|
|
226
|
+
};
|
|
227
|
+
}): Promise<void>;
|
|
228
|
+
createPartition(_options: CreatePartitionOptions): Promise<void>;
|
|
229
|
+
attachPartition(_options: AttachPartitionOptions): Promise<void>;
|
|
230
|
+
detachPartition(_options: DetachPartitionOptions): Promise<void>;
|
|
231
|
+
dropPartition(_partitionName: string, _options?: {
|
|
232
|
+
ifExists?: boolean;
|
|
233
|
+
cascade?: boolean;
|
|
234
|
+
}): Promise<void>;
|
|
235
|
+
createForeignDataWrapper(_fdwName: string, _options?: {
|
|
236
|
+
handler?: string;
|
|
237
|
+
}): Promise<void>;
|
|
238
|
+
dropForeignDataWrapper(_fdwName: string, _options?: {
|
|
239
|
+
ifExists?: boolean;
|
|
240
|
+
}): Promise<void>;
|
|
241
|
+
createForeignServer(_serverName: string, _fdwName: string, _options?: {
|
|
242
|
+
options?: Record<string, string>;
|
|
243
|
+
ifNotExists?: boolean;
|
|
244
|
+
}): Promise<void>;
|
|
245
|
+
dropForeignServer(_serverName: string, _options?: {
|
|
246
|
+
ifExists?: boolean;
|
|
247
|
+
cascade?: boolean;
|
|
248
|
+
}): Promise<void>;
|
|
249
|
+
createForeignTable(_tableName: string, _columns: Record<string, {
|
|
250
|
+
type: string;
|
|
251
|
+
}>, _options?: {
|
|
252
|
+
serverName?: string;
|
|
253
|
+
ifNotExists?: boolean;
|
|
254
|
+
}): Promise<void>;
|
|
255
|
+
createUserMapping(_userName: string, _serverName: string, _options?: unknown): Promise<void>;
|
|
256
|
+
dropUserMapping(_userName: string, _serverName: string, _options?: unknown): Promise<void>;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Create a new CrateDB dialect instance
|
|
260
|
+
*/
|
|
261
|
+
export declare function createCrateDBDialect(options?: CrateDBDialectOptions): CrateDBDialect;
|
|
262
|
+
export default CrateDBDialect;
|
|
@@ -37,6 +37,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
37
37
|
exports.CrateDBDialect = void 0;
|
|
38
38
|
exports.createCrateDBDialect = createCrateDBDialect;
|
|
39
39
|
const postgres_1 = require("../postgres");
|
|
40
|
+
const index_1 = require("../../errors/index");
|
|
40
41
|
/**
|
|
41
42
|
* CrateDB dialect class. Extends the PostgreSQL dialect (PG-wire compatible) and
|
|
42
43
|
* overrides CREATE TABLE generation and type mapping for CrateDB.
|
|
@@ -421,6 +422,153 @@ class CrateDBDialect extends postgres_1.PostgresDialect {
|
|
|
421
422
|
}
|
|
422
423
|
return super.buildInsertQuery(tableName, values, options);
|
|
423
424
|
}
|
|
425
|
+
// ---------------------------------------------------------------------------
|
|
426
|
+
// Capability guards for PostgreSQL features CrateDB does NOT implement.
|
|
427
|
+
//
|
|
428
|
+
// These methods are inherited from PostgresDialect, which would happily emit
|
|
429
|
+
// valid *PostgreSQL* DDL (CREATE SEQUENCE, CREATE MATERIALIZED VIEW, CREATE
|
|
430
|
+
// FUNCTION/PROCEDURE, CREATE TRIGGER, CREATE POLICY / ENABLE ROW LEVEL
|
|
431
|
+
// SECURITY, CREATE TYPE ... AS ENUM, CREATE DOMAIN, PostgreSQL-style
|
|
432
|
+
// partitioning, and the Foreign Data Wrapper stack). CrateDB rejects all of
|
|
433
|
+
// it at execution time with an opaque parser/"not supported" error. Rather
|
|
434
|
+
// than let callers discover that at runtime through a confusing wire error,
|
|
435
|
+
// these overrides throw an immediate, typed capability error (DatabaseError)
|
|
436
|
+
// that names the missing feature and points at CrateDB's supported
|
|
437
|
+
// alternative where one exists. This keeps the "no silent wrong SQL" contract:
|
|
438
|
+
// a feature either works through the builder API or fails loudly and clearly.
|
|
439
|
+
//
|
|
440
|
+
// @see https://cratedb.com/docs/crate/reference/en/latest/sql/index.html
|
|
441
|
+
// ---------------------------------------------------------------------------
|
|
442
|
+
static unsupported(feature, hint) {
|
|
443
|
+
throw new index_1.DatabaseError(`CrateDB does not support ${feature}.${hint ? ` ${hint}` : ''}`);
|
|
444
|
+
}
|
|
445
|
+
// --- Sequences (CrateDB has no sequences / SERIAL; use client-generated keys)
|
|
446
|
+
async createSequence(_options) {
|
|
447
|
+
CrateDBDialect.unsupported('sequences', 'CrateDB has no CREATE SEQUENCE / SERIAL; generate keys client-side (e.g. a UUID/TEXT primary key) or use gen_random_text_uuid().');
|
|
448
|
+
}
|
|
449
|
+
async dropSequence(_sequenceName, _options) {
|
|
450
|
+
CrateDBDialect.unsupported('sequences');
|
|
451
|
+
}
|
|
452
|
+
async nextSequenceValue(_sequenceName) {
|
|
453
|
+
CrateDBDialect.unsupported('sequences');
|
|
454
|
+
}
|
|
455
|
+
async hasSequence(_sequenceName) {
|
|
456
|
+
// Non-throwing existence check: CrateDB never has sequences.
|
|
457
|
+
return false;
|
|
458
|
+
}
|
|
459
|
+
// --- Materialized views (unsupported; plain CREATE VIEW works and is inherited)
|
|
460
|
+
async createMaterializedView(_options) {
|
|
461
|
+
CrateDBDialect.unsupported('materialized views', 'Use a regular view (createView) — CrateDB has no CREATE MATERIALIZED VIEW.');
|
|
462
|
+
}
|
|
463
|
+
async refreshMaterializedView(_viewName, _options) {
|
|
464
|
+
CrateDBDialect.unsupported('materialized views');
|
|
465
|
+
}
|
|
466
|
+
async dropMaterializedView(_viewName, _options) {
|
|
467
|
+
CrateDBDialect.unsupported('materialized views');
|
|
468
|
+
}
|
|
469
|
+
async hasMaterializedView(_viewName) {
|
|
470
|
+
return false;
|
|
471
|
+
}
|
|
472
|
+
async showMaterializedViews() {
|
|
473
|
+
return [];
|
|
474
|
+
}
|
|
475
|
+
// --- Stored procedures / functions (no PL/pgSQL or CREATE FUNCTION/PROCEDURE)
|
|
476
|
+
async createStoredProcedure(_options) {
|
|
477
|
+
CrateDBDialect.unsupported('stored procedures or user-defined functions');
|
|
478
|
+
}
|
|
479
|
+
async dropStoredProcedure(_procedureName, _options) {
|
|
480
|
+
CrateDBDialect.unsupported('stored procedures or user-defined functions');
|
|
481
|
+
}
|
|
482
|
+
async executeStoredProcedure(_options) {
|
|
483
|
+
CrateDBDialect.unsupported('stored procedures or user-defined functions');
|
|
484
|
+
}
|
|
485
|
+
async hasStoredProcedure(_procedureName, _schema) {
|
|
486
|
+
return false;
|
|
487
|
+
}
|
|
488
|
+
// --- Triggers (unsupported)
|
|
489
|
+
async createTrigger(_options) {
|
|
490
|
+
CrateDBDialect.unsupported('triggers');
|
|
491
|
+
}
|
|
492
|
+
async dropTrigger(_triggerName, _tableName, _options) {
|
|
493
|
+
CrateDBDialect.unsupported('triggers');
|
|
494
|
+
}
|
|
495
|
+
async hasTrigger(_triggerName, _tableName) {
|
|
496
|
+
return false;
|
|
497
|
+
}
|
|
498
|
+
// --- Row-Level Security (unsupported)
|
|
499
|
+
async createPolicy(_options) {
|
|
500
|
+
CrateDBDialect.unsupported('row-level security policies');
|
|
501
|
+
}
|
|
502
|
+
async dropPolicy(_policyName, _tableName, _options) {
|
|
503
|
+
CrateDBDialect.unsupported('row-level security policies');
|
|
504
|
+
}
|
|
505
|
+
async enableRLS(_tableName, _schema) {
|
|
506
|
+
CrateDBDialect.unsupported('row-level security');
|
|
507
|
+
}
|
|
508
|
+
async disableRLS(_tableName, _schema) {
|
|
509
|
+
CrateDBDialect.unsupported('row-level security');
|
|
510
|
+
}
|
|
511
|
+
async hasPolicy(_policyName, _tableName) {
|
|
512
|
+
return false;
|
|
513
|
+
}
|
|
514
|
+
// --- Enum types & domains (no CREATE TYPE AS ENUM / CREATE DOMAIN)
|
|
515
|
+
async createEnumType(_name, _values, _options) {
|
|
516
|
+
CrateDBDialect.unsupported('enum types', 'Model enumerated values as a TEXT column with a CHECK constraint instead.');
|
|
517
|
+
}
|
|
518
|
+
async dropType(_name, _options) {
|
|
519
|
+
CrateDBDialect.unsupported('user-defined types');
|
|
520
|
+
}
|
|
521
|
+
async createDomain(_name, _baseType, _options) {
|
|
522
|
+
CrateDBDialect.unsupported('domains');
|
|
523
|
+
}
|
|
524
|
+
async dropDomain(_name, _options) {
|
|
525
|
+
CrateDBDialect.unsupported('domains');
|
|
526
|
+
}
|
|
527
|
+
// --- PostgreSQL-style declarative partitioning.
|
|
528
|
+
// CrateDB partitions a table via the `partitionedBy` option on createTable
|
|
529
|
+
// (`PARTITIONED BY (col)`), NOT via CREATE TABLE ... PARTITION OF / ATTACH /
|
|
530
|
+
// DETACH PARTITION. The inherited Postgres methods would emit rejected SQL.
|
|
531
|
+
async createPartitionedTable(tableName, columns, options) {
|
|
532
|
+
// Emulate through CrateDB's native partitioning: forward the partition
|
|
533
|
+
// column(s) to `PARTITIONED BY` so callers get a working partitioned table
|
|
534
|
+
// instead of an error.
|
|
535
|
+
const partitionedBy = options.partitionBy.column;
|
|
536
|
+
return this.createTable(tableName, columns, { ...options, partitionedBy });
|
|
537
|
+
}
|
|
538
|
+
async createPartition(_options) {
|
|
539
|
+
CrateDBDialect.unsupported('explicit partition management', 'CrateDB creates partitions automatically from the PARTITIONED BY column value on INSERT.');
|
|
540
|
+
}
|
|
541
|
+
async attachPartition(_options) {
|
|
542
|
+
CrateDBDialect.unsupported('ATTACH PARTITION');
|
|
543
|
+
}
|
|
544
|
+
async detachPartition(_options) {
|
|
545
|
+
CrateDBDialect.unsupported('DETACH PARTITION');
|
|
546
|
+
}
|
|
547
|
+
async dropPartition(_partitionName, _options) {
|
|
548
|
+
CrateDBDialect.unsupported('DROP PARTITION', "Delete the partition's rows instead (DELETE ... WHERE partition_col = value).");
|
|
549
|
+
}
|
|
550
|
+
// --- Foreign Data Wrappers (the whole FDW stack is PostgreSQL-only).
|
|
551
|
+
async createForeignDataWrapper(_fdwName, _options) {
|
|
552
|
+
CrateDBDialect.unsupported('foreign data wrappers');
|
|
553
|
+
}
|
|
554
|
+
async dropForeignDataWrapper(_fdwName, _options) {
|
|
555
|
+
CrateDBDialect.unsupported('foreign data wrappers');
|
|
556
|
+
}
|
|
557
|
+
async createForeignServer(_serverName, _fdwName, _options) {
|
|
558
|
+
CrateDBDialect.unsupported('foreign servers');
|
|
559
|
+
}
|
|
560
|
+
async dropForeignServer(_serverName, _options) {
|
|
561
|
+
CrateDBDialect.unsupported('foreign servers');
|
|
562
|
+
}
|
|
563
|
+
async createForeignTable(_tableName, _columns, _options) {
|
|
564
|
+
CrateDBDialect.unsupported('foreign tables');
|
|
565
|
+
}
|
|
566
|
+
async createUserMapping(_userName, _serverName, _options) {
|
|
567
|
+
CrateDBDialect.unsupported('foreign data wrapper user mappings');
|
|
568
|
+
}
|
|
569
|
+
async dropUserMapping(_userName, _serverName, _options) {
|
|
570
|
+
CrateDBDialect.unsupported('foreign data wrapper user mappings');
|
|
571
|
+
}
|
|
424
572
|
}
|
|
425
573
|
exports.CrateDBDialect = CrateDBDialect;
|
|
426
574
|
// ---------------------------------------------------------------------------
|