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.
Files changed (460) hide show
  1. package/CHANGELOG.md +83 -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 +711 -0
  239. package/dist/index.js +19 -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,660 @@
1
+ /**
2
+ * ClickHouse dialect implementation for the TypeScript ORM
3
+ *
4
+ * ClickHouse is a columnar OLAP database, not an OLTP relational database like the
5
+ * other dialects in this codebase. Several assumptions the rest of this ORM makes
6
+ * about "a SQL database" do not hold for ClickHouse, and this file tries to be
7
+ * explicit (in comments, thrown errors, and generated SQL) about where ClickHouse
8
+ * genuinely behaves differently rather than papering over the differences:
9
+ *
10
+ * - `CREATE TABLE` requires an `ENGINE = ...` clause (e.g. `MergeTree()`), and
11
+ * MergeTree-family engines require an `ORDER BY` clause - ClickHouse's sorting
12
+ * key, which stands in for a traditional single-column auto-increment primary
13
+ * key (there is no such concept here).
14
+ * - There is no enforced FOREIGN KEY, UNIQUE, or (traditionally) PRIMARY KEY
15
+ * constraint. ClickHouse will happily store duplicate "keys" - the ORDER BY
16
+ * key only controls physical sort order/merges, it does not deduplicate or
17
+ * enforce uniqueness unless combined with a ReplacingMergeTree engine and a
18
+ * subsequent (asynchronous, background) merge/`OPTIMIZE ... FINAL`.
19
+ * - There are no synchronous, transactional UPDATE/DELETE statements. ClickHouse
20
+ * supports `ALTER TABLE ... UPDATE` / `ALTER TABLE ... DELETE`, but these are
21
+ * asynchronous *mutations*: the statement returns as soon as the mutation is
22
+ * scheduled, and the actual rewrite happens in the background (progress is
23
+ * visible in `system.mutations`).
24
+ * - There is no multi-statement ACID transaction support (no BEGIN/COMMIT/
25
+ * ROLLBACK spanning multiple statements). A single INSERT is atomic at the
26
+ * block level; nothing else is. `startTransaction`/`commitTransaction`/
27
+ * `rollbackTransaction` throw a clear error rather than silently no-op-ing,
28
+ * matching how this codebase signals genuinely unsupported capabilities
29
+ * elsewhere (see MSSQL's partition methods, or the FDW/extension stubs on
30
+ * non-PostgreSQL dialects).
31
+ * - "Upsert" is not a synchronous `ON CONFLICT` / `MERGE` statement. The
32
+ * idiomatic ClickHouse pattern is: insert a new row into a
33
+ * ReplacingMergeTree(-family) table and let ClickHouse's background merges
34
+ * asynchronously drop older rows sharing the same ORDER BY key (optionally
35
+ * keeping the row with the greatest `version` column). `buildUpsertQuery()`
36
+ * therefore just emits a plain INSERT and documents this loudly instead of
37
+ * pretending to provide synchronous upsert semantics ClickHouse doesn't have.
38
+ */
39
+ import type { ClickHouseClient as CHClient } from '@clickhouse/client';
40
+ import { Dialect, DialectOptions, ColumnDefinition, TableOptions, DropTableOptions, TableDescription, IndexOptions, IndexDefinition, InsertOptions, UpdateOptions as DUpdateOptions, DeleteOptions, SelectOptions, UpsertQueryOptions, DropSchemaOptions, ViewOptions, DropViewOptions, ConstraintDefinition, DropConstraintOptions, BuildOptions, FdwForeignServerOptions, FdwAlterForeignServerOptions, FdwUserMappingOptions, FdwForeignTableOptions, FdwImportForeignSchemaOptions, ExtensionInfo } from '../dialect';
41
+ import { Transaction, TransactionOptions, QueryResult, QueryOptions, DataType, WhereOptions, Order, CreatePartitionOptions, AttachPartitionOptions, DetachPartitionOptions, StoredProcedureOptions, DropStoredProcedureOptions, ExecuteStoredProcedureOptions, StreamOptions } from '../../types';
42
+ import { Readable } from 'stream';
43
+ import { Literal } from '../../prorm';
44
+ /**
45
+ * Typed configuration for ClickHouse's MergeTree engine family, passed as
46
+ * `(options as any).mergeTreeEngine` (or the `mergeTreeEngine` field on the
47
+ * loosely-typed `TableOptions` extension this dialect already uses for
48
+ * `orderBy`/`partitionBy`/`ttl`) to `createTable()`/`createPartitionedTable()`.
49
+ *
50
+ * Each variant has genuinely different merge/aggregation semantics and a
51
+ * distinct set of required columns, which `buildMergeTreeEngineClause()`
52
+ * validates against the table's declared columns before ever reaching
53
+ * ClickHouse (rather than letting a caller discover a missing `Sign` column
54
+ * via an opaque server-side error at INSERT/merge time):
55
+ *
56
+ * - `MergeTree` / `ReplacingMergeTree`: already-supported plain engines.
57
+ * `ReplacingMergeTree` optionally takes a `version` column (keeps the row
58
+ * with the greatest value on merge) and, since v22.6, an `isDeleted`
59
+ * column (paired with `version`, for soft-delete-on-merge semantics).
60
+ * - `SummingMergeTree`: sums numeric columns (not part of the ORDER BY key)
61
+ * on merge. `columns`, if given, restricts summing to specific numeric
62
+ * columns instead of every numeric column in the table.
63
+ * - `AggregatingMergeTree`: merges rows sharing an ORDER BY key by combining
64
+ * partial aggregate states. Requires at least one `AggregateFunction(...)`
65
+ * (or `SimpleAggregateFunction(...)`) column - ClickHouse's real rollup
66
+ * mechanism, almost always paired with a materialized view.
67
+ * - `CollapsingMergeTree`: cancels out row pairs sharing an ORDER BY key via
68
+ * a `Sign Int8` column (`1` = insert the "current" state, `-1` = cancel a
69
+ * previous one). Requires that `Sign Int8` column to exist.
70
+ * - `VersionedCollapsingMergeTree`: like `CollapsingMergeTree`, but adds a
71
+ * `Version` column so out-of-order (e.g. multi-threaded) inserts of
72
+ * matching +1/-1 pairs still collapse correctly. Requires both the
73
+ * `Sign Int8` column and a numeric `Version` column.
74
+ */
75
+ export type MergeTreeEngineConfig = {
76
+ type: 'MergeTree';
77
+ } | {
78
+ type: 'ReplacingMergeTree';
79
+ version?: string;
80
+ isDeleted?: string;
81
+ } | {
82
+ type: 'SummingMergeTree';
83
+ columns?: string[];
84
+ } | {
85
+ type: 'AggregatingMergeTree';
86
+ } | {
87
+ type: 'CollapsingMergeTree';
88
+ sign: string;
89
+ } | {
90
+ type: 'VersionedCollapsingMergeTree';
91
+ sign: string;
92
+ version: string;
93
+ };
94
+ /**
95
+ * Definition of a MergeTree-family "projection": a table-scoped, ClickHouse-
96
+ * maintained alternate physical layout (its own sort order and, optionally,
97
+ * its own pre-aggregation) of a subset of a table's columns, kept in sync on
98
+ * every INSERT/merge. ClickHouse's query planner transparently substitutes a
99
+ * matching projection when it would answer a query more cheaply than the
100
+ * base table - this is ClickHouse's real mechanism for "multiple sort orders
101
+ * of the same data" / materialized rollups without a separate table.
102
+ *
103
+ * Maps onto the real SQL grammar, which uses the same projection body shape
104
+ * in both places ClickHouse accepts one:
105
+ * - inline at `CREATE TABLE` time: `PROJECTION name (SELECT ... [GROUP BY
106
+ * ...] [ORDER BY ...])`
107
+ * - `ALTER TABLE t ADD PROJECTION name (SELECT ... [GROUP BY ...]
108
+ * [ORDER BY ...])`
109
+ * `select` is the column list only (e.g. `'id, value'` or
110
+ * `'toStartOfHour(ts) AS hour, count() AS c'`) - a projection body has no
111
+ * `FROM` clause, only the column list and optional GROUP BY/ORDER BY.
112
+ */
113
+ export interface ProjectionDefinition {
114
+ /** Column list / expressions selected into the projection (no `SELECT` keyword, no `FROM`). */
115
+ select: string;
116
+ /** Optional `GROUP BY` expression(s) for a pre-aggregated (rollup) projection. */
117
+ groupBy?: string | string[];
118
+ /** Optional `ORDER BY` expression(s) - the projection's own physical sort key. */
119
+ orderBy?: string | string[];
120
+ }
121
+ /**
122
+ * ClickHouse dialect connection/behavior options.
123
+ */
124
+ export interface ClickHouseDialectOptions extends DialectOptions {
125
+ /** ClickHouse HTTP interface host. @default 'localhost' */
126
+ host?: string;
127
+ /** ClickHouse HTTP interface port. @default 8123 (ClickHouse's default HTTP port) */
128
+ port?: number;
129
+ /** 'http' or 'https'. @default 'http' */
130
+ protocol?: 'http' | 'https';
131
+ database?: string;
132
+ username?: string;
133
+ password?: string;
134
+ /**
135
+ * Default `ENGINE = ...` clause used by createTable()/createPartitionedTable()
136
+ * when `TableOptions.engine` is not supplied for a given call.
137
+ * @default 'MergeTree()'
138
+ */
139
+ engine?: string;
140
+ /**
141
+ * Default ORDER BY expression/columns used by createTable() when the caller
142
+ * doesn't specify one (via a non-standard `orderBy` field on TableOptions) and
143
+ * no column is marked `primaryKey`. ClickHouse's MergeTree-family engines
144
+ * REQUIRE an ORDER BY (their sorting key) - there is no implicit single-column
145
+ * auto-increment primary key the way OLTP databases have.
146
+ */
147
+ orderBy?: string | string[];
148
+ /** Request timeout in milliseconds, forwarded to `@clickhouse/client`. */
149
+ requestTimeout?: number;
150
+ /** Arbitrary ClickHouse session settings applied to every request. */
151
+ clickhouseSettings?: Record<string, unknown>;
152
+ }
153
+ /**
154
+ * ClickHouse dialect class that implements the Dialect interface.
155
+ *
156
+ * Uses the official `@clickhouse/client` (Promise-native) driver, talking to
157
+ * ClickHouse's HTTP interface (default port 8123).
158
+ */
159
+ export declare class ClickHouseDialect implements Dialect {
160
+ readonly name = "clickhouse";
161
+ readonly library = "@clickhouse/client";
162
+ private client;
163
+ private _isConnected;
164
+ private config;
165
+ constructor(config: ClickHouseDialectOptions);
166
+ connect(): Promise<void>;
167
+ disconnect(): Promise<void>;
168
+ getConnection(): CHClient | null;
169
+ isConnected(): boolean;
170
+ getDatabaseVersion(): Promise<string>;
171
+ /**
172
+ * Stream query results by paging through `sql` via repeated
173
+ * dialect-appropriate LIMIT/OFFSET queries (see
174
+ * `createPaginatedQueryStream()` in `src/dialects/query-stream-helper.ts`)
175
+ * instead of loading the whole result set into memory at once.
176
+ * @param sql - The SELECT statement to stream
177
+ * @param options - Streaming options (batch size, backpressure watermark, model mapping)
178
+ */
179
+ queryStream(sql: string, options?: StreamOptions): Readable;
180
+ /**
181
+ * Execute a raw SQL statement.
182
+ *
183
+ * `@clickhouse/client` exposes distinct methods for statements that return
184
+ * data (`query()`, used here for SELECT/SHOW/DESCRIBE/EXPLAIN) versus
185
+ * statements that don't (`command()`, used here for everything else - DDL,
186
+ * INSERT, and the ALTER TABLE ... UPDATE/DELETE mutations built below).
187
+ * `command()` does not return row data, so non-SELECT statements always come
188
+ * back with `rows: []`; in particular, `rowCount` after an
189
+ * `ALTER TABLE ... UPDATE/DELETE` mutation is NOT the number of rows the
190
+ * mutation will eventually touch - ClickHouse only reports that
191
+ * asynchronously via `system.mutations`.
192
+ */
193
+ query(sql: string, options?: QueryOptions): Promise<QueryResult>;
194
+ /**
195
+ * Substitute `?` (positional) or `:name` (named) placeholders with escaped
196
+ * literal values. ClickHouse's HTTP client sends a single opaque SQL string
197
+ * per request - unlike the pg/mysql2/mssql drivers used by the other
198
+ * dialects in this codebase, there is no native positional-parameter binding
199
+ * for arbitrary values and WHERE trees (ClickHouse's own `{name:Type}` query
200
+ * parameters require a separate `query_params` map and only support scalar
201
+ * substitution). So, exactly like the SQLite/PostgreSQL dialects already do
202
+ * when `options.replacements` is supplied to `query()`, this performs plain
203
+ * string substitution with escaped literals before the SQL is sent.
204
+ */
205
+ replaceReplacements(sql: string, replacements?: Record<string, unknown> | unknown[]): string;
206
+ escape(value: unknown): string;
207
+ private escapeString;
208
+ private formatDateTime;
209
+ escapeId(identifier: unknown): string;
210
+ quoteIdentifier(identifier: string): string;
211
+ quoteTable(tableName: string, schema?: string): string;
212
+ createSchema(schema: string): Promise<void>;
213
+ dropSchema(schema: string, options?: DropSchemaOptions): Promise<void>;
214
+ showAllSchemas(): Promise<string[]>;
215
+ listSchemas(): Promise<string[]>;
216
+ createDatabaseSQL(options: {
217
+ name: string;
218
+ encoding?: string;
219
+ lcCollate?: string;
220
+ lcCtype?: string;
221
+ template?: string;
222
+ tablespace?: string;
223
+ collate?: string;
224
+ isTemplate?: boolean;
225
+ }): string;
226
+ dropDatabaseSQL(name: string): string;
227
+ createSavepointSQL(_name?: string): string;
228
+ releaseSavepointSQL(_name: string): string;
229
+ rollbackToSavepointSQL(_name: string): string;
230
+ createExtension(_extensionName: string, _options?: unknown): Promise<void>;
231
+ dropExtension(_extensionName: string, _options?: unknown): Promise<void>;
232
+ getExtensions(): Promise<ExtensionInfo[]>;
233
+ hasExtension(_extensionName: string): Promise<boolean>;
234
+ /**
235
+ * Resolve the ORDER BY (sorting key) clause for a MergeTree-family table:
236
+ * an explicit `orderBy` (non-standard extension read off `options` since
237
+ * `TableOptions` doesn't declare it), else column(s) marked `primaryKey`,
238
+ * else the dialect-level default, else the first declared column, else
239
+ * `tuple()` (ClickHouse's explicit "no sorting key" spelling).
240
+ */
241
+ private resolveOrderBy;
242
+ /**
243
+ * Build a validated `ENGINE = ...` clause for one of the MergeTree-family
244
+ * engines from a typed `MergeTreeEngineConfig`, checking the distinct
245
+ * required-column rules each engine variant has (see the doc comment on
246
+ * `MergeTreeEngineConfig` above) against the table's declared columns.
247
+ * Throws a descriptive error - rather than emitting SQL ClickHouse would
248
+ * reject at CREATE TABLE or (worse) silently misbehave on at merge time -
249
+ * when a required column is missing or the wrong type.
250
+ */
251
+ private buildMergeTreeEngineClause;
252
+ /**
253
+ * Build a projection body - `name (SELECT ... [GROUP BY ...] [ORDER BY ...])`
254
+ * - shared by the inline `PROJECTION` clause in `CREATE TABLE` and
255
+ * `ALTER TABLE ... ADD PROJECTION`, since both use the exact same grammar.
256
+ */
257
+ private buildProjectionClause;
258
+ private getColumnDefinitionSql;
259
+ private getDefaultValue;
260
+ createTable(tableName: string, columns: Record<string, ColumnDefinition>, options?: TableOptions): Promise<void>;
261
+ dropTable(tableName: string, options?: DropTableOptions): Promise<void>;
262
+ createPartitionedTable(tableName: string, columns: Record<string, ColumnDefinition>, options?: TableOptions & {
263
+ partitionBy: {
264
+ type: 'range' | 'list' | 'hash';
265
+ column: string | string[];
266
+ };
267
+ partitions?: {
268
+ name: string;
269
+ }[];
270
+ }): Promise<void>;
271
+ createPartition(_options: CreatePartitionOptions): Promise<void>;
272
+ attachPartition(options: AttachPartitionOptions): Promise<void>;
273
+ detachPartition(_options: DetachPartitionOptions): Promise<void>;
274
+ dropPartition(_partitionName: string, _options?: {
275
+ ifExists?: boolean;
276
+ cascade?: boolean;
277
+ }): Promise<void>;
278
+ /** Format a partition value/expression for ATTACH/DETACH/DROP PARTITION. */
279
+ private formatPartitionExpr;
280
+ createView(viewName: string, query: string, options?: ViewOptions): Promise<void>;
281
+ /**
282
+ * `CREATE MATERIALIZED VIEW ... TO <target> AS SELECT ...` - ClickHouse's
283
+ * real materialized-view syntax. Unlike a plain (or most other databases')
284
+ * view, a ClickHouse materialized view is a push-based, insert-triggered
285
+ * transform: every time a row is INSERTed into the underlying source
286
+ * table(s) referenced by `query`'s FROM clause, ClickHouse runs `query`
287
+ * against just the newly-inserted block and appends the result into the
288
+ * `to` target table - it is NOT recomputed at read time the way a normal
289
+ * view or a re-run query would be, and it does not "backfill" existing
290
+ * rows already in the source table unless `populate: true` is given.
291
+ *
292
+ * `showViews()` already queries `system.tables` for `engine =
293
+ * 'MaterializedView'`, so this is the corresponding write-side method that
294
+ * was previously entirely missing (only plain, non-materialized
295
+ * `CREATE VIEW` existed via `createView()` above).
296
+ *
297
+ * Two real ClickHouse forms are supported:
298
+ * - `{ to: 'target_table' }`: the common, recommended form - the target
299
+ * table is created separately (with its own ENGINE/ORDER BY, e.g. an
300
+ * AggregatingMergeTree for rollups) and the materialized view just
301
+ * describes the transform feeding it.
302
+ * - Omitting `to` (with an inline `engine`/`orderBy0`): ClickHouse also
303
+ * allows a materialized view to own an implicit hidden target table
304
+ * (`CREATE MATERIALIZED VIEW ... ENGINE = ... AS SELECT ...`); provide
305
+ * `engine`/`orderBy` in that case instead of `to`.
306
+ */
307
+ createMaterializedView(viewName: string, query: string, options?: {
308
+ to?: string;
309
+ schema?: string;
310
+ engine?: string;
311
+ orderBy?: string | string[];
312
+ populate?: boolean;
313
+ ifNotExists?: boolean;
314
+ replace?: boolean;
315
+ }): Promise<void>;
316
+ dropView(viewName: string, options?: DropViewOptions): Promise<void>;
317
+ showViews(): Promise<string[]>;
318
+ /**
319
+ * Run `OPTIMIZE TABLE <t> [PARTITION ...] [FINAL] [DEDUPLICATE [BY ...]]` —
320
+ * ClickHouse's on-demand merge trigger. This is the *write-side* counterpart
321
+ * to reading with `FINAL`: it forces the background merge that collapses
322
+ * ReplacingMergeTree/CollapsingMergeTree rows to their final state so that
323
+ * ordinary (non-`FINAL`) reads see deduplicated data.
324
+ *
325
+ * Prefer this after a batch of ReplacingMergeTree "upserts" (which are plain
326
+ * INSERTs — see {@link buildUpsertQuery}) when you want subsequent reads to be
327
+ * clean without paying the per-query `FINAL` merge-on-read cost. Note
328
+ * `OPTIMIZE` is heavy and not guaranteed to merge everything in one pass on
329
+ * very large tables; `FINAL` on the read is the guaranteed-correct fallback.
330
+ *
331
+ * @param options.final - append `FINAL` (merge even a single existing part).
332
+ * @param options.deduplicate - append `DEDUPLICATE` (drop fully-identical rows).
333
+ * @param options.deduplicateBy - column list for `DEDUPLICATE BY (...)`.
334
+ * @param options.partition - restrict to a single partition (`PARTITION <expr>`).
335
+ */
336
+ optimizeTable(tableName: string, options?: {
337
+ final?: boolean;
338
+ deduplicate?: boolean;
339
+ deduplicateBy?: string[];
340
+ partition?: string;
341
+ }): Promise<void>;
342
+ /**
343
+ * `CREATE DICTIONARY <name> (attrs) PRIMARY KEY <key> SOURCE(...) LAYOUT(...)
344
+ * LIFETIME(...)` — ClickHouse's in-memory key/value lookup/enrichment object
345
+ * backed by another table, file, or HTTP/DB source. Exposed so callers get a
346
+ * typed builder instead of hand-writing the multi-clause DDL.
347
+ *
348
+ * @param options.attributes - dictionary columns (`name type`, optional default/expression).
349
+ * @param options.primaryKey - key attribute name(s).
350
+ * @param options.source - raw `SOURCE(...)` body, e.g. `CLICKHOUSE(TABLE 'users')`.
351
+ * @param options.layout - raw `LAYOUT(...)` body, e.g. `HASHED()` / `FLAT()` / `COMPLEX_KEY_HASHED()`.
352
+ * @param options.lifetime - refresh lifetime; a number => `LIFETIME(n)`, a
353
+ * `{min,max}` => `LIFETIME(MIN min MAX max)`.
354
+ */
355
+ createDictionary(name: string, options: {
356
+ attributes: Array<{
357
+ name: string;
358
+ type: string;
359
+ default?: string;
360
+ expression?: string;
361
+ }>;
362
+ primaryKey: string | string[];
363
+ source: string;
364
+ layout: string;
365
+ lifetime?: number | {
366
+ min: number;
367
+ max: number;
368
+ };
369
+ replace?: boolean;
370
+ ifNotExists?: boolean;
371
+ comment?: string;
372
+ }): Promise<void>;
373
+ dropDictionary(name: string, options?: {
374
+ ifExists?: boolean;
375
+ }): Promise<void>;
376
+ showTables(): Promise<string[]>;
377
+ addColumn(tableName: string, columnName: string, definition: ColumnDefinition): Promise<void>;
378
+ removeColumn(tableName: string, columnName: string): Promise<void>;
379
+ changeColumn(tableName: string, columnName: string, definition: ColumnDefinition): Promise<void>;
380
+ renameColumn(tableName: string, oldColumnName: string, newColumnName: string): Promise<void>;
381
+ addForeignKey(_tableName: string, _columnName: string, _referencedTableName: string, _referencedColumnName: string, _options?: any): Promise<void>;
382
+ bulkInsert(tableName: string, records: Record<string, any>[], _options?: any): Promise<QueryResult>;
383
+ showConstraints(_tableName: string): Promise<any[]>;
384
+ addConstraint(tableName: string, options: {
385
+ type: 'UNIQUE' | 'CHECK' | 'PRIMARY KEY' | 'FOREIGN KEY';
386
+ fields: string[];
387
+ name?: string;
388
+ references?: {
389
+ table: string;
390
+ fields: string[];
391
+ };
392
+ check?: string;
393
+ }): Promise<void>;
394
+ removeConstraint(tableName: string, constraintName: string): Promise<void>;
395
+ createConstraint(tableName: string, constraintDef: ConstraintDefinition): Promise<void>;
396
+ dropConstraint(tableName: string, constraintName: string, _options?: DropConstraintOptions): Promise<void>;
397
+ showIndexes(tableName: string): Promise<any[]>;
398
+ addIndex(tableName: string, indexName: string, fields?: string[], options?: IndexOptions): Promise<void>;
399
+ removeIndex(tableName: string, indexName: string): Promise<void>;
400
+ createIndex(tableName: string, indexDef: IndexDefinition): Promise<void>;
401
+ dropIndex(tableName: string, indexName: string, options?: {
402
+ ifExists?: boolean;
403
+ cascade?: boolean;
404
+ }): Promise<void>;
405
+ /**
406
+ * `ALTER TABLE table ADD PROJECTION name (SELECT ... [GROUP BY ...] [ORDER BY ...])`.
407
+ *
408
+ * Adding a projection only registers its definition; ClickHouse does not
409
+ * retroactively backfill it for existing parts. Call
410
+ * `materializeProjection()` (`ALTER TABLE ... MATERIALIZE PROJECTION`)
411
+ * afterwards to build it for data that already exists - new
412
+ * inserts/merges are kept in sync automatically from this point on
413
+ * either way.
414
+ */
415
+ addProjection(tableName: string, projectionName: string, definition: ProjectionDefinition): Promise<void>;
416
+ /**
417
+ * `ALTER TABLE table DROP PROJECTION [IF EXISTS] name`.
418
+ *
419
+ * Implemented as a mutation: removes the projection's definition from the
420
+ * table's metadata and deletes its files from disk.
421
+ */
422
+ dropProjection(tableName: string, projectionName: string, options?: {
423
+ ifExists?: boolean;
424
+ }): Promise<void>;
425
+ /**
426
+ * `ALTER TABLE table MATERIALIZE PROJECTION [IF EXISTS] name [IN PARTITION partition]`.
427
+ *
428
+ * Builds (or rebuilds) a projection for existing data. Needed after
429
+ * `addProjection()` on a table that already has rows - a freshly-added
430
+ * projection definition otherwise only applies to data inserted/merged
431
+ * after it was added.
432
+ */
433
+ materializeProjection(tableName: string, projectionName: string, options?: {
434
+ ifExists?: boolean;
435
+ partition?: string;
436
+ }): Promise<void>;
437
+ createFulltextIndex(tableName: string, indexName: string, fields: string[], _options?: {
438
+ parser?: string;
439
+ comment?: string;
440
+ }): Promise<void>;
441
+ createSpatialIndex(_tableName: string, _indexName: string, _fields: string[], _options?: {
442
+ storage?: string;
443
+ srid?: number;
444
+ }): Promise<void>;
445
+ describeTable(tableName: string): Promise<TableDescription>;
446
+ renameTable(oldName: string, newName: string): Promise<void>;
447
+ changeOwner(_newOwner: string, _tableName: string): Promise<void>;
448
+ createSecurityPolicy(policyName: string, tableName: string, options?: {
449
+ predicate?: string;
450
+ }): Promise<void>;
451
+ dropSecurityPolicy(policyName: string, tableName: string): Promise<void>;
452
+ startTransaction(_options?: TransactionOptions): Promise<Transaction>;
453
+ commitTransaction(_transaction: Transaction): Promise<void>;
454
+ rollbackTransaction(_transaction: Transaction): Promise<void>;
455
+ getDataTypeSql(dataType: DataType): string;
456
+ /**
457
+ * `uniq(column)` - ClickHouse's default approximate distinct-count
458
+ * (adaptive sampling, small constant memory, ~1-2% error). The fastest and
459
+ * least memory-hungry of the `uniq*` family; prefer this unless you need
460
+ * `uniqExact`'s precision or `uniqCombined`'s tunable accuracy/memory
461
+ * trade-off.
462
+ */
463
+ uniq(column: string, alias?: string): Literal;
464
+ /**
465
+ * `uniqCombined([precision])(column)` - approximate distinct count that
466
+ * blends an array, a hash table, and HyperLogLog depending on cardinality,
467
+ * giving better accuracy-per-byte than plain `uniq` at the cost of a bit
468
+ * more CPU. `precision` (`HLL_precision`, default 17) trades memory for
469
+ * accuracy: higher precision = more memory, lower error.
470
+ */
471
+ uniqCombined(column: string, alias?: string, precision?: number): Literal;
472
+ /** `uniqHLL12(column)` - classic HyperLogLog-based approximate distinct count. */
473
+ uniqHLL12(column: string, alias?: string): Literal;
474
+ /**
475
+ * `uniqExact(column)` - EXACT distinct count (not approximate - despite
476
+ * living in the `uniq*` family). Included here for symmetry/discoverability
477
+ * since callers reaching for `uniq*` helpers need an easy way to opt into
478
+ * exactness when cardinality is low enough that the memory/CPU cost is
479
+ * acceptable.
480
+ */
481
+ uniqExact(column: string, alias?: string): Literal;
482
+ /**
483
+ * `quantile(level)(column)` - approximate percentile/quantile estimation
484
+ * (reservoir sampling) - e.g. `quantile(0.99)(latency_ms)` for p99 latency.
485
+ * `level` must be in `[0, 1]`.
486
+ */
487
+ quantile(level: number, column: string, alias?: string): Literal;
488
+ /**
489
+ * `quantiles(level1, level2, ...)(column)` - like `quantile()`, but computes
490
+ * several quantiles in one pass (e.g. p50/p90/p99 together is cheaper than
491
+ * three separate `quantile()` calls since ClickHouse shares the sample).
492
+ * Returns an Array(Float64) column.
493
+ */
494
+ quantiles(levels: number[], column: string, alias?: string): Literal;
495
+ /**
496
+ * `quantileExact(level)(column)` - EXACT quantile (loads all values into
497
+ * memory; use for small-to-medium datasets where precision matters more
498
+ * than the approximate functions' bounded memory usage).
499
+ */
500
+ quantileExact(level: number, column: string, alias?: string): Literal;
501
+ /**
502
+ * `quantileTDigest(level)(column)` - approximate quantile via the t-digest
503
+ * algorithm: lower memory than `quantileExact`, better accuracy at extreme
504
+ * percentiles (e.g. p99.9) than the default reservoir-sampling `quantile()`.
505
+ */
506
+ quantileTDigest(level: number, column: string, alias?: string): Literal;
507
+ private assertQuantileLevel;
508
+ buildWhereClause(where: WhereOptions, _options?: BuildOptions): {
509
+ sql: string;
510
+ values: unknown[];
511
+ };
512
+ buildOrderClause(order: Order, _options?: BuildOptions): string;
513
+ buildLimitOffset(limit?: number | string, offset?: number | string): string;
514
+ buildInsertQuery(tableName: string, values: Record<string, unknown>, options?: InsertOptions): {
515
+ sql: string;
516
+ values: unknown[];
517
+ };
518
+ /**
519
+ * ClickHouse has no synchronous UPSERT / `ON CONFLICT` / `MERGE` statement.
520
+ * The idiomatic ClickHouse pattern is: insert a new row into a
521
+ * ReplacingMergeTree(-family) table and let ClickHouse's background merges
522
+ * asynchronously drop older rows sharing the same ORDER BY key (optionally
523
+ * keeping the row with the greatest `version` column, if the engine and
524
+ * table were set up with one). Until that merge runs, duplicate rows for
525
+ * the same key coexist, and reads must use `SELECT ... FINAL` (or the table
526
+ * must be `OPTIMIZE ... FINAL`-ed) to see "the latest" value.
527
+ *
528
+ * This method therefore only ever builds a plain INSERT - `conflictFields`/
529
+ * `updateOnDuplicate` are accepted (to satisfy the shared Dialect signature)
530
+ * but silently have no effect, and that is called out loudly below rather
531
+ * than pretending this performs a real, synchronous upsert.
532
+ *
533
+ * IMPORTANT: pass `{ final: true }` to `buildSelectQuery()` on subsequent
534
+ * reads of this table (`SELECT ... FROM <table> FINAL`) to force ClickHouse
535
+ * to apply ReplacingMergeTree's merge-time dedup logic at query time -
536
+ * otherwise a plain SELECT can return duplicate/stale rows for the same
537
+ * ORDER BY key until a background merge happens. See the doc comment on
538
+ * `buildSelectQuery()`'s `final` handling for why this is opt-in rather
539
+ * than automatic.
540
+ */
541
+ buildUpsertQuery(tableName: string, values: Record<string, unknown>, options?: UpsertQueryOptions): {
542
+ sql: string;
543
+ values: unknown[];
544
+ };
545
+ /**
546
+ * `ALTER TABLE ... UPDATE` is an asynchronous ClickHouse *mutation*, not a
547
+ * synchronous, transactional UPDATE. The statement returns as soon as the
548
+ * mutation is scheduled; ClickHouse rewrites the affected data parts in the
549
+ * background (progress/completion is visible via `system.mutations`), so
550
+ * `query()`'s `rowCount` for this statement is always 0 - it reflects "rows
551
+ * returned by this HTTP request", not "rows the mutation will touch".
552
+ */
553
+ buildUpdateQuery(tableName: string, values: Record<string, unknown>, where: WhereOptions, options?: DUpdateOptions): {
554
+ sql: string;
555
+ values: unknown[];
556
+ };
557
+ /**
558
+ * `ALTER TABLE ... DELETE` is likewise an asynchronous mutation (see
559
+ * buildUpdateQuery's doc comment above) - not a synchronous, transactional
560
+ * DELETE. ClickHouse also offers a syntactically lighter `DELETE FROM ...
561
+ * WHERE ...` ("lightweight delete", available since v23.3) which marks rows
562
+ * deleted immediately for query purposes while physically removing them in
563
+ * the background; this builder intentionally uses the classic, more widely
564
+ * supported `ALTER TABLE ... DELETE` mutation form instead.
565
+ */
566
+ buildDeleteQuery(tableName: string, where: WhereOptions, options?: DeleteOptions): {
567
+ sql: string;
568
+ values: unknown[];
569
+ };
570
+ buildSelectQuery(options: SelectOptions): {
571
+ sql: string;
572
+ values: unknown[];
573
+ };
574
+ /**
575
+ * Increment/decrement is built on the same asynchronous ALTER TABLE ...
576
+ * UPDATE mutation mechanism as buildUpdateQuery() - see its doc comment.
577
+ */
578
+ buildIncrementQuery(tableName: string, fields: string | string[] | Record<string, number>, where: WhereOptions, options?: {
579
+ by?: number;
580
+ }): {
581
+ sql: string;
582
+ values: unknown[];
583
+ };
584
+ private fdwUnsupported;
585
+ buildCreateServerQuery(_name: string, _opts: FdwForeignServerOptions): string;
586
+ buildAlterServerQuery(_name: string, _opts: FdwAlterForeignServerOptions): string;
587
+ buildDropServerQuery(_name: string, _opts?: {
588
+ ifExists?: boolean;
589
+ cascade?: boolean;
590
+ }): string;
591
+ buildCreateUserMappingQuery(_opts: FdwUserMappingOptions): string;
592
+ buildAlterUserMappingQuery(_opts: FdwUserMappingOptions): string;
593
+ buildDropUserMappingQuery(_serverName: string, _user: string, _opts?: {
594
+ ifExists?: boolean;
595
+ }): string;
596
+ buildCreateForeignTableQuery(_tableName: string, _opts: FdwForeignTableOptions): string;
597
+ buildDropForeignTableQuery(_tableName: string, _opts?: {
598
+ ifExists?: boolean;
599
+ cascade?: boolean;
600
+ }): string;
601
+ buildImportForeignSchemaQuery(_remoteSchema: string, _serverName: string, _opts?: FdwImportForeignSchemaOptions): string;
602
+ getServersQuery(): string;
603
+ createForeignDataWrapper(_fdwName: string, _options?: {
604
+ handler?: string;
605
+ }): Promise<void>;
606
+ dropForeignDataWrapper(_fdwName: string, _options?: {
607
+ ifExists?: boolean;
608
+ }): Promise<void>;
609
+ createForeignServer(_serverName: string, _fdwName: string, _options?: {
610
+ options?: Record<string, string>;
611
+ ifNotExists?: boolean;
612
+ }): Promise<void>;
613
+ dropForeignServer(_serverName: string, _options?: {
614
+ ifExists?: boolean;
615
+ cascade?: boolean;
616
+ }): Promise<void>;
617
+ createForeignTable(_tableName: string, _columns: Record<string, {
618
+ type: string;
619
+ }>, _options?: {
620
+ serverName?: string;
621
+ ifNotExists?: boolean;
622
+ }): Promise<void>;
623
+ createUserMapping(_userName: string, _serverName: string, _options?: any): Promise<void>;
624
+ dropUserMapping(_userName: string, _serverName: string, _options?: any): Promise<void>;
625
+ buildCreateUserQuery(username: string, options?: any): string;
626
+ buildAlterUserQuery(username: string, options: any): string;
627
+ buildDropUserQuery(username: string, options?: any): string;
628
+ getUsersQuery(): string;
629
+ buildGrantQuery(options: any): string;
630
+ buildRevokeQuery(options: any): string;
631
+ buildShowGrantsQuery(username: string, _host?: string): string;
632
+ buildFlushPrivilegesQuery(): string;
633
+ buildCreateRoleQuery(roleName: string, options?: any): string;
634
+ buildDropRoleQuery(roleName: string, options?: any): string;
635
+ buildGrantRoleQuery(role: string, to: any, _options?: any): string;
636
+ buildRevokeRoleQuery(role: string, from: any, _options?: any): string;
637
+ getRolesQuery(): string;
638
+ createStoredProcedure(_options: StoredProcedureOptions): Promise<void>;
639
+ createProcedure(options: StoredProcedureOptions): Promise<void>;
640
+ dropStoredProcedure(_procedureName: string, _options?: DropStoredProcedureOptions): Promise<void>;
641
+ dropProcedure(procedureName: string, options?: DropStoredProcedureOptions): Promise<void>;
642
+ executeStoredProcedure(_options: ExecuteStoredProcedureOptions): Promise<QueryResult>;
643
+ hasStoredProcedure(_procedureName: string, _schema?: string): Promise<boolean>;
644
+ /**
645
+ * Build an expression to shred a JSON document/array into relational rows.
646
+ * ClickHouse has no `JSON_TABLE`/`OPENJSON` function; the real equivalent composes
647
+ * `JSONExtractArrayRaw` (split a JSON array into raw per-element JSON strings) with
648
+ * `arrayJoin` (explode an array into rows), then per-column `JSONExtract*` functions
649
+ * (chosen by the requested column type) to pull typed values out of each element.
650
+ * ClickHouse: (SELECT JSONExtractString(elem, 'name') AS name, ... FROM
651
+ * (SELECT arrayJoin(JSONExtractArrayRaw(expr, 'rowPath')) AS elem)) AS alias
652
+ */
653
+ buildJsonTable(jsonExpression: string, rowPath: string, columns: Array<{
654
+ name: string;
655
+ type?: string;
656
+ path?: string;
657
+ forOrdinality?: boolean;
658
+ }>, alias: string): string;
659
+ }
660
+ export declare function createClickHouseDialect(config: ClickHouseDialectOptions): ClickHouseDialect;