ts-prorm-orm 1.1.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +95 -0
- package/README.md +194 -72
- package/dist/audit/history-query.d.ts +35 -0
- package/dist/audit/index.d.ts +16 -0
- package/dist/audit/logger.d.ts +126 -0
- package/dist/cache/cache-manager.d.ts +341 -0
- package/dist/cache/index.d.ts +8 -0
- package/dist/cache/redis-cluster-cache.d.ts +164 -0
- package/dist/cache/redis-cluster-cache.js +19 -36
- package/dist/cli/cloud.d.ts +55 -0
- package/dist/cli/cloud.js +318 -0
- package/dist/cli/commands/auth.d.ts +2 -0
- package/dist/cli/commands/auth.js +345 -0
- package/dist/cli/commands/billing.d.ts +2 -0
- package/dist/cli/commands/billing.js +135 -0
- package/dist/cli/commands/code.d.ts +2 -0
- package/dist/cli/commands/code.js +168 -0
- package/dist/cli/commands/config.d.ts +2 -0
- package/dist/cli/commands/config.js +154 -0
- package/dist/cli/commands/db.d.ts +2 -0
- package/dist/cli/commands/db.js +189 -0
- package/dist/cli/commands/index.d.ts +1 -0
- package/dist/cli/commands/index.js +22 -0
- package/dist/cli/commands/keys.d.ts +2 -0
- package/dist/cli/commands/keys.js +100 -0
- package/dist/cli/commands/misc.d.ts +2 -0
- package/dist/cli/commands/misc.js +282 -0
- package/dist/cli/commands/pull.d.ts +2 -0
- package/dist/cli/commands/pull.js +306 -0
- package/dist/cli/commands/runners.d.ts +2 -0
- package/dist/cli/commands/runners.js +218 -0
- package/dist/cli/commands/scaffold.d.ts +2 -0
- package/dist/cli/commands/scaffold.js +383 -0
- package/dist/cli/commands/secrets.d.ts +2 -0
- package/dist/cli/commands/secrets.js +162 -0
- package/dist/cli/commands/store.d.ts +2 -0
- package/dist/cli/commands/store.js +274 -0
- package/dist/cli/commands/system.d.ts +10 -0
- package/dist/cli/commands/system.js +169 -0
- package/dist/cli/commands/teams.d.ts +2 -0
- package/dist/cli/commands/teams.js +189 -0
- package/dist/cli/commands/user.d.ts +2 -0
- package/dist/cli/commands/user.js +171 -0
- package/dist/cli/framework.d.ts +103 -0
- package/dist/cli/framework.js +436 -0
- package/dist/cli/io.d.ts +26 -0
- package/dist/cli/io.js +181 -0
- package/dist/cli/keychain.d.ts +10 -0
- package/dist/cli/keychain.js +101 -0
- package/dist/cli/prompt.d.ts +20 -0
- package/dist/cli/prompt.js +111 -0
- package/dist/cli.d.ts +214 -0
- package/dist/cli.js +72 -5
- package/dist/compliance/audit-trail.d.ts +66 -0
- package/dist/compliance/backup-verification.d.ts +279 -0
- package/dist/compliance/breach-detector.d.ts +197 -0
- package/dist/compliance/consent-record.d.ts +107 -0
- package/dist/compliance/consent-versioning.d.ts +169 -0
- package/dist/compliance/cross-border-log.d.ts +254 -0
- package/dist/compliance/data-classifier.d.ts +127 -0
- package/dist/compliance/data-lineage.d.ts +268 -0
- package/dist/compliance/data-masker.d.ts +110 -0
- package/dist/compliance/data-portability.d.ts +98 -0
- package/dist/compliance/data-retention.d.ts +108 -0
- package/dist/compliance/dsar-workflow.d.ts +175 -0
- package/dist/compliance/field-encryption.d.ts +84 -0
- package/dist/compliance/immutable-record.d.ts +84 -0
- package/dist/compliance/index.d.ts +93 -0
- package/dist/compliance/privacy-impact-assessment.d.ts +196 -0
- package/dist/compliance/pseudonymization.d.ts +96 -0
- package/dist/compliance/query-firewall.d.ts +661 -0
- package/dist/compliance/rate-limiter.d.ts +203 -0
- package/dist/compliance/right-to-erasure.d.ts +96 -0
- package/dist/compliance/row-level-security.d.ts +152 -0
- package/dist/compliance/security-decorator.d.ts +388 -0
- package/dist/compliance/security-monitor.d.ts +170 -0
- package/dist/compliance/sensitive-data-discovery.d.ts +151 -0
- package/dist/compliance/session-isolation.d.ts +286 -0
- package/dist/compliance/tls-enforcer.d.ts +51 -0
- package/dist/compliance/worm-storage.d.ts +225 -0
- package/dist/connection-manager.d.ts +130 -0
- package/dist/connection-pool.d.ts +311 -0
- package/dist/decorators/audit.d.ts +49 -0
- package/dist/decorators/check.d.ts +218 -0
- package/dist/decorators/collate.d.ts +346 -0
- package/dist/decorators/comment.d.ts +51 -0
- package/dist/decorators/database-settings.d.ts +193 -0
- package/dist/decorators/default.d.ts +148 -0
- package/dist/decorators/encryption.d.ts +175 -0
- package/dist/decorators/engine.d.ts +97 -0
- package/dist/decorators/fk-constraints.d.ts +387 -0
- package/dist/decorators/foreign-table.d.ts +57 -0
- package/dist/decorators/generated.d.ts +232 -0
- package/dist/decorators/hstore.d.ts +96 -0
- package/dist/decorators/index.d.ts +57 -0
- package/dist/decorators/index.js +14 -30
- package/dist/decorators/json-column.d.ts +47 -0
- package/dist/decorators/jsonb.d.ts +83 -0
- package/dist/decorators/orm-decorators.d.ts +274 -0
- package/dist/decorators/permissions.d.ts +192 -0
- package/dist/decorators/procedure.d.ts +168 -0
- package/dist/decorators/procedure.js +31 -7
- package/dist/decorators/query-options.d.ts +527 -0
- package/dist/decorators/range.d.ts +122 -0
- package/dist/decorators/set-column.d.ts +43 -0
- package/dist/decorators/spatial.d.ts +60 -0
- package/dist/decorators/storage.d.ts +561 -0
- package/dist/decorators/timezone.d.ts +319 -0
- package/dist/decorators/trigger.d.ts +50 -0
- package/dist/decorators/uuid.d.ts +102 -0
- package/dist/decorators/view.d.ts +213 -0
- package/dist/diagrams/chen-diagram.d.ts +70 -0
- package/dist/diagrams/chen-diagram.js +33 -31
- package/dist/diagrams/class-diagram.d.ts +78 -0
- package/dist/diagrams/class-diagram.js +23 -27
- package/dist/diagrams/dependency-diagram.d.ts +82 -0
- package/dist/diagrams/dependency-diagram.js +18 -9
- package/dist/diagrams/er-diagram.d.ts +82 -0
- package/dist/diagrams/er-diagram.js +174 -231
- package/dist/diagrams/flow-diagram.d.ts +70 -0
- package/dist/diagrams/flow-diagram.js +23 -18
- package/dist/diagrams/gantt-diagram.d.ts +67 -0
- package/dist/diagrams/gantt-diagram.js +20 -18
- package/dist/diagrams/index-diagram.d.ts +61 -0
- package/dist/diagrams/index-diagram.js +36 -31
- package/dist/diagrams/index.d.ts +155 -0
- package/dist/diagrams/index.js +7 -1
- package/dist/diagrams/migration-diagram.d.ts +67 -0
- package/dist/diagrams/migration-diagram.js +45 -57
- package/dist/diagrams/model-diagram.d.ts +85 -0
- package/dist/diagrams/model-diagram.js +225 -287
- package/dist/diagrams/package-diagram.d.ts +69 -0
- package/dist/diagrams/package-diagram.js +30 -32
- package/dist/diagrams/palette.d.ts +138 -0
- package/dist/diagrams/palette.js +134 -25
- package/dist/diagrams/relational-diagram.d.ts +82 -0
- package/dist/diagrams/relational-diagram.js +51 -59
- package/dist/diagrams/schemadoc-diagram.d.ts +57 -0
- package/dist/diagrams/schemadoc-diagram.js +36 -28
- package/dist/diagrams/sequence-diagram.d.ts +61 -0
- package/dist/diagrams/sequence-diagram.js +20 -11
- package/dist/diagrams/state-diagram.d.ts +85 -0
- package/dist/diagrams/state-diagram.js +21 -17
- package/dist/diagrams/svg-dom.d.ts +62 -0
- package/dist/diagrams/svg-dom.js +11 -0
- package/dist/diagrams/tree-diagram.d.ts +47 -0
- package/dist/diagrams/tree-diagram.js +19 -10
- package/dist/dialects/clickhouse/index.d.ts +660 -0
- package/dist/dialects/clickhouse/index.js +107 -2
- package/dist/dialects/cockroachdb/index.d.ts +1708 -0
- package/dist/dialects/cockroachdb/index.js +139 -10
- package/dist/dialects/cratedb/index.d.ts +262 -0
- package/dist/dialects/cratedb/index.js +148 -0
- package/dist/dialects/databricks/index.d.ts +397 -0
- package/dist/dialects/databricks/index.js +233 -11
- package/dist/dialects/db2/index.d.ts +729 -0
- package/dist/dialects/db2/index.js +152 -2
- package/dist/dialects/dialect.d.ts +1653 -0
- package/dist/dialects/duckdb/index.d.ts +440 -0
- package/dist/dialects/duckdb/index.js +21 -37
- package/dist/dialects/exasol/index.d.ts +197 -0
- package/dist/dialects/exasol/index.js +14 -0
- package/dist/dialects/firebird/index.d.ts +286 -0
- package/dist/dialects/firebird/index.js +135 -0
- package/dist/dialects/greenplum/index.d.ts +336 -0
- package/dist/dialects/greenplum/index.js +168 -0
- package/dist/dialects/hana/index.d.ts +512 -0
- package/dist/dialects/hana/index.js +17 -35
- package/dist/dialects/mariadb/index.d.ts +1241 -0
- package/dist/dialects/mariadb/index.js +181 -43
- package/dist/dialects/mssql/index.d.ts +729 -0
- package/dist/dialects/mssql/index.js +76 -7
- package/dist/dialects/mysql/index.d.ts +1233 -0
- package/dist/dialects/mysql/index.js +87 -19
- package/dist/dialects/oracle/index.d.ts +1222 -0
- package/dist/dialects/oracle/index.js +210 -9
- package/dist/dialects/postgres/index.d.ts +1598 -0
- package/dist/dialects/postgres/index.js +34 -13
- package/dist/dialects/query-stream-helper.d.ts +58 -0
- package/dist/dialects/questdb/index.d.ts +430 -0
- package/dist/dialects/questdb/index.js +292 -0
- package/dist/dialects/redshift/index.d.ts +933 -0
- package/dist/dialects/redshift/index.js +17 -5
- package/dist/dialects/singlestore/index.d.ts +233 -0
- package/dist/dialects/singlestore/index.js +53 -0
- package/dist/dialects/snowflake/index.d.ts +727 -0
- package/dist/dialects/snowflake/index.js +154 -5
- package/dist/dialects/spanner/index.d.ts +660 -0
- package/dist/dialects/spanner/index.js +43 -21
- package/dist/dialects/sqlite/index.d.ts +1133 -0
- package/dist/dialects/sqlite/index.js +168 -30
- package/dist/dialects/tidb/index.d.ts +226 -0
- package/dist/dialects/tidb/index.js +10 -0
- package/dist/dialects/timescaledb/index.d.ts +286 -0
- package/dist/dialects/timescaledb/index.js +179 -0
- package/dist/dialects/trino/index.d.ts +230 -0
- package/dist/dialects/trino/index.js +85 -10
- package/dist/dialects/turso/index.d.ts +98 -0
- package/dist/dialects/turso/index.js +10 -0
- package/dist/dialects/vertica/index.d.ts +321 -0
- package/dist/dialects/vertica/index.js +161 -0
- package/dist/dialects/yugabytedb/index.d.ts +276 -0
- package/dist/dialects/yugabytedb/index.js +121 -0
- package/dist/errors/index.d.ts +378 -0
- package/dist/errors/index.js +29 -1
- package/dist/errors/utils.d.ts +53 -0
- package/dist/errors.d.ts +5 -0
- package/dist/extensions/catalog/cloud-warehouse-features.d.ts +27 -0
- package/dist/extensions/catalog/mssql-features.d.ts +20 -0
- package/dist/extensions/catalog/mysql-mariadb-plugins.d.ts +18 -0
- package/dist/extensions/catalog/oracle-db2-features.d.ts +17 -0
- package/dist/extensions/catalog/postgres-extensions.d.ts +15 -0
- package/dist/extensions/index.d.ts +34 -0
- package/dist/extensions/types.d.ts +43 -0
- package/dist/external-fields/adapters.d.ts +50 -0
- package/dist/external-fields/adapters.js +227 -0
- package/dist/external-fields/decorator.d.ts +77 -0
- package/dist/external-fields/decorator.js +80 -0
- package/dist/external-fields/index.d.ts +10 -0
- package/dist/external-fields/index.js +19 -0
- package/dist/external-fields/runtime.d.ts +39 -0
- package/dist/external-fields/runtime.js +221 -0
- package/dist/foreign-data.d.ts +168 -0
- package/dist/graph/base-graph-dialect.d.ts +250 -0
- package/dist/graph/base-graph-dialect.js +539 -0
- package/dist/graph/dgraph/index.d.ts +65 -0
- package/dist/graph/dgraph/index.js +559 -0
- package/dist/graph/gremlin/index.d.ts +59 -0
- package/dist/graph/gremlin/index.js +378 -0
- package/dist/graph/index.d.ts +60 -0
- package/dist/graph/index.js +67 -0
- package/dist/graph/neo4j/index.d.ts +50 -0
- package/dist/graph/neo4j/index.js +462 -0
- package/dist/graph/types.d.ts +213 -0
- package/dist/graph/types.js +234 -0
- package/dist/hooks/hooks-manager.d.ts +189 -0
- package/dist/hooks/index.d.ts +8 -0
- package/dist/index.d.ts +713 -0
- package/dist/index.js +36 -4
- package/dist/logging.d.ts +183 -0
- package/dist/migrations/index.d.ts +9 -0
- package/dist/migrations/migration.d.ts +143 -0
- package/dist/migrations/migrator.d.ts +199 -0
- package/dist/migrations/prormmigration.d.ts +131 -0
- package/dist/migrations/query-interface.d.ts +335 -0
- package/dist/migrations/seeder.d.ts +167 -0
- package/dist/models/associations.d.ts +131 -0
- package/dist/models/associations.js +7 -2
- package/dist/models/constraints.d.ts +175 -0
- package/dist/models/data-types.d.ts +1656 -0
- package/dist/models/decorators.d.ts +328 -0
- package/dist/models/decorators.js +61 -82
- package/dist/models/eager-load.d.ts +86 -0
- package/dist/models/eager-load.js +369 -0
- package/dist/models/index.d.ts +13 -0
- package/dist/models/indexes.d.ts +325 -0
- package/dist/models/methods.d.ts +419 -0
- package/dist/models/model-manager.d.ts +76 -0
- package/dist/models/model.d.ts +820 -0
- package/dist/models/model.js +15 -101
- package/dist/models/operators.d.ts +29 -0
- package/dist/models/scopes.d.ts +71 -0
- package/dist/models/typescript-types.d.ts +177 -0
- package/dist/nosql/aerospike/index.d.ts +126 -0
- package/dist/nosql/allegrograph/index.d.ts +86 -0
- package/dist/nosql/arangodb/index.d.ts +285 -0
- package/dist/nosql/arangodb/index.js +274 -2
- package/dist/nosql/arangodb/where.d.ts +38 -0
- package/dist/nosql/arangodb/where.js +94 -0
- package/dist/nosql/azure-blob/index.d.ts +104 -0
- package/dist/nosql/beanstalkd/index.d.ts +88 -0
- package/dist/nosql/beequeue/index.d.ts +99 -0
- package/dist/nosql/bigchaindb/index.d.ts +113 -0
- package/dist/nosql/bigtable/index.d.ts +144 -0
- package/dist/nosql/blazegraph/index.d.ts +88 -0
- package/dist/nosql/bullmq/index.d.ts +83 -0
- package/dist/nosql/cassandra/index.d.ts +119 -0
- package/dist/nosql/chroma/index.d.ts +151 -0
- package/dist/nosql/cloudflare-kv/index.d.ts +120 -0
- package/dist/nosql/coherence/index.d.ts +91 -0
- package/dist/nosql/cosmosdb/index.d.ts +78 -0
- package/dist/nosql/couchbase/index.d.ts +103 -0
- package/dist/nosql/dax/index.d.ts +118 -0
- package/dist/nosql/deno-kv/index.d.ts +109 -0
- package/dist/nosql/dgraph/index.d.ts +80 -0
- package/dist/nosql/doris/index.d.ts +88 -0
- package/dist/nosql/druid/index.d.ts +95 -0
- package/dist/nosql/dynamodb/index.d.ts +643 -0
- package/dist/nosql/dynamodb/index.js +423 -0
- package/dist/nosql/elasticsearch/index.d.ts +239 -0
- package/dist/nosql/etcd/index.d.ts +243 -0
- package/dist/nosql/eventhubs/index.d.ts +89 -0
- package/dist/nosql/eventstore/index.d.ts +102 -0
- package/dist/nosql/faunadb/index.d.ts +141 -0
- package/dist/nosql/faunadb/index.js +329 -0
- package/dist/nosql/firestore/index.d.ts +67 -0
- package/dist/nosql/fluree/index.d.ts +88 -0
- package/dist/nosql/fuseki/index.d.ts +94 -0
- package/dist/nosql/gcs/index.d.ts +62 -0
- package/dist/nosql/gearman/index.d.ts +77 -0
- package/dist/nosql/geode/index.d.ts +93 -0
- package/dist/nosql/graphdb/index.d.ts +86 -0
- package/dist/nosql/graylog/index.d.ts +118 -0
- package/dist/nosql/gridgain/index.d.ts +78 -0
- package/dist/nosql/hazelcast/index.d.ts +73 -0
- package/dist/nosql/hbase/index.d.ts +123 -0
- package/dist/nosql/ignite/index.d.ts +80 -0
- package/dist/nosql/immudb/index.d.ts +131 -0
- package/dist/nosql/index.d.ts +215 -0
- package/dist/nosql/infinispan/index.d.ts +95 -0
- package/dist/nosql/influxdb/flux-compiler.d.ts +23 -0
- package/dist/nosql/influxdb/flux-compiler.js +170 -0
- package/dist/nosql/influxdb/index.d.ts +300 -0
- package/dist/nosql/influxdb/index.js +0 -0
- package/dist/nosql/kafka/index.d.ts +113 -0
- package/dist/nosql/keyspaces/index.d.ts +122 -0
- package/dist/nosql/kinesis/index.d.ts +121 -0
- package/dist/nosql/leveldb/index.d.ts +112 -0
- package/dist/nosql/leveldb/index.js +103 -1
- package/dist/nosql/lmdb/index.d.ts +76 -0
- package/dist/nosql/loki/index.d.ts +126 -0
- package/dist/nosql/marklogic/index.d.ts +76 -0
- package/dist/nosql/materialize/index.d.ts +91 -0
- package/dist/nosql/meilisearch/index.d.ts +76 -0
- package/dist/nosql/memcached/index.d.ts +138 -0
- package/dist/nosql/milvus/index.d.ts +167 -0
- package/dist/nosql/minio/index.d.ts +122 -0
- package/dist/nosql/momento/index.d.ts +99 -0
- package/dist/nosql/mongodb/index.d.ts +265 -0
- package/dist/nosql/mongodb/index.js +139 -0
- package/dist/nosql/mongodb/where.d.ts +8 -0
- package/dist/nosql/mongodb/where.js +181 -0
- package/dist/nosql/nats/index.d.ts +139 -0
- package/dist/nosql/nedb/index.d.ts +79 -0
- package/dist/nosql/neo4j/index.d.ts +217 -0
- package/dist/nosql/neo4j/index.js +26 -14
- package/dist/nosql/neptune/index.d.ts +234 -0
- package/dist/nosql/neptune/index.js +23 -9
- package/dist/nosql/nsq/index.d.ts +93 -0
- package/dist/nosql/opensearch/index.d.ts +97 -0
- package/dist/nosql/orientdb/index.d.ts +72 -0
- package/dist/nosql/papertrail/index.d.ts +120 -0
- package/dist/nosql/pinecone/index.d.ts +148 -0
- package/dist/nosql/pinot/index.d.ts +90 -0
- package/dist/nosql/pouchdb/index.d.ts +95 -0
- package/dist/nosql/prometheus/index.d.ts +112 -0
- package/dist/nosql/provendb/index.d.ts +143 -0
- package/dist/nosql/provendb/index.js +262 -0
- package/dist/nosql/pubsub/index.d.ts +83 -0
- package/dist/nosql/pulsar/index.d.ts +105 -0
- package/dist/nosql/qdrant/index.d.ts +231 -0
- package/dist/nosql/qldb/index.d.ts +182 -0
- package/dist/nosql/qldb/index.js +302 -1
- package/dist/nosql/r2/index.d.ts +160 -0
- package/dist/nosql/rabbitmq/index.d.ts +131 -0
- package/dist/nosql/ravendb/index.d.ts +138 -0
- package/dist/nosql/ravendb/index.js +323 -9
- package/dist/nosql/ravendb/where.d.ts +38 -0
- package/dist/nosql/ravendb/where.js +94 -0
- package/dist/nosql/redis/index.d.ts +267 -0
- package/dist/nosql/redis/index.js +19 -5
- package/dist/nosql/redpanda/index.d.ts +117 -0
- package/dist/nosql/resque/index.d.ts +91 -0
- package/dist/nosql/rethinkdb/index.d.ts +194 -0
- package/dist/nosql/rethinkdb/index.js +290 -0
- package/dist/nosql/rethinkdb/where.d.ts +38 -0
- package/dist/nosql/rethinkdb/where.js +94 -0
- package/dist/nosql/rocksdb/document-layer.d.ts +162 -0
- package/dist/nosql/rocksdb/document-layer.js +338 -0
- package/dist/nosql/rocksdb/index.d.ts +112 -0
- package/dist/nosql/rocksdb/index.js +103 -1
- package/dist/nosql/rocksdb/where-match.d.ts +21 -0
- package/dist/nosql/rocksdb/where-match.js +238 -0
- package/dist/nosql/rockset/index.d.ts +84 -0
- package/dist/nosql/s3/index.d.ts +170 -0
- package/dist/nosql/scylladb/index.d.ts +117 -0
- package/dist/nosql/signoz/index.d.ts +116 -0
- package/dist/nosql/sns/index.d.ts +99 -0
- package/dist/nosql/solr/index.d.ts +129 -0
- package/dist/nosql/splunk/index.d.ts +125 -0
- package/dist/nosql/sqs/index.d.ts +116 -0
- package/dist/nosql/stardog/index.d.ts +86 -0
- package/dist/nosql/starrocks/index.d.ts +89 -0
- package/dist/nosql/store.d.ts +23 -0
- package/dist/nosql/sumologic/index.d.ts +119 -0
- package/dist/nosql/surrealdb/index.d.ts +156 -0
- package/dist/nosql/surrealdb/index.js +174 -1
- package/dist/nosql/surrealdb/query-compiler.d.ts +26 -0
- package/dist/nosql/surrealdb/query-compiler.js +193 -0
- package/dist/nosql/terminusdb/index.d.ts +95 -0
- package/dist/nosql/tigergraph/index.d.ts +314 -0
- package/dist/nosql/typesense/index.d.ts +82 -0
- package/dist/nosql/unqlite/index.d.ts +68 -0
- package/dist/nosql/upstash/index.d.ts +80 -0
- package/dist/nosql/vercel-kv/index.d.ts +82 -0
- package/dist/nosql/victoriametrics/index.d.ts +129 -0
- package/dist/nosql/virtuoso/index.d.ts +87 -0
- package/dist/nosql/weaviate/index.d.ts +196 -0
- package/dist/operators/index.d.ts +7 -0
- package/dist/operators.d.ts +2947 -0
- package/dist/operators.js +46 -1
- package/dist/prisma-migrate/index.d.ts +28 -0
- package/dist/prisma-migrate/migration-generator.d.ts +21 -0
- package/dist/prisma-migrate/model-generator.d.ts +12 -0
- package/dist/prisma-migrate/relations.d.ts +28 -0
- package/dist/prisma-migrate/schema-parser.d.ts +42 -0
- package/dist/prisma-migrate/type-mapper.d.ts +20 -0
- package/dist/prorm.d.ts +2093 -0
- package/dist/prorm.js +721 -302
- package/dist/query-builders/cte-builder.d.ts +104 -0
- package/dist/query-builders/functions/aggregate.d.ts +199 -0
- package/dist/query-builders/functions/conditional.d.ts +195 -0
- package/dist/query-builders/functions/datetime.d.ts +202 -0
- package/dist/query-builders/functions/fulltext.d.ts +220 -0
- package/dist/query-builders/functions/index.d.ts +17 -0
- package/dist/query-builders/functions/json.d.ts +157 -0
- package/dist/query-builders/functions/math.d.ts +215 -0
- package/dist/query-builders/functions/string.d.ts +233 -0
- package/dist/query-builders/functions/window.d.ts +209 -0
- package/dist/query-builders/include-builder.d.ts +85 -0
- package/dist/query-builders/index-expression-builder.d.ts +153 -0
- package/dist/query-builders/index.d.ts +121 -0
- package/dist/query-builders/index.js +10 -0
- package/dist/query-builders/insert-builder.d.ts +62 -0
- package/dist/query-builders/model-helpers.d.ts +28 -0
- package/dist/query-builders/order-limit-builder.d.ts +84 -0
- package/dist/query-builders/sql-compiler.d.ts +562 -0
- package/dist/query-builders/subquery-builder.d.ts +133 -0
- package/dist/query-builders/update-builder.d.ts +71 -0
- package/dist/query-builders/view-builder.d.ts +189 -0
- package/dist/query-builders/where-builder.d.ts +124 -0
- package/dist/query-interface.d.ts +407 -0
- package/dist/query-interface.js +84 -0
- package/dist/query-optimizers/batch-optimizer.d.ts +175 -0
- package/dist/query-optimizers/explain-plans.d.ts +187 -0
- package/dist/query-optimizers/index.d.ts +27 -0
- package/dist/query-optimizers/prepared-statement-cache.d.ts +252 -0
- package/dist/query-optimizers/query-hints.d.ts +201 -0
- package/dist/query-optimizers/query-optimizer.d.ts +162 -0
- package/dist/query-optimizers/slow-query-logger.d.ts +186 -0
- package/dist/replica-manager.d.ts +235 -0
- package/dist/schema/index.d.ts +7 -0
- package/dist/schema/migration-generator.d.ts +74 -0
- package/dist/schema/schema-differ.d.ts +114 -0
- package/dist/schema/types.d.ts +246 -0
- package/dist/schema-objects.d.ts +78 -0
- package/dist/schema-objects.js +203 -0
- package/dist/sql-constants.d.ts +240 -0
- package/dist/sqlite-advanced.d.ts +572 -0
- package/dist/streams/index.d.ts +5 -0
- package/dist/streams/transforms.d.ts +120 -0
- package/dist/transaction.d.ts +221 -0
- package/dist/types/index.d.ts +3123 -0
- package/dist/user-management.d.ts +141 -0
- package/dist/utils/date.d.ts +149 -0
- package/dist/utils/index.d.ts +359 -0
- package/dist/utils/string.d.ts +88 -0
- package/dist/validators/index.d.ts +7 -0
- package/dist/validators/validator.d.ts +306 -0
- package/package.json +20 -5
|
@@ -0,0 +1,727 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Snowflake dialect implementation for the TypeScript ORM
|
|
3
|
+
*
|
|
4
|
+
* Notes on Snowflake-specific semantics that differ from most other dialects
|
|
5
|
+
* implemented in this project:
|
|
6
|
+
* - Snowflake has no traditional B-tree indexes. Storage is organized via
|
|
7
|
+
* automatic micro-partitioning, and the closest user-facing concept is a
|
|
8
|
+
* "clustering key" (ALTER TABLE ... CLUSTER BY (...)). Index-shaped
|
|
9
|
+
* interface methods (addIndex/createIndex/removeIndex/dropIndex/etc.) are
|
|
10
|
+
* therefore implemented as documented no-ops that emit a console warning,
|
|
11
|
+
* mirroring how src/dialects/sqlite/index.ts handles options that are
|
|
12
|
+
* accepted for interface-compatibility but have no real effect for that
|
|
13
|
+
* dialect (e.g. `engine`/`charset`/table comments).
|
|
14
|
+
* - Semi-structured data uses VARIANT/OBJECT/ARRAY types with PARSE_JSON(),
|
|
15
|
+
* `:` path access and GET/GET_PATH functions instead of JSON/JSONB.
|
|
16
|
+
* - Upserts use MERGE INTO (standard SQL, well supported).
|
|
17
|
+
* - Pagination uses standard LIMIT/OFFSET (unlike Oracle/MSSQL's
|
|
18
|
+
* OFFSET...FETCH-only style).
|
|
19
|
+
* - Auto-increment uses AUTOINCREMENT/IDENTITY column properties.
|
|
20
|
+
* - Sequences are supported via CREATE SEQUENCE / NEXTVAL.
|
|
21
|
+
* - Connections require an "account" identifier and may specify a
|
|
22
|
+
* "warehouse" (the compute resource that must be active for queries to
|
|
23
|
+
* run). If provided, `USE WAREHOUSE <name>` is issued right after connect.
|
|
24
|
+
* - Auth supports both password auth and key-pair auth (privateKey /
|
|
25
|
+
* privateKeyPath), matching the snowflake-sdk driver's ConnectionOptions.
|
|
26
|
+
*/
|
|
27
|
+
import type { Connection as SnowflakeConnection } from 'snowflake-sdk';
|
|
28
|
+
import { Dialect, DialectOptions, ColumnDefinition, TableOptions, DropTableOptions, TableDescription, IndexOptions, IndexDefinition, InsertOptions, UpdateOptions, DeleteOptions, SelectOptions, UpsertQueryOptions, DropSchemaOptions, ViewOptions, DropViewOptions, DropIndexOptions, ConstraintDefinition, DropConstraintOptions, BuildOptions, FdwForeignServerOptions, FdwAlterForeignServerOptions, FdwUserMappingOptions, FdwForeignTableOptions, FdwImportForeignSchemaOptions, ExtensionInfo, CreateExtensionOptions, DropExtensionOptions } from '../dialect';
|
|
29
|
+
import { Transaction, TransactionOptions, QueryResult, QueryOptions, DataType, WhereOptions, Order, RetryOptions, CreatePartitionOptions, AttachPartitionOptions, DetachPartitionOptions, StoredProcedureOptions, DropStoredProcedureOptions, ExecuteStoredProcedureOptions, SequenceOptions, DropSequenceOptions, StreamOptions as QueryStreamOptions } from '../../types';
|
|
30
|
+
import { Readable } from 'stream';
|
|
31
|
+
/**
|
|
32
|
+
* Snowflake dialect connection/config options.
|
|
33
|
+
*
|
|
34
|
+
* Supports both password authentication (`password`) and key-pair
|
|
35
|
+
* authentication (`privateKey` / `privateKeyPath`, optionally with
|
|
36
|
+
* `privateKeyPass` for an encrypted key). The `warehouse` option activates
|
|
37
|
+
* the given virtual warehouse right after connecting via `USE WAREHOUSE`.
|
|
38
|
+
*/
|
|
39
|
+
export interface SnowflakeDialectOptions extends DialectOptions {
|
|
40
|
+
/** Snowflake account identifier, e.g. "xy12345" or "xy12345.us-east-1" */
|
|
41
|
+
account?: string;
|
|
42
|
+
/** Virtual warehouse (compute resource) to activate on connect */
|
|
43
|
+
warehouse?: string;
|
|
44
|
+
/** Default schema for the session */
|
|
45
|
+
schema?: string;
|
|
46
|
+
/** Default security role for the session */
|
|
47
|
+
role?: string;
|
|
48
|
+
/** PEM-encoded private key contents for key-pair authentication */
|
|
49
|
+
privateKey?: string;
|
|
50
|
+
/** Path to a PEM-encoded private key file for key-pair authentication */
|
|
51
|
+
privateKeyPath?: string;
|
|
52
|
+
/** Passphrase for an encrypted private key */
|
|
53
|
+
privateKeyPass?: string;
|
|
54
|
+
/** Authenticator to use (defaults to Snowflake's built-in password auth) */
|
|
55
|
+
authenticator?: string;
|
|
56
|
+
/** Client application name reported to Snowflake */
|
|
57
|
+
application?: string;
|
|
58
|
+
/** Connection/query retry configuration */
|
|
59
|
+
retry?: RetryOptions;
|
|
60
|
+
/** Role-agnostic client session keep alive toggle */
|
|
61
|
+
clientSessionKeepAlive?: boolean;
|
|
62
|
+
}
|
|
63
|
+
/** Options for `cloneTable`/`cloneSchema`/`cloneDatabase` (zero-copy CLONE). */
|
|
64
|
+
export interface CloneOptions {
|
|
65
|
+
ifNotExists?: boolean;
|
|
66
|
+
replace?: boolean;
|
|
67
|
+
schema?: string;
|
|
68
|
+
/** Clone the source as of a specific timestamp (Time Travel `AT(TIMESTAMP => ...)`) */
|
|
69
|
+
atTimestamp?: string | Date;
|
|
70
|
+
/** Clone the source as of a relative offset in seconds (`AT(OFFSET => ...)`) */
|
|
71
|
+
atOffset?: number;
|
|
72
|
+
/** Clone the source as of a specific query ID (`AT(STATEMENT => ...)`) */
|
|
73
|
+
atStatement?: string;
|
|
74
|
+
/** Clone the source immediately before a specific query ID (`BEFORE(STATEMENT => ...)`) */
|
|
75
|
+
beforeStatement?: string;
|
|
76
|
+
}
|
|
77
|
+
/** Options for `createFileFormat` (`CREATE FILE FORMAT`). */
|
|
78
|
+
export interface FileFormatOptions {
|
|
79
|
+
type: 'CSV' | 'JSON' | 'PARQUET' | 'AVRO' | 'ORC' | 'XML' | string;
|
|
80
|
+
ifNotExists?: boolean;
|
|
81
|
+
replace?: boolean;
|
|
82
|
+
schema?: string;
|
|
83
|
+
fieldDelimiter?: string;
|
|
84
|
+
recordDelimiter?: string;
|
|
85
|
+
skipHeader?: number;
|
|
86
|
+
fieldOptionallyEnclosedBy?: string;
|
|
87
|
+
nullIf?: string | string[];
|
|
88
|
+
emptyFieldAsNull?: boolean;
|
|
89
|
+
stripOuterArray?: boolean;
|
|
90
|
+
binaryAsText?: boolean;
|
|
91
|
+
compression?: string;
|
|
92
|
+
dateFormat?: string;
|
|
93
|
+
timestampFormat?: string;
|
|
94
|
+
/** Escape hatch for any additional `KEY = value` clause, appended verbatim */
|
|
95
|
+
raw?: string;
|
|
96
|
+
}
|
|
97
|
+
/** Options for `createStage` (`CREATE STAGE`). */
|
|
98
|
+
export interface StageOptions {
|
|
99
|
+
ifNotExists?: boolean;
|
|
100
|
+
replace?: boolean;
|
|
101
|
+
schema?: string;
|
|
102
|
+
/** External location URL, e.g. 's3://my-bucket/path/' */
|
|
103
|
+
url?: string;
|
|
104
|
+
/** Credential key/value pairs, e.g. { awsKeyId: '...', awsSecretKey: '...' } */
|
|
105
|
+
credentials?: Record<string, string>;
|
|
106
|
+
/** Name of a previously created FILE FORMAT to associate with this stage */
|
|
107
|
+
fileFormatName?: string;
|
|
108
|
+
}
|
|
109
|
+
/** Options for `copyInto` (bulk load via `COPY INTO <table> FROM @stage`). */
|
|
110
|
+
export interface CopyIntoOptions {
|
|
111
|
+
schema?: string;
|
|
112
|
+
files?: string[];
|
|
113
|
+
pattern?: string;
|
|
114
|
+
fileFormatName?: string;
|
|
115
|
+
fileFormat?: Record<string, string | number | boolean>;
|
|
116
|
+
onError?: 'CONTINUE' | 'SKIP_FILE' | 'ABORT_STATEMENT' | string;
|
|
117
|
+
force?: boolean;
|
|
118
|
+
purge?: boolean;
|
|
119
|
+
matchByColumnName?: 'CASE_SENSITIVE' | 'CASE_INSENSITIVE' | 'NONE' | string;
|
|
120
|
+
}
|
|
121
|
+
/** Options for `unloadTo` (bulk unload via `COPY INTO @stage FROM <table>`). */
|
|
122
|
+
export interface UnloadOptions {
|
|
123
|
+
schema?: string;
|
|
124
|
+
fileFormatName?: string;
|
|
125
|
+
fileFormat?: Record<string, string | number | boolean>;
|
|
126
|
+
overwrite?: boolean;
|
|
127
|
+
single?: boolean;
|
|
128
|
+
header?: boolean;
|
|
129
|
+
maxFileSize?: number;
|
|
130
|
+
}
|
|
131
|
+
/** Options for `createStream` (`CREATE STREAM ... ON TABLE ...`). */
|
|
132
|
+
export interface StreamOptions {
|
|
133
|
+
ifNotExists?: boolean;
|
|
134
|
+
replace?: boolean;
|
|
135
|
+
schema?: string;
|
|
136
|
+
appendOnly?: boolean;
|
|
137
|
+
showInitialRows?: boolean;
|
|
138
|
+
comment?: string;
|
|
139
|
+
}
|
|
140
|
+
/** Options for `createTask` (`CREATE TASK ...`). */
|
|
141
|
+
export interface TaskOptions {
|
|
142
|
+
ifNotExists?: boolean;
|
|
143
|
+
replace?: boolean;
|
|
144
|
+
schema?: string;
|
|
145
|
+
warehouse?: string;
|
|
146
|
+
/** Cron expression or interval, e.g. "USING CRON 0 0 * * * UTC" or "60 MINUTE" */
|
|
147
|
+
schedule?: string;
|
|
148
|
+
/**
|
|
149
|
+
* Name(s) of predecessor task(s), forming a DAG (`AFTER <task>`). Snowflake
|
|
150
|
+
* tasks may depend on more than one predecessor (a task runs only after
|
|
151
|
+
* *all* of its predecessors complete); pass an array to emit
|
|
152
|
+
* `AFTER <task1>, <task2>, ...`.
|
|
153
|
+
*/
|
|
154
|
+
after?: string | string[];
|
|
155
|
+
/** Condition expression gating execution (`WHEN <expr>`) */
|
|
156
|
+
when?: string;
|
|
157
|
+
comment?: string;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Options shared by `createWarehouse`/`alterWarehouse` (`CREATE WAREHOUSE
|
|
161
|
+
* ... WITH ...` / `ALTER WAREHOUSE ... SET ...`). Field names mirror the
|
|
162
|
+
* Snowflake object properties they map to (WAREHOUSE_SIZE, AUTO_SUSPEND,
|
|
163
|
+
* etc.), snake_case-to-camelCase.
|
|
164
|
+
*/
|
|
165
|
+
export interface WarehouseOptions {
|
|
166
|
+
/** `IF NOT EXISTS` — only meaningful on create, ignored on alter */
|
|
167
|
+
ifNotExists?: boolean;
|
|
168
|
+
/** `CREATE OR REPLACE WAREHOUSE` — only meaningful on create */
|
|
169
|
+
replace?: boolean;
|
|
170
|
+
/** `WAREHOUSE_SIZE`, e.g. 'X-SMALL', 'SMALL', 'MEDIUM', 'LARGE', 'X-LARGE', '2X-LARGE', ... */
|
|
171
|
+
size?: string;
|
|
172
|
+
/** `AUTO_SUSPEND` — seconds of inactivity before the warehouse suspends (0 disables auto-suspend) */
|
|
173
|
+
autoSuspend?: number;
|
|
174
|
+
/** `AUTO_RESUME` — whether the warehouse automatically resumes when a query is submitted */
|
|
175
|
+
autoResume?: boolean;
|
|
176
|
+
/** `MIN_CLUSTER_COUNT` — minimum clusters for a multi-cluster warehouse */
|
|
177
|
+
minClusterCount?: number;
|
|
178
|
+
/** `MAX_CLUSTER_COUNT` — maximum clusters for a multi-cluster warehouse */
|
|
179
|
+
maxClusterCount?: number;
|
|
180
|
+
/** `SCALING_POLICY`, e.g. 'STANDARD' or 'ECONOMY' */
|
|
181
|
+
scalingPolicy?: 'STANDARD' | 'ECONOMY' | string;
|
|
182
|
+
/** `INITIALLY_SUSPENDED` — only meaningful on create */
|
|
183
|
+
initiallySuspended?: boolean;
|
|
184
|
+
/** `RESOURCE_MONITOR` — name of a resource monitor to assign to this warehouse */
|
|
185
|
+
resourceMonitor?: string;
|
|
186
|
+
/** `COMMENT` */
|
|
187
|
+
comment?: string;
|
|
188
|
+
}
|
|
189
|
+
/** A single `TRIGGERS ON <threshold> PERCENT DO <action>` clause of a resource monitor. */
|
|
190
|
+
export interface ResourceMonitorTrigger {
|
|
191
|
+
/** Percentage of the credit quota that activates this trigger */
|
|
192
|
+
threshold: number;
|
|
193
|
+
/** Action to take once the threshold is reached */
|
|
194
|
+
action: 'NOTIFY' | 'SUSPEND' | 'SUSPEND_IMMEDIATE';
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Options for `createResourceMonitor`/`alterResourceMonitor`
|
|
198
|
+
* (`CREATE RESOURCE MONITOR ... WITH ...` / `ALTER RESOURCE MONITOR ... SET ...`).
|
|
199
|
+
* Resource monitors track Snowflake credit usage and can automatically
|
|
200
|
+
* notify, suspend, or immediately suspend the warehouse(s)/account they are
|
|
201
|
+
* assigned to once usage crosses configured thresholds.
|
|
202
|
+
*/
|
|
203
|
+
export interface ResourceMonitorOptions {
|
|
204
|
+
/** `IF NOT EXISTS` — only meaningful on create; mutually exclusive with `replace` */
|
|
205
|
+
ifNotExists?: boolean;
|
|
206
|
+
/** `CREATE OR REPLACE RESOURCE MONITOR` — only meaningful on create; mutually exclusive with `ifNotExists` */
|
|
207
|
+
replace?: boolean;
|
|
208
|
+
/** `CREDIT_QUOTA` */
|
|
209
|
+
creditQuota?: number;
|
|
210
|
+
/** `FREQUENCY`, e.g. 'MONTHLY', 'DAILY', 'WEEKLY', 'YEARLY', 'NEVER' */
|
|
211
|
+
frequency?: 'MONTHLY' | 'DAILY' | 'WEEKLY' | 'YEARLY' | 'NEVER' | string;
|
|
212
|
+
/** `START_TIMESTAMP` — a timestamp literal, or 'IMMEDIATELY' */
|
|
213
|
+
startTimestamp?: string;
|
|
214
|
+
/** `END_TIMESTAMP` */
|
|
215
|
+
endTimestamp?: string;
|
|
216
|
+
/** `NOTIFY_USERS = (...)` — Snowflake usernames to notify */
|
|
217
|
+
notifyUsers?: string[];
|
|
218
|
+
/** `TRIGGERS ON <n> PERCENT DO <action> ...` */
|
|
219
|
+
triggers?: ResourceMonitorTrigger[];
|
|
220
|
+
}
|
|
221
|
+
export declare class SnowflakeDialect implements Dialect {
|
|
222
|
+
readonly name = "snowflake";
|
|
223
|
+
readonly library = "snowflake-sdk";
|
|
224
|
+
private connection;
|
|
225
|
+
private _isConnected;
|
|
226
|
+
private config;
|
|
227
|
+
private retryOptions;
|
|
228
|
+
constructor(config: SnowflakeDialectOptions);
|
|
229
|
+
/**
|
|
230
|
+
* Connect to Snowflake. Wraps the callback-based snowflake-sdk API
|
|
231
|
+
* (`createConnection(...).connect(callback)`) in a Promise. If a
|
|
232
|
+
* `warehouse` was configured, activates it with `USE WAREHOUSE` right
|
|
233
|
+
* after the connection is established.
|
|
234
|
+
*/
|
|
235
|
+
connect(): Promise<void>;
|
|
236
|
+
/**
|
|
237
|
+
* Disconnect from Snowflake, terminating the connection immediately.
|
|
238
|
+
*
|
|
239
|
+
* A failed `destroy()` callback is surfaced by rejecting this promise
|
|
240
|
+
* (rather than silently resolving as if the disconnect succeeded), so
|
|
241
|
+
* callers relying on disconnect() aren't misled into thinking the
|
|
242
|
+
* underlying socket was cleanly torn down. The local connection state is
|
|
243
|
+
* still cleared in a `finally` regardless of outcome, since from this
|
|
244
|
+
* dialect's perspective the connection should no longer be used either way.
|
|
245
|
+
*/
|
|
246
|
+
disconnect(): Promise<void>;
|
|
247
|
+
getConnection(): SnowflakeConnection | null;
|
|
248
|
+
isConnected(): boolean;
|
|
249
|
+
/**
|
|
250
|
+
* Builds the shared `complete` callback used by both `query()` and
|
|
251
|
+
* `queryWithCancel()` to translate a snowflake-sdk statement completion
|
|
252
|
+
* into a resolved/rejected `QueryResult` promise.
|
|
253
|
+
*/
|
|
254
|
+
private makeCompleteHandler;
|
|
255
|
+
private resolveExecuteArgs;
|
|
256
|
+
/**
|
|
257
|
+
* Stream query results by paging through `sql` via repeated
|
|
258
|
+
* dialect-appropriate LIMIT/OFFSET queries (see
|
|
259
|
+
* `createPaginatedQueryStream()` in `src/dialects/query-stream-helper.ts`)
|
|
260
|
+
* instead of loading the whole result set into memory at once.
|
|
261
|
+
* @param sql - The SELECT statement to stream
|
|
262
|
+
* @param options - Streaming options (batch size, backpressure watermark, model mapping)
|
|
263
|
+
*/
|
|
264
|
+
queryStream(sql: string, options?: QueryStreamOptions): Readable;
|
|
265
|
+
/**
|
|
266
|
+
* Execute a raw SQL query, wrapping the callback-based
|
|
267
|
+
* `connection.execute({ sqlText, binds, complete })` API in a Promise.
|
|
268
|
+
*/
|
|
269
|
+
query(sql: string, options?: QueryOptions): Promise<QueryResult>;
|
|
270
|
+
/**
|
|
271
|
+
* Execute a query and return a handle that allows cancelling it before it
|
|
272
|
+
* completes, via snowflake-sdk's `Statement.cancel()` API. This is the
|
|
273
|
+
* long-running-query abort path that plain `query()` does not offer: once
|
|
274
|
+
* a query has been submitted, `query()` gives the caller no way to stop it
|
|
275
|
+
* short of waiting (or retrying, which only compounds wait time under
|
|
276
|
+
* warehouse auto-suspend/resume scenarios).
|
|
277
|
+
*
|
|
278
|
+
* Unlike `query()`, this method does not go through the retry wrapper —
|
|
279
|
+
* callers that need cancellation are expected to manage their own
|
|
280
|
+
* retry/backoff around the returned `result` promise if desired.
|
|
281
|
+
*/
|
|
282
|
+
queryWithCancel(sql: string, options?: QueryOptions): {
|
|
283
|
+
result: Promise<QueryResult>;
|
|
284
|
+
cancel: () => Promise<void>;
|
|
285
|
+
getQueryId: () => string | undefined;
|
|
286
|
+
};
|
|
287
|
+
private executeWithRetry;
|
|
288
|
+
escape(value: unknown): string;
|
|
289
|
+
private escapeString;
|
|
290
|
+
private formatDate;
|
|
291
|
+
escapeId(identifier: unknown): string;
|
|
292
|
+
quoteIdentifier(identifier: string): string;
|
|
293
|
+
quoteTable(tableName: string, schema?: string): string;
|
|
294
|
+
createSchema(schema: string): Promise<void>;
|
|
295
|
+
dropSchema(schema: string, options?: DropSchemaOptions): Promise<void>;
|
|
296
|
+
showAllSchemas(): Promise<string[]>;
|
|
297
|
+
listSchemas(): Promise<string[]>;
|
|
298
|
+
createDatabaseSQL(options: {
|
|
299
|
+
name: string;
|
|
300
|
+
encoding?: string;
|
|
301
|
+
lcCollate?: string;
|
|
302
|
+
lcCtype?: string;
|
|
303
|
+
template?: string;
|
|
304
|
+
tablespace?: string;
|
|
305
|
+
collate?: string;
|
|
306
|
+
isTemplate?: boolean;
|
|
307
|
+
}): string;
|
|
308
|
+
dropDatabaseSQL(name: string): string;
|
|
309
|
+
createSavepointSQL(name?: string): string;
|
|
310
|
+
releaseSavepointSQL(name: string): string;
|
|
311
|
+
rollbackToSavepointSQL(name: string): string;
|
|
312
|
+
createExtension(_extensionName: string, _options?: CreateExtensionOptions): Promise<void>;
|
|
313
|
+
dropExtension(_extensionName: string, _options?: DropExtensionOptions): Promise<void>;
|
|
314
|
+
getExtensions(): Promise<ExtensionInfo[]>;
|
|
315
|
+
hasExtension(_extensionName: string): Promise<boolean>;
|
|
316
|
+
getDatabaseVersion(): Promise<string>;
|
|
317
|
+
createTable(tableName: string, columns: Record<string, ColumnDefinition>, options?: TableOptions): Promise<void>;
|
|
318
|
+
private buildConstraintSql;
|
|
319
|
+
private getColumnDefinitionSql;
|
|
320
|
+
private getDefaultValue;
|
|
321
|
+
dropTable(tableName: string, options?: DropTableOptions): Promise<void>;
|
|
322
|
+
createPartitionedTable(): Promise<void>;
|
|
323
|
+
createPartition(_options: CreatePartitionOptions): Promise<void>;
|
|
324
|
+
attachPartition(_options: AttachPartitionOptions): Promise<void>;
|
|
325
|
+
detachPartition(_options: DetachPartitionOptions): Promise<void>;
|
|
326
|
+
dropPartition(): Promise<void>;
|
|
327
|
+
/**
|
|
328
|
+
* Set (or clear) a clustering key for a table — Snowflake's replacement
|
|
329
|
+
* for manual indexing/partitioning to influence micro-partition pruning.
|
|
330
|
+
*/
|
|
331
|
+
setClusteringKey(tableName: string, fields: string[]): Promise<void>;
|
|
332
|
+
dropClusteringKey(tableName: string): Promise<void>;
|
|
333
|
+
createView(viewName: string, query: string, options?: ViewOptions): Promise<void>;
|
|
334
|
+
dropView(viewName: string, options?: DropViewOptions): Promise<void>;
|
|
335
|
+
showViews(): Promise<string[]>;
|
|
336
|
+
showMaterializedViews(): Promise<string[]>;
|
|
337
|
+
addColumn(tableName: string, columnName: string, definition: ColumnDefinition): Promise<void>;
|
|
338
|
+
removeColumn(tableName: string, columnName: string): Promise<void>;
|
|
339
|
+
changeColumn(tableName: string, columnName: string, definition: ColumnDefinition): Promise<void>;
|
|
340
|
+
renameColumn(tableName: string, oldColumnName: string, newColumnName: string): Promise<void>;
|
|
341
|
+
addForeignKey(tableName: string, columnName: string, referencedTableName: string, referencedColumnName: string, options?: any): Promise<void>;
|
|
342
|
+
bulkInsert(tableName: string, records: Record<string, any>[], _options?: any): Promise<QueryResult>;
|
|
343
|
+
showTables(): Promise<string[]>;
|
|
344
|
+
showConstraints(tableName: string): Promise<any[]>;
|
|
345
|
+
addConstraint(tableName: string, options: {
|
|
346
|
+
type: 'UNIQUE' | 'CHECK' | 'PRIMARY KEY' | 'FOREIGN KEY';
|
|
347
|
+
fields: string[];
|
|
348
|
+
name?: string;
|
|
349
|
+
references?: {
|
|
350
|
+
table: string;
|
|
351
|
+
fields: string[];
|
|
352
|
+
};
|
|
353
|
+
check?: string;
|
|
354
|
+
}): Promise<void>;
|
|
355
|
+
removeConstraint(tableName: string, constraintName: string): Promise<void>;
|
|
356
|
+
/**
|
|
357
|
+
* Snowflake has no traditional indexes; it returns an empty list rather
|
|
358
|
+
* than throwing so generic ORM code paths that inspect "current indexes"
|
|
359
|
+
* degrade gracefully.
|
|
360
|
+
*/
|
|
361
|
+
showIndexes(_tableName: string): Promise<any[]>;
|
|
362
|
+
describeTable(tableName: string): Promise<TableDescription>;
|
|
363
|
+
renameTable(oldName: string, newName: string): Promise<void>;
|
|
364
|
+
addIndex(tableName: string, indexName: string, _fields: string[], _options?: IndexOptions): Promise<void>;
|
|
365
|
+
removeIndex(tableName: string, indexName: string): Promise<void>;
|
|
366
|
+
createIndex(tableName: string, indexDef: IndexDefinition): Promise<void>;
|
|
367
|
+
dropIndex(tableName: string, indexName: string, _options?: DropIndexOptions): Promise<void>;
|
|
368
|
+
createFulltextIndex(tableName: string, indexName: string, _fields: string[], _options?: {
|
|
369
|
+
parser?: string;
|
|
370
|
+
comment?: string;
|
|
371
|
+
}): Promise<void>;
|
|
372
|
+
createSpatialIndex(tableName: string, indexName: string, _fields: string[], _options?: {
|
|
373
|
+
storage?: string;
|
|
374
|
+
srid?: number;
|
|
375
|
+
}): Promise<void>;
|
|
376
|
+
createConstraint(tableName: string, constraintDef: ConstraintDefinition): Promise<void>;
|
|
377
|
+
dropConstraint(tableName: string, constraintName: string, options?: DropConstraintOptions): Promise<void>;
|
|
378
|
+
changeOwner(newOwner: string, tableName: string): Promise<void>;
|
|
379
|
+
createForeignDataWrapper(): Promise<void>;
|
|
380
|
+
dropForeignDataWrapper(): Promise<void>;
|
|
381
|
+
createForeignServer(): Promise<void>;
|
|
382
|
+
dropForeignServer(): Promise<void>;
|
|
383
|
+
createForeignTable(): Promise<void>;
|
|
384
|
+
createSecurityPolicy(_policyName: string, _tableName: string, _options?: {
|
|
385
|
+
predicate?: string;
|
|
386
|
+
}): Promise<void>;
|
|
387
|
+
dropSecurityPolicy(_policyName: string, _tableName: string): Promise<void>;
|
|
388
|
+
startTransaction(_options?: TransactionOptions): Promise<Transaction>;
|
|
389
|
+
commitTransaction(_transaction: Transaction): Promise<void>;
|
|
390
|
+
rollbackTransaction(_transaction: Transaction): Promise<void>;
|
|
391
|
+
getDataTypeSql(dataType: DataType): string;
|
|
392
|
+
/**
|
|
393
|
+
* Build a Snowflake VARIANT/OBJECT path query using `:` path access
|
|
394
|
+
* (e.g. `data:key::STRING`) rather than JSON_EXTRACT.
|
|
395
|
+
*/
|
|
396
|
+
buildJsonQuery(column: string, path: string, value?: unknown, operator?: string): {
|
|
397
|
+
sql: string;
|
|
398
|
+
values: unknown[];
|
|
399
|
+
};
|
|
400
|
+
buildWhereClause(where: WhereOptions, _options?: BuildOptions): {
|
|
401
|
+
sql: string;
|
|
402
|
+
values: any[];
|
|
403
|
+
};
|
|
404
|
+
buildOrderClause(order: Order, _options?: BuildOptions): string;
|
|
405
|
+
/**
|
|
406
|
+
* Snowflake supports standard LIMIT/OFFSET pagination (unlike Oracle/MSSQL's
|
|
407
|
+
* FETCH FIRST-only style), so this is a direct passthrough.
|
|
408
|
+
*/
|
|
409
|
+
buildLimitOffset(limit?: number | string, offset?: number | string): string;
|
|
410
|
+
buildInsertQuery(tableName: string, values: Record<string, any>, options?: InsertOptions): {
|
|
411
|
+
sql: string;
|
|
412
|
+
values: any[];
|
|
413
|
+
};
|
|
414
|
+
buildUpdateQuery(tableName: string, values: Record<string, any>, where: WhereOptions, options?: UpdateOptions): {
|
|
415
|
+
sql: string;
|
|
416
|
+
values: any[];
|
|
417
|
+
};
|
|
418
|
+
buildDeleteQuery(tableName: string, where: WhereOptions, options?: DeleteOptions): {
|
|
419
|
+
sql: string;
|
|
420
|
+
values: any[];
|
|
421
|
+
};
|
|
422
|
+
/**
|
|
423
|
+
* Formats a single SELECT attribute. Plain column names are identifier-
|
|
424
|
+
* quoted as before; entries that look like SQL expressions rather than
|
|
425
|
+
* bare identifiers (e.g. window functions like
|
|
426
|
+
* `ROW_NUMBER() OVER (PARTITION BY dept ORDER BY salary DESC) AS rn`, or
|
|
427
|
+
* any other expression containing parentheses/whitespace/an `AS` alias)
|
|
428
|
+
* are passed through unescaped so callers can use analytical SQL that a
|
|
429
|
+
* plain identifier-quoting pass would otherwise mangle.
|
|
430
|
+
*/
|
|
431
|
+
private formatSelectAttribute;
|
|
432
|
+
/**
|
|
433
|
+
* Builds a `WITH [RECURSIVE] ...` prefix from `options.cte`, Snowflake's
|
|
434
|
+
* (standard-SQL) Common Table Expression syntax. Each entry may set its
|
|
435
|
+
* own `recursive` flag; if any entry is recursive the whole `WITH` clause
|
|
436
|
+
* is emitted as `WITH RECURSIVE` (Snowflake, like most engines, applies
|
|
437
|
+
* RECURSIVE to the entire WITH clause rather than per-CTE).
|
|
438
|
+
*/
|
|
439
|
+
private buildCteClause;
|
|
440
|
+
/**
|
|
441
|
+
* Builds Snowflake's Time Travel clause (`AT(...)`/`BEFORE(...)`) to
|
|
442
|
+
* append right after a table reference in the FROM clause, e.g.
|
|
443
|
+
* `FROM "T" AT(TIMESTAMP => '2024-01-01 00:00:00')`.
|
|
444
|
+
*/
|
|
445
|
+
private buildTimeTravelClause;
|
|
446
|
+
buildSelectQuery(options: SelectOptions): {
|
|
447
|
+
sql: string;
|
|
448
|
+
values: any[];
|
|
449
|
+
};
|
|
450
|
+
/**
|
|
451
|
+
* Build an upsert using Snowflake's MERGE INTO, which is well-supported
|
|
452
|
+
* and close to standard SQL MERGE.
|
|
453
|
+
*/
|
|
454
|
+
buildUpsertQuery(tableName: string, values: Record<string, any>, options?: UpsertQueryOptions): {
|
|
455
|
+
sql: string;
|
|
456
|
+
values: any[];
|
|
457
|
+
};
|
|
458
|
+
buildIncrementQuery(tableName: string, fields: string | string[] | Record<string, number>, where: WhereOptions, options?: {
|
|
459
|
+
by?: number;
|
|
460
|
+
}): {
|
|
461
|
+
sql: string;
|
|
462
|
+
values: any[];
|
|
463
|
+
};
|
|
464
|
+
/**
|
|
465
|
+
* Replace placeholders in SQL with actual escaped values. Supports both
|
|
466
|
+
* named (:param) and positional (?) placeholders.
|
|
467
|
+
*/
|
|
468
|
+
replaceReplacements(sql: string, replacements?: Record<string, unknown> | unknown[]): string;
|
|
469
|
+
buildCreateServerQuery(_name: string, _opts: FdwForeignServerOptions): string;
|
|
470
|
+
buildAlterServerQuery(_name: string, _opts: FdwAlterForeignServerOptions): string;
|
|
471
|
+
buildDropServerQuery(_name: string, _opts?: {
|
|
472
|
+
ifExists?: boolean;
|
|
473
|
+
cascade?: boolean;
|
|
474
|
+
}): string;
|
|
475
|
+
buildCreateUserMappingQuery(_opts: FdwUserMappingOptions): string;
|
|
476
|
+
buildAlterUserMappingQuery(_opts: FdwUserMappingOptions): string;
|
|
477
|
+
buildDropUserMappingQuery(_serverName: string, _user: string, _opts?: {
|
|
478
|
+
ifExists?: boolean;
|
|
479
|
+
}): string;
|
|
480
|
+
createUserMapping(): Promise<void>;
|
|
481
|
+
dropUserMapping(): Promise<void>;
|
|
482
|
+
buildCreateForeignTableQuery(_tableName: string, _opts: FdwForeignTableOptions): string;
|
|
483
|
+
buildDropForeignTableQuery(_tableName: string, _opts?: {
|
|
484
|
+
ifExists?: boolean;
|
|
485
|
+
cascade?: boolean;
|
|
486
|
+
}): string;
|
|
487
|
+
buildImportForeignSchemaQuery(_remoteSchema: string, _serverName: string, _opts?: FdwImportForeignSchemaOptions): string;
|
|
488
|
+
getServersQuery(): string;
|
|
489
|
+
buildCreateUserQuery(_username: string, _options?: any): string;
|
|
490
|
+
buildAlterUserQuery(_username: string, _options: any): string;
|
|
491
|
+
buildDropUserQuery(_username: string, _options?: any): string;
|
|
492
|
+
getUsersQuery(): string;
|
|
493
|
+
buildGrantQuery(_options: any): string;
|
|
494
|
+
buildRevokeQuery(_options: any): string;
|
|
495
|
+
buildShowGrantsQuery(_username: string, _host?: string): string;
|
|
496
|
+
buildFlushPrivilegesQuery(): string;
|
|
497
|
+
buildCreateRoleQuery(_roleName: string, _options?: any): string;
|
|
498
|
+
buildDropRoleQuery(_roleName: string, _options?: any): string;
|
|
499
|
+
buildGrantRoleQuery(_role: string, _to: any, _options?: any): string;
|
|
500
|
+
buildRevokeRoleQuery(_role: string, _from: any, _options?: any): string;
|
|
501
|
+
getRolesQuery(): string;
|
|
502
|
+
createSequence(options: SequenceOptions): Promise<void>;
|
|
503
|
+
dropSequence(sequenceName: string, options?: DropSequenceOptions): Promise<void>;
|
|
504
|
+
nextSequenceValue(sequenceName: string): Promise<number>;
|
|
505
|
+
hasSequence(sequenceName: string): Promise<boolean>;
|
|
506
|
+
listSequences(): Promise<string[]>;
|
|
507
|
+
createStoredProcedure(options: StoredProcedureOptions): Promise<void>;
|
|
508
|
+
createProcedure(options: StoredProcedureOptions): Promise<void>;
|
|
509
|
+
dropStoredProcedure(procedureName: string, options?: DropStoredProcedureOptions): Promise<void>;
|
|
510
|
+
dropProcedure(procedureName: string, options?: DropStoredProcedureOptions): Promise<void>;
|
|
511
|
+
executeStoredProcedure(options: ExecuteStoredProcedureOptions): Promise<QueryResult>;
|
|
512
|
+
hasStoredProcedure(procedureName: string, schema?: string): Promise<boolean>;
|
|
513
|
+
/**
|
|
514
|
+
* Builds the optional `AT(...)`/`BEFORE(...)` suffix used by CLONE
|
|
515
|
+
* statements, reusing the same Time Travel clause builder as SELECT.
|
|
516
|
+
*/
|
|
517
|
+
private buildCloneTimeTravelClause;
|
|
518
|
+
/**
|
|
519
|
+
* Zero-copy clone of a table: `CREATE TABLE <target> CLONE <source>`.
|
|
520
|
+
* Supports an optional Time Travel clause (`atTimestamp`/`atOffset`/
|
|
521
|
+
* `atStatement`/`beforeStatement`) to clone a historical version of the
|
|
522
|
+
* source table, and `ifNotExists`/`replace` like `createTable`.
|
|
523
|
+
*/
|
|
524
|
+
cloneTable(source: string, target: string, options?: CloneOptions): Promise<void>;
|
|
525
|
+
/**
|
|
526
|
+
* Zero-copy clone of a schema: `CREATE SCHEMA <target> CLONE <source>`.
|
|
527
|
+
*/
|
|
528
|
+
cloneSchema(source: string, target: string, options?: CloneOptions): Promise<void>;
|
|
529
|
+
/**
|
|
530
|
+
* Zero-copy clone of a database: `CREATE DATABASE <target> CLONE <source>`.
|
|
531
|
+
*/
|
|
532
|
+
cloneDatabase(source: string, target: string, options?: CloneOptions): Promise<void>;
|
|
533
|
+
/**
|
|
534
|
+
* `CREATE FILE FORMAT <name> TYPE = <CSV|JSON|PARQUET|...> [options...]`.
|
|
535
|
+
* Supports the most commonly used per-type options; any additional/rare
|
|
536
|
+
* option can be passed through `raw` and is appended verbatim.
|
|
537
|
+
*/
|
|
538
|
+
createFileFormat(name: string, options: FileFormatOptions): Promise<void>;
|
|
539
|
+
dropFileFormat(name: string, options?: {
|
|
540
|
+
ifExists?: boolean;
|
|
541
|
+
schema?: string;
|
|
542
|
+
}): Promise<void>;
|
|
543
|
+
/**
|
|
544
|
+
* `CREATE STAGE <name> [URL = '...'] [CREDENTIALS = (...)] [FILE_FORMAT = ...]`.
|
|
545
|
+
* A stage is Snowflake's named reference to a bulk-load/unload location
|
|
546
|
+
* (internal, or external S3/Azure/GCS); required before `COPY INTO` can
|
|
547
|
+
* reference `@<stage>`.
|
|
548
|
+
*/
|
|
549
|
+
createStage(name: string, options?: StageOptions): Promise<void>;
|
|
550
|
+
dropStage(name: string, options?: {
|
|
551
|
+
ifExists?: boolean;
|
|
552
|
+
schema?: string;
|
|
553
|
+
}): Promise<void>;
|
|
554
|
+
/**
|
|
555
|
+
* Bulk load: `COPY INTO <table> FROM @<stage>[/path] [FILES = (...)]
|
|
556
|
+
* [PATTERN = '...'] [FILE_FORMAT = (...)] [ON_ERROR = ...] [FORCE = ...]`.
|
|
557
|
+
* `stagePath` may be a bare stage name (`my_stage`) or already include the
|
|
558
|
+
* `@` prefix / sub-path (`@my_stage/2024/`); both are normalized.
|
|
559
|
+
*/
|
|
560
|
+
copyInto(tableName: string, stagePath: string, options?: CopyIntoOptions): Promise<QueryResult>;
|
|
561
|
+
/**
|
|
562
|
+
* Bulk unload: `COPY INTO @<stage>[/path] FROM <table> [FILE_FORMAT = (...)]
|
|
563
|
+
* [OVERWRITE = ...] [SINGLE = ...] [HEADER = ...]`.
|
|
564
|
+
*/
|
|
565
|
+
unloadTo(tableName: string, stagePath: string, options?: UnloadOptions): Promise<QueryResult>;
|
|
566
|
+
/**
|
|
567
|
+
* Builds the `WAREHOUSE_SIZE = '...' AUTO_SUSPEND = ... ...` object
|
|
568
|
+
* properties shared by `CREATE WAREHOUSE ... WITH ...` and
|
|
569
|
+
* `ALTER WAREHOUSE ... SET ...`. `includeCreateOnly` controls whether
|
|
570
|
+
* create-only properties (`INITIALLY_SUSPENDED`) are included, since
|
|
571
|
+
* `ALTER WAREHOUSE ... SET` does not accept them.
|
|
572
|
+
*/
|
|
573
|
+
private buildWarehousePropertiesSql;
|
|
574
|
+
/**
|
|
575
|
+
* `CREATE [OR REPLACE] WAREHOUSE [IF NOT EXISTS] <name> WITH <properties>`.
|
|
576
|
+
*/
|
|
577
|
+
createWarehouse(name: string, options?: WarehouseOptions): Promise<void>;
|
|
578
|
+
/**
|
|
579
|
+
* `ALTER WAREHOUSE <name> SET <properties>`. Also used to (re)assign a
|
|
580
|
+
* resource monitor to a warehouse via `options.resourceMonitor`
|
|
581
|
+
* (`ALTER WAREHOUSE <name> SET RESOURCE_MONITOR = <monitor_name>`).
|
|
582
|
+
*/
|
|
583
|
+
alterWarehouse(name: string, options: WarehouseOptions): Promise<void>;
|
|
584
|
+
dropWarehouse(name: string, options?: {
|
|
585
|
+
ifExists?: boolean;
|
|
586
|
+
}): Promise<void>;
|
|
587
|
+
suspendWarehouse(name: string): Promise<void>;
|
|
588
|
+
resumeWarehouse(name: string): Promise<void>;
|
|
589
|
+
/**
|
|
590
|
+
* Builds the `CREDIT_QUOTA = ... FREQUENCY = ... TRIGGERS ON ... PERCENT DO ...`
|
|
591
|
+
* body shared by `CREATE RESOURCE MONITOR ... WITH ...` and
|
|
592
|
+
* `ALTER RESOURCE MONITOR ... SET ...`.
|
|
593
|
+
*/
|
|
594
|
+
private buildResourceMonitorPropertiesSql;
|
|
595
|
+
/** `CREATE [OR REPLACE] RESOURCE MONITOR [IF NOT EXISTS] <name> WITH <properties>`. */
|
|
596
|
+
createResourceMonitor(name: string, options: ResourceMonitorOptions): Promise<void>;
|
|
597
|
+
/** `ALTER RESOURCE MONITOR <name> SET <properties>` (updates quota/frequency/triggers/etc). */
|
|
598
|
+
alterResourceMonitor(name: string, options: ResourceMonitorOptions): Promise<void>;
|
|
599
|
+
dropResourceMonitor(name: string, options?: {
|
|
600
|
+
ifExists?: boolean;
|
|
601
|
+
}): Promise<void>;
|
|
602
|
+
/**
|
|
603
|
+
* `CREATE STREAM <name> ON TABLE <table> [APPEND_ONLY = ...] [SHOW_INITIAL_ROWS = ...]`.
|
|
604
|
+
* A stream tracks row-level INSERT/UPDATE/DELETE changes on a table (or
|
|
605
|
+
* view) since it was created or last consumed, Snowflake's native CDC
|
|
606
|
+
* mechanism.
|
|
607
|
+
*/
|
|
608
|
+
createStream(name: string, tableName: string, options?: StreamOptions): Promise<void>;
|
|
609
|
+
dropStream(name: string, options?: {
|
|
610
|
+
ifExists?: boolean;
|
|
611
|
+
schema?: string;
|
|
612
|
+
}): Promise<void>;
|
|
613
|
+
showStreams(): Promise<string[]>;
|
|
614
|
+
/**
|
|
615
|
+
* `CREATE TASK <name> [WAREHOUSE = ...] [SCHEDULE = '...'] [AFTER <task>]
|
|
616
|
+
* AS <sql>`. A task runs a single SQL statement (often `CALL` on a stored
|
|
617
|
+
* procedure) on a schedule (cron/interval) or as part of a DAG (`AFTER`).
|
|
618
|
+
*/
|
|
619
|
+
createTask(name: string, sql: string, options?: TaskOptions): Promise<void>;
|
|
620
|
+
dropTask(name: string, options?: {
|
|
621
|
+
ifExists?: boolean;
|
|
622
|
+
schema?: string;
|
|
623
|
+
}): Promise<void>;
|
|
624
|
+
resumeTask(name: string, schema?: string): Promise<void>;
|
|
625
|
+
suspendTask(name: string, schema?: string): Promise<void>;
|
|
626
|
+
/** Runs a task immediately, outside of its schedule: `EXECUTE TASK <name>`. */
|
|
627
|
+
executeTask(name: string, schema?: string): Promise<QueryResult>;
|
|
628
|
+
showTasks(): Promise<string[]>;
|
|
629
|
+
/**
|
|
630
|
+
* `CREATE [OR REPLACE] [SECURE] MATERIALIZED VIEW <name> AS <query>`.
|
|
631
|
+
* Snowflake materialized views are single-table, automatically maintained by
|
|
632
|
+
* the service. Pass `secure: true` for a SECURE materialized view (hides the
|
|
633
|
+
* definition/optimizer internals for data sharing).
|
|
634
|
+
*/
|
|
635
|
+
createMaterializedView(viewName: string, query: string, options?: {
|
|
636
|
+
replace?: boolean;
|
|
637
|
+
secure?: boolean;
|
|
638
|
+
comment?: string;
|
|
639
|
+
schema?: string;
|
|
640
|
+
clusterBy?: string[];
|
|
641
|
+
}): Promise<void>;
|
|
642
|
+
dropMaterializedView(viewName: string, options?: {
|
|
643
|
+
ifExists?: boolean;
|
|
644
|
+
schema?: string;
|
|
645
|
+
}): Promise<void>;
|
|
646
|
+
/**
|
|
647
|
+
* `CREATE [OR REPLACE] DYNAMIC TABLE <name> TARGET_LAG = '...' WAREHOUSE = ...
|
|
648
|
+
* AS <query>`. Dynamic tables are Snowflake's declarative, automatically
|
|
649
|
+
* refreshed alternative to materialized views for multi-table
|
|
650
|
+
* transforms/rollups; `targetLag` (e.g. `'1 minute'` or `'DOWNSTREAM'`) sets
|
|
651
|
+
* the freshness target and `warehouse` runs the refresh.
|
|
652
|
+
*/
|
|
653
|
+
createDynamicTable(name: string, query: string, options: {
|
|
654
|
+
targetLag: string;
|
|
655
|
+
warehouse: string;
|
|
656
|
+
replace?: boolean;
|
|
657
|
+
ifNotExists?: boolean;
|
|
658
|
+
schema?: string;
|
|
659
|
+
clusterBy?: string[];
|
|
660
|
+
comment?: string;
|
|
661
|
+
}): Promise<void>;
|
|
662
|
+
dropDynamicTable(name: string, options?: {
|
|
663
|
+
ifExists?: boolean;
|
|
664
|
+
schema?: string;
|
|
665
|
+
}): Promise<void>;
|
|
666
|
+
/** Manually refresh a dynamic table: `ALTER DYNAMIC TABLE <name> REFRESH`. */
|
|
667
|
+
refreshDynamicTable(name: string, schema?: string): Promise<void>;
|
|
668
|
+
/**
|
|
669
|
+
* `UNDROP TABLE <name>` — restore a table dropped within the Time Travel
|
|
670
|
+
* retention window. Snowflake's counterpart to an accidental-DROP undo; also
|
|
671
|
+
* available for schemas/databases via {@link undropSchema}/{@link undropDatabase}.
|
|
672
|
+
*/
|
|
673
|
+
undropTable(tableName: string, schema?: string): Promise<void>;
|
|
674
|
+
undropSchema(schema: string): Promise<void>;
|
|
675
|
+
undropDatabase(name: string): Promise<void>;
|
|
676
|
+
/**
|
|
677
|
+
* Fetch the full `CREATE` DDL for an object via `SELECT GET_DDL(<type>, <name>)`.
|
|
678
|
+
* Higher fidelity than parsing `DESCRIBE TABLE` rows — returns the exact,
|
|
679
|
+
* reproducible statement Snowflake would use to recreate the object.
|
|
680
|
+
*
|
|
681
|
+
* @param objectType - e.g. `'TABLE'`, `'VIEW'`, `'FUNCTION'`, `'PROCEDURE'`, `'SCHEMA'`.
|
|
682
|
+
*/
|
|
683
|
+
getDdl(objectType: string, name: string, schema?: string): Promise<string>;
|
|
684
|
+
/**
|
|
685
|
+
* `CREATE [OR REPLACE] [SECURE] FUNCTION <name>(args) RETURNS <type>
|
|
686
|
+
* [LANGUAGE ...] AS $$ <body> $$`. UDFs return a value (scalar or table) and
|
|
687
|
+
* are callable inline in SQL, unlike stored procedures. `language` defaults to
|
|
688
|
+
* SQL; JavaScript/Python/Java UDFs pass the matching `language` + `body`.
|
|
689
|
+
*/
|
|
690
|
+
createFunction(name: string, options: {
|
|
691
|
+
args?: Array<{
|
|
692
|
+
name: string;
|
|
693
|
+
type: string;
|
|
694
|
+
}>;
|
|
695
|
+
returns: string;
|
|
696
|
+
body: string;
|
|
697
|
+
language?: 'SQL' | 'JAVASCRIPT' | 'PYTHON' | 'JAVA' | 'SCALA';
|
|
698
|
+
replace?: boolean;
|
|
699
|
+
secure?: boolean;
|
|
700
|
+
schema?: string;
|
|
701
|
+
immutable?: boolean;
|
|
702
|
+
runtimeVersion?: string;
|
|
703
|
+
handler?: string;
|
|
704
|
+
comment?: string;
|
|
705
|
+
}): Promise<void>;
|
|
706
|
+
dropFunction(name: string, argTypes?: string[], options?: {
|
|
707
|
+
ifExists?: boolean;
|
|
708
|
+
schema?: string;
|
|
709
|
+
}): Promise<void>;
|
|
710
|
+
/**
|
|
711
|
+
* Build an expression to shred a JSON document/array into relational rows.
|
|
712
|
+
* Snowflake has no `JSON_TABLE`; its real equivalent is the `FLATTEN` table function
|
|
713
|
+
* (`TABLE(FLATTEN(input => ..., path => ...))`), which explodes a VARIANT array/object
|
|
714
|
+
* into rows exposing `value` (and `index` for array position). This wraps FLATTEN in a
|
|
715
|
+
* derived table that projects `value:<key>::<type>` per requested column, matching the
|
|
716
|
+
* named/typed column shape of JSON_TABLE/OPENJSON in the other dialects.
|
|
717
|
+
* Snowflake: (SELECT f.value:name::type AS name, ... FROM
|
|
718
|
+
* TABLE(FLATTEN(input => expr, path => 'rowPath')) AS f) AS alias
|
|
719
|
+
*/
|
|
720
|
+
buildJsonTable(jsonExpression: string, rowPath: string, columns: Array<{
|
|
721
|
+
name: string;
|
|
722
|
+
type?: string;
|
|
723
|
+
path?: string;
|
|
724
|
+
forOrdinality?: boolean;
|
|
725
|
+
}>, alias: string): string;
|
|
726
|
+
}
|
|
727
|
+
export default SnowflakeDialect;
|