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.
Files changed (460) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/README.md +194 -72
  3. package/dist/audit/history-query.d.ts +35 -0
  4. package/dist/audit/index.d.ts +16 -0
  5. package/dist/audit/logger.d.ts +126 -0
  6. package/dist/cache/cache-manager.d.ts +341 -0
  7. package/dist/cache/index.d.ts +8 -0
  8. package/dist/cache/redis-cluster-cache.d.ts +164 -0
  9. package/dist/cache/redis-cluster-cache.js +19 -36
  10. package/dist/cli/cloud.d.ts +55 -0
  11. package/dist/cli/cloud.js +318 -0
  12. package/dist/cli/commands/auth.d.ts +2 -0
  13. package/dist/cli/commands/auth.js +345 -0
  14. package/dist/cli/commands/billing.d.ts +2 -0
  15. package/dist/cli/commands/billing.js +135 -0
  16. package/dist/cli/commands/code.d.ts +2 -0
  17. package/dist/cli/commands/code.js +168 -0
  18. package/dist/cli/commands/config.d.ts +2 -0
  19. package/dist/cli/commands/config.js +154 -0
  20. package/dist/cli/commands/db.d.ts +2 -0
  21. package/dist/cli/commands/db.js +189 -0
  22. package/dist/cli/commands/index.d.ts +1 -0
  23. package/dist/cli/commands/index.js +22 -0
  24. package/dist/cli/commands/keys.d.ts +2 -0
  25. package/dist/cli/commands/keys.js +100 -0
  26. package/dist/cli/commands/misc.d.ts +2 -0
  27. package/dist/cli/commands/misc.js +282 -0
  28. package/dist/cli/commands/pull.d.ts +2 -0
  29. package/dist/cli/commands/pull.js +306 -0
  30. package/dist/cli/commands/runners.d.ts +2 -0
  31. package/dist/cli/commands/runners.js +218 -0
  32. package/dist/cli/commands/scaffold.d.ts +2 -0
  33. package/dist/cli/commands/scaffold.js +383 -0
  34. package/dist/cli/commands/secrets.d.ts +2 -0
  35. package/dist/cli/commands/secrets.js +162 -0
  36. package/dist/cli/commands/store.d.ts +2 -0
  37. package/dist/cli/commands/store.js +274 -0
  38. package/dist/cli/commands/system.d.ts +10 -0
  39. package/dist/cli/commands/system.js +169 -0
  40. package/dist/cli/commands/teams.d.ts +2 -0
  41. package/dist/cli/commands/teams.js +189 -0
  42. package/dist/cli/commands/user.d.ts +2 -0
  43. package/dist/cli/commands/user.js +171 -0
  44. package/dist/cli/framework.d.ts +103 -0
  45. package/dist/cli/framework.js +436 -0
  46. package/dist/cli/io.d.ts +26 -0
  47. package/dist/cli/io.js +181 -0
  48. package/dist/cli/keychain.d.ts +10 -0
  49. package/dist/cli/keychain.js +101 -0
  50. package/dist/cli/prompt.d.ts +20 -0
  51. package/dist/cli/prompt.js +111 -0
  52. package/dist/cli.d.ts +214 -0
  53. package/dist/cli.js +72 -5
  54. package/dist/compliance/audit-trail.d.ts +66 -0
  55. package/dist/compliance/backup-verification.d.ts +279 -0
  56. package/dist/compliance/breach-detector.d.ts +197 -0
  57. package/dist/compliance/consent-record.d.ts +107 -0
  58. package/dist/compliance/consent-versioning.d.ts +169 -0
  59. package/dist/compliance/cross-border-log.d.ts +254 -0
  60. package/dist/compliance/data-classifier.d.ts +127 -0
  61. package/dist/compliance/data-lineage.d.ts +268 -0
  62. package/dist/compliance/data-masker.d.ts +110 -0
  63. package/dist/compliance/data-portability.d.ts +98 -0
  64. package/dist/compliance/data-retention.d.ts +108 -0
  65. package/dist/compliance/dsar-workflow.d.ts +175 -0
  66. package/dist/compliance/field-encryption.d.ts +84 -0
  67. package/dist/compliance/immutable-record.d.ts +84 -0
  68. package/dist/compliance/index.d.ts +93 -0
  69. package/dist/compliance/privacy-impact-assessment.d.ts +196 -0
  70. package/dist/compliance/pseudonymization.d.ts +96 -0
  71. package/dist/compliance/query-firewall.d.ts +661 -0
  72. package/dist/compliance/rate-limiter.d.ts +203 -0
  73. package/dist/compliance/right-to-erasure.d.ts +96 -0
  74. package/dist/compliance/row-level-security.d.ts +152 -0
  75. package/dist/compliance/security-decorator.d.ts +388 -0
  76. package/dist/compliance/security-monitor.d.ts +170 -0
  77. package/dist/compliance/sensitive-data-discovery.d.ts +151 -0
  78. package/dist/compliance/session-isolation.d.ts +286 -0
  79. package/dist/compliance/tls-enforcer.d.ts +51 -0
  80. package/dist/compliance/worm-storage.d.ts +225 -0
  81. package/dist/connection-manager.d.ts +130 -0
  82. package/dist/connection-pool.d.ts +311 -0
  83. package/dist/decorators/audit.d.ts +49 -0
  84. package/dist/decorators/check.d.ts +218 -0
  85. package/dist/decorators/collate.d.ts +346 -0
  86. package/dist/decorators/comment.d.ts +51 -0
  87. package/dist/decorators/database-settings.d.ts +193 -0
  88. package/dist/decorators/default.d.ts +148 -0
  89. package/dist/decorators/encryption.d.ts +175 -0
  90. package/dist/decorators/engine.d.ts +97 -0
  91. package/dist/decorators/fk-constraints.d.ts +387 -0
  92. package/dist/decorators/foreign-table.d.ts +57 -0
  93. package/dist/decorators/generated.d.ts +232 -0
  94. package/dist/decorators/hstore.d.ts +96 -0
  95. package/dist/decorators/index.d.ts +57 -0
  96. package/dist/decorators/index.js +14 -30
  97. package/dist/decorators/json-column.d.ts +47 -0
  98. package/dist/decorators/jsonb.d.ts +83 -0
  99. package/dist/decorators/orm-decorators.d.ts +274 -0
  100. package/dist/decorators/permissions.d.ts +192 -0
  101. package/dist/decorators/procedure.d.ts +168 -0
  102. package/dist/decorators/procedure.js +31 -7
  103. package/dist/decorators/query-options.d.ts +527 -0
  104. package/dist/decorators/range.d.ts +122 -0
  105. package/dist/decorators/set-column.d.ts +43 -0
  106. package/dist/decorators/spatial.d.ts +60 -0
  107. package/dist/decorators/storage.d.ts +561 -0
  108. package/dist/decorators/timezone.d.ts +319 -0
  109. package/dist/decorators/trigger.d.ts +50 -0
  110. package/dist/decorators/uuid.d.ts +102 -0
  111. package/dist/decorators/view.d.ts +213 -0
  112. package/dist/diagrams/chen-diagram.d.ts +70 -0
  113. package/dist/diagrams/chen-diagram.js +33 -31
  114. package/dist/diagrams/class-diagram.d.ts +78 -0
  115. package/dist/diagrams/class-diagram.js +23 -27
  116. package/dist/diagrams/dependency-diagram.d.ts +82 -0
  117. package/dist/diagrams/dependency-diagram.js +18 -9
  118. package/dist/diagrams/er-diagram.d.ts +82 -0
  119. package/dist/diagrams/er-diagram.js +174 -231
  120. package/dist/diagrams/flow-diagram.d.ts +70 -0
  121. package/dist/diagrams/flow-diagram.js +23 -18
  122. package/dist/diagrams/gantt-diagram.d.ts +67 -0
  123. package/dist/diagrams/gantt-diagram.js +20 -18
  124. package/dist/diagrams/index-diagram.d.ts +61 -0
  125. package/dist/diagrams/index-diagram.js +36 -31
  126. package/dist/diagrams/index.d.ts +155 -0
  127. package/dist/diagrams/index.js +7 -1
  128. package/dist/diagrams/migration-diagram.d.ts +67 -0
  129. package/dist/diagrams/migration-diagram.js +45 -57
  130. package/dist/diagrams/model-diagram.d.ts +85 -0
  131. package/dist/diagrams/model-diagram.js +225 -287
  132. package/dist/diagrams/package-diagram.d.ts +69 -0
  133. package/dist/diagrams/package-diagram.js +30 -32
  134. package/dist/diagrams/palette.d.ts +138 -0
  135. package/dist/diagrams/palette.js +134 -25
  136. package/dist/diagrams/relational-diagram.d.ts +82 -0
  137. package/dist/diagrams/relational-diagram.js +51 -59
  138. package/dist/diagrams/schemadoc-diagram.d.ts +57 -0
  139. package/dist/diagrams/schemadoc-diagram.js +36 -28
  140. package/dist/diagrams/sequence-diagram.d.ts +61 -0
  141. package/dist/diagrams/sequence-diagram.js +20 -11
  142. package/dist/diagrams/state-diagram.d.ts +85 -0
  143. package/dist/diagrams/state-diagram.js +21 -17
  144. package/dist/diagrams/svg-dom.d.ts +62 -0
  145. package/dist/diagrams/svg-dom.js +11 -0
  146. package/dist/diagrams/tree-diagram.d.ts +47 -0
  147. package/dist/diagrams/tree-diagram.js +19 -10
  148. package/dist/dialects/clickhouse/index.d.ts +660 -0
  149. package/dist/dialects/clickhouse/index.js +107 -2
  150. package/dist/dialects/cockroachdb/index.d.ts +1708 -0
  151. package/dist/dialects/cockroachdb/index.js +139 -10
  152. package/dist/dialects/cratedb/index.d.ts +262 -0
  153. package/dist/dialects/cratedb/index.js +148 -0
  154. package/dist/dialects/databricks/index.d.ts +397 -0
  155. package/dist/dialects/databricks/index.js +233 -11
  156. package/dist/dialects/db2/index.d.ts +729 -0
  157. package/dist/dialects/db2/index.js +152 -2
  158. package/dist/dialects/dialect.d.ts +1653 -0
  159. package/dist/dialects/duckdb/index.d.ts +440 -0
  160. package/dist/dialects/duckdb/index.js +21 -37
  161. package/dist/dialects/exasol/index.d.ts +197 -0
  162. package/dist/dialects/exasol/index.js +14 -0
  163. package/dist/dialects/firebird/index.d.ts +286 -0
  164. package/dist/dialects/firebird/index.js +135 -0
  165. package/dist/dialects/greenplum/index.d.ts +336 -0
  166. package/dist/dialects/greenplum/index.js +168 -0
  167. package/dist/dialects/hana/index.d.ts +512 -0
  168. package/dist/dialects/hana/index.js +17 -35
  169. package/dist/dialects/mariadb/index.d.ts +1241 -0
  170. package/dist/dialects/mariadb/index.js +181 -43
  171. package/dist/dialects/mssql/index.d.ts +729 -0
  172. package/dist/dialects/mssql/index.js +76 -7
  173. package/dist/dialects/mysql/index.d.ts +1233 -0
  174. package/dist/dialects/mysql/index.js +87 -19
  175. package/dist/dialects/oracle/index.d.ts +1222 -0
  176. package/dist/dialects/oracle/index.js +210 -9
  177. package/dist/dialects/postgres/index.d.ts +1598 -0
  178. package/dist/dialects/postgres/index.js +34 -13
  179. package/dist/dialects/query-stream-helper.d.ts +58 -0
  180. package/dist/dialects/questdb/index.d.ts +430 -0
  181. package/dist/dialects/questdb/index.js +292 -0
  182. package/dist/dialects/redshift/index.d.ts +933 -0
  183. package/dist/dialects/redshift/index.js +17 -5
  184. package/dist/dialects/singlestore/index.d.ts +233 -0
  185. package/dist/dialects/singlestore/index.js +53 -0
  186. package/dist/dialects/snowflake/index.d.ts +727 -0
  187. package/dist/dialects/snowflake/index.js +154 -5
  188. package/dist/dialects/spanner/index.d.ts +660 -0
  189. package/dist/dialects/spanner/index.js +43 -21
  190. package/dist/dialects/sqlite/index.d.ts +1133 -0
  191. package/dist/dialects/sqlite/index.js +168 -30
  192. package/dist/dialects/tidb/index.d.ts +226 -0
  193. package/dist/dialects/tidb/index.js +10 -0
  194. package/dist/dialects/timescaledb/index.d.ts +286 -0
  195. package/dist/dialects/timescaledb/index.js +179 -0
  196. package/dist/dialects/trino/index.d.ts +230 -0
  197. package/dist/dialects/trino/index.js +85 -10
  198. package/dist/dialects/turso/index.d.ts +98 -0
  199. package/dist/dialects/turso/index.js +10 -0
  200. package/dist/dialects/vertica/index.d.ts +321 -0
  201. package/dist/dialects/vertica/index.js +161 -0
  202. package/dist/dialects/yugabytedb/index.d.ts +276 -0
  203. package/dist/dialects/yugabytedb/index.js +121 -0
  204. package/dist/errors/index.d.ts +378 -0
  205. package/dist/errors/index.js +29 -1
  206. package/dist/errors/utils.d.ts +53 -0
  207. package/dist/errors.d.ts +5 -0
  208. package/dist/extensions/catalog/cloud-warehouse-features.d.ts +27 -0
  209. package/dist/extensions/catalog/mssql-features.d.ts +20 -0
  210. package/dist/extensions/catalog/mysql-mariadb-plugins.d.ts +18 -0
  211. package/dist/extensions/catalog/oracle-db2-features.d.ts +17 -0
  212. package/dist/extensions/catalog/postgres-extensions.d.ts +15 -0
  213. package/dist/extensions/index.d.ts +34 -0
  214. package/dist/extensions/types.d.ts +43 -0
  215. package/dist/external-fields/adapters.d.ts +50 -0
  216. package/dist/external-fields/adapters.js +227 -0
  217. package/dist/external-fields/decorator.d.ts +77 -0
  218. package/dist/external-fields/decorator.js +80 -0
  219. package/dist/external-fields/index.d.ts +10 -0
  220. package/dist/external-fields/index.js +19 -0
  221. package/dist/external-fields/runtime.d.ts +39 -0
  222. package/dist/external-fields/runtime.js +221 -0
  223. package/dist/foreign-data.d.ts +168 -0
  224. package/dist/graph/base-graph-dialect.d.ts +250 -0
  225. package/dist/graph/base-graph-dialect.js +539 -0
  226. package/dist/graph/dgraph/index.d.ts +65 -0
  227. package/dist/graph/dgraph/index.js +559 -0
  228. package/dist/graph/gremlin/index.d.ts +59 -0
  229. package/dist/graph/gremlin/index.js +378 -0
  230. package/dist/graph/index.d.ts +60 -0
  231. package/dist/graph/index.js +67 -0
  232. package/dist/graph/neo4j/index.d.ts +50 -0
  233. package/dist/graph/neo4j/index.js +462 -0
  234. package/dist/graph/types.d.ts +213 -0
  235. package/dist/graph/types.js +234 -0
  236. package/dist/hooks/hooks-manager.d.ts +189 -0
  237. package/dist/hooks/index.d.ts +8 -0
  238. package/dist/index.d.ts +713 -0
  239. package/dist/index.js +36 -4
  240. package/dist/logging.d.ts +183 -0
  241. package/dist/migrations/index.d.ts +9 -0
  242. package/dist/migrations/migration.d.ts +143 -0
  243. package/dist/migrations/migrator.d.ts +199 -0
  244. package/dist/migrations/prormmigration.d.ts +131 -0
  245. package/dist/migrations/query-interface.d.ts +335 -0
  246. package/dist/migrations/seeder.d.ts +167 -0
  247. package/dist/models/associations.d.ts +131 -0
  248. package/dist/models/associations.js +7 -2
  249. package/dist/models/constraints.d.ts +175 -0
  250. package/dist/models/data-types.d.ts +1656 -0
  251. package/dist/models/decorators.d.ts +328 -0
  252. package/dist/models/decorators.js +61 -82
  253. package/dist/models/eager-load.d.ts +86 -0
  254. package/dist/models/eager-load.js +369 -0
  255. package/dist/models/index.d.ts +13 -0
  256. package/dist/models/indexes.d.ts +325 -0
  257. package/dist/models/methods.d.ts +419 -0
  258. package/dist/models/model-manager.d.ts +76 -0
  259. package/dist/models/model.d.ts +820 -0
  260. package/dist/models/model.js +15 -101
  261. package/dist/models/operators.d.ts +29 -0
  262. package/dist/models/scopes.d.ts +71 -0
  263. package/dist/models/typescript-types.d.ts +177 -0
  264. package/dist/nosql/aerospike/index.d.ts +126 -0
  265. package/dist/nosql/allegrograph/index.d.ts +86 -0
  266. package/dist/nosql/arangodb/index.d.ts +285 -0
  267. package/dist/nosql/arangodb/index.js +274 -2
  268. package/dist/nosql/arangodb/where.d.ts +38 -0
  269. package/dist/nosql/arangodb/where.js +94 -0
  270. package/dist/nosql/azure-blob/index.d.ts +104 -0
  271. package/dist/nosql/beanstalkd/index.d.ts +88 -0
  272. package/dist/nosql/beequeue/index.d.ts +99 -0
  273. package/dist/nosql/bigchaindb/index.d.ts +113 -0
  274. package/dist/nosql/bigtable/index.d.ts +144 -0
  275. package/dist/nosql/blazegraph/index.d.ts +88 -0
  276. package/dist/nosql/bullmq/index.d.ts +83 -0
  277. package/dist/nosql/cassandra/index.d.ts +119 -0
  278. package/dist/nosql/chroma/index.d.ts +151 -0
  279. package/dist/nosql/cloudflare-kv/index.d.ts +120 -0
  280. package/dist/nosql/coherence/index.d.ts +91 -0
  281. package/dist/nosql/cosmosdb/index.d.ts +78 -0
  282. package/dist/nosql/couchbase/index.d.ts +103 -0
  283. package/dist/nosql/dax/index.d.ts +118 -0
  284. package/dist/nosql/deno-kv/index.d.ts +109 -0
  285. package/dist/nosql/dgraph/index.d.ts +80 -0
  286. package/dist/nosql/doris/index.d.ts +88 -0
  287. package/dist/nosql/druid/index.d.ts +95 -0
  288. package/dist/nosql/dynamodb/index.d.ts +643 -0
  289. package/dist/nosql/dynamodb/index.js +423 -0
  290. package/dist/nosql/elasticsearch/index.d.ts +239 -0
  291. package/dist/nosql/etcd/index.d.ts +243 -0
  292. package/dist/nosql/eventhubs/index.d.ts +89 -0
  293. package/dist/nosql/eventstore/index.d.ts +102 -0
  294. package/dist/nosql/faunadb/index.d.ts +141 -0
  295. package/dist/nosql/faunadb/index.js +329 -0
  296. package/dist/nosql/firestore/index.d.ts +67 -0
  297. package/dist/nosql/fluree/index.d.ts +88 -0
  298. package/dist/nosql/fuseki/index.d.ts +94 -0
  299. package/dist/nosql/gcs/index.d.ts +62 -0
  300. package/dist/nosql/gearman/index.d.ts +77 -0
  301. package/dist/nosql/geode/index.d.ts +93 -0
  302. package/dist/nosql/graphdb/index.d.ts +86 -0
  303. package/dist/nosql/graylog/index.d.ts +118 -0
  304. package/dist/nosql/gridgain/index.d.ts +78 -0
  305. package/dist/nosql/hazelcast/index.d.ts +73 -0
  306. package/dist/nosql/hbase/index.d.ts +123 -0
  307. package/dist/nosql/ignite/index.d.ts +80 -0
  308. package/dist/nosql/immudb/index.d.ts +131 -0
  309. package/dist/nosql/index.d.ts +215 -0
  310. package/dist/nosql/infinispan/index.d.ts +95 -0
  311. package/dist/nosql/influxdb/flux-compiler.d.ts +23 -0
  312. package/dist/nosql/influxdb/flux-compiler.js +170 -0
  313. package/dist/nosql/influxdb/index.d.ts +300 -0
  314. package/dist/nosql/influxdb/index.js +0 -0
  315. package/dist/nosql/kafka/index.d.ts +113 -0
  316. package/dist/nosql/keyspaces/index.d.ts +122 -0
  317. package/dist/nosql/kinesis/index.d.ts +121 -0
  318. package/dist/nosql/leveldb/index.d.ts +112 -0
  319. package/dist/nosql/leveldb/index.js +103 -1
  320. package/dist/nosql/lmdb/index.d.ts +76 -0
  321. package/dist/nosql/loki/index.d.ts +126 -0
  322. package/dist/nosql/marklogic/index.d.ts +76 -0
  323. package/dist/nosql/materialize/index.d.ts +91 -0
  324. package/dist/nosql/meilisearch/index.d.ts +76 -0
  325. package/dist/nosql/memcached/index.d.ts +138 -0
  326. package/dist/nosql/milvus/index.d.ts +167 -0
  327. package/dist/nosql/minio/index.d.ts +122 -0
  328. package/dist/nosql/momento/index.d.ts +99 -0
  329. package/dist/nosql/mongodb/index.d.ts +265 -0
  330. package/dist/nosql/mongodb/index.js +139 -0
  331. package/dist/nosql/mongodb/where.d.ts +8 -0
  332. package/dist/nosql/mongodb/where.js +181 -0
  333. package/dist/nosql/nats/index.d.ts +139 -0
  334. package/dist/nosql/nedb/index.d.ts +79 -0
  335. package/dist/nosql/neo4j/index.d.ts +217 -0
  336. package/dist/nosql/neo4j/index.js +26 -14
  337. package/dist/nosql/neptune/index.d.ts +234 -0
  338. package/dist/nosql/neptune/index.js +23 -9
  339. package/dist/nosql/nsq/index.d.ts +93 -0
  340. package/dist/nosql/opensearch/index.d.ts +97 -0
  341. package/dist/nosql/orientdb/index.d.ts +72 -0
  342. package/dist/nosql/papertrail/index.d.ts +120 -0
  343. package/dist/nosql/pinecone/index.d.ts +148 -0
  344. package/dist/nosql/pinot/index.d.ts +90 -0
  345. package/dist/nosql/pouchdb/index.d.ts +95 -0
  346. package/dist/nosql/prometheus/index.d.ts +112 -0
  347. package/dist/nosql/provendb/index.d.ts +143 -0
  348. package/dist/nosql/provendb/index.js +262 -0
  349. package/dist/nosql/pubsub/index.d.ts +83 -0
  350. package/dist/nosql/pulsar/index.d.ts +105 -0
  351. package/dist/nosql/qdrant/index.d.ts +231 -0
  352. package/dist/nosql/qldb/index.d.ts +182 -0
  353. package/dist/nosql/qldb/index.js +302 -1
  354. package/dist/nosql/r2/index.d.ts +160 -0
  355. package/dist/nosql/rabbitmq/index.d.ts +131 -0
  356. package/dist/nosql/ravendb/index.d.ts +138 -0
  357. package/dist/nosql/ravendb/index.js +323 -9
  358. package/dist/nosql/ravendb/where.d.ts +38 -0
  359. package/dist/nosql/ravendb/where.js +94 -0
  360. package/dist/nosql/redis/index.d.ts +267 -0
  361. package/dist/nosql/redis/index.js +19 -5
  362. package/dist/nosql/redpanda/index.d.ts +117 -0
  363. package/dist/nosql/resque/index.d.ts +91 -0
  364. package/dist/nosql/rethinkdb/index.d.ts +194 -0
  365. package/dist/nosql/rethinkdb/index.js +290 -0
  366. package/dist/nosql/rethinkdb/where.d.ts +38 -0
  367. package/dist/nosql/rethinkdb/where.js +94 -0
  368. package/dist/nosql/rocksdb/document-layer.d.ts +162 -0
  369. package/dist/nosql/rocksdb/document-layer.js +338 -0
  370. package/dist/nosql/rocksdb/index.d.ts +112 -0
  371. package/dist/nosql/rocksdb/index.js +103 -1
  372. package/dist/nosql/rocksdb/where-match.d.ts +21 -0
  373. package/dist/nosql/rocksdb/where-match.js +238 -0
  374. package/dist/nosql/rockset/index.d.ts +84 -0
  375. package/dist/nosql/s3/index.d.ts +170 -0
  376. package/dist/nosql/scylladb/index.d.ts +117 -0
  377. package/dist/nosql/signoz/index.d.ts +116 -0
  378. package/dist/nosql/sns/index.d.ts +99 -0
  379. package/dist/nosql/solr/index.d.ts +129 -0
  380. package/dist/nosql/splunk/index.d.ts +125 -0
  381. package/dist/nosql/sqs/index.d.ts +116 -0
  382. package/dist/nosql/stardog/index.d.ts +86 -0
  383. package/dist/nosql/starrocks/index.d.ts +89 -0
  384. package/dist/nosql/store.d.ts +23 -0
  385. package/dist/nosql/sumologic/index.d.ts +119 -0
  386. package/dist/nosql/surrealdb/index.d.ts +156 -0
  387. package/dist/nosql/surrealdb/index.js +174 -1
  388. package/dist/nosql/surrealdb/query-compiler.d.ts +26 -0
  389. package/dist/nosql/surrealdb/query-compiler.js +193 -0
  390. package/dist/nosql/terminusdb/index.d.ts +95 -0
  391. package/dist/nosql/tigergraph/index.d.ts +314 -0
  392. package/dist/nosql/typesense/index.d.ts +82 -0
  393. package/dist/nosql/unqlite/index.d.ts +68 -0
  394. package/dist/nosql/upstash/index.d.ts +80 -0
  395. package/dist/nosql/vercel-kv/index.d.ts +82 -0
  396. package/dist/nosql/victoriametrics/index.d.ts +129 -0
  397. package/dist/nosql/virtuoso/index.d.ts +87 -0
  398. package/dist/nosql/weaviate/index.d.ts +196 -0
  399. package/dist/operators/index.d.ts +7 -0
  400. package/dist/operators.d.ts +2947 -0
  401. package/dist/operators.js +46 -1
  402. package/dist/prisma-migrate/index.d.ts +28 -0
  403. package/dist/prisma-migrate/migration-generator.d.ts +21 -0
  404. package/dist/prisma-migrate/model-generator.d.ts +12 -0
  405. package/dist/prisma-migrate/relations.d.ts +28 -0
  406. package/dist/prisma-migrate/schema-parser.d.ts +42 -0
  407. package/dist/prisma-migrate/type-mapper.d.ts +20 -0
  408. package/dist/prorm.d.ts +2093 -0
  409. package/dist/prorm.js +721 -302
  410. package/dist/query-builders/cte-builder.d.ts +104 -0
  411. package/dist/query-builders/functions/aggregate.d.ts +199 -0
  412. package/dist/query-builders/functions/conditional.d.ts +195 -0
  413. package/dist/query-builders/functions/datetime.d.ts +202 -0
  414. package/dist/query-builders/functions/fulltext.d.ts +220 -0
  415. package/dist/query-builders/functions/index.d.ts +17 -0
  416. package/dist/query-builders/functions/json.d.ts +157 -0
  417. package/dist/query-builders/functions/math.d.ts +215 -0
  418. package/dist/query-builders/functions/string.d.ts +233 -0
  419. package/dist/query-builders/functions/window.d.ts +209 -0
  420. package/dist/query-builders/include-builder.d.ts +85 -0
  421. package/dist/query-builders/index-expression-builder.d.ts +153 -0
  422. package/dist/query-builders/index.d.ts +121 -0
  423. package/dist/query-builders/index.js +10 -0
  424. package/dist/query-builders/insert-builder.d.ts +62 -0
  425. package/dist/query-builders/model-helpers.d.ts +28 -0
  426. package/dist/query-builders/order-limit-builder.d.ts +84 -0
  427. package/dist/query-builders/sql-compiler.d.ts +562 -0
  428. package/dist/query-builders/subquery-builder.d.ts +133 -0
  429. package/dist/query-builders/update-builder.d.ts +71 -0
  430. package/dist/query-builders/view-builder.d.ts +189 -0
  431. package/dist/query-builders/where-builder.d.ts +124 -0
  432. package/dist/query-interface.d.ts +407 -0
  433. package/dist/query-interface.js +84 -0
  434. package/dist/query-optimizers/batch-optimizer.d.ts +175 -0
  435. package/dist/query-optimizers/explain-plans.d.ts +187 -0
  436. package/dist/query-optimizers/index.d.ts +27 -0
  437. package/dist/query-optimizers/prepared-statement-cache.d.ts +252 -0
  438. package/dist/query-optimizers/query-hints.d.ts +201 -0
  439. package/dist/query-optimizers/query-optimizer.d.ts +162 -0
  440. package/dist/query-optimizers/slow-query-logger.d.ts +186 -0
  441. package/dist/replica-manager.d.ts +235 -0
  442. package/dist/schema/index.d.ts +7 -0
  443. package/dist/schema/migration-generator.d.ts +74 -0
  444. package/dist/schema/schema-differ.d.ts +114 -0
  445. package/dist/schema/types.d.ts +246 -0
  446. package/dist/schema-objects.d.ts +78 -0
  447. package/dist/schema-objects.js +203 -0
  448. package/dist/sql-constants.d.ts +240 -0
  449. package/dist/sqlite-advanced.d.ts +572 -0
  450. package/dist/streams/index.d.ts +5 -0
  451. package/dist/streams/transforms.d.ts +120 -0
  452. package/dist/transaction.d.ts +221 -0
  453. package/dist/types/index.d.ts +3123 -0
  454. package/dist/user-management.d.ts +141 -0
  455. package/dist/utils/date.d.ts +149 -0
  456. package/dist/utils/index.d.ts +359 -0
  457. package/dist/utils/string.d.ts +88 -0
  458. package/dist/validators/index.d.ts +7 -0
  459. package/dist/validators/validator.d.ts +306 -0
  460. package/package.json +20 -5
@@ -0,0 +1,933 @@
1
+ /**
2
+ * Amazon Redshift dialect implementation for the TypeScript ORM
3
+ *
4
+ * Redshift speaks the PostgreSQL wire protocol (it is a fork of Postgres 8.0.2),
5
+ * so this dialect reuses the `pg` driver exactly like the Postgres dialect and
6
+ * mirrors much of its query-building behavior. However, Redshift diverges from
7
+ * Postgres in ways that matter a lot in practice — two gotchas in particular:
8
+ *
9
+ * 1. FOREIGN KEY / UNIQUE / PRIMARY KEY constraints are accepted syntactically
10
+ * (and stored in the catalog for the query planner / documentation
11
+ * purposes) but are **NEVER enforced** at write time. `INSERT`/`UPDATE`
12
+ * statements that violate a declared FK or UNIQUE constraint will succeed
13
+ * silently. Do not rely on Redshift to guarantee referential integrity or
14
+ * uniqueness — enforce that in application code. See the inline comments
15
+ * on `getColumnDefinitionSql`, `buildConstraintSql`, `addForeignKey`,
16
+ * `createConstraint` below for where this shows up.
17
+ *
18
+ * 2. There are no traditional B-tree secondary indexes. Instead, performance
19
+ * is governed by table-level `DISTSTYLE`/`DISTKEY` (how rows are
20
+ * distributed across compute node slices) and `SORTKEY` (how rows are
21
+ * physically ordered on disk, either `COMPOUND` or `INTERLEAVED`). These
22
+ * are specified via `RedshiftTableOptions` on `createTable` and emitted
23
+ * directly in the `CREATE TABLE` DDL. Methods that would create a
24
+ * traditional index (`addIndex`, `createIndex`, `createPartialIndex`, ...)
25
+ * throw a clear error pointing callers at DISTKEY/SORTKEY instead.
26
+ *
27
+ * Other notable differences from the Postgres dialect:
28
+ * - Default port is 5439 (not 5432).
29
+ * - No native JSON/JSONB type before Redshift's semi-structured `SUPER` type;
30
+ * `getDataTypeSql` maps both `JSON` and `JSONB` DataTypes to `SUPER`.
31
+ * - Auto-increment columns use `IDENTITY(seed, step)` rather than
32
+ * `SERIAL`/`BIGSERIAL`.
33
+ * - `MERGE` is only available in Redshift starting ~2023 and `ON CONFLICT`
34
+ * has never been supported, so `buildUpsertQuery` does NOT generate
35
+ * `INSERT ... ON CONFLICT DO UPDATE` (that would simply fail against a real
36
+ * cluster prior to MERGE support, and is not portable). Instead it
37
+ * generates AWS's own documented staging-table + `DELETE` + `INSERT`
38
+ * pattern. See the comment on `buildUpsertQuery` for the full rationale.
39
+ * - Bulk loads are normally done via `COPY FROM S3` rather than row-by-row
40
+ * `INSERT`. `copyFromS3()` is added as an extra (non-`Dialect`-interface)
41
+ * method for that; ordinary `bulkInsert`/`buildInsertQuery` still work via
42
+ * plain multi-row `INSERT` for compatibility with the rest of the ORM.
43
+ * - No triggers, no sequences (`CREATE SEQUENCE`/`nextval`), no row-level
44
+ * security policies, and no foreign-data-wrapper support (Redshift uses
45
+ * Redshift Spectrum's `CREATE EXTERNAL SCHEMA` for federated/external data
46
+ * instead). All of these throw a clear, explanatory `Error`.
47
+ * - Redshift *does* support views, materialized views (with optional
48
+ * `AUTO REFRESH`), and a limited form of stored procedures
49
+ * (`CREATE OR REPLACE PROCEDURE ... LANGUAGE plpgsql`), so those are
50
+ * implemented much like Postgres.
51
+ */
52
+ import type { Pool, PoolClient } from 'pg';
53
+ import { Dialect, DialectOptions, ColumnDefinition, TableOptions, DropTableOptions, TableDescription, IndexOptions, IndexDefinition, InsertOptions, UpdateOptions as DUpdateOptions, DeleteOptions, SelectOptions, UpsertQueryOptions, CreateExtensionOptions, DropExtensionOptions, ExtensionInfo, FdwForeignServerOptions, FdwAlterForeignServerOptions, FdwUserMappingOptions, FdwForeignTableOptions, FdwImportForeignSchemaOptions, ConstraintDefinition, DropConstraintOptions, DropIndexOptions, ViewOptions, DropViewOptions, DropSchemaOptions, MaterializedViewOptions, RefreshOptions, DropMaterializedViewOptions } from '../dialect';
54
+ import { Transaction, TransactionOptions, QueryResult, QueryOptions, DataType, WhereOptions, Order, CreatePartitionOptions, AttachPartitionOptions, DetachPartitionOptions, StoredProcedureOptions, DropStoredProcedureOptions, ExecuteStoredProcedureOptions, TriggerOptions, DropTriggerOptions, SequenceOptions, DropSequenceOptions, PolicyOptions, DropPolicyOptions, StreamOptions } from '../../types';
55
+ import { Readable } from 'stream';
56
+ /**
57
+ * Redshift-specific extensions to `TableOptions` for the `DISTSTYLE` /
58
+ * `DISTKEY` / `SORTKEY` table-level performance clauses that replace
59
+ * traditional B-tree indexes in Redshift.
60
+ */
61
+ export interface RedshiftTableOptions {
62
+ /**
63
+ * Distribution style. `KEY` requires `distKey` to also be set. Defaults to
64
+ * Redshift's own default (`AUTO`) when omitted.
65
+ */
66
+ diststyle?: 'EVEN' | 'KEY' | 'ALL' | 'AUTO';
67
+ /** Column used to distribute rows across slices when diststyle is 'KEY'. */
68
+ distKey?: string;
69
+ /** Column(s) used to physically order rows on disk. */
70
+ sortKey?: string | string[];
71
+ /** Sort key algorithm. Defaults to COMPOUND (Redshift's own default) when a sortKey is given. */
72
+ sortkeyType?: 'COMPOUND' | 'INTERLEAVED';
73
+ }
74
+ /**
75
+ * Redshift-specific extensions to `MaterializedViewOptions`.
76
+ *
77
+ * Redshift materialized views support several clauses beyond the plain
78
+ * boolean `AUTO REFRESH YES` this dialect originally emitted:
79
+ * - `BACKUP NO` opts the view's data out of automated cluster snapshots
80
+ * (commonly used for views cheap to rebuild, to save snapshot storage/time).
81
+ * - `DISTKEY`/`SORTKEY`/`DISTSTYLE` on the materialized view itself, exactly
82
+ * like `RedshiftTableOptions` on `createTable`.
83
+ */
84
+ export interface RedshiftMaterializedViewOptions {
85
+ /** Whether AUTO REFRESH is enabled at creation time. */
86
+ autoRefresh?: boolean;
87
+ /** Set to `false` to emit `BACKUP NO`, excluding the view's data from automated cluster snapshots. Defaults to Redshift's own default (BACKUP YES) when omitted. */
88
+ backup?: boolean;
89
+ /** Distribution style for the materialized view's underlying result table. */
90
+ diststyle?: 'EVEN' | 'KEY' | 'ALL' | 'AUTO';
91
+ /** Column used to distribute rows when diststyle is 'KEY'. */
92
+ distKey?: string;
93
+ /** Column(s) used to physically order rows on disk. */
94
+ sortKey?: string | string[];
95
+ /** Sort key algorithm. Defaults to COMPOUND when a sortKey is given. */
96
+ sortkeyType?: 'COMPOUND' | 'INTERLEAVED';
97
+ }
98
+ /**
99
+ * Redshift-specific extension to `ColumnDefinition` adding column-level
100
+ * compression `ENCODE` types (e.g. `AZ64`, `ZSTD`, `LZO`, `BYTEDICT`,
101
+ * `RUNLENGTH`, `DELTA`, `RAW`, ...). This is a first-class, perf-critical
102
+ * Redshift DDL feature and a natural sibling to `RedshiftTableOptions`'s
103
+ * `distKey`/`sortKey`. Emitted in `getColumnDefinitionSql` immediately after
104
+ * the column's data type, matching Redshift's own
105
+ * `column_name data_type ENCODE encoding-type` syntax.
106
+ */
107
+ export interface RedshiftColumnDefinition {
108
+ /**
109
+ * Compression encoding for this column. Accepts any of Redshift's
110
+ * documented encoding types (`AZ64`, `ZSTD`, `LZO`, `BYTEDICT`, `DELTA`,
111
+ * `DELTA32K`, `MOSTLY8`, `MOSTLY16`, `MOSTLY32`, `RUNLENGTH`, `TEXT255`,
112
+ * `TEXT32K`, `RAW`, ...); passed through verbatim so newer encoding types
113
+ * Redshift adds in the future work without a dialect update.
114
+ */
115
+ encode?: string;
116
+ }
117
+ /**
118
+ * Options accepted by `copyFromS3` for Redshift's bulk-load `COPY` command.
119
+ */
120
+ export interface CopyFromS3Options {
121
+ /** IAM role ARN to use for the COPY (mutually exclusive with credentials). */
122
+ iamRole?: string;
123
+ /** Static AWS credentials to use for the COPY (mutually exclusive with iamRole). */
124
+ credentials?: {
125
+ accessKeyId: string;
126
+ secretAccessKey: string;
127
+ sessionToken?: string;
128
+ };
129
+ /** Source data format. Defaults to CSV. */
130
+ format?: 'CSV' | 'JSON' | 'PARQUET' | 'AVRO' | 'ORC';
131
+ /** Field delimiter for CSV/delimited data. Defaults to ','. */
132
+ delimiter?: string;
133
+ /** Path to a JSON 'jsonpaths' file, or 'auto' for JSON format. */
134
+ jsonOption?: string;
135
+ /** Number of header rows to skip (CSV). */
136
+ ignoreHeader?: number;
137
+ /** Region the S3 bucket lives in, if not the cluster's default region. */
138
+ region?: string;
139
+ /** Compression of the source files. */
140
+ compression?: 'GZIP' | 'BZIP2' | 'ZSTD';
141
+ /** Continue loading when a threshold of rows have errors. */
142
+ maxError?: number;
143
+ /** Additional raw COPY options appended verbatim (escape hatch). */
144
+ extra?: string;
145
+ }
146
+ /**
147
+ * Options accepted by `unloadToS3` for Redshift's bulk-export `UNLOAD`
148
+ * command — the write-side counterpart to `copyFromS3`.
149
+ */
150
+ export interface UnloadOptions {
151
+ /** IAM role ARN to use for the UNLOAD (mutually exclusive with credentials). */
152
+ iamRole?: string;
153
+ /** Static AWS credentials to use for the UNLOAD (mutually exclusive with iamRole). */
154
+ credentials?: {
155
+ accessKeyId: string;
156
+ secretAccessKey: string;
157
+ sessionToken?: string;
158
+ };
159
+ /** Output file format. Defaults to plain delimited text (Redshift's UNLOAD default) when omitted. */
160
+ format?: 'PARQUET' | 'CSV' | 'JSON';
161
+ /** Field delimiter for delimited text output. Ignored for PARQUET/JSON. */
162
+ delimiter?: string;
163
+ /** Split output across slices in parallel (Redshift's default). Set to false to force a single output file (PARALLEL OFF). */
164
+ parallel?: boolean;
165
+ /** Compress the output files. */
166
+ compression?: 'GZIP' | 'BZIP2' | 'ZSTD';
167
+ /** Maximum size of each output file/part. */
168
+ maxFileSize?: string;
169
+ /** Region the destination S3 bucket lives in, if not the cluster's default region. */
170
+ region?: string;
171
+ /** Write a manifest file listing the unloaded data files. */
172
+ manifest?: boolean;
173
+ /** Overwrite existing files at the destination prefix. */
174
+ allowOverwrite?: boolean;
175
+ /** Add a header row with column names (CSV/text output only). */
176
+ header?: boolean;
177
+ /** Additional raw UNLOAD options appended verbatim (escape hatch). */
178
+ extra?: string;
179
+ }
180
+ /**
181
+ * Redshift-specific extensions to `UpsertQueryOptions`.
182
+ */
183
+ export interface RedshiftUpsertOptions {
184
+ /**
185
+ * Emit a native `MERGE INTO ... USING ... WHEN MATCHED / WHEN NOT MATCHED`
186
+ * statement instead of the staging-table + DELETE + INSERT workaround.
187
+ *
188
+ * Redshift only added `MERGE` support in 2023 (and it requires a reasonably
189
+ * modern maintenance track), so this is opt-in rather than the default —
190
+ * set it to `true` only when you know the target cluster supports `MERGE`.
191
+ * When `true`, the whole upsert becomes a single atomic statement, so the
192
+ * transaction-wrapping performed by `upsert()`/`bulkUpsert()` is not
193
+ * strictly required for atomicity (though it's still applied for a
194
+ * consistent calling convention).
195
+ */
196
+ useMerge?: boolean;
197
+ /**
198
+ * Columns to SET on `WHEN MATCHED THEN UPDATE`, when `useMerge` is used.
199
+ * Defaults to all non-conflict columns (mirrors `updateOnDuplicate`).
200
+ */
201
+ updateColumns?: string[];
202
+ }
203
+ /**
204
+ * Redshift-specific extensions to `TransactionOptions`.
205
+ *
206
+ * Redshift only supports two isolation levels via `BEGIN`/`SET TRANSACTION`:
207
+ * READ COMMITTED (the default) and SERIALIZABLE. The ANSI READ
208
+ * UNCOMMITTED/REPEATABLE READ levels have no equivalent and are rejected.
209
+ */
210
+ export interface RedshiftTransactionOptions extends TransactionOptions {
211
+ /** Mark the transaction READ ONLY (true) or explicitly READ WRITE (false). */
212
+ readOnly?: boolean;
213
+ }
214
+ /**
215
+ * Options accepted by `vacuum()`.
216
+ */
217
+ export interface RedshiftVacuumOptions {
218
+ /**
219
+ * Which vacuum operation to run. Defaults to a full `VACUUM` (resorts and
220
+ * reclaims space). `SORT ONLY` re-sorts rows without reclaiming space,
221
+ * `DELETE ONLY` reclaims space from deleted rows without re-sorting, and
222
+ * `REINDEX` additionally rebuilds interleaved sort key indexes before
223
+ * doing a full vacuum.
224
+ */
225
+ mode?: 'FULL' | 'SORT ONLY' | 'DELETE ONLY' | 'REINDEX';
226
+ /** Vacuum to at least this percent sorted before stopping (1-100). */
227
+ toPercent?: number;
228
+ /** Boost the priority of the vacuum operation. */
229
+ boost?: boolean;
230
+ }
231
+ /**
232
+ * Options accepted by `analyze()`.
233
+ */
234
+ export interface RedshiftAnalyzeOptions {
235
+ /** Only analyze these columns (mutually exclusive with `predicateColumns`). */
236
+ columns?: string[];
237
+ /** Restrict ANALYZE to columns that have been used as predicates. */
238
+ predicateColumns?: boolean;
239
+ }
240
+ /**
241
+ * Options accepted by `createDatashare()`.
242
+ *
243
+ * NOTE: unlike most Redshift `CREATE ...` statements, `CREATE DATASHARE`
244
+ * does NOT support an `IF NOT EXISTS` clause (verified against the AWS
245
+ * documentation) - creating a datashare that already exists is a plain
246
+ * error. There is therefore no `ifNotExists` option here.
247
+ */
248
+ export interface CreateDatashareOptions {
249
+ /**
250
+ * Emits `SET PUBLICACCESSIBLE TRUE|FALSE`, controlling whether the
251
+ * datashare can be shared to publicly-accessible consumer clusters.
252
+ * Redshift's own default (when omitted) is `FALSE`.
253
+ */
254
+ publiclyAccessible?: boolean;
255
+ }
256
+ /**
257
+ * Consumer/target of `GRANT USAGE ON DATASHARE ... TO ...`.
258
+ *
259
+ * Redshift's `GRANT USAGE ON DATASHARE` grants either to a namespace GUID
260
+ * within the same account (`TO NAMESPACE 'guid'`) or to a whole other AWS
261
+ * account (`TO ACCOUNT 'accountnumber' [VIA DATA CATALOG]`) - never to an
262
+ * individual database user/role. `viaDataCatalog` is only meaningful (and
263
+ * only emitted) alongside `account`.
264
+ */
265
+ export type DatashareGrantTarget = {
266
+ account: string;
267
+ viaDataCatalog?: boolean;
268
+ } | {
269
+ namespace: string;
270
+ };
271
+ /**
272
+ * Options accepted by `createDatabaseFromDatashare()`.
273
+ */
274
+ export interface CreateDatabaseFromDatashareOptions {
275
+ /**
276
+ * Producer AWS account ID owning the datashare's namespace. Required for
277
+ * cross-account data sharing; omit it for same-account sharing (only
278
+ * `NAMESPACE` is then required, per AWS docs).
279
+ */
280
+ account?: string;
281
+ /**
282
+ * Emits `WITH PERMISSIONS`, requiring consumer-side grantees to be given
283
+ * object-level permissions individually rather than automatically getting
284
+ * access to every object in the database via a single `USAGE` grant.
285
+ */
286
+ withPermissions?: boolean;
287
+ }
288
+ /**
289
+ * Options accepted by `createExternalSchemaFederated()` for Redshift
290
+ * federated queries against a *live* Amazon RDS/Aurora PostgreSQL or MySQL
291
+ * database - as opposed to Redshift Spectrum's `CREATE EXTERNAL SCHEMA ...
292
+ * FROM DATA CATALOG/HIVE METASTORE`, which reads static files from S3
293
+ * through an external data catalog. Federated query connects directly to an
294
+ * OLTP database over the wire and is a distinct Redshift feature with its
295
+ * own `FROM POSTGRES` / `FROM MYSQL` syntax.
296
+ */
297
+ export interface ExternalSchemaFederatedOptions {
298
+ /** Which federated engine the target database speaks. */
299
+ engine: 'POSTGRES' | 'MYSQL';
300
+ /** Name of the database on the remote PostgreSQL/MySQL server. */
301
+ database: string;
302
+ /**
303
+ * Remote schema name (PostgreSQL only - `SCHEMA` isn't supported for
304
+ * federated queries to MySQL, which has no separate schema namespace
305
+ * beyond the database itself). Defaults to `public` on the Postgres side
306
+ * when omitted.
307
+ */
308
+ schema?: string;
309
+ /** Hostname of the RDS/Aurora endpoint (the URI clause). */
310
+ uri: string;
311
+ /** Port to connect on. Defaults to 5432 (Postgres) / 3306 (MySQL) when omitted. */
312
+ port?: number;
313
+ /** IAM role ARN (or `'default'`) Redshift assumes to read the Secrets Manager secret. */
314
+ iamRole: string;
315
+ /** ARN of the AWS Secrets Manager secret holding the remote database credentials. */
316
+ secretArn: string;
317
+ /** Emits `IF NOT EXISTS` after `CREATE EXTERNAL SCHEMA`. */
318
+ ifNotExists?: boolean;
319
+ }
320
+ /**
321
+ * Amazon Redshift dialect class implementing the Dialect interface.
322
+ *
323
+ * See the module-level doc comment above for the two biggest Postgres ->
324
+ * Redshift surprises: unenforced FK/UNIQUE constraints, and DISTKEY/SORTKEY
325
+ * replacing B-tree indexes.
326
+ */
327
+ export declare class RedshiftDialect implements Dialect {
328
+ readonly name = "redshift";
329
+ readonly library = "pg";
330
+ private pool;
331
+ private _isConnected;
332
+ private config;
333
+ private transactionDepth;
334
+ constructor(config: RedshiftDialectOptions);
335
+ connect(): Promise<void>;
336
+ disconnect(): Promise<void>;
337
+ getConnection(): Pool | null;
338
+ isConnected(): boolean;
339
+ /**
340
+ * Stream query results by paging through `sql` via repeated
341
+ * dialect-appropriate LIMIT/OFFSET queries (see
342
+ * `createPaginatedQueryStream()` in `src/dialects/query-stream-helper.ts`)
343
+ * instead of loading the whole result set into memory at once.
344
+ * @param sql - The SELECT statement to stream
345
+ * @param options - Streaming options (batch size, backpressure watermark, model mapping)
346
+ */
347
+ queryStream(sql: string, options?: StreamOptions): Readable;
348
+ query(sql: string, options?: QueryOptions): Promise<QueryResult>;
349
+ private executeWithRetry;
350
+ escape(value: unknown): string;
351
+ private escapeString;
352
+ private formatDate;
353
+ escapeId(identifier: unknown): string;
354
+ quoteIdentifier(identifier: string): string;
355
+ quoteTable(tableName: string, schema?: string): string;
356
+ getDatabaseVersion(): Promise<string>;
357
+ createSchema(schema: string): Promise<void>;
358
+ dropSchema(schema: string, options?: DropSchemaOptions): Promise<void>;
359
+ showAllSchemas(): Promise<string[]>;
360
+ listSchemas(): Promise<string[]>;
361
+ createDatabaseSQL(options: {
362
+ name: string;
363
+ }): string;
364
+ dropDatabaseSQL(name: string): string;
365
+ createSavepointSQL(name?: string): string;
366
+ releaseSavepointSQL(name: string): string;
367
+ rollbackToSavepointSQL(name: string): string;
368
+ createExtension(_extensionName: string, _options?: CreateExtensionOptions): Promise<void>;
369
+ dropExtension(_extensionName: string, _options?: DropExtensionOptions): Promise<void>;
370
+ getExtensions(): Promise<ExtensionInfo[]>;
371
+ hasExtension(_extensionName: string): Promise<boolean>;
372
+ /**
373
+ * Create a table.
374
+ *
375
+ * Emits Redshift's DISTSTYLE/DISTKEY/SORTKEY table-level clauses (the
376
+ * replacement for traditional B-tree indexes) when present on `options`.
377
+ *
378
+ * FOREIGN KEY / UNIQUE / PRIMARY KEY constraints given via `options.constraints`
379
+ * are still emitted as DDL — Redshift's parser accepts the syntax and stores
380
+ * it in the catalog for the query planner and for documentation/ERD tooling
381
+ * — but NONE of them are enforced at write time. Do not rely on this DDL for
382
+ * actual data integrity guarantees.
383
+ */
384
+ createTable(tableName: string, columns: Record<string, ColumnDefinition>, options?: TableOptions & RedshiftTableOptions): Promise<void>;
385
+ /**
386
+ * Build constraint SQL for table creation.
387
+ *
388
+ * NOTE: Redshift accepts PRIMARY KEY / UNIQUE / FOREIGN KEY DDL but never
389
+ * enforces any of it. CHECK constraints are not supported at all by
390
+ * Redshift and will throw.
391
+ */
392
+ private buildConstraintSql;
393
+ /**
394
+ * Generate column definition SQL.
395
+ *
396
+ * Auto-increment columns use Redshift's `IDENTITY(seed, step)` clause
397
+ * instead of Postgres's `SERIAL`/`BIGSERIAL` (Redshift has no SERIAL type
398
+ * and no sequence objects backing it).
399
+ *
400
+ * Also emits Redshift's column-level `ENCODE <type>` compression clause
401
+ * (e.g. `ENCODE AZ64`, `ENCODE ZSTD`, `ENCODE BYTEDICT`, ...) immediately
402
+ * after the data type when `definition.encode` (see `RedshiftColumnDefinition`)
403
+ * is set. This is a perf-critical, Redshift-specific storage option with no
404
+ * Postgres equivalent.
405
+ */
406
+ private getColumnDefinitionSql;
407
+ private getDefaultValue;
408
+ dropTable(tableName: string, options?: DropTableOptions): Promise<void>;
409
+ createPartitionedTable(): Promise<void>;
410
+ createPartition(_options: CreatePartitionOptions): Promise<void>;
411
+ attachPartition(_options: AttachPartitionOptions): Promise<void>;
412
+ detachPartition(_options: DetachPartitionOptions): Promise<void>;
413
+ dropPartition(_partitionName: string, _options?: {
414
+ ifExists?: boolean;
415
+ cascade?: boolean;
416
+ }): Promise<void>;
417
+ createView(viewName: string, query: string, options?: ViewOptions): Promise<void>;
418
+ dropView(viewName: string, options?: DropViewOptions): Promise<void>;
419
+ showViews(): Promise<string[]>;
420
+ createMaterializedView(options: MaterializedViewOptions & RedshiftMaterializedViewOptions): Promise<void>;
421
+ refreshMaterializedView(viewName: string, _options?: RefreshOptions): Promise<void>;
422
+ /**
423
+ * Toggle Redshift's `AUTO REFRESH` mode on an existing materialized view
424
+ * after creation, via `ALTER MATERIALIZED VIEW ... AUTO REFRESH YES|NO`.
425
+ * This is distinct from `refreshMaterializedView`, which performs a single
426
+ * manual blocking refresh; this method instead changes whether Redshift
427
+ * automatically re-refreshes the view in the background going forward.
428
+ */
429
+ setMaterializedViewAutoRefresh(viewName: string, autoRefresh: boolean): Promise<void>;
430
+ dropMaterializedView(viewName: string, options?: DropMaterializedViewOptions): Promise<void>;
431
+ hasMaterializedView(viewName: string): Promise<boolean>;
432
+ showMaterializedViews(): Promise<string[]>;
433
+ addColumn(tableName: string, columnName: string, definition: ColumnDefinition): Promise<void>;
434
+ removeColumn(tableName: string, columnName: string): Promise<void>;
435
+ /**
436
+ * Change a column's type. Note: Redshift's ALTER COLUMN TYPE support is far
437
+ * more limited than Postgres's — it generally only allows widening VARCHAR
438
+ * lengths and a handful of numeric-type widenings, not arbitrary type
439
+ * changes. The SQL is still emitted here; Redshift itself will reject
440
+ * unsupported conversions.
441
+ */
442
+ changeColumn(tableName: string, columnName: string, definition: ColumnDefinition): Promise<void>;
443
+ renameColumn(tableName: string, oldColumnName: string, newColumnName: string): Promise<void>;
444
+ /**
445
+ * Add a foreign key to a table.
446
+ *
447
+ * IMPORTANT: Redshift accepts this DDL and records it in the catalog, but
448
+ * NEVER enforces it. Inserts/updates that violate the relationship will
449
+ * succeed. See class doc comment.
450
+ */
451
+ addForeignKey(tableName: string, columnName: string, referencedTableName: string, referencedColumnName: string, options?: {
452
+ name?: string;
453
+ }): Promise<void>;
454
+ bulkInsert(tableName: string, records: Record<string, any>[], _options?: any): Promise<QueryResult>;
455
+ /**
456
+ * Bulk-load data into a table from Amazon S3 using Redshift's `COPY`
457
+ * command. This is NOT part of the `Dialect` interface (it's Redshift-
458
+ * specific) — it's an addition on top of the standard CRUD surface, which
459
+ * still works via plain `INSERT` through `bulkInsert`/`buildInsertQuery`.
460
+ *
461
+ * Authentication is via either an IAM role ARN (recommended) or static
462
+ * credentials — exactly one of `options.iamRole` / `options.credentials`
463
+ * must be supplied.
464
+ */
465
+ copyFromS3(tableName: string, s3Path: string, options?: CopyFromS3Options): Promise<QueryResult>;
466
+ /**
467
+ * Bulk-export the result of a query to Amazon S3 using Redshift's `UNLOAD`
468
+ * command — the write-side counterpart to `copyFromS3`. Like `copyFromS3`,
469
+ * this is NOT part of the `Dialect` interface (it's Redshift-specific).
470
+ *
471
+ * Authentication is via either an IAM role ARN (recommended) or static
472
+ * credentials — exactly one of `options.iamRole` / `options.credentials`
473
+ * must be supplied.
474
+ *
475
+ * Builds: `UNLOAD ('<query>') TO 's3://...' IAM_ROLE '...' [FORMAT AS
476
+ * PARQUET|CSV|JSON] [DELIMITER ...] [PARALLEL ON|OFF] [MANIFEST] ...`
477
+ */
478
+ unloadToS3(query: string, s3Path: string, options?: UnloadOptions): Promise<QueryResult>;
479
+ /**
480
+ * `CREATE DATASHARE datashare_name [SET PUBLICACCESSIBLE TRUE|FALSE]`
481
+ *
482
+ * Creates a new datashare in the current database, owned by the issuing
483
+ * user. Adding objects to it is a separate step - see
484
+ * `alterDatashareAddSchema`/`alterDatashareAddTable`.
485
+ */
486
+ createDatashare(name: string, options?: CreateDatashareOptions): Promise<QueryResult>;
487
+ /**
488
+ * `DROP DATASHARE datashare_name`
489
+ *
490
+ * Irreversible. Only a superuser or the datashare owner can run this.
491
+ */
492
+ dropDatashare(name: string): Promise<QueryResult>;
493
+ /**
494
+ * `ALTER DATASHARE datashare_name ADD SCHEMA schema`
495
+ *
496
+ * Adding a schema does NOT add the objects inside it - each table still
497
+ * needs to be added explicitly via `alterDatashareAddTable`.
498
+ */
499
+ alterDatashareAddSchema(datashareName: string, schemaName: string): Promise<QueryResult>;
500
+ /**
501
+ * `ALTER DATASHARE datashare_name ADD TABLE schema.table`
502
+ *
503
+ * The schema must already have been added to the datashare (via
504
+ * `alterDatashareAddSchema`) before tables within it can be added.
505
+ */
506
+ alterDatashareAddTable(datashareName: string, schemaName: string, tableName: string): Promise<QueryResult>;
507
+ /**
508
+ * `GRANT USAGE ON DATASHARE datashare_name TO NAMESPACE 'guid' | ACCOUNT 'accountnumber' [VIA DATA CATALOG]`
509
+ *
510
+ * Grants a consumer (another namespace in the same account, or an entire
511
+ * other AWS account) read-only access to the datashare. The caller must
512
+ * already have been granted the `SHARE` permission on the datashare (via
513
+ * `GRANT SHARE ON DATASHARE ... TO ...`) unless they're the owner/superuser.
514
+ */
515
+ grantDatashareUsage(datashareName: string, target: DatashareGrantTarget): Promise<QueryResult>;
516
+ /**
517
+ * Consumer-side: `CREATE DATABASE db_name [WITH PERMISSIONS] FROM DATASHARE
518
+ * datashare_name OF [ACCOUNT account_id] NAMESPACE namespace_guid`
519
+ *
520
+ * Creates a local database backed by a datashare a producer has granted
521
+ * this cluster/namespace `USAGE` on. Only one consumer database can be
522
+ * created per datashare on a given cluster.
523
+ */
524
+ createDatabaseFromDatashare(dbName: string, datashareName: string, fromNamespace: string, options?: CreateDatabaseFromDatashareOptions): Promise<QueryResult>;
525
+ /**
526
+ * `CREATE EXTERNAL SCHEMA [IF NOT EXISTS] schema_name FROM POSTGRES|MYSQL
527
+ * DATABASE 'db' [SCHEMA 'schema'] URI 'host' [PORT n] IAM_ROLE 'role'
528
+ * SECRET_ARN 'arn'`
529
+ *
530
+ * `options.schema` is only valid (and only emitted) for `POSTGRES` -
531
+ * Redshift federated queries to MySQL don't support a separate schema
532
+ * namespace.
533
+ */
534
+ createExternalSchemaFederated(schemaName: string, options: ExternalSchemaFederatedOptions): Promise<QueryResult>;
535
+ showTables(): Promise<string[]>;
536
+ /**
537
+ * Show constraints for a table. Remember: any FK/UNIQUE/PK rows returned
538
+ * here describe DECLARED, not ENFORCED, constraints in Redshift.
539
+ */
540
+ showConstraints(tableName: string): Promise<any[]>;
541
+ /**
542
+ * Add a constraint. NOTE: Redshift accepts PRIMARY KEY/UNIQUE/FOREIGN KEY
543
+ * here but never enforces them (see class doc comment). CHECK constraints
544
+ * are rejected outright since Redshift has no CHECK constraint support.
545
+ */
546
+ addConstraint(tableName: string, options: {
547
+ type: 'UNIQUE' | 'CHECK' | 'PRIMARY KEY' | 'FOREIGN KEY';
548
+ fields: string[];
549
+ name?: string;
550
+ references?: {
551
+ table: string;
552
+ fields: string[];
553
+ };
554
+ check?: string;
555
+ }): Promise<void>;
556
+ removeConstraint(tableName: string, constraintName: string): Promise<void>;
557
+ createConstraint(tableName: string, constraintDef: ConstraintDefinition): Promise<void>;
558
+ dropConstraint(tableName: string, constraintName: string, options?: DropConstraintOptions): Promise<void>;
559
+ describeTable(tableName: string): Promise<TableDescription>;
560
+ renameTable(oldName: string, newName: string): Promise<void>;
561
+ changeOwner(newOwner: string, tableName: string): Promise<void>;
562
+ private noIndexSupport;
563
+ showIndexes(_tableName: string): Promise<any[]>;
564
+ addIndex(_tableName: string, _indexName: string, _fields?: string[], _options?: IndexOptions): Promise<void>;
565
+ removeIndex(_tableName: string, _indexName: string): Promise<void>;
566
+ createIndex(_tableName: string, _indexDef: IndexDefinition): Promise<void>;
567
+ dropIndex(_tableName: string, _indexName: string, _options?: DropIndexOptions): Promise<void>;
568
+ createFulltextIndex(): Promise<void>;
569
+ createSpatialIndex(): Promise<void>;
570
+ createPartialIndex(): Promise<void>;
571
+ createExpressionIndex(): Promise<void>;
572
+ private noFdwSupport;
573
+ createForeignDataWrapper(): Promise<void>;
574
+ dropForeignDataWrapper(): Promise<void>;
575
+ createForeignServer(): Promise<void>;
576
+ dropForeignServer(): Promise<void>;
577
+ createForeignTable(): Promise<void>;
578
+ buildCreateServerQuery(_name: string, _opts: FdwForeignServerOptions): string;
579
+ buildAlterServerQuery(_name: string, _opts: FdwAlterForeignServerOptions): string;
580
+ buildDropServerQuery(_name: string, _opts?: {
581
+ ifExists?: boolean;
582
+ cascade?: boolean;
583
+ }): string;
584
+ buildCreateUserMappingQuery(_opts: FdwUserMappingOptions): string;
585
+ buildAlterUserMappingQuery(_opts: FdwUserMappingOptions): string;
586
+ buildDropUserMappingQuery(_serverName: string, _user: string, _opts?: {
587
+ ifExists?: boolean;
588
+ }): string;
589
+ createUserMapping(): Promise<void>;
590
+ dropUserMapping(): Promise<void>;
591
+ buildCreateForeignTableQuery(_tableName: string, _opts: FdwForeignTableOptions): string;
592
+ buildDropForeignTableQuery(_tableName: string, _opts?: {
593
+ ifExists?: boolean;
594
+ cascade?: boolean;
595
+ }): string;
596
+ buildImportForeignSchemaQuery(_remoteSchema: string, _serverName: string, _opts?: FdwImportForeignSchemaOptions): string;
597
+ getServersQuery(): string;
598
+ createSecurityPolicy(): Promise<void>;
599
+ dropSecurityPolicy(): Promise<void>;
600
+ createPolicy(_options: PolicyOptions): Promise<void>;
601
+ dropPolicy(_policyName: string, _tableName: string, _options?: DropPolicyOptions): Promise<void>;
602
+ enableRLS(): Promise<void>;
603
+ disableRLS(): Promise<void>;
604
+ hasPolicy(): Promise<boolean>;
605
+ private noSequenceSupport;
606
+ createSequence(_options: SequenceOptions): Promise<void>;
607
+ dropSequence(_sequenceName: string, _options?: DropSequenceOptions): Promise<void>;
608
+ nextSequenceValue(_sequenceName: string): Promise<number>;
609
+ hasSequence(_sequenceName: string): Promise<boolean>;
610
+ listSequences(): Promise<string[]>;
611
+ createTrigger(_options: TriggerOptions): Promise<void>;
612
+ dropTrigger(_triggerName: string, _tableName: string, _options?: DropTriggerOptions): Promise<void>;
613
+ hasTrigger(): Promise<boolean>;
614
+ createIdentityColumn(): Promise<void>;
615
+ createComputedColumn(): Promise<void>;
616
+ commentTable(tableName: string, comment: string): Promise<void>;
617
+ commentColumn(tableName: string, columnName: string, comment: string): Promise<void>;
618
+ createStoredProcedure(options: StoredProcedureOptions): Promise<void>;
619
+ createProcedure(options: StoredProcedureOptions): Promise<void>;
620
+ dropStoredProcedure(procedureName: string, options?: DropStoredProcedureOptions): Promise<void>;
621
+ dropProcedure(procedureName: string, options?: DropStoredProcedureOptions): Promise<void>;
622
+ executeStoredProcedure(options: ExecuteStoredProcedureOptions): Promise<QueryResult>;
623
+ hasStoredProcedure(procedureName: string, schema?: string): Promise<boolean>;
624
+ /**
625
+ * Run Redshift's `VACUUM` maintenance command, which resorts rows within
626
+ * sort key order and reclaims space from deleted rows. Neither of these
627
+ * happen automatically the way Postgres's autovacuum does.
628
+ *
629
+ * Builds: `VACUUM [FULL|SORT ONLY|DELETE ONLY|REINDEX] [<table>] [TO <n> PERCENT] [BOOST]`
630
+ */
631
+ vacuum(tableName?: string, options?: RedshiftVacuumOptions): Promise<QueryResult>;
632
+ /**
633
+ * Run Redshift's `ANALYZE` maintenance command to refresh planner
634
+ * statistics (or `ANALYZE COMPRESSION` to get column encoding
635
+ * recommendations). Redshift's query planner relies entirely on these
636
+ * explicitly-collected stats; there is no background stats collector like
637
+ * Postgres's autovacuum/autoanalyze.
638
+ *
639
+ * Builds: `ANALYZE [<table> [(<col>, ...)]] [PREDICATE COLUMNS]`
640
+ */
641
+ analyze(tableName?: string, options?: RedshiftAnalyzeOptions): Promise<QueryResult>;
642
+ /**
643
+ * Run Redshift's `ANALYZE COMPRESSION` command, which samples a table (or
644
+ * the whole database when `tableName` is omitted) and recommends column
645
+ * encodings. This is a separate command from `ANALYZE` in Redshift - it
646
+ * does not update planner statistics, it only reports encoding advice.
647
+ */
648
+ analyzeCompression(tableName?: string): Promise<QueryResult>;
649
+ /**
650
+ * Redshift only supports two isolation levels: READ COMMITTED (the
651
+ * default) and SERIALIZABLE. Unlike Postgres, it has no MVCC snapshot
652
+ * mode equivalent to REPEATABLE READ, and no dirty-read mode (READ
653
+ * UNCOMMITTED). Requesting either of those would silently give the caller
654
+ * a *different, unrequested* isolation guarantee if we just ignored the
655
+ * option, so both are rejected outright instead.
656
+ */
657
+ private static readonly SUPPORTED_ISOLATION_LEVELS;
658
+ private getIsolationLevelSql;
659
+ startTransaction(options?: TransactionOptions): Promise<Transaction>;
660
+ commitTransaction(transaction: Transaction): Promise<void>;
661
+ rollbackTransaction(transaction: Transaction): Promise<void>;
662
+ /**
663
+ * Get the SQL for a data type.
664
+ *
665
+ * Notably: Redshift has no native JSON/JSONB type (that only exists in
666
+ * Postgres). Both `JSON` and `JSONB` DataTypes map to Redshift's
667
+ * semi-structured `SUPER` type instead.
668
+ */
669
+ getDataTypeSql(dataType: DataType): string;
670
+ buildWhereClause(where: WhereOptions, _options?: {
671
+ replacements?: Record<string, unknown>;
672
+ }): {
673
+ sql: string;
674
+ values: unknown[];
675
+ };
676
+ buildOrderClause(order: Order, _options?: {
677
+ replacements?: Record<string, unknown>;
678
+ }): string;
679
+ buildLimitOffset(limit?: number | string, offset?: number | string): string;
680
+ buildInsertQuery(tableName: string, values: Record<string, unknown>, options?: InsertOptions): {
681
+ sql: string;
682
+ values: unknown[];
683
+ };
684
+ /**
685
+ * Generate a collision-resistant temp/staging table name.
686
+ *
687
+ * Previously this used `${tableName}_staging_${Date.now()}` — millisecond
688
+ * wall-clock time only, with no randomness. Two concurrent upserts against
689
+ * the same table within the same millisecond (realistic under load, or in
690
+ * a tight parallel batch) would produce an identical staging table name.
691
+ * A random component (via `generateShortUUID()`) makes collisions
692
+ * practically impossible even when many upserts race within the same
693
+ * millisecond, on the same connection, or across processes/hosts.
694
+ *
695
+ * Also guards against exceeding Redshift's 127-byte identifier limit by
696
+ * truncating the base table name portion if necessary.
697
+ */
698
+ private generateStagingTableName;
699
+ /**
700
+ * Build an UPSERT "query" for Redshift.
701
+ *
702
+ * Why not `ON CONFLICT ... DO UPDATE` (what the Postgres dialect uses)?
703
+ * Redshift has never supported `ON CONFLICT` — it is a Postgres 9.5+
704
+ * feature, and Redshift's SQL layer, forked from Postgres 8.0, does not
705
+ * have it. Attempting to send `ON CONFLICT` SQL to a real Redshift cluster
706
+ * fails with a syntax error.
707
+ *
708
+ * Two strategies are available:
709
+ *
710
+ * 1. (default) AWS's documented "merge by replacing existing rows"
711
+ * staging-table pattern, which works on every Redshift version:
712
+ * a. Load the new/changed row(s) into a staging table (temp table
713
+ * with the same shape as the target).
714
+ * b. `DELETE FROM target USING staging WHERE target.<key> = staging.<key>`
715
+ * to remove rows that are about to be replaced.
716
+ * c. `INSERT INTO target SELECT * FROM staging` to insert the new
717
+ * versions (and any brand new rows).
718
+ *
719
+ * 2. (opt-in via `options.useMerge`) A native `MERGE INTO ... USING ...
720
+ * WHEN MATCHED THEN UPDATE ... WHEN NOT MATCHED THEN INSERT ...`
721
+ * statement. Redshift only added `MERGE` support in 2023, so this is
722
+ * NOT the default (it would fail with a syntax error on older/still-
723
+ * common cluster versions) — set `options.useMerge: true` only when you
724
+ * know the target cluster supports it. It has the advantage of being a
725
+ * single atomic statement with no staging table required at all.
726
+ *
727
+ * IMPORTANT — atomicity: the staging-table strategy is inherently multiple
728
+ * statements (not a single parameterized `INSERT`), so the returned `sql`
729
+ * is a semicolon-separated multi-statement string. Running these
730
+ * statements one at a time through a connection pool (rather than a single
731
+ * pinned connection wrapped in `BEGIN`/`COMMIT`) risks the temp table
732
+ * created by statement 1 not being visible to later statements (temp
733
+ * tables are session-scoped), and leaves no rollback path if a
734
+ * mid-sequence statement fails. Use `upsert()` (below), which pins a
735
+ * single connection and wraps the whole sequence in an explicit
736
+ * transaction, rather than sending this string through the pooled
737
+ * `query()` method directly.
738
+ */
739
+ buildUpsertQuery(tableName: string, values: Record<string, unknown>, options?: UpsertQueryOptions & RedshiftUpsertOptions): {
740
+ sql: string;
741
+ values: unknown[];
742
+ };
743
+ /**
744
+ * Bulk variant of `buildUpsertQuery`: accepts an array of rows and builds
745
+ * ONE staging table populated with a single multi-row `INSERT`, rather
746
+ * than requiring one `buildUpsertQuery`/`upsert` call per row.
747
+ *
748
+ * This matches how the staging-table pattern is actually used in
749
+ * production Redshift pipelines — AWS documents it primarily as a *bulk*
750
+ * upsert technique (commonly fed by a `COPY` into the staging table for
751
+ * very large batches), so a single-row-only implementation undermines the
752
+ * main reason to prefer it over row-by-row `INSERT`/`UPDATE`.
753
+ *
754
+ * Not part of the `Dialect` interface (whose `buildUpsertQuery` takes a
755
+ * single `Record`) — this is a Redshift-specific addition, similar to
756
+ * `copyFromS3`.
757
+ */
758
+ buildBulkUpsertQuery(tableName: string, rows: Record<string, unknown>[], options?: UpsertQueryOptions & RedshiftUpsertOptions): {
759
+ sql: string;
760
+ values: unknown[];
761
+ };
762
+ /**
763
+ * Build a native `MERGE INTO` statement (Redshift 2023+ only). Shared by
764
+ * the single-row and bulk upsert paths — `columnsPerRow` is one entry per
765
+ * incoming row (all rows are expected to share the same column set).
766
+ */
767
+ private buildMergeStatement;
768
+ /**
769
+ * Execute a single-row upsert against Redshift, pinning ONE connection for
770
+ * the whole multi-statement sequence and wrapping it in an explicit
771
+ * `BEGIN`/`COMMIT` (`ROLLBACK` on any failure). This is the fix for the
772
+ * correctness bug in the raw `buildUpsertQuery()` string: sending that
773
+ * string's statements through the pooled `query()` method one at a time
774
+ * can land different statements on different physical connections (temp
775
+ * tables are session-scoped in Redshift, so the staging table created in
776
+ * statement 1 may not exist by the time statement 3 runs), and gives no
777
+ * atomicity/rollback if a statement mid-sequence fails.
778
+ *
779
+ * When `options.useMerge` is set, this still pins a connection and wraps
780
+ * the (single) `MERGE` statement in `BEGIN`/`COMMIT` for a consistent
781
+ * calling convention, even though a single statement is already atomic on
782
+ * its own.
783
+ */
784
+ upsert(tableName: string, values: Record<string, unknown>, options?: UpsertQueryOptions & RedshiftUpsertOptions): Promise<QueryResult>;
785
+ /**
786
+ * Bulk counterpart to `upsert()`: builds one staging-table (or `MERGE`)
787
+ * statement sequence for the whole `rows` array via `buildBulkUpsertQuery`,
788
+ * then runs it on a single pinned connection inside an explicit
789
+ * transaction, exactly like `upsert()`.
790
+ */
791
+ bulkUpsert(tableName: string, rows: Record<string, unknown>[], options?: UpsertQueryOptions & RedshiftUpsertOptions): Promise<QueryResult>;
792
+ /**
793
+ * Shared execution path for `upsert()`/`bulkUpsert()`: pins a single
794
+ * client from the pool, runs `BEGIN`, then each `;`-separated statement in
795
+ * `sql` in order (substituting `params` into only the first statement that
796
+ * needs them, i.e. the staging-table INSERT or the MERGE's USING clause),
797
+ * then `COMMIT`. Any failure triggers `ROLLBACK` before re-throwing, and
798
+ * the client is always released back to the pool.
799
+ */
800
+ private runUpsertStatements;
801
+ buildIncrementQuery(tableName: string, fields: string | string[] | Record<string, number>, where: WhereOptions, options?: {
802
+ by?: number;
803
+ }): {
804
+ sql: string;
805
+ values: unknown[];
806
+ };
807
+ buildUpdateQuery(tableName: string, values: Record<string, unknown>, where: WhereOptions, options?: DUpdateOptions): {
808
+ sql: string;
809
+ values: unknown[];
810
+ };
811
+ buildDeleteQuery(tableName: string, where: WhereOptions, options?: DeleteOptions): {
812
+ sql: string;
813
+ values: unknown[];
814
+ };
815
+ /**
816
+ * Format a single SELECT-list attribute into SQL.
817
+ *
818
+ * `options.attributes` isn't limited to plain column-name strings: the
819
+ * typed window-function builder library (`src/query-builders/functions/
820
+ * window.ts`, e.g. `rowNumber().partitionBy(...).as('rn')`) and the
821
+ * `fn()`/`col()`/`literal()`/`cast()`/`extract()` helpers in
822
+ * `src/operators.ts` all resolve to either a raw `LiteralExpression`
823
+ * (`{ __type: 'literal', sql }`) or a `[expression, alias]` tuple.
824
+ *
825
+ * Blindly calling `escapeId()` on those (as this method used to do) is
826
+ * broken: `escapeId` stringifies whatever it's given and wraps it in
827
+ * double quotes, so a tuple like `[literalExpr('ROW_NUMBER() OVER (...)'),
828
+ * 'rn']` became the identifier `"[object Object],rn"` instead of
829
+ * `ROW_NUMBER() OVER (...) AS "rn"`. This mirrors the attribute-resolution
830
+ * logic in `SqlCompiler.attributeToSqlWithAlias`/`processAttribute`
831
+ * (`src/query-builders/sql-compiler.ts`), but is implemented locally so it
832
+ * always renders identifiers via this dialect's own `escapeId`.
833
+ */
834
+ private formatSelectAttribute;
835
+ /**
836
+ * Build a `WITH [RECURSIVE] name [(cols)] AS (query), ...` prefix from
837
+ * `options.cte`.
838
+ *
839
+ * Each entry's `query` may be a raw SQL string, or a nested `SelectOptions`
840
+ * object (compiled recursively via `buildSelectQuery`); nested `SelectOptions`
841
+ * CTE bodies never carry positional parameter values of their own in this
842
+ * dialect - callers needing bound values in a CTE body should pass a raw
843
+ * SQL string with the values already inlined/escaped, or use `Literal`.
844
+ *
845
+ * If any entry sets `recursive: true`, the WHOLE clause is emitted as
846
+ * `WITH RECURSIVE` - Redshift, like Postgres and most other engines,
847
+ * applies `RECURSIVE` to the entire `WITH` clause rather than per-CTE.
848
+ *
849
+ * NOTE on version support: Amazon Redshift only added `WITH RECURSIVE`
850
+ * support relatively recently (RA3 node types on a sufficiently current
851
+ * maintenance track); clusters on older node types/tracks will reject
852
+ * `WITH RECURSIVE` with a syntax error even though plain (non-recursive)
853
+ * `WITH` CTEs have always been supported. This method does not attempt to
854
+ * detect the cluster's capabilities - it emits `WITH RECURSIVE` whenever
855
+ * asked and leaves it to the caller to know their cluster supports it.
856
+ */
857
+ private buildCteClause;
858
+ buildSelectQuery(options: SelectOptions): {
859
+ sql: string;
860
+ values: unknown[];
861
+ };
862
+ replaceReplacements(sql: string, replacements?: Record<string, unknown> | unknown[]): string;
863
+ buildCreateUserQuery(username: string, options?: any): string;
864
+ buildAlterUserQuery(username: string, options: any): string;
865
+ buildDropUserQuery(username: string, options?: any): string;
866
+ getUsersQuery(): string;
867
+ createUser(username: string, options?: Record<string, any>): Promise<void>;
868
+ buildGrantQuery(_options: any): string;
869
+ buildRevokeQuery(_options: any): string;
870
+ buildShowGrantsQuery(_username: string, _host?: string): string;
871
+ buildFlushPrivilegesQuery(): string;
872
+ buildCreateRoleQuery(_roleName: string, _options?: any): string;
873
+ buildDropRoleQuery(_roleName: string, _options?: any): string;
874
+ buildGrantRoleQuery(_role: string, _to: any, _options?: any): string;
875
+ buildRevokeRoleQuery(_role: string, _from: any, _options?: any): string;
876
+ getRolesQuery(): string;
877
+ /**
878
+ * Build a JSON_TABLE-equivalent expression to shred a JSON array into relational rows.
879
+ * Not supported: Redshift has no `JSON_TABLE`, no `OPENJSON`, and no
880
+ * `json_to_recordset`/`jsonb_to_recordset` (it has no JSONB type at all — JSON is
881
+ * mapped to the `SUPER` type, see `getDataTypeSql`). Redshift's real answer to
882
+ * shredding nested/array `SUPER` data is `UNNEST`/implicit lateral unnest over a
883
+ * `SUPER` column already stored in a table, not a general `(json, path) => rows`
884
+ * function that can operate on an arbitrary JSON expression, so it cannot be exposed
885
+ * through this API shape.
886
+ */
887
+ buildJsonTable(_jsonExpression: string, _rowPath: string, _columns: Array<{
888
+ name: string;
889
+ type?: string;
890
+ path?: string;
891
+ forOrdinality?: boolean;
892
+ }>, _alias: string): string;
893
+ }
894
+ /**
895
+ * Transaction handle for Redshift, backed by a single pooled `pg` client.
896
+ */
897
+ export declare class RedshiftTransaction implements Transaction {
898
+ id: string;
899
+ finished: boolean;
900
+ options: TransactionOptions;
901
+ parent: Transaction | null;
902
+ savepoints: string[];
903
+ client: PoolClient | null;
904
+ private savepointCount;
905
+ constructor(client: PoolClient, _depth: number, options?: TransactionOptions);
906
+ createSavepoint(name?: string): Promise<string>;
907
+ rollbackToSavepoint(name: string): Promise<void>;
908
+ releaseSavepoint(name: string): Promise<void>;
909
+ commit(): Promise<void>;
910
+ rollback(): Promise<void>;
911
+ }
912
+ export interface RedshiftDialectOptions extends DialectOptions {
913
+ host?: string;
914
+ port?: number;
915
+ database?: string;
916
+ username?: string;
917
+ password?: string;
918
+ ssl?: any;
919
+ max?: number;
920
+ idleTimeoutMillis?: number;
921
+ connectionTimeoutMillis?: number;
922
+ statementTimeout?: number;
923
+ queryTimeout?: number;
924
+ /** Default DISTKEY to use for tables created without an explicit distKey. */
925
+ distKey?: string;
926
+ /** Default SORTKEY to use for tables created without an explicit sortKey. */
927
+ sortKey?: string | string[];
928
+ }
929
+ /**
930
+ * Create a new Redshift dialect instance.
931
+ */
932
+ export declare function createRedshiftDialect(options?: RedshiftDialectOptions): RedshiftDialect;
933
+ export default RedshiftDialect;