ts-prorm-orm 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +83 -0
- package/README.md +194 -72
- package/dist/audit/history-query.d.ts +35 -0
- package/dist/audit/index.d.ts +16 -0
- package/dist/audit/logger.d.ts +126 -0
- package/dist/cache/cache-manager.d.ts +341 -0
- package/dist/cache/index.d.ts +8 -0
- package/dist/cache/redis-cluster-cache.d.ts +164 -0
- package/dist/cache/redis-cluster-cache.js +19 -36
- package/dist/cli/cloud.d.ts +55 -0
- package/dist/cli/cloud.js +318 -0
- package/dist/cli/commands/auth.d.ts +2 -0
- package/dist/cli/commands/auth.js +345 -0
- package/dist/cli/commands/billing.d.ts +2 -0
- package/dist/cli/commands/billing.js +135 -0
- package/dist/cli/commands/code.d.ts +2 -0
- package/dist/cli/commands/code.js +168 -0
- package/dist/cli/commands/config.d.ts +2 -0
- package/dist/cli/commands/config.js +154 -0
- package/dist/cli/commands/db.d.ts +2 -0
- package/dist/cli/commands/db.js +189 -0
- package/dist/cli/commands/index.d.ts +1 -0
- package/dist/cli/commands/index.js +22 -0
- package/dist/cli/commands/keys.d.ts +2 -0
- package/dist/cli/commands/keys.js +100 -0
- package/dist/cli/commands/misc.d.ts +2 -0
- package/dist/cli/commands/misc.js +282 -0
- package/dist/cli/commands/pull.d.ts +2 -0
- package/dist/cli/commands/pull.js +306 -0
- package/dist/cli/commands/runners.d.ts +2 -0
- package/dist/cli/commands/runners.js +218 -0
- package/dist/cli/commands/scaffold.d.ts +2 -0
- package/dist/cli/commands/scaffold.js +383 -0
- package/dist/cli/commands/secrets.d.ts +2 -0
- package/dist/cli/commands/secrets.js +162 -0
- package/dist/cli/commands/store.d.ts +2 -0
- package/dist/cli/commands/store.js +274 -0
- package/dist/cli/commands/system.d.ts +10 -0
- package/dist/cli/commands/system.js +169 -0
- package/dist/cli/commands/teams.d.ts +2 -0
- package/dist/cli/commands/teams.js +189 -0
- package/dist/cli/commands/user.d.ts +2 -0
- package/dist/cli/commands/user.js +171 -0
- package/dist/cli/framework.d.ts +103 -0
- package/dist/cli/framework.js +436 -0
- package/dist/cli/io.d.ts +26 -0
- package/dist/cli/io.js +181 -0
- package/dist/cli/keychain.d.ts +10 -0
- package/dist/cli/keychain.js +101 -0
- package/dist/cli/prompt.d.ts +20 -0
- package/dist/cli/prompt.js +111 -0
- package/dist/cli.d.ts +214 -0
- package/dist/cli.js +72 -5
- package/dist/compliance/audit-trail.d.ts +66 -0
- package/dist/compliance/backup-verification.d.ts +279 -0
- package/dist/compliance/breach-detector.d.ts +197 -0
- package/dist/compliance/consent-record.d.ts +107 -0
- package/dist/compliance/consent-versioning.d.ts +169 -0
- package/dist/compliance/cross-border-log.d.ts +254 -0
- package/dist/compliance/data-classifier.d.ts +127 -0
- package/dist/compliance/data-lineage.d.ts +268 -0
- package/dist/compliance/data-masker.d.ts +110 -0
- package/dist/compliance/data-portability.d.ts +98 -0
- package/dist/compliance/data-retention.d.ts +108 -0
- package/dist/compliance/dsar-workflow.d.ts +175 -0
- package/dist/compliance/field-encryption.d.ts +84 -0
- package/dist/compliance/immutable-record.d.ts +84 -0
- package/dist/compliance/index.d.ts +93 -0
- package/dist/compliance/privacy-impact-assessment.d.ts +196 -0
- package/dist/compliance/pseudonymization.d.ts +96 -0
- package/dist/compliance/query-firewall.d.ts +661 -0
- package/dist/compliance/rate-limiter.d.ts +203 -0
- package/dist/compliance/right-to-erasure.d.ts +96 -0
- package/dist/compliance/row-level-security.d.ts +152 -0
- package/dist/compliance/security-decorator.d.ts +388 -0
- package/dist/compliance/security-monitor.d.ts +170 -0
- package/dist/compliance/sensitive-data-discovery.d.ts +151 -0
- package/dist/compliance/session-isolation.d.ts +286 -0
- package/dist/compliance/tls-enforcer.d.ts +51 -0
- package/dist/compliance/worm-storage.d.ts +225 -0
- package/dist/connection-manager.d.ts +130 -0
- package/dist/connection-pool.d.ts +311 -0
- package/dist/decorators/audit.d.ts +49 -0
- package/dist/decorators/check.d.ts +218 -0
- package/dist/decorators/collate.d.ts +346 -0
- package/dist/decorators/comment.d.ts +51 -0
- package/dist/decorators/database-settings.d.ts +193 -0
- package/dist/decorators/default.d.ts +148 -0
- package/dist/decorators/encryption.d.ts +175 -0
- package/dist/decorators/engine.d.ts +97 -0
- package/dist/decorators/fk-constraints.d.ts +387 -0
- package/dist/decorators/foreign-table.d.ts +57 -0
- package/dist/decorators/generated.d.ts +232 -0
- package/dist/decorators/hstore.d.ts +96 -0
- package/dist/decorators/index.d.ts +57 -0
- package/dist/decorators/index.js +14 -30
- package/dist/decorators/json-column.d.ts +47 -0
- package/dist/decorators/jsonb.d.ts +83 -0
- package/dist/decorators/orm-decorators.d.ts +274 -0
- package/dist/decorators/permissions.d.ts +192 -0
- package/dist/decorators/procedure.d.ts +168 -0
- package/dist/decorators/procedure.js +31 -7
- package/dist/decorators/query-options.d.ts +527 -0
- package/dist/decorators/range.d.ts +122 -0
- package/dist/decorators/set-column.d.ts +43 -0
- package/dist/decorators/spatial.d.ts +60 -0
- package/dist/decorators/storage.d.ts +561 -0
- package/dist/decorators/timezone.d.ts +319 -0
- package/dist/decorators/trigger.d.ts +50 -0
- package/dist/decorators/uuid.d.ts +102 -0
- package/dist/decorators/view.d.ts +213 -0
- package/dist/diagrams/chen-diagram.d.ts +70 -0
- package/dist/diagrams/chen-diagram.js +33 -31
- package/dist/diagrams/class-diagram.d.ts +78 -0
- package/dist/diagrams/class-diagram.js +23 -27
- package/dist/diagrams/dependency-diagram.d.ts +82 -0
- package/dist/diagrams/dependency-diagram.js +18 -9
- package/dist/diagrams/er-diagram.d.ts +82 -0
- package/dist/diagrams/er-diagram.js +174 -231
- package/dist/diagrams/flow-diagram.d.ts +70 -0
- package/dist/diagrams/flow-diagram.js +23 -18
- package/dist/diagrams/gantt-diagram.d.ts +67 -0
- package/dist/diagrams/gantt-diagram.js +20 -18
- package/dist/diagrams/index-diagram.d.ts +61 -0
- package/dist/diagrams/index-diagram.js +36 -31
- package/dist/diagrams/index.d.ts +155 -0
- package/dist/diagrams/index.js +7 -1
- package/dist/diagrams/migration-diagram.d.ts +67 -0
- package/dist/diagrams/migration-diagram.js +45 -57
- package/dist/diagrams/model-diagram.d.ts +85 -0
- package/dist/diagrams/model-diagram.js +225 -287
- package/dist/diagrams/package-diagram.d.ts +69 -0
- package/dist/diagrams/package-diagram.js +30 -32
- package/dist/diagrams/palette.d.ts +138 -0
- package/dist/diagrams/palette.js +134 -25
- package/dist/diagrams/relational-diagram.d.ts +82 -0
- package/dist/diagrams/relational-diagram.js +51 -59
- package/dist/diagrams/schemadoc-diagram.d.ts +57 -0
- package/dist/diagrams/schemadoc-diagram.js +36 -28
- package/dist/diagrams/sequence-diagram.d.ts +61 -0
- package/dist/diagrams/sequence-diagram.js +20 -11
- package/dist/diagrams/state-diagram.d.ts +85 -0
- package/dist/diagrams/state-diagram.js +21 -17
- package/dist/diagrams/svg-dom.d.ts +62 -0
- package/dist/diagrams/svg-dom.js +11 -0
- package/dist/diagrams/tree-diagram.d.ts +47 -0
- package/dist/diagrams/tree-diagram.js +19 -10
- package/dist/dialects/clickhouse/index.d.ts +660 -0
- package/dist/dialects/clickhouse/index.js +107 -2
- package/dist/dialects/cockroachdb/index.d.ts +1708 -0
- package/dist/dialects/cockroachdb/index.js +139 -10
- package/dist/dialects/cratedb/index.d.ts +262 -0
- package/dist/dialects/cratedb/index.js +148 -0
- package/dist/dialects/databricks/index.d.ts +397 -0
- package/dist/dialects/databricks/index.js +233 -11
- package/dist/dialects/db2/index.d.ts +729 -0
- package/dist/dialects/db2/index.js +152 -2
- package/dist/dialects/dialect.d.ts +1653 -0
- package/dist/dialects/duckdb/index.d.ts +440 -0
- package/dist/dialects/duckdb/index.js +21 -37
- package/dist/dialects/exasol/index.d.ts +197 -0
- package/dist/dialects/exasol/index.js +14 -0
- package/dist/dialects/firebird/index.d.ts +286 -0
- package/dist/dialects/firebird/index.js +135 -0
- package/dist/dialects/greenplum/index.d.ts +336 -0
- package/dist/dialects/greenplum/index.js +168 -0
- package/dist/dialects/hana/index.d.ts +512 -0
- package/dist/dialects/hana/index.js +17 -35
- package/dist/dialects/mariadb/index.d.ts +1241 -0
- package/dist/dialects/mariadb/index.js +181 -43
- package/dist/dialects/mssql/index.d.ts +729 -0
- package/dist/dialects/mssql/index.js +76 -7
- package/dist/dialects/mysql/index.d.ts +1233 -0
- package/dist/dialects/mysql/index.js +87 -19
- package/dist/dialects/oracle/index.d.ts +1222 -0
- package/dist/dialects/oracle/index.js +210 -9
- package/dist/dialects/postgres/index.d.ts +1598 -0
- package/dist/dialects/postgres/index.js +34 -13
- package/dist/dialects/query-stream-helper.d.ts +58 -0
- package/dist/dialects/questdb/index.d.ts +430 -0
- package/dist/dialects/questdb/index.js +292 -0
- package/dist/dialects/redshift/index.d.ts +933 -0
- package/dist/dialects/redshift/index.js +17 -5
- package/dist/dialects/singlestore/index.d.ts +233 -0
- package/dist/dialects/singlestore/index.js +53 -0
- package/dist/dialects/snowflake/index.d.ts +727 -0
- package/dist/dialects/snowflake/index.js +154 -5
- package/dist/dialects/spanner/index.d.ts +660 -0
- package/dist/dialects/spanner/index.js +43 -21
- package/dist/dialects/sqlite/index.d.ts +1133 -0
- package/dist/dialects/sqlite/index.js +168 -30
- package/dist/dialects/tidb/index.d.ts +226 -0
- package/dist/dialects/tidb/index.js +10 -0
- package/dist/dialects/timescaledb/index.d.ts +286 -0
- package/dist/dialects/timescaledb/index.js +179 -0
- package/dist/dialects/trino/index.d.ts +230 -0
- package/dist/dialects/trino/index.js +85 -10
- package/dist/dialects/turso/index.d.ts +98 -0
- package/dist/dialects/turso/index.js +10 -0
- package/dist/dialects/vertica/index.d.ts +321 -0
- package/dist/dialects/vertica/index.js +161 -0
- package/dist/dialects/yugabytedb/index.d.ts +276 -0
- package/dist/dialects/yugabytedb/index.js +121 -0
- package/dist/errors/index.d.ts +378 -0
- package/dist/errors/index.js +29 -1
- package/dist/errors/utils.d.ts +53 -0
- package/dist/errors.d.ts +5 -0
- package/dist/extensions/catalog/cloud-warehouse-features.d.ts +27 -0
- package/dist/extensions/catalog/mssql-features.d.ts +20 -0
- package/dist/extensions/catalog/mysql-mariadb-plugins.d.ts +18 -0
- package/dist/extensions/catalog/oracle-db2-features.d.ts +17 -0
- package/dist/extensions/catalog/postgres-extensions.d.ts +15 -0
- package/dist/extensions/index.d.ts +34 -0
- package/dist/extensions/types.d.ts +43 -0
- package/dist/external-fields/adapters.d.ts +50 -0
- package/dist/external-fields/adapters.js +227 -0
- package/dist/external-fields/decorator.d.ts +77 -0
- package/dist/external-fields/decorator.js +80 -0
- package/dist/external-fields/index.d.ts +10 -0
- package/dist/external-fields/index.js +19 -0
- package/dist/external-fields/runtime.d.ts +39 -0
- package/dist/external-fields/runtime.js +221 -0
- package/dist/foreign-data.d.ts +168 -0
- package/dist/graph/base-graph-dialect.d.ts +250 -0
- package/dist/graph/base-graph-dialect.js +539 -0
- package/dist/graph/dgraph/index.d.ts +65 -0
- package/dist/graph/dgraph/index.js +559 -0
- package/dist/graph/gremlin/index.d.ts +59 -0
- package/dist/graph/gremlin/index.js +378 -0
- package/dist/graph/index.d.ts +60 -0
- package/dist/graph/index.js +67 -0
- package/dist/graph/neo4j/index.d.ts +50 -0
- package/dist/graph/neo4j/index.js +462 -0
- package/dist/graph/types.d.ts +213 -0
- package/dist/graph/types.js +234 -0
- package/dist/hooks/hooks-manager.d.ts +189 -0
- package/dist/hooks/index.d.ts +8 -0
- package/dist/index.d.ts +711 -0
- package/dist/index.js +19 -4
- package/dist/logging.d.ts +183 -0
- package/dist/migrations/index.d.ts +9 -0
- package/dist/migrations/migration.d.ts +143 -0
- package/dist/migrations/migrator.d.ts +199 -0
- package/dist/migrations/prormmigration.d.ts +131 -0
- package/dist/migrations/query-interface.d.ts +335 -0
- package/dist/migrations/seeder.d.ts +167 -0
- package/dist/models/associations.d.ts +131 -0
- package/dist/models/associations.js +7 -2
- package/dist/models/constraints.d.ts +175 -0
- package/dist/models/data-types.d.ts +1656 -0
- package/dist/models/decorators.d.ts +328 -0
- package/dist/models/decorators.js +61 -82
- package/dist/models/eager-load.d.ts +86 -0
- package/dist/models/eager-load.js +369 -0
- package/dist/models/index.d.ts +13 -0
- package/dist/models/indexes.d.ts +325 -0
- package/dist/models/methods.d.ts +419 -0
- package/dist/models/model-manager.d.ts +76 -0
- package/dist/models/model.d.ts +820 -0
- package/dist/models/model.js +15 -101
- package/dist/models/operators.d.ts +29 -0
- package/dist/models/scopes.d.ts +71 -0
- package/dist/models/typescript-types.d.ts +177 -0
- package/dist/nosql/aerospike/index.d.ts +126 -0
- package/dist/nosql/allegrograph/index.d.ts +86 -0
- package/dist/nosql/arangodb/index.d.ts +285 -0
- package/dist/nosql/arangodb/index.js +274 -2
- package/dist/nosql/arangodb/where.d.ts +38 -0
- package/dist/nosql/arangodb/where.js +94 -0
- package/dist/nosql/azure-blob/index.d.ts +104 -0
- package/dist/nosql/beanstalkd/index.d.ts +88 -0
- package/dist/nosql/beequeue/index.d.ts +99 -0
- package/dist/nosql/bigchaindb/index.d.ts +113 -0
- package/dist/nosql/bigtable/index.d.ts +144 -0
- package/dist/nosql/blazegraph/index.d.ts +88 -0
- package/dist/nosql/bullmq/index.d.ts +83 -0
- package/dist/nosql/cassandra/index.d.ts +119 -0
- package/dist/nosql/chroma/index.d.ts +151 -0
- package/dist/nosql/cloudflare-kv/index.d.ts +120 -0
- package/dist/nosql/coherence/index.d.ts +91 -0
- package/dist/nosql/cosmosdb/index.d.ts +78 -0
- package/dist/nosql/couchbase/index.d.ts +103 -0
- package/dist/nosql/dax/index.d.ts +118 -0
- package/dist/nosql/deno-kv/index.d.ts +109 -0
- package/dist/nosql/dgraph/index.d.ts +80 -0
- package/dist/nosql/doris/index.d.ts +88 -0
- package/dist/nosql/druid/index.d.ts +95 -0
- package/dist/nosql/dynamodb/index.d.ts +643 -0
- package/dist/nosql/dynamodb/index.js +423 -0
- package/dist/nosql/elasticsearch/index.d.ts +239 -0
- package/dist/nosql/etcd/index.d.ts +243 -0
- package/dist/nosql/eventhubs/index.d.ts +89 -0
- package/dist/nosql/eventstore/index.d.ts +102 -0
- package/dist/nosql/faunadb/index.d.ts +141 -0
- package/dist/nosql/faunadb/index.js +329 -0
- package/dist/nosql/firestore/index.d.ts +67 -0
- package/dist/nosql/fluree/index.d.ts +88 -0
- package/dist/nosql/fuseki/index.d.ts +94 -0
- package/dist/nosql/gcs/index.d.ts +62 -0
- package/dist/nosql/gearman/index.d.ts +77 -0
- package/dist/nosql/geode/index.d.ts +93 -0
- package/dist/nosql/graphdb/index.d.ts +86 -0
- package/dist/nosql/graylog/index.d.ts +118 -0
- package/dist/nosql/gridgain/index.d.ts +78 -0
- package/dist/nosql/hazelcast/index.d.ts +73 -0
- package/dist/nosql/hbase/index.d.ts +123 -0
- package/dist/nosql/ignite/index.d.ts +80 -0
- package/dist/nosql/immudb/index.d.ts +131 -0
- package/dist/nosql/index.d.ts +215 -0
- package/dist/nosql/infinispan/index.d.ts +95 -0
- package/dist/nosql/influxdb/flux-compiler.d.ts +23 -0
- package/dist/nosql/influxdb/flux-compiler.js +170 -0
- package/dist/nosql/influxdb/index.d.ts +300 -0
- package/dist/nosql/influxdb/index.js +0 -0
- package/dist/nosql/kafka/index.d.ts +113 -0
- package/dist/nosql/keyspaces/index.d.ts +122 -0
- package/dist/nosql/kinesis/index.d.ts +121 -0
- package/dist/nosql/leveldb/index.d.ts +112 -0
- package/dist/nosql/leveldb/index.js +103 -1
- package/dist/nosql/lmdb/index.d.ts +76 -0
- package/dist/nosql/loki/index.d.ts +126 -0
- package/dist/nosql/marklogic/index.d.ts +76 -0
- package/dist/nosql/materialize/index.d.ts +91 -0
- package/dist/nosql/meilisearch/index.d.ts +76 -0
- package/dist/nosql/memcached/index.d.ts +138 -0
- package/dist/nosql/milvus/index.d.ts +167 -0
- package/dist/nosql/minio/index.d.ts +122 -0
- package/dist/nosql/momento/index.d.ts +99 -0
- package/dist/nosql/mongodb/index.d.ts +265 -0
- package/dist/nosql/mongodb/index.js +139 -0
- package/dist/nosql/mongodb/where.d.ts +8 -0
- package/dist/nosql/mongodb/where.js +181 -0
- package/dist/nosql/nats/index.d.ts +139 -0
- package/dist/nosql/nedb/index.d.ts +79 -0
- package/dist/nosql/neo4j/index.d.ts +217 -0
- package/dist/nosql/neo4j/index.js +26 -14
- package/dist/nosql/neptune/index.d.ts +234 -0
- package/dist/nosql/neptune/index.js +23 -9
- package/dist/nosql/nsq/index.d.ts +93 -0
- package/dist/nosql/opensearch/index.d.ts +97 -0
- package/dist/nosql/orientdb/index.d.ts +72 -0
- package/dist/nosql/papertrail/index.d.ts +120 -0
- package/dist/nosql/pinecone/index.d.ts +148 -0
- package/dist/nosql/pinot/index.d.ts +90 -0
- package/dist/nosql/pouchdb/index.d.ts +95 -0
- package/dist/nosql/prometheus/index.d.ts +112 -0
- package/dist/nosql/provendb/index.d.ts +143 -0
- package/dist/nosql/provendb/index.js +262 -0
- package/dist/nosql/pubsub/index.d.ts +83 -0
- package/dist/nosql/pulsar/index.d.ts +105 -0
- package/dist/nosql/qdrant/index.d.ts +231 -0
- package/dist/nosql/qldb/index.d.ts +182 -0
- package/dist/nosql/qldb/index.js +302 -1
- package/dist/nosql/r2/index.d.ts +160 -0
- package/dist/nosql/rabbitmq/index.d.ts +131 -0
- package/dist/nosql/ravendb/index.d.ts +138 -0
- package/dist/nosql/ravendb/index.js +323 -9
- package/dist/nosql/ravendb/where.d.ts +38 -0
- package/dist/nosql/ravendb/where.js +94 -0
- package/dist/nosql/redis/index.d.ts +267 -0
- package/dist/nosql/redis/index.js +19 -5
- package/dist/nosql/redpanda/index.d.ts +117 -0
- package/dist/nosql/resque/index.d.ts +91 -0
- package/dist/nosql/rethinkdb/index.d.ts +194 -0
- package/dist/nosql/rethinkdb/index.js +290 -0
- package/dist/nosql/rethinkdb/where.d.ts +38 -0
- package/dist/nosql/rethinkdb/where.js +94 -0
- package/dist/nosql/rocksdb/document-layer.d.ts +162 -0
- package/dist/nosql/rocksdb/document-layer.js +338 -0
- package/dist/nosql/rocksdb/index.d.ts +112 -0
- package/dist/nosql/rocksdb/index.js +103 -1
- package/dist/nosql/rocksdb/where-match.d.ts +21 -0
- package/dist/nosql/rocksdb/where-match.js +238 -0
- package/dist/nosql/rockset/index.d.ts +84 -0
- package/dist/nosql/s3/index.d.ts +170 -0
- package/dist/nosql/scylladb/index.d.ts +117 -0
- package/dist/nosql/signoz/index.d.ts +116 -0
- package/dist/nosql/sns/index.d.ts +99 -0
- package/dist/nosql/solr/index.d.ts +129 -0
- package/dist/nosql/splunk/index.d.ts +125 -0
- package/dist/nosql/sqs/index.d.ts +116 -0
- package/dist/nosql/stardog/index.d.ts +86 -0
- package/dist/nosql/starrocks/index.d.ts +89 -0
- package/dist/nosql/store.d.ts +23 -0
- package/dist/nosql/sumologic/index.d.ts +119 -0
- package/dist/nosql/surrealdb/index.d.ts +156 -0
- package/dist/nosql/surrealdb/index.js +174 -1
- package/dist/nosql/surrealdb/query-compiler.d.ts +26 -0
- package/dist/nosql/surrealdb/query-compiler.js +193 -0
- package/dist/nosql/terminusdb/index.d.ts +95 -0
- package/dist/nosql/tigergraph/index.d.ts +314 -0
- package/dist/nosql/typesense/index.d.ts +82 -0
- package/dist/nosql/unqlite/index.d.ts +68 -0
- package/dist/nosql/upstash/index.d.ts +80 -0
- package/dist/nosql/vercel-kv/index.d.ts +82 -0
- package/dist/nosql/victoriametrics/index.d.ts +129 -0
- package/dist/nosql/virtuoso/index.d.ts +87 -0
- package/dist/nosql/weaviate/index.d.ts +196 -0
- package/dist/operators/index.d.ts +7 -0
- package/dist/operators.d.ts +2947 -0
- package/dist/operators.js +46 -1
- package/dist/prisma-migrate/index.d.ts +28 -0
- package/dist/prisma-migrate/migration-generator.d.ts +21 -0
- package/dist/prisma-migrate/model-generator.d.ts +12 -0
- package/dist/prisma-migrate/relations.d.ts +28 -0
- package/dist/prisma-migrate/schema-parser.d.ts +42 -0
- package/dist/prisma-migrate/type-mapper.d.ts +20 -0
- package/dist/prorm.d.ts +2093 -0
- package/dist/prorm.js +721 -302
- package/dist/query-builders/cte-builder.d.ts +104 -0
- package/dist/query-builders/functions/aggregate.d.ts +199 -0
- package/dist/query-builders/functions/conditional.d.ts +195 -0
- package/dist/query-builders/functions/datetime.d.ts +202 -0
- package/dist/query-builders/functions/fulltext.d.ts +220 -0
- package/dist/query-builders/functions/index.d.ts +17 -0
- package/dist/query-builders/functions/json.d.ts +157 -0
- package/dist/query-builders/functions/math.d.ts +215 -0
- package/dist/query-builders/functions/string.d.ts +233 -0
- package/dist/query-builders/functions/window.d.ts +209 -0
- package/dist/query-builders/include-builder.d.ts +85 -0
- package/dist/query-builders/index-expression-builder.d.ts +153 -0
- package/dist/query-builders/index.d.ts +121 -0
- package/dist/query-builders/index.js +10 -0
- package/dist/query-builders/insert-builder.d.ts +62 -0
- package/dist/query-builders/model-helpers.d.ts +28 -0
- package/dist/query-builders/order-limit-builder.d.ts +84 -0
- package/dist/query-builders/sql-compiler.d.ts +562 -0
- package/dist/query-builders/subquery-builder.d.ts +133 -0
- package/dist/query-builders/update-builder.d.ts +71 -0
- package/dist/query-builders/view-builder.d.ts +189 -0
- package/dist/query-builders/where-builder.d.ts +124 -0
- package/dist/query-interface.d.ts +407 -0
- package/dist/query-interface.js +84 -0
- package/dist/query-optimizers/batch-optimizer.d.ts +175 -0
- package/dist/query-optimizers/explain-plans.d.ts +187 -0
- package/dist/query-optimizers/index.d.ts +27 -0
- package/dist/query-optimizers/prepared-statement-cache.d.ts +252 -0
- package/dist/query-optimizers/query-hints.d.ts +201 -0
- package/dist/query-optimizers/query-optimizer.d.ts +162 -0
- package/dist/query-optimizers/slow-query-logger.d.ts +186 -0
- package/dist/replica-manager.d.ts +235 -0
- package/dist/schema/index.d.ts +7 -0
- package/dist/schema/migration-generator.d.ts +74 -0
- package/dist/schema/schema-differ.d.ts +114 -0
- package/dist/schema/types.d.ts +246 -0
- package/dist/schema-objects.d.ts +78 -0
- package/dist/schema-objects.js +203 -0
- package/dist/sql-constants.d.ts +240 -0
- package/dist/sqlite-advanced.d.ts +572 -0
- package/dist/streams/index.d.ts +5 -0
- package/dist/streams/transforms.d.ts +120 -0
- package/dist/transaction.d.ts +221 -0
- package/dist/types/index.d.ts +3123 -0
- package/dist/user-management.d.ts +141 -0
- package/dist/utils/date.d.ts +149 -0
- package/dist/utils/index.d.ts +359 -0
- package/dist/utils/string.d.ts +88 -0
- package/dist/validators/index.d.ts +7 -0
- package/dist/validators/validator.d.ts +306 -0
- package/package.json +20 -5
|
@@ -0,0 +1,660 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Google Cloud Spanner dialect implementation for the TypeScript ORM
|
|
3
|
+
*
|
|
4
|
+
* ---------------------------------------------------------------------------
|
|
5
|
+
* GoogleSQL vs. the Postgres interface
|
|
6
|
+
* ---------------------------------------------------------------------------
|
|
7
|
+
* Cloud Spanner exposes two SQL dialects: **GoogleSQL** (Spanner's native
|
|
8
|
+
* dialect, close to standard SQL/BigQuery syntax) and a newer **PostgreSQL
|
|
9
|
+
* interface** (`google-cloud/spanner` `databaseDialect: POSTGRESQL`, wire- and
|
|
10
|
+
* syntax-compatible with a useful subset of Postgres). This dialect targets
|
|
11
|
+
* **GoogleSQL**, which is the default/primary Spanner dialect and the one
|
|
12
|
+
* with full feature coverage (interleaved tables, the Mutation API,
|
|
13
|
+
* `GENERATE_UUID()`, bit-reversed sequences, `STORING` indexes, fine-grained
|
|
14
|
+
* IAM/database roles, etc.). The Postgres interface is a compatibility layer
|
|
15
|
+
* aimed at easing migrations from Postgres and still lags GoogleSQL in
|
|
16
|
+
* feature parity (e.g. no interleaved tables, different DDL for sequences).
|
|
17
|
+
* Since this codebase already has a Postgres-wire dialect (`postgres`) and a
|
|
18
|
+
* Postgres-*compatible* distributed dialect (`cockroachdb`), implementing
|
|
19
|
+
* Spanner via GoogleSQL is what actually makes it a meaningfully different,
|
|
20
|
+
* complementary dialect rather than a third near-duplicate of the Postgres
|
|
21
|
+
* query builder.
|
|
22
|
+
*
|
|
23
|
+
* ---------------------------------------------------------------------------
|
|
24
|
+
* Mutation API vs. SQL DML
|
|
25
|
+
* ---------------------------------------------------------------------------
|
|
26
|
+
* Spanner offers two ways to write data:
|
|
27
|
+
* 1. SQL DML (`INSERT`/`UPDATE`/`DELETE`), run inside a read-write
|
|
28
|
+
* transaction (`database.runTransaction()` + `transaction.runUpdate()`).
|
|
29
|
+
* 2. The **Mutation API** (`table.insert()`/`update()`/`upsert()`/
|
|
30
|
+
* `deleteRows()`), which encodes writes as structured mutations rather
|
|
31
|
+
* than parsed/planned SQL strings. Mutations are the cheaper, safer path
|
|
32
|
+
* for bulk/blind writes: no SQL parsing/planning overhead, no risk of
|
|
33
|
+
* conflicting on read-your-writes semantics, and they compose directly
|
|
34
|
+
* with `Table#insert/update/upsert/deleteRows`.
|
|
35
|
+
*
|
|
36
|
+
* This dialect exposes **both**: `buildUpsertQuery()`/`buildInsertQuery()`
|
|
37
|
+
* satisfy the shared `Dialect` interface using GoogleSQL's `INSERT OR UPDATE
|
|
38
|
+
* INTO ... VALUES (...)` upsert statement (Spanner has no `ON CONFLICT`
|
|
39
|
+
* clause - verified against the GoogleSQL DML reference - but it does support
|
|
40
|
+
* `INSERT OR UPDATE` / `INSERT OR IGNORE` / `INSERT OR REPLACE` as distinct
|
|
41
|
+
* conflict-action variants at the language level). All three are selectable
|
|
42
|
+
* via the `conflictAction` option (`'UPDATE' | 'IGNORE' | 'REPLACE'`) on
|
|
43
|
+
* `buildInsertQuery()`/`buildUpsertQuery()`; `upsert: true` remains a legacy
|
|
44
|
+
* alias for `conflictAction: 'UPDATE'`. Additionally, `mutationUpsert()`/`mutationInsert()`/
|
|
45
|
+
* `mutationUpdate()`/`mutationDelete()` and `bulkInsert()` are implemented
|
|
46
|
+
* using the Mutation API directly and are the **recommended, primary**
|
|
47
|
+
* mechanism for bulk/blind writes - they are simpler, avoid a SQL round-trip,
|
|
48
|
+
* and sidestep DML's read-write-transaction requirement entirely.
|
|
49
|
+
*
|
|
50
|
+
* ---------------------------------------------------------------------------
|
|
51
|
+
* Transactions & consistency model
|
|
52
|
+
* ---------------------------------------------------------------------------
|
|
53
|
+
* Spanner does **not** have a READ COMMITTED / REPEATABLE READ / SERIALIZABLE
|
|
54
|
+
* spectrum the way traditional RDBMSes do. Every read-write transaction is
|
|
55
|
+
* always externally consistent (equivalent to, and often described as
|
|
56
|
+
* stronger than, SERIALIZABLE) by construction, using TrueTime to assign a
|
|
57
|
+
* commit timestamp that reflects real-world transaction ordering. There is no
|
|
58
|
+
* meaningful "isolation level" knob to turn: `startTransaction()` accepts a
|
|
59
|
+
* `TransactionOptions.isolationLevel` for interface parity with the other
|
|
60
|
+
* dialects, but the value is ignored (with a warning) rather than silently
|
|
61
|
+
* mapped to something it isn't. Read-only transactions (strong reads or
|
|
62
|
+
* stale/bounded-staleness reads) are a distinct concept from read-write
|
|
63
|
+
* transactions in Spanner and are exposed here via `getSnapshot()`/
|
|
64
|
+
* `runReadOnlyTransaction()` rather than through `startTransaction()`.
|
|
65
|
+
*
|
|
66
|
+
* ---------------------------------------------------------------------------
|
|
67
|
+
* Hotspot avoidance / auto-generated keys
|
|
68
|
+
* ---------------------------------------------------------------------------
|
|
69
|
+
* Spanner shards key ranges across servers by primary key order. A naive
|
|
70
|
+
* monotonically-increasing integer primary key (the `autoIncrement` pattern
|
|
71
|
+
* used by every other dialect in this codebase) concentrates all writes on
|
|
72
|
+
* the single tablet holding the current "tail" of the key range - a hotspot.
|
|
73
|
+
* Spanner's own docs explicitly discourage monotonic keys. To keep the
|
|
74
|
+
* `ColumnDefinition.autoIncrement` flag meaningful without reproducing that
|
|
75
|
+
* anti-pattern, this dialect maps `autoIncrement: true` to a
|
|
76
|
+
* `STRING(36) DEFAULT (GENERATE_UUID())` column (a random, well-distributed
|
|
77
|
+
* key) and logs a warning explaining the tradeoff. For callers who need an
|
|
78
|
+
* ordered-but-distributed numeric key, `createBitReversedSequence()` /
|
|
79
|
+
* `nextBitReversedSequenceValue()` expose Spanner's bit-reversed sequence
|
|
80
|
+
* feature (`CREATE SEQUENCE ... OPTIONS (sequence_kind = 'bit_reversed_positive')`),
|
|
81
|
+
* which produces roughly-increasing-over-time but bit-shuffled values that
|
|
82
|
+
* spread writes across the keyspace.
|
|
83
|
+
*
|
|
84
|
+
* @see https://cloud.google.com/spanner/docs/reference/standard-sql/overview
|
|
85
|
+
* @see https://cloud.google.com/spanner/docs/reference/standard-sql/dml-syntax#insert_or_update
|
|
86
|
+
* @see https://cloud.google.com/spanner/docs/schema-and-data-model#choosing_a_primary_key
|
|
87
|
+
* @see https://cloud.google.com/spanner/docs/reference/standard-sql/data-definition-language#create_sequence
|
|
88
|
+
*/
|
|
89
|
+
import { Dialect, ColumnDefinition, TableOptions, DropTableOptions, TableDescription, IndexOptions, IndexDefinition, InsertOptions, UpdateOptions as DUpdateOptions, DeleteOptions, SelectOptions, UpsertQueryOptions, CreateExtensionOptions, DropExtensionOptions, ExtensionInfo, FdwForeignServerOptions, FdwAlterForeignServerOptions, FdwUserMappingOptions, FdwForeignTableOptions, FdwImportForeignSchemaOptions, ConstraintDefinition, ViewOptions, DropViewOptions, DropSchemaOptions, DropIndexOptions, DropConstraintOptions } from '../dialect';
|
|
90
|
+
import { Transaction, TransactionOptions, QueryResult, QueryOptions, DataType, WhereOptions, Order, StoredProcedureOptions, DropStoredProcedureOptions, ExecuteStoredProcedureOptions, StreamOptions } from '../../types';
|
|
91
|
+
import { Readable } from 'stream';
|
|
92
|
+
/**
|
|
93
|
+
* Authentication / connection options for the Spanner dialect.
|
|
94
|
+
*
|
|
95
|
+
* Spanner authenticates via Google Application Default Credentials (ADC) by
|
|
96
|
+
* default - i.e. the `GOOGLE_APPLICATION_CREDENTIALS` environment variable
|
|
97
|
+
* pointing at a service-account JSON key file, or ambient credentials when
|
|
98
|
+
* running on GCP (GCE/GKE/Cloud Run metadata server). `keyFilename` and
|
|
99
|
+
* `credentials` are provided for explicit, non-ADC auth and are passed
|
|
100
|
+
* straight through to the underlying `Spanner` client constructor.
|
|
101
|
+
*/
|
|
102
|
+
export interface SpannerDialectOptions {
|
|
103
|
+
/** GCP project ID that owns the Spanner instance */
|
|
104
|
+
projectId?: string;
|
|
105
|
+
/** Spanner instance ID (e.g. 'prod-instance') */
|
|
106
|
+
instanceId: string;
|
|
107
|
+
/** Spanner database ID within the instance */
|
|
108
|
+
databaseId: string;
|
|
109
|
+
/**
|
|
110
|
+
* Path to a service-account key file. If omitted, falls back to
|
|
111
|
+
* `GOOGLE_APPLICATION_CREDENTIALS` / ambient Application Default
|
|
112
|
+
* Credentials, same as the raw `@google-cloud/spanner` client.
|
|
113
|
+
*/
|
|
114
|
+
keyFilename?: string;
|
|
115
|
+
/** Explicit service-account credentials object (alternative to keyFilename/ADC) */
|
|
116
|
+
credentials?: Record<string, any>;
|
|
117
|
+
/** Override API endpoint (e.g. for the Spanner emulator: 'localhost:9010') */
|
|
118
|
+
apiEndpoint?: string;
|
|
119
|
+
/** Use the Spanner emulator (sets emulator-friendly defaults) */
|
|
120
|
+
emulator?: boolean;
|
|
121
|
+
/** Query options forwarded to every `database.run()` call (e.g. optimizer version) */
|
|
122
|
+
queryOptions?: Record<string, any>;
|
|
123
|
+
/**
|
|
124
|
+
* Skip the automatic GoogleSQL-dialect check that `connect()` otherwise
|
|
125
|
+
* performs (see `assertGoogleSqlDialect()`). Set this if you've already
|
|
126
|
+
* verified the target database's dialect out of band, or when talking to
|
|
127
|
+
* an emulator/environment where `getDatabaseDialect()` is unavailable.
|
|
128
|
+
*/
|
|
129
|
+
skipDialectCheck?: boolean;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Spanner-specific table options: explicit primary key (Spanner's `PRIMARY
|
|
133
|
+
* KEY (...)` clause is written *after* the column list, unlike every other
|
|
134
|
+
* dialect in this codebase where PK is a column/table constraint inside the
|
|
135
|
+
* parens) and interleaving.
|
|
136
|
+
*/
|
|
137
|
+
export interface SpannerTableOptions {
|
|
138
|
+
/**
|
|
139
|
+
* Explicit primary key column list and order. If omitted, inferred from
|
|
140
|
+
* columns whose `ColumnDefinition.primaryKey` is `true`, in declaration
|
|
141
|
+
* order.
|
|
142
|
+
*/
|
|
143
|
+
primaryKey?: string[];
|
|
144
|
+
/** Interleave this table as a child of `parentTable` (`INTERLEAVE IN PARENT ...`) */
|
|
145
|
+
interleaveInParent?: string;
|
|
146
|
+
/** `ON DELETE CASCADE` vs. the default `ON DELETE NO ACTION` for interleaved tables */
|
|
147
|
+
interleaveOnDeleteCascade?: boolean;
|
|
148
|
+
/** Row deletion policy (Spanner TTL): `OLDER_THAN(column, INTERVAL n DAY)` */
|
|
149
|
+
rowDeletionPolicy?: {
|
|
150
|
+
column: string;
|
|
151
|
+
olderThanDays: number;
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Options for `createInterleavedTable()`.
|
|
156
|
+
*/
|
|
157
|
+
export interface InterleavedTableOptions extends TableOptions {
|
|
158
|
+
/** Explicit primary key (must include the parent table's primary key as a prefix) */
|
|
159
|
+
primaryKey: string[];
|
|
160
|
+
/** `ON DELETE CASCADE` vs. the default `ON DELETE NO ACTION` */
|
|
161
|
+
onDeleteCascade?: boolean;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Which GoogleSQL DML conflict-action variant to emit on primary-key
|
|
165
|
+
* collision (Spanner has no `ON CONFLICT` clause):
|
|
166
|
+
* - `UPDATE` → `INSERT OR UPDATE INTO` (overwrite non-key columns)
|
|
167
|
+
* - `IGNORE` → `INSERT OR IGNORE INTO` (skip the row)
|
|
168
|
+
* - `REPLACE` → `INSERT OR REPLACE INTO` (delete-then-reinsert the whole row)
|
|
169
|
+
*/
|
|
170
|
+
export type SpannerConflictAction = 'UPDATE' | 'IGNORE' | 'REPLACE';
|
|
171
|
+
/**
|
|
172
|
+
* `InsertOptions` extended with Spanner's `conflictAction` selector. The
|
|
173
|
+
* legacy `upsert: true` boolean remains supported and is equivalent to
|
|
174
|
+
* `conflictAction: 'UPDATE'`.
|
|
175
|
+
*/
|
|
176
|
+
export interface SpannerInsertOptions extends InsertOptions {
|
|
177
|
+
conflictAction?: SpannerConflictAction;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* `UpsertQueryOptions` extended with Spanner's `conflictAction` selector
|
|
181
|
+
* (defaults to `'UPDATE'` when omitted).
|
|
182
|
+
*/
|
|
183
|
+
export interface SpannerUpsertQueryOptions extends UpsertQueryOptions {
|
|
184
|
+
conflictAction?: SpannerConflictAction;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* A Spanner read-write transaction, bridging the driver's callback-based
|
|
188
|
+
* `database.runTransaction()` API to the imperative
|
|
189
|
+
* `startTransaction()`/`commitTransaction()`/`rollbackTransaction()` shape
|
|
190
|
+
* used by every other dialect in this codebase. See `SpannerDialect.
|
|
191
|
+
* startTransaction()` for how `spannerTransaction`/completion signalling is
|
|
192
|
+
* wired up.
|
|
193
|
+
*/
|
|
194
|
+
export declare class SpannerTransaction extends Transaction {
|
|
195
|
+
/** The underlying `@google-cloud/spanner` Transaction object */
|
|
196
|
+
spannerTransaction: any;
|
|
197
|
+
constructor(spannerTransaction: any, options?: TransactionOptions);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Google Cloud Spanner dialect class implementing the shared `Dialect` interface.
|
|
201
|
+
*/
|
|
202
|
+
export declare class SpannerDialect implements Dialect {
|
|
203
|
+
readonly name = "spanner";
|
|
204
|
+
readonly library = "@google-cloud/spanner";
|
|
205
|
+
private spannerClient;
|
|
206
|
+
private instance;
|
|
207
|
+
private database;
|
|
208
|
+
private _isConnected;
|
|
209
|
+
private config;
|
|
210
|
+
/**
|
|
211
|
+
* Tracks in-flight `database.runTransaction()` calls started via
|
|
212
|
+
* `startTransaction()`, keyed by `Transaction#id`. Each entry is the
|
|
213
|
+
* resolver for the "I'm done with this transaction" promise that the
|
|
214
|
+
* `runTransaction()` callback returns (and therefore awaits) before the
|
|
215
|
+
* driver finalizes/retries the attempt. `commitTransaction()`/
|
|
216
|
+
* `rollbackTransaction()` call the resolver to let the callback - and the
|
|
217
|
+
* transaction lease - complete.
|
|
218
|
+
*/
|
|
219
|
+
private pendingTx;
|
|
220
|
+
constructor(config: SpannerDialectOptions);
|
|
221
|
+
connect(): Promise<void>;
|
|
222
|
+
/**
|
|
223
|
+
* Verify the connected database is running in **GoogleSQL** dialect mode,
|
|
224
|
+
* not Spanner's PostgreSQL-interface mode. See the file header: this
|
|
225
|
+
* entire dialect - DDL (backtick-quoted identifiers, `STRING(n)`/`INT64`
|
|
226
|
+
* types, trailing `PRIMARY KEY (...)`), DML (`@pN` named parameters,
|
|
227
|
+
* `INSERT OR UPDATE INTO` upserts), and introspection queries
|
|
228
|
+
* (`information_schema` queried GoogleSQL-style) - assumes GoogleSQL.
|
|
229
|
+
* None of it is valid against a database provisioned with
|
|
230
|
+
* `databaseDialect: POSTGRESQL`, which uses Postgres syntax/wire behavior
|
|
231
|
+
* instead. Rather than let that surface as a confusing "SQL syntax error"
|
|
232
|
+
* on the first query, this checks the dialect via the Database Admin API
|
|
233
|
+
* (`Database#getDatabaseDialect()`, which wraps
|
|
234
|
+
* `DatabaseAdminClient#getDatabase()` and its `databaseDialect` field) and
|
|
235
|
+
* fails fast with an actionable error.
|
|
236
|
+
*
|
|
237
|
+
* Called automatically by `connect()` unless `skipDialectCheck: true` is
|
|
238
|
+
* set; also callable directly (e.g. to re-verify after a reconnect, or to
|
|
239
|
+
* probe a database before wiring up this dialect against it).
|
|
240
|
+
*/
|
|
241
|
+
assertGoogleSqlDialect(): Promise<void>;
|
|
242
|
+
disconnect(): Promise<void>;
|
|
243
|
+
getConnection(): any;
|
|
244
|
+
isConnected(): boolean;
|
|
245
|
+
/**
|
|
246
|
+
* Determine whether an error should be retried by the caller. Spanner
|
|
247
|
+
* surfaces contention on read-write transactions as an `ABORTED` error
|
|
248
|
+
* (gRPC status code 10); `database.runTransaction()` already retries these
|
|
249
|
+
* internally, but callers driving their own retry loop around
|
|
250
|
+
* `startTransaction()`/`commitTransaction()` can use this helper too.
|
|
251
|
+
*/
|
|
252
|
+
isRetryableError(error: any): boolean;
|
|
253
|
+
/**
|
|
254
|
+
* Convert an array/object of replacement values into the named-parameter
|
|
255
|
+
* object Spanner's driver expects (`{ p1: value, ... }` for positional
|
|
256
|
+
* arrays, passed through as-is for already-named objects matching `@name`
|
|
257
|
+
* placeholders in the SQL).
|
|
258
|
+
*/
|
|
259
|
+
private buildParams;
|
|
260
|
+
/**
|
|
261
|
+
* Stream query results by paging through `sql` via repeated
|
|
262
|
+
* dialect-appropriate LIMIT/OFFSET queries (see
|
|
263
|
+
* `createPaginatedQueryStream()` in `src/dialects/query-stream-helper.ts`)
|
|
264
|
+
* instead of loading the whole result set into memory at once.
|
|
265
|
+
* @param sql - The SELECT statement to stream
|
|
266
|
+
* @param options - Streaming options (batch size, backpressure watermark, model mapping)
|
|
267
|
+
*/
|
|
268
|
+
queryStream(sql: string, options?: StreamOptions): Readable;
|
|
269
|
+
/**
|
|
270
|
+
* Execute a raw SQL query.
|
|
271
|
+
*
|
|
272
|
+
* Dispatches based on statement type, since Spanner requires different
|
|
273
|
+
* driver entry points for each:
|
|
274
|
+
* - `CREATE`/`ALTER`/`DROP` -> `database.updateSchema()` (a long-running
|
|
275
|
+
* DDL operation).
|
|
276
|
+
* - `SELECT`/`WITH` (including recursive CTEs and window functions, which
|
|
277
|
+
* GoogleSQL supports natively) -> `database.run()` (single-use read).
|
|
278
|
+
* - Everything else (`INSERT`/`UPDATE`/`DELETE`) -> a read-write
|
|
279
|
+
* transaction via `runDML()`, since Spanner only allows DML inside a
|
|
280
|
+
* transaction (there is no autocommit-single-statement DML path the way
|
|
281
|
+
* `pg`/`mysql2` provide).
|
|
282
|
+
*/
|
|
283
|
+
query(sql: string, options?: QueryOptions): Promise<QueryResult>;
|
|
284
|
+
private runDDL;
|
|
285
|
+
private runRead;
|
|
286
|
+
/**
|
|
287
|
+
* Run a DML statement (`INSERT`/`UPDATE`/`DELETE`) inside a fresh
|
|
288
|
+
* read-write transaction, committing (or rolling back on error)
|
|
289
|
+
* automatically. This is the "autocommit" convenience path used by
|
|
290
|
+
* `query()`; for multi-statement transactions, use
|
|
291
|
+
* `startTransaction()`/`commitTransaction()`/`rollbackTransaction()`
|
|
292
|
+
* directly and run DML against the returned transaction's connection.
|
|
293
|
+
*/
|
|
294
|
+
private runDML;
|
|
295
|
+
escape(value: any): string;
|
|
296
|
+
/**
|
|
297
|
+
* Escape a string literal for GoogleSQL. Unlike ANSI-SQL/Postgres (which
|
|
298
|
+
* escape embedded quotes by doubling them, `''`), GoogleSQL string
|
|
299
|
+
* literals use C-style backslash escaping (`\'`, `\\`).
|
|
300
|
+
*/
|
|
301
|
+
private escapeString;
|
|
302
|
+
/**
|
|
303
|
+
* GoogleSQL quotes identifiers with backticks (like BigQuery/MySQL), not
|
|
304
|
+
* double quotes.
|
|
305
|
+
*/
|
|
306
|
+
escapeId(identifier: string): string;
|
|
307
|
+
quoteIdentifier(identifier: string): string;
|
|
308
|
+
quoteTable(tableName: string, schema?: string): string;
|
|
309
|
+
/**
|
|
310
|
+
* Replace `@pN` / `@name` placeholders in SQL with escaped literal values.
|
|
311
|
+
*/
|
|
312
|
+
replaceReplacements(sql: string, replacements?: Record<string, unknown> | unknown[]): string;
|
|
313
|
+
createSchema(_schema: string): Promise<void>;
|
|
314
|
+
dropSchema(_schema: string, _options?: DropSchemaOptions): Promise<void>;
|
|
315
|
+
showAllSchemas(): Promise<string[]>;
|
|
316
|
+
listSchemas(): Promise<string[]>;
|
|
317
|
+
createDatabaseSQL(_options: {
|
|
318
|
+
name: string;
|
|
319
|
+
encoding?: string;
|
|
320
|
+
lcCollate?: string;
|
|
321
|
+
lcCtype?: string;
|
|
322
|
+
template?: string;
|
|
323
|
+
tablespace?: string;
|
|
324
|
+
collate?: string;
|
|
325
|
+
isTemplate?: boolean;
|
|
326
|
+
}): string;
|
|
327
|
+
dropDatabaseSQL(_name: string): string;
|
|
328
|
+
/**
|
|
329
|
+
* Spanner has no `SAVEPOINT`. Savepoints exist to allow partial rollback
|
|
330
|
+
* within a larger transaction; Spanner read-write transactions are
|
|
331
|
+
* expected to be short-lived and are retried wholesale on conflict, so
|
|
332
|
+
* there is no nested-rollback primitive.
|
|
333
|
+
*/
|
|
334
|
+
createSavepointSQL(_name?: string): string;
|
|
335
|
+
releaseSavepointSQL(_name: string): string;
|
|
336
|
+
rollbackToSavepointSQL(_name: string): string;
|
|
337
|
+
createExtension(_extensionName: string, _options?: CreateExtensionOptions): Promise<void>;
|
|
338
|
+
dropExtension(_extensionName: string, _options?: DropExtensionOptions): Promise<void>;
|
|
339
|
+
getExtensions(): Promise<ExtensionInfo[]>;
|
|
340
|
+
hasExtension(_extensionName: string): Promise<boolean>;
|
|
341
|
+
getDatabaseVersion(): Promise<string>;
|
|
342
|
+
/**
|
|
343
|
+
* Create a table.
|
|
344
|
+
*
|
|
345
|
+
* Notable GoogleSQL DDL differences from every other dialect here:
|
|
346
|
+
* - The primary key is declared *after* the closing paren of the column
|
|
347
|
+
* list (`) PRIMARY KEY (col1, col2)`), not inline as a column/table
|
|
348
|
+
* constraint.
|
|
349
|
+
* - There is no `ALTER TABLE ... ADD CONSTRAINT` for primary keys - the
|
|
350
|
+
* primary key is fixed at table-creation time.
|
|
351
|
+
* - `autoIncrement` columns are mapped to `STRING(36) DEFAULT
|
|
352
|
+
* (GENERATE_UUID())` rather than a monotonic counter - see the
|
|
353
|
+
* hotspot-avoidance note in the file header.
|
|
354
|
+
*/
|
|
355
|
+
createTable(tableName: string, columns: Record<string, ColumnDefinition>, options?: TableOptions & SpannerTableOptions): Promise<void>;
|
|
356
|
+
private buildConstraintSql;
|
|
357
|
+
private getColumnDefinitionSql;
|
|
358
|
+
private getDefaultValue;
|
|
359
|
+
dropTable(tableName: string, options?: DropTableOptions): Promise<void>;
|
|
360
|
+
/**
|
|
361
|
+
* Create a table interleaved inside a parent table
|
|
362
|
+
* (`INTERLEAVE IN PARENT ...`), Spanner's mechanism for physically
|
|
363
|
+
* co-locating related rows (e.g. Orders interleaved in Customers) so that
|
|
364
|
+
* point look-ups and joins across the relationship stay within a single
|
|
365
|
+
* storage split instead of fanning out across the cluster.
|
|
366
|
+
*
|
|
367
|
+
* `columns` must include the parent table's primary key column(s) as a
|
|
368
|
+
* prefix of `options.primaryKey`.
|
|
369
|
+
*/
|
|
370
|
+
createInterleavedTable(tableName: string, parentTable: string, columns: Record<string, ColumnDefinition>, options: InterleavedTableOptions): Promise<void>;
|
|
371
|
+
createPartitionedTable(): Promise<void>;
|
|
372
|
+
createPartition(): Promise<void>;
|
|
373
|
+
attachPartition(): Promise<void>;
|
|
374
|
+
detachPartition(): Promise<void>;
|
|
375
|
+
dropPartition(): Promise<void>;
|
|
376
|
+
createView(viewName: string, query: string, options?: ViewOptions): Promise<void>;
|
|
377
|
+
dropView(viewName: string, options?: DropViewOptions): Promise<void>;
|
|
378
|
+
showViews(): Promise<string[]>;
|
|
379
|
+
addColumn(tableName: string, columnName: string, definition: ColumnDefinition): Promise<void>;
|
|
380
|
+
removeColumn(tableName: string, columnName: string): Promise<void>;
|
|
381
|
+
changeColumn(tableName: string, columnName: string, definition: ColumnDefinition): Promise<void>;
|
|
382
|
+
renameColumn(): Promise<void>;
|
|
383
|
+
addForeignKey(tableName: string, columnName: string, referencedTableName: string, referencedColumnName: string, options?: any): Promise<void>;
|
|
384
|
+
/**
|
|
385
|
+
* Bulk-insert records using the Mutation API (`table.insert()`) rather
|
|
386
|
+
* than a multi-row SQL `INSERT`. This is the recommended path for bulk
|
|
387
|
+
* writes on Spanner: mutations skip SQL parsing/planning entirely and are
|
|
388
|
+
* batched into a single commit.
|
|
389
|
+
*/
|
|
390
|
+
bulkInsert(tableName: string, records: Record<string, any>[], _options?: any): Promise<QueryResult>;
|
|
391
|
+
/** Mutation API: insert rows (fails if any row's key already exists). */
|
|
392
|
+
mutationInsert(tableName: string, rows: Record<string, any>[]): Promise<void>;
|
|
393
|
+
/** Mutation API: update rows (fails if a row's key does not exist). */
|
|
394
|
+
mutationUpdate(tableName: string, rows: Record<string, any>[]): Promise<void>;
|
|
395
|
+
/**
|
|
396
|
+
* Mutation API: upsert rows (insert-or-update by primary key). This is the
|
|
397
|
+
* **primary/recommended** upsert mechanism for this dialect - see the file
|
|
398
|
+
* header for the tradeoff vs. `buildUpsertQuery()`'s SQL `INSERT OR
|
|
399
|
+
* UPDATE` fallback.
|
|
400
|
+
*/
|
|
401
|
+
mutationUpsert(tableName: string, rows: Record<string, any>[]): Promise<void>;
|
|
402
|
+
/** Mutation API: delete rows by primary key. */
|
|
403
|
+
mutationDelete(tableName: string, keys: (string | number | (string | number)[])[]): Promise<void>;
|
|
404
|
+
showTables(): Promise<string[]>;
|
|
405
|
+
showConstraints(tableName: string): Promise<any[]>;
|
|
406
|
+
addConstraint(tableName: string, options: {
|
|
407
|
+
type: 'UNIQUE' | 'CHECK' | 'PRIMARY KEY' | 'FOREIGN KEY';
|
|
408
|
+
fields: string[];
|
|
409
|
+
name?: string;
|
|
410
|
+
references?: {
|
|
411
|
+
table: string;
|
|
412
|
+
fields: string[];
|
|
413
|
+
};
|
|
414
|
+
check?: string;
|
|
415
|
+
}): Promise<void>;
|
|
416
|
+
removeConstraint(tableName: string, constraintName: string): Promise<void>;
|
|
417
|
+
showIndexes(tableName: string): Promise<any[]>;
|
|
418
|
+
describeTable(tableName: string): Promise<TableDescription>;
|
|
419
|
+
renameTable(): Promise<void>;
|
|
420
|
+
/**
|
|
421
|
+
* Add a secondary index. `options.include` maps to Spanner's `STORING
|
|
422
|
+
* (...)` clause - a covering index that duplicates the listed columns
|
|
423
|
+
* alongside the index entry so lookups can be satisfied without a join
|
|
424
|
+
* back to the base table.
|
|
425
|
+
*/
|
|
426
|
+
addIndex(tableName: string, indexName: string, fields: string[], options?: IndexOptions): Promise<void>;
|
|
427
|
+
removeIndex(tableName: string, indexName: string): Promise<void>;
|
|
428
|
+
createIndex(tableName: string, indexDef: IndexDefinition): Promise<void>;
|
|
429
|
+
createFulltextIndex(): Promise<void>;
|
|
430
|
+
createSpatialIndex(): Promise<void>;
|
|
431
|
+
dropIndex(tableName: string, indexName: string, options?: DropIndexOptions): Promise<void>;
|
|
432
|
+
createConstraint(tableName: string, constraintDef: ConstraintDefinition): Promise<void>;
|
|
433
|
+
dropConstraint(tableName: string, constraintName: string, options?: DropConstraintOptions): Promise<void>;
|
|
434
|
+
changeOwner(): Promise<void>;
|
|
435
|
+
private static readonly FDW_NOT_SUPPORTED;
|
|
436
|
+
createForeignDataWrapper(): Promise<void>;
|
|
437
|
+
dropForeignDataWrapper(): Promise<void>;
|
|
438
|
+
createForeignServer(): Promise<void>;
|
|
439
|
+
dropForeignServer(): Promise<void>;
|
|
440
|
+
createForeignTable(): Promise<void>;
|
|
441
|
+
buildCreateServerQuery(_name: string, _opts: FdwForeignServerOptions): string;
|
|
442
|
+
buildAlterServerQuery(_name: string, _opts: FdwAlterForeignServerOptions): string;
|
|
443
|
+
buildDropServerQuery(): string;
|
|
444
|
+
buildCreateUserMappingQuery(_opts: FdwUserMappingOptions): string;
|
|
445
|
+
buildAlterUserMappingQuery(_opts: FdwUserMappingOptions): string;
|
|
446
|
+
buildDropUserMappingQuery(): string;
|
|
447
|
+
createUserMapping(): Promise<void>;
|
|
448
|
+
dropUserMapping(): Promise<void>;
|
|
449
|
+
buildCreateForeignTableQuery(_tableName: string, _opts: FdwForeignTableOptions): string;
|
|
450
|
+
buildDropForeignTableQuery(): string;
|
|
451
|
+
buildImportForeignSchemaQuery(_remoteSchema: string, _serverName: string, _opts?: FdwImportForeignSchemaOptions): string;
|
|
452
|
+
getServersQuery(): string;
|
|
453
|
+
private static readonly USER_MGMT_NOT_SUPPORTED;
|
|
454
|
+
buildCreateUserQuery(): string;
|
|
455
|
+
buildAlterUserQuery(): string;
|
|
456
|
+
buildDropUserQuery(): string;
|
|
457
|
+
getUsersQuery(): string;
|
|
458
|
+
buildGrantQuery(): string;
|
|
459
|
+
buildRevokeQuery(): string;
|
|
460
|
+
buildShowGrantsQuery(): string;
|
|
461
|
+
buildFlushPrivilegesQuery(): string;
|
|
462
|
+
buildCreateRoleQuery(roleName: string): string;
|
|
463
|
+
buildDropRoleQuery(roleName: string): string;
|
|
464
|
+
buildGrantRoleQuery(role: string, to: any): string;
|
|
465
|
+
buildRevokeRoleQuery(role: string, from: any): string;
|
|
466
|
+
getRolesQuery(): string;
|
|
467
|
+
createSecurityPolicy(): Promise<void>;
|
|
468
|
+
dropSecurityPolicy(): Promise<void>;
|
|
469
|
+
private static readonly PROC_NOT_SUPPORTED;
|
|
470
|
+
createStoredProcedure(_options: StoredProcedureOptions): Promise<void>;
|
|
471
|
+
createProcedure(options: StoredProcedureOptions): Promise<void>;
|
|
472
|
+
dropStoredProcedure(_procedureName: string, _options?: DropStoredProcedureOptions): Promise<void>;
|
|
473
|
+
dropProcedure(procedureName: string, options?: DropStoredProcedureOptions): Promise<void>;
|
|
474
|
+
executeStoredProcedure(_options: ExecuteStoredProcedureOptions): Promise<QueryResult>;
|
|
475
|
+
hasStoredProcedure(): Promise<boolean>;
|
|
476
|
+
/**
|
|
477
|
+
* Create a bit-reversed sequence: an ordered-but-shuffled numeric
|
|
478
|
+
* generator (`CREATE SEQUENCE ... OPTIONS (sequence_kind =
|
|
479
|
+
* 'bit_reversed_positive')`) that spreads generated values across the
|
|
480
|
+
* keyspace instead of producing a monotonic run, avoiding the hotspotting
|
|
481
|
+
* that a plain auto-increment counter would cause.
|
|
482
|
+
*/
|
|
483
|
+
createBitReversedSequence(name: string, options?: {
|
|
484
|
+
startWithCounter?: number;
|
|
485
|
+
skipRangeMin?: number;
|
|
486
|
+
skipRangeMax?: number;
|
|
487
|
+
}): Promise<void>;
|
|
488
|
+
dropSequence(name: string, options?: {
|
|
489
|
+
ifExists?: boolean;
|
|
490
|
+
}): Promise<void>;
|
|
491
|
+
/** SQL fragment to pull the next value from a bit-reversed sequence. */
|
|
492
|
+
nextBitReversedSequenceValueSql(name: string): string;
|
|
493
|
+
nextBitReversedSequenceValue(name: string): Promise<number>;
|
|
494
|
+
/**
|
|
495
|
+
* Start a read-write transaction.
|
|
496
|
+
*
|
|
497
|
+
* See the file header: Spanner read-write transactions have no
|
|
498
|
+
* configurable isolation level - they are always externally consistent by
|
|
499
|
+
* construction. `options.isolationLevel` is accepted for interface parity
|
|
500
|
+
* with every other dialect but is ignored (with a warning) rather than
|
|
501
|
+
* silently mapped to a Spanner concept it doesn't correspond to.
|
|
502
|
+
*
|
|
503
|
+
* Implementation note: `database.runTransaction()` is callback-based
|
|
504
|
+
* (`(err, transaction) => ...`) and keeps the transaction lease open only
|
|
505
|
+
* as long as the promise returned from that callback is pending. To
|
|
506
|
+
* expose the imperative `startTransaction()`/`commitTransaction()`/
|
|
507
|
+
* `rollbackTransaction()` shape used elsewhere in this codebase, this
|
|
508
|
+
* method opens the transaction, hands the driver a promise that resolves
|
|
509
|
+
* only once `commitTransaction()`/`rollbackTransaction()` is called (see
|
|
510
|
+
* `pendingTx`), and returns immediately with the transaction handle.
|
|
511
|
+
*/
|
|
512
|
+
startTransaction(options?: TransactionOptions): Promise<Transaction>;
|
|
513
|
+
commitTransaction(transaction: Transaction): Promise<void>;
|
|
514
|
+
rollbackTransaction(transaction: Transaction): Promise<void>;
|
|
515
|
+
/**
|
|
516
|
+
* Run a read-only transaction (strong read, or a stale/bounded-staleness
|
|
517
|
+
* read for lower latency at the cost of recency). This is a distinct
|
|
518
|
+
* concept from a read-write transaction in Spanner - it takes a
|
|
519
|
+
* consistent snapshot and never participates in commit/abort/retry - so
|
|
520
|
+
* it is exposed as its own method rather than forced through
|
|
521
|
+
* `startTransaction()`.
|
|
522
|
+
*/
|
|
523
|
+
runReadOnlyTransaction<T>(fn: (run: (sql: string, params?: Record<string, unknown>) => Promise<any[]>) => Promise<T>, options?: {
|
|
524
|
+
strong?: boolean;
|
|
525
|
+
maxStaleness?: {
|
|
526
|
+
seconds: number;
|
|
527
|
+
};
|
|
528
|
+
exactStaleness?: {
|
|
529
|
+
seconds: number;
|
|
530
|
+
};
|
|
531
|
+
readTimestamp?: Date;
|
|
532
|
+
}): Promise<T>;
|
|
533
|
+
/** Resolve the project ID used to build Admin API resource paths. */
|
|
534
|
+
private getProjectId;
|
|
535
|
+
private getDatabaseAdminClient;
|
|
536
|
+
/**
|
|
537
|
+
* Start a backup of `databaseId` (defaults to this dialect's configured
|
|
538
|
+
* database), storing it as `backupId` with the given expiration time.
|
|
539
|
+
* Returns the completed `Backup` resource once the long-running operation
|
|
540
|
+
* finishes (`Backup.state` will be `READY`).
|
|
541
|
+
*/
|
|
542
|
+
createBackup(backupId: string, expireTime: Date, databaseId?: string): Promise<any>;
|
|
543
|
+
/**
|
|
544
|
+
* List backups in this dialect's instance. `filter` is a Cloud Spanner
|
|
545
|
+
* backup filter expression (e.g. `state:READY`,
|
|
546
|
+
* `database:my-db`) - see `DatabaseAdminClient#listBackups()`'s
|
|
547
|
+
* `request.filter` for the supported grammar; omit for all backups in the
|
|
548
|
+
* instance.
|
|
549
|
+
*/
|
|
550
|
+
listBackups(filter?: string): Promise<any[]>;
|
|
551
|
+
/** Fetch a single backup's metadata by ID. */
|
|
552
|
+
getBackup(backupId: string): Promise<any>;
|
|
553
|
+
/** Delete a backup by ID. */
|
|
554
|
+
deleteBackup(backupId: string): Promise<void>;
|
|
555
|
+
/**
|
|
556
|
+
* Restore `backupId` into a brand-new database `newDatabaseId` in this
|
|
557
|
+
* dialect's instance. The new database must not already exist, and must
|
|
558
|
+
* be created in an instance with the same instance configuration as the
|
|
559
|
+
* one holding the backup. Returns the completed `Database` resource once
|
|
560
|
+
* the long-running restore operation finishes.
|
|
561
|
+
*/
|
|
562
|
+
restoreDatabase(backupId: string, newDatabaseId: string): Promise<any>;
|
|
563
|
+
getDataTypeSql(dataType: DataType): string;
|
|
564
|
+
buildWhereClause(where: WhereOptions, _options?: any): {
|
|
565
|
+
sql: string;
|
|
566
|
+
values: any[];
|
|
567
|
+
};
|
|
568
|
+
buildOrderClause(order: Order): string;
|
|
569
|
+
/**
|
|
570
|
+
* Build a `LIMIT`/`OFFSET` clause. GoogleSQL requires `LIMIT` whenever
|
|
571
|
+
* `OFFSET` is used (there's no bare `OFFSET n` the way Postgres allows) -
|
|
572
|
+
* when only an offset is given, this emits a very large LIMIT to satisfy
|
|
573
|
+
* that requirement.
|
|
574
|
+
*/
|
|
575
|
+
buildLimitOffset(limit?: number | string, offset?: number | string): string;
|
|
576
|
+
/**
|
|
577
|
+
* Map a Spanner conflict action (or the legacy `upsert: true` boolean) onto
|
|
578
|
+
* the corresponding GoogleSQL insert verb. GoogleSQL's DML upsert extension
|
|
579
|
+
* offers three distinct conflict-action variants (verified against the
|
|
580
|
+
* GoogleSQL DML reference - Spanner has no `ON CONFLICT` clause):
|
|
581
|
+
* - `UPDATE` → `INSERT OR UPDATE INTO` (insert, or overwrite the row's non-key columns on PK collision)
|
|
582
|
+
* - `IGNORE` → `INSERT OR IGNORE INTO` (insert, or silently skip on PK collision)
|
|
583
|
+
* - `REPLACE` → `INSERT OR REPLACE INTO` (insert, or delete-then-reinsert the whole row on PK collision)
|
|
584
|
+
*/
|
|
585
|
+
private insertVerb;
|
|
586
|
+
/**
|
|
587
|
+
* Build an INSERT statement. Set `options.upsert` (legacy boolean, ⇒
|
|
588
|
+
* `INSERT OR UPDATE INTO`) or `options.conflictAction`
|
|
589
|
+
* (`'UPDATE' | 'IGNORE' | 'REPLACE'`) to emit one of GoogleSQL's three DML
|
|
590
|
+
* conflict-action upsert variants (Spanner has no `ON CONFLICT` clause). For
|
|
591
|
+
* bulk/blind writes prefer `mutationInsert()`/`mutationUpsert()` (the
|
|
592
|
+
* Mutation API) instead - see the file header.
|
|
593
|
+
*/
|
|
594
|
+
buildInsertQuery(tableName: string, values: Record<string, any>, options?: SpannerInsertOptions): {
|
|
595
|
+
sql: string;
|
|
596
|
+
values: any[];
|
|
597
|
+
};
|
|
598
|
+
/**
|
|
599
|
+
* Build an upsert statement using one of GoogleSQL's `INSERT OR ...` DML
|
|
600
|
+
* variants. Defaults to `INSERT OR UPDATE INTO`; pass
|
|
601
|
+
* `options.conflictAction` (`'UPDATE' | 'IGNORE' | 'REPLACE'`) to select
|
|
602
|
+
* ignore/replace semantics instead. Note this is a *SQL DML* path for
|
|
603
|
+
* interface parity - the primary, recommended mechanism for upserts on this
|
|
604
|
+
* dialect is the Mutation API (`mutationUpsert()` /
|
|
605
|
+
* `database.table(name).upsert(rows)`); see the file header for why.
|
|
606
|
+
*/
|
|
607
|
+
buildUpsertQuery(tableName: string, values: Record<string, any>, options?: SpannerUpsertQueryOptions): {
|
|
608
|
+
sql: string;
|
|
609
|
+
values: any[];
|
|
610
|
+
};
|
|
611
|
+
buildIncrementQuery(tableName: string, fields: string | string[] | Record<string, number>, where: WhereOptions, options?: {
|
|
612
|
+
by?: number;
|
|
613
|
+
}): {
|
|
614
|
+
sql: string;
|
|
615
|
+
values: any[];
|
|
616
|
+
};
|
|
617
|
+
buildUpdateQuery(tableName: string, values: Record<string, any>, where: WhereOptions, options?: DUpdateOptions): {
|
|
618
|
+
sql: string;
|
|
619
|
+
values: any[];
|
|
620
|
+
};
|
|
621
|
+
buildDeleteQuery(tableName: string, where: WhereOptions, options?: DeleteOptions): {
|
|
622
|
+
sql: string;
|
|
623
|
+
values: any[];
|
|
624
|
+
};
|
|
625
|
+
/**
|
|
626
|
+
* Build a SELECT statement. GoogleSQL supports standard window functions
|
|
627
|
+
* (`OVER (...)`) and CTEs (including `WITH RECURSIVE`) natively as part of
|
|
628
|
+
* its query syntax; pass them straight through as raw SQL fragments via
|
|
629
|
+
* `Literal`/`attributes` (window functions) or `buildRecursiveCteQuery()`
|
|
630
|
+
* (CTEs) - no special dialect-layer plumbing is required beyond what's
|
|
631
|
+
* already here, since both are just SELECT-query syntax GoogleSQL parses
|
|
632
|
+
* natively.
|
|
633
|
+
*/
|
|
634
|
+
buildSelectQuery(options: SelectOptions): {
|
|
635
|
+
sql: string;
|
|
636
|
+
values: any[];
|
|
637
|
+
};
|
|
638
|
+
/**
|
|
639
|
+
* Build a (optionally recursive) CTE-prefixed query -
|
|
640
|
+
* `WITH [RECURSIVE] name AS (...), ... <mainQuery>` - which GoogleSQL
|
|
641
|
+
* supports natively, including recursive CTEs (`WITH RECURSIVE`).
|
|
642
|
+
*/
|
|
643
|
+
buildRecursiveCteQuery(ctes: {
|
|
644
|
+
name: string;
|
|
645
|
+
query: string;
|
|
646
|
+
recursive?: boolean;
|
|
647
|
+
}[], mainQuery: string): string;
|
|
648
|
+
/**
|
|
649
|
+
* Build a `ROW_NUMBER()`/`RANK()`/`DENSE_RANK()`-style window function
|
|
650
|
+
* expression string, for use inside `attributes`/`Literal`. GoogleSQL's
|
|
651
|
+
* window function syntax matches standard SQL exactly, so this is a thin
|
|
652
|
+
* convenience wrapper rather than something requiring dialect-specific
|
|
653
|
+
* translation.
|
|
654
|
+
*/
|
|
655
|
+
buildWindowFunction(fn: string, options?: {
|
|
656
|
+
partitionBy?: string[];
|
|
657
|
+
orderBy?: [string, string?][];
|
|
658
|
+
frame?: string;
|
|
659
|
+
}): string;
|
|
660
|
+
}
|