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,2093 @@
1
+ /**
2
+ * Main Prorm ORM class
3
+ */
4
+ import { EventEmitter } from 'events';
5
+ import { Dialect, ColumnDefinition, TableOptions, CreateExtensionOptions, DropExtensionOptions, ExtensionInfo } from './dialects/dialect';
6
+ import { ForeignDataManager, ForeignServerOptions, UserMappingOptions, ForeignTableOptions, ImportForeignSchemaOptions, ServerInfo } from './foreign-data';
7
+ import { UserManager } from './user-management';
8
+ import { DatabaseConnectionPool } from './connection-pool';
9
+ import { PrormOptions, ModelStatic, ModelOptions as ModelOptionsType, AttributeOptions, DestroyOptions, ReloadOptions, Transaction, TransactionOptions, DataType } from './types';
10
+ import { ExternalStoreRegistry } from './external-fields';
11
+ import type { RegisterStoreOptions } from './external-fields';
12
+ import { Logger } from './logging';
13
+ import { ValidationError } from './errors';
14
+ import { type IsolationLevelValue } from './sql-constants';
15
+ type AnyModel = any;
16
+ /**
17
+ * Hook types for the ORM
18
+ */
19
+ export type HookCallback = (...args: any[]) => void | Promise<void>;
20
+ /**
21
+ * Connection type for hook callbacks
22
+ */
23
+ export interface Connection {
24
+ id: string;
25
+ createdAt: number;
26
+ [key: string]: any;
27
+ }
28
+ /**
29
+ * Hook manager for Prorm instance
30
+ */
31
+ export declare class HooksManager {
32
+ private beforeDefineHooks;
33
+ private afterDefineHooks;
34
+ private beforeSyncHooks;
35
+ private afterSyncHooks;
36
+ private beforeConnectHooks;
37
+ private afterConnectHooks;
38
+ private beforeDisconnectHooks;
39
+ private afterDisconnectHooks;
40
+ private beforeDestroyHooks;
41
+ private afterDestroyHooks;
42
+ private beforeUpsertHooks;
43
+ private afterUpsertHooks;
44
+ private beforeReloadHooks;
45
+ /**
46
+ * Register a beforeDefine hook
47
+ */
48
+ beforeDefine(callback: HookCallback): void;
49
+ /**
50
+ * Register an afterDefine hook
51
+ */
52
+ afterDefine(callback: HookCallback): void;
53
+ /**
54
+ * Register a beforeSync hook
55
+ */
56
+ beforeSync(callback: HookCallback): void;
57
+ /**
58
+ * Register an afterSync hook
59
+ */
60
+ afterSync(callback: HookCallback): void;
61
+ /**
62
+ * Register a beforeConnect hook
63
+ */
64
+ beforeConnect(callback: HookCallback): void;
65
+ /**
66
+ * Register an afterConnect hook
67
+ */
68
+ afterConnect(callback: HookCallback): void;
69
+ /**
70
+ * Register a beforeDisconnect hook
71
+ */
72
+ beforeDisconnect(callback: HookCallback): void;
73
+ /**
74
+ * Register an afterDisconnect hook
75
+ */
76
+ afterDisconnect(callback: HookCallback): void;
77
+ /**
78
+ * Register a beforeDestroy hook
79
+ */
80
+ beforeDestroy(callback: HookCallback): void;
81
+ /**
82
+ * Register an afterDestroy hook
83
+ */
84
+ afterDestroy(callback: HookCallback): void;
85
+ /**
86
+ * Register a beforeUpsert hook
87
+ */
88
+ beforeUpsert(callback: HookCallback): void;
89
+ /**
90
+ * Register an afterUpsert hook
91
+ */
92
+ afterUpsert(callback: HookCallback): void;
93
+ /**
94
+ * Register a beforeReload hook
95
+ */
96
+ beforeReload(callback: HookCallback): void;
97
+ /**
98
+ * Execute all beforeDefine hooks
99
+ */
100
+ runBeforeDefine(modelName: string, attributes: Record<string, AttributeOptions>, options: ModelOptionsType): Promise<void>;
101
+ /**
102
+ * Execute all afterDefine hooks
103
+ */
104
+ runAfterDefine(model: ModelStatic<AnyModel>): Promise<void>;
105
+ /**
106
+ * Execute all beforeSync hooks
107
+ */
108
+ runBeforeSync(options: SyncOptions): Promise<void>;
109
+ /**
110
+ * Execute all afterSync hooks
111
+ */
112
+ runAfterSync(options: SyncOptions): Promise<void>;
113
+ /**
114
+ * Execute all beforeConnect hooks
115
+ */
116
+ runBeforeConnect(): Promise<void>;
117
+ /**
118
+ * Execute all afterConnect hooks
119
+ * @param connection - The connection object to pass to hooks
120
+ */
121
+ runAfterConnect(connection: Connection): Promise<void>;
122
+ /**
123
+ * Execute all beforeDisconnect hooks
124
+ * @param connection - The connection object to pass to hooks
125
+ */
126
+ runBeforeDisconnect(connection: Connection): Promise<void>;
127
+ /**
128
+ * Execute all afterDisconnect hooks
129
+ * @param connection - The connection object to pass to hooks
130
+ */
131
+ runAfterDisconnect(connection: Connection): Promise<void>;
132
+ /**
133
+ * Execute all beforeDestroy hooks
134
+ * @param options - The destroy options
135
+ */
136
+ runBeforeDestroy(options: DestroyOptions): Promise<void>;
137
+ /**
138
+ * Execute all afterDestroy hooks
139
+ * @param options - The destroy options
140
+ */
141
+ runAfterDestroy(options: DestroyOptions): Promise<void>;
142
+ /**
143
+ * Execute all beforeUpsert hooks
144
+ * @param options - The upsert options
145
+ */
146
+ runBeforeUpsert(options: any): Promise<void>;
147
+ /**
148
+ * Execute all afterUpsert hooks
149
+ * @param options - The upsert options
150
+ */
151
+ runAfterUpsert(options: any): Promise<void>;
152
+ /**
153
+ * Execute all beforeReload hooks
154
+ * @param options - The reload options
155
+ */
156
+ runBeforeReload(options: ReloadOptions): Promise<void>;
157
+ /**
158
+ * Add a hook by name
159
+ * @param hookName - The name of the hook (e.g., 'beforeDefine', 'afterSync')
160
+ * @param callback - The hook callback function
161
+ */
162
+ addHook(hookName: string, callback: HookCallback): void;
163
+ /**
164
+ * Clear all hooks
165
+ */
166
+ clearHooks(): void;
167
+ }
168
+ /**
169
+ * Options for sync method
170
+ */
171
+ export interface SyncOptions {
172
+ /**
173
+ * If true, drops all tables and recreates them.
174
+ * WARNING: This will destroy all data in the tables!
175
+ * @default false
176
+ */
177
+ force?: boolean;
178
+ /**
179
+ * If true, alter tables to match model definitions.
180
+ * This will add new columns, remove extra columns, and change column types as needed.
181
+ * Preserves existing data in the table.
182
+ * Can be an object with { drop: false } to prevent dropping columns
183
+ * @default false
184
+ */
185
+ alter?: boolean | {
186
+ drop?: boolean;
187
+ };
188
+ /**
189
+ * Regular expression to match the database name.
190
+ * Sync will only proceed if the database name matches this pattern.
191
+ * Useful for development vs production environments.
192
+ * Example: /test/ - only syncs if database name contains "test"
193
+ */
194
+ match?: RegExp;
195
+ /**
196
+ * Custom logging function
197
+ */
198
+ logging?: boolean | ((sql: string, timing?: number) => void);
199
+ /**
200
+ * If true, run sync hooks (beforeSync, afterSync, etc.)
201
+ * @default true
202
+ */
203
+ hooks?: boolean;
204
+ /**
205
+ * If true, also sync indexes
206
+ * @default true
207
+ */
208
+ indexes?: boolean;
209
+ /**
210
+ * If true, also sync foreign key constraints
211
+ * @default true
212
+ */
213
+ constraints?: boolean;
214
+ }
215
+ /**
216
+ * Represents a raw SQL literal value
217
+ * Used for inserting raw SQL expressions into queries
218
+ *
219
+ * @example
220
+ * // Use in default values
221
+ * createdAt: { type: DATE, defaultValue: prorm.literal('NOW()') }
222
+ *
223
+ * @example
224
+ * // Use in updates
225
+ * User.update({ count: prorm.literal('count + 1') }, {...})
226
+ *
227
+ * @example
228
+ * // Use in select with calculations
229
+ * User.findAll({ attributes: [[prorm.literal('1 + 1'), 'two']] })
230
+ */
231
+ export declare class Literal {
232
+ readonly val: string;
233
+ constructor(sql: string);
234
+ /**
235
+ * Get the raw SQL string
236
+ */
237
+ toString(): string;
238
+ }
239
+ /**
240
+ * Class representing a column reference for use with Prorm functions
241
+ * Used to create properly quoted column identifiers
242
+ *
243
+ * @example
244
+ * // Single column: col('name') -> "name"
245
+ * // Table and column: col('User', 'name') -> "User"."name"
246
+ * // Dot notation: col('table.column') -> "table"."column"
247
+ */
248
+ export declare class Col {
249
+ private readonly col;
250
+ /**
251
+ * Create a column reference
252
+ * @param tableOrColumn - Table name (if second param provided) or column name
253
+ * @param column - Column name (if first param is table name)
254
+ */
255
+ constructor(tableOrColumn: string, column?: string);
256
+ /**
257
+ * Get the SQL representation of the column
258
+ */
259
+ toSql(): string;
260
+ /**
261
+ * Get the column as a string
262
+ */
263
+ toString(): string;
264
+ }
265
+ /**
266
+ * Query types for raw SQL queries
267
+ */
268
+ export declare enum QueryTypes {
269
+ SELECT = "SELECT",
270
+ INSERT = "INSERT",
271
+ UPDATE = "UPDATE",
272
+ DELETE = "DELETE",
273
+ BULKDELETE = "BULKDELETE",
274
+ BULKINSERT = "BULKINSERT",
275
+ UPSERT = "UPSERT",
276
+ VERSION = "VERSION",
277
+ SHOWTABLES = "SHOWTABLES",
278
+ DESCRIBE = "DESCRIBE",
279
+ RAW = "RAW"
280
+ }
281
+ /**
282
+ * Options for raw query execution
283
+ */
284
+ export interface RawQueryResult {
285
+ rows: unknown[];
286
+ count: number;
287
+ isSelect: boolean;
288
+ }
289
+ export interface QueryOptions {
290
+ /**
291
+ * Query type - determines how results are processed
292
+ * Forces the query type for result handling
293
+ * - SELECT: Returns array of rows
294
+ * - INSERT: Returns [rows, created]
295
+ * - UPDATE: Returns affected count
296
+ * - DELETE: Returns affected count
297
+ * - BULKDELETE: Returns affected count
298
+ * - UPSERT: Returns [rows, created]
299
+ */
300
+ type?: QueryTypes | 'SELECT' | 'INSERT' | 'UPDATE' | 'DELETE' | 'BULKDELETE' | 'UPSERT' | 'BULKINSERT' | 'VERSION' | 'SHOWTABLES' | 'DESCRIBE' | 'RAW';
301
+ /**
302
+ * Replacements for named (:param) or positional (?) placeholders
303
+ * For named: { username: 'john' } replaces :username in SQL
304
+ * For positional: ['john', 'smith'] replaces ? in order
305
+ */
306
+ replacements?: Record<string, unknown> | unknown[];
307
+ /**
308
+ * Return raw results without model instantiation
309
+ */
310
+ raw?: boolean;
311
+ /**
312
+ * Whether to log the query
313
+ */
314
+ logging?: boolean | ((sql: string, timing?: number) => void);
315
+ /**
316
+ * When true, logs query execution time
317
+ */
318
+ benchmark?: boolean;
319
+ /**
320
+ * Transaction to use for the query
321
+ */
322
+ transaction?: Transaction;
323
+ /**
324
+ * Retry configuration for query execution
325
+ * On connection failure or retryable errors, retry up to max times
326
+ * @param max - Maximum number of retry attempts
327
+ * @param match - Array of error message patterns that trigger retry
328
+ *
329
+ * @example
330
+ * // Retry on connection refused or timeout errors
331
+ * await prorm.query('SELECT * FROM users', {
332
+ * retry: { max: 3, match: ['Connection refused', 'Timeout', 'ECONNREFUSED'] }
333
+ * });
334
+ */
335
+ retry?: {
336
+ max: number;
337
+ match?: string[];
338
+ };
339
+ /**
340
+ * Map raw query results to a model instance
341
+ * When true, maps the result rows to ModelInstance objects using the provided model
342
+ * @default false
343
+ */
344
+ mapToModel?: boolean;
345
+ /**
346
+ * Model to use for mapping raw results to model instances
347
+ * Used together with mapToModel to create ModelInstance objects from raw query results
348
+ */
349
+ model?: ModelStatic<any>;
350
+ }
351
+ /**
352
+ * Main Prorm class with error handling and logging
353
+ */
354
+ export declare class Prorm extends EventEmitter {
355
+ private dialect;
356
+ private _fdwManager;
357
+ private _userManager;
358
+ private _models;
359
+ /**
360
+ * Get all models as an object for backward compatibility
361
+ * Allows accessing models via prorm.models.ModelName
362
+ */
363
+ get models(): Record<string, ModelStatic<AnyModel>>;
364
+ /**
365
+ * Sequelize-style model manager, exposing the registered models along
366
+ * with a few convenience accessors on top of the internal model map.
367
+ */
368
+ get modelManager(): {
369
+ models: Record<string, ModelStatic<AnyModel>>;
370
+ all: ModelStatic<AnyModel>[];
371
+ getModel(name: string): ModelStatic<AnyModel> | undefined;
372
+ addModel(name: string, model: ModelStatic<AnyModel>): void;
373
+ removeModel(name: string): boolean;
374
+ };
375
+ private currentTransaction;
376
+ private _rootTransactionQueue;
377
+ private modelDefinitions;
378
+ associations: Map<string, any>;
379
+ /**
380
+ * Decorator-declared associations waiting for their target model to be
381
+ * registered. See `_flushPendingAssociations()`.
382
+ */
383
+ private _pendingAssociations;
384
+ /** Model classes registered via `addModel`, consulted for @View/@Trigger DDL. */
385
+ private _decoratedClasses;
386
+ /** Classes registered via `registerProcedures`, for @Procedure/@SqlFunction DDL. */
387
+ private _procedureClasses;
388
+ /**
389
+ * Object/key-value stores backing @ExternalField properties. Public so the
390
+ * instance accessors built in `_wrapInstance` can resolve them.
391
+ */
392
+ readonly externalStores: ExternalStoreRegistry;
393
+ private pendingTableCreates;
394
+ private config;
395
+ private _isConnected;
396
+ private logger;
397
+ private loggingOptions;
398
+ private hooksManager;
399
+ private modelHooks;
400
+ /**
401
+ * The connection pool instance
402
+ * @example
403
+ * // Get pool statistics
404
+ * console.log('Pool size:', prorm.pool.size);
405
+ * console.log('Available:', prorm.pool.available);
406
+ * console.log('Used:', prorm.pool.used);
407
+ * console.log('Pending:', prorm.pool.pending);
408
+ *
409
+ * // Listen to pool events
410
+ * prorm.pool.on('acquire', (connection) => {
411
+ * console.log('Connection acquired:', connection?.id);
412
+ * });
413
+ * prorm.pool.on('release', (connection) => {
414
+ * console.log('Connection released:', connection?.id);
415
+ * });
416
+ * prorm.pool.on('error', (err) => {
417
+ * console.error('Pool error:', err);
418
+ * });
419
+ *
420
+ * // Manually acquire a connection
421
+ * const conn = await prorm.pool.acquire();
422
+ *
423
+ * // Release a connection
424
+ * prorm.pool.release(conn);
425
+ *
426
+ * // Destroy a connection
427
+ * await prorm.pool.destroy(conn);
428
+ */
429
+ pool: DatabaseConnectionPool | null;
430
+ /**
431
+ * Create a new Prorm instance
432
+ * @param options - Configuration options
433
+ *
434
+ * @example
435
+ * // Basic usage with console logging
436
+ * const prorm = new Prorm({
437
+ * dialect: 'sqlite',
438
+ * storage: ':memory:',
439
+ * logging: console.log
440
+ * });
441
+ *
442
+ * @example
443
+ * // Custom logging function that receives SQL and timing
444
+ * const prorm = new Prorm({
445
+ * dialect: 'sqlite',
446
+ * storage: ':memory:',
447
+ * logging: (sql, timing) => {
448
+ * console.log(`Query took ${timing}ms: ${sql}`);
449
+ * }
450
+ * });
451
+ *
452
+ * @example
453
+ * // Enable benchmark mode for query timing
454
+ * const prorm = new Prorm({
455
+ * dialect: 'sqlite',
456
+ * storage: ':memory:',
457
+ * logging: console.log
458
+ * });
459
+ *
460
+ * // Now all queries will log execution time
461
+ * await User.findAll({ benchmark: true });
462
+ *
463
+ * @example
464
+ * // Listen to query events
465
+ * prorm.on('query', (event) => {
466
+ * console.log('Query executed:', event.sql, 'Duration:', event.duration, 'ms');
467
+ * });
468
+ *
469
+ * // Listen to slow query events
470
+ * prorm.on('slowQuery', (event) => {
471
+ * console.warn('Slow query detected:', event.sql, 'Duration:', event.duration, 'ms', 'Threshold:', event.threshold);
472
+ * });
473
+ */
474
+ constructor(options: PrormOptions);
475
+ /**
476
+ * Create a literal/raw SQL expression
477
+ * Use this to insert raw SQL into queries without parameter escaping
478
+ *
479
+ * @param sql - The raw SQL expression
480
+ * @returns A Literal instance that can be used in queries
481
+ *
482
+ * @example
483
+ * // Use in default values
484
+ * const User = prorm.define('User', {
485
+ * createdAt: { type: DATE, defaultValue: prorm.literal('NOW()') },
486
+ * updatedAt: { type: DATE, defaultValue: prorm.literal("strftime('%Y-%m-%d %H:%M:%S', 'now')") }
487
+ * });
488
+ *
489
+ * @example
490
+ * // Use in updates (increment counter)
491
+ * await User.update(
492
+ * { count: prorm.literal('count + 1') },
493
+ * { where: { id: 1 } }
494
+ * );
495
+ *
496
+ * @example
497
+ * // Use in complex calculations in select
498
+ * const users = await User.findAll({
499
+ * attributes: [
500
+ * 'id',
501
+ * 'name',
502
+ * [prorm.literal('price * quantity'), 'total']
503
+ * ]
504
+ * });
505
+ *
506
+ * @example
507
+ * // Use in subqueries
508
+ * const posts = await Post.findAll({
509
+ * where: {
510
+ * userId: prorm.literal('(SELECT id FROM users WHERE active = 1 LIMIT 1)')
511
+ * }
512
+ * });
513
+ */
514
+ literal(sql: string): Literal;
515
+ /**
516
+ * Set up the connection pool with event forwarding
517
+ * @param poolOptions - Pool configuration options
518
+ */
519
+ private setupPool;
520
+ /**
521
+ * Get the connection pool instance
522
+ * @returns The connection pool or null if not configured
523
+ */
524
+ getPool(): DatabaseConnectionPool | null;
525
+ /**
526
+ * Get pool statistics
527
+ * @returns Pool statistics or null if pool not configured
528
+ */
529
+ getPoolStats(): {
530
+ size: number;
531
+ available: number;
532
+ inUse: number;
533
+ pending: number;
534
+ } | null;
535
+ /**
536
+ * Set up error event handling
537
+ */
538
+ private setupErrorHandling;
539
+ /**
540
+ * Get the logger instance
541
+ */
542
+ getLogger(): Logger;
543
+ /**
544
+ * Set logging level
545
+ */
546
+ setLoggingLevel(level: 'debug' | 'info' | 'warn' | 'error'): void;
547
+ /**
548
+ * Emit error event with proper error handling
549
+ */
550
+ private emitError;
551
+ /**
552
+ * Wrap query execution with error handling
553
+ */
554
+ private executeWithErrorHandling;
555
+ /**
556
+ * Wrap query with timing and logging
557
+ * @param sql - The SQL query string
558
+ * @param operation - The operation to execute
559
+ * @param options - Optional logging options to override instance-level logging
560
+ */
561
+ private executeWithLogging;
562
+ /**
563
+ * Set up query logging event handlers
564
+ * This enables external listeners to react to each query execution
565
+ */
566
+ private setupQueryLogging;
567
+ /**
568
+ * Create the appropriate dialect instance
569
+ */
570
+ private createDialect;
571
+ /**
572
+ * Connect to the database and authenticate
573
+ */
574
+ connect(): Promise<void>;
575
+ /**
576
+ * Disconnect from the database and close the connection pool
577
+ */
578
+ close(): Promise<void>;
579
+ /**
580
+ * Add a hook to the Prorm instance
581
+ * @param hookName - The name of the hook (e.g., 'beforeDefine', 'afterSync', 'beforeConnect')
582
+ * @param handler - The hook handler function
583
+ * @returns The Prorm instance for chaining
584
+ *
585
+ * @example
586
+ * prorm.addHook('beforeDefine', ({ modelName, attributes }) => {
587
+ * console.log('Defining model:', modelName);
588
+ * });
589
+ *
590
+ * @example
591
+ * prorm.addHook('beforeConnect', async () => {
592
+ * console.log('About to connect to database');
593
+ * });
594
+ */
595
+ addHook(hookName: string, handler: HookCallback): this;
596
+ /**
597
+ * Check if connected
598
+ */
599
+ get isConnected(): boolean;
600
+ /**
601
+ * Authenticate the connection by running a test query
602
+ * @returns Promise that resolves if connection is successful
603
+ * @throws Error if connection fails
604
+ *
605
+ * @example
606
+ * await prorm.authenticate();
607
+ * console.log('Connection OK');
608
+ */
609
+ authenticate(): Promise<void>;
610
+ /**
611
+ * Get the dialect name
612
+ * @returns The dialect name (e.g., 'sqlite', 'postgres', 'mysql')
613
+ */
614
+ getDialect(): string;
615
+ /**
616
+ * Get the dialect instance
617
+ * @returns The dialect instance or null if not initialized
618
+ */
619
+ getDialectInstance(): Dialect | null;
620
+ /**
621
+ * Get the query interface for DDL operations
622
+ */
623
+ getQueryInterface(): any;
624
+ /**
625
+ * Create a partitioned table (PostgreSQL 10+)
626
+ *
627
+ * @param tableName - Name of the table to create
628
+ * @param columns - Column definitions
629
+ * @param options - Table options including partition configuration
630
+ */
631
+ createPartitionedTable(tableName: string, columns: Record<string, ColumnDefinition>, options?: TableOptions & {
632
+ partitionBy: {
633
+ type: 'range' | 'list' | 'hash';
634
+ column: string | string[];
635
+ };
636
+ partitions?: {
637
+ name: string;
638
+ bound?: {
639
+ from: string | number | Date;
640
+ to?: string | number | Date;
641
+ values?: (string | number)[];
642
+ modulus?: number;
643
+ remainder?: number;
644
+ };
645
+ tablespace?: string;
646
+ storageParameters?: Record<string, string | number>;
647
+ }[];
648
+ }): Promise<void>;
649
+ /**
650
+ * Create a partition for an existing partitioned table (PostgreSQL 10+)
651
+ *
652
+ * @param options - Partition creation options
653
+ */
654
+ createPartition(options: {
655
+ parentTable: string;
656
+ name: string;
657
+ bound?: {
658
+ from: string | number | Date;
659
+ to?: string | number | Date;
660
+ values?: (string | number)[];
661
+ modulus?: number;
662
+ remainder?: number;
663
+ };
664
+ tablespace?: string;
665
+ storageParameters?: Record<string, string | number>;
666
+ }): Promise<void>;
667
+ /**
668
+ * Attach a partition to a partitioned table (PostgreSQL 11+)
669
+ *
670
+ * @param options - Partition attachment options
671
+ */
672
+ attachPartition(options: {
673
+ parentTable: string;
674
+ partitionName: string;
675
+ }): Promise<void>;
676
+ /**
677
+ * Detach a partition from a partitioned table (PostgreSQL 11+)
678
+ *
679
+ * @param options - Partition detachment options
680
+ */
681
+ detachPartition(options: {
682
+ partitionName: string;
683
+ validate?: boolean;
684
+ }): Promise<void>;
685
+ /**
686
+ * Drop a partition (PostgreSQL 10+)
687
+ *
688
+ * @param partitionName - Name of the partition to drop
689
+ * @param options - Drop options
690
+ */
691
+ dropPartition(partitionName: string, options?: {
692
+ ifExists?: boolean;
693
+ cascade?: boolean;
694
+ }): Promise<void>;
695
+ /**
696
+ * Disable foreign key checks for the current session
697
+ * @returns Promise that resolves when foreign key checks are disabled
698
+ */
699
+ disableForeignKeyChecks(): Promise<void>;
700
+ /**
701
+ * Enable foreign key checks for the current session
702
+ * @returns Promise that resolves when foreign key checks are enabled
703
+ */
704
+ enableForeignKeyChecks(): Promise<void>;
705
+ /**
706
+ * Set the transaction isolation level
707
+ * @param level - The isolation level to set
708
+ * @returns Promise that resolves when the isolation level is set
709
+ */
710
+ setIsolationLevel(level: IsolationLevelValue): Promise<void>;
711
+ /**
712
+ * Get SQL for disabling foreign key checks for the current dialect
713
+ * @returns SQL string for disabling foreign key checks
714
+ */
715
+ getDisableForeignKeyChecksSQL(): string;
716
+ /**
717
+ * Get SQL for enabling foreign key checks for the current dialect
718
+ * @returns SQL string for enabling foreign key checks
719
+ */
720
+ getEnableForeignKeyChecksSQL(): string;
721
+ /**
722
+ * Get SQL for setting transaction isolation level for the current dialect
723
+ * @param level - The isolation level
724
+ * @returns SQL string for setting the isolation level
725
+ */
726
+ getSetIsolationLevelSQL(level: IsolationLevelValue): string;
727
+ /**
728
+ * Disable unique key checks for the current session (MySQL/MariaDB only)
729
+ * @returns Promise that resolves when unique key checks are disabled
730
+ */
731
+ disableUniqueKeyChecks(): Promise<void>;
732
+ /**
733
+ * Enable unique key checks for the current session (MySQL/MariaDB only)
734
+ * @returns Promise that resolves when unique key checks are enabled
735
+ */
736
+ enableUniqueKeyChecks(): Promise<void>;
737
+ /**
738
+ * Get SQL constants for the current dialect
739
+ * @returns SQL constants for the current dialect
740
+ */
741
+ getSQLConstants(): object;
742
+ /**
743
+ * Get the database name
744
+ * @returns The database name from the configuration
745
+ */
746
+ getDatabase(): string;
747
+ /**
748
+ * Get the host name
749
+ * @returns The host from the configuration
750
+ */
751
+ getHost(): string;
752
+ /**
753
+ * Get the port number
754
+ * @returns The port from the configuration
755
+ */
756
+ getPort(): number | string;
757
+ /**
758
+ * Get the username
759
+ * @returns The username from the configuration
760
+ */
761
+ getUsername(): string;
762
+ /**
763
+ * Get all registered models
764
+ */
765
+ getModels(): Map<string, ModelStatic<AnyModel>>;
766
+ /**
767
+ * Get all models as an object (for backward compatibility)
768
+ */
769
+ get allModels(): Record<string, ModelStatic<AnyModel>>;
770
+ /**
771
+ * Get a model by name
772
+ */
773
+ model(name: string): ModelStatic<AnyModel> | undefined;
774
+ /**
775
+ * Get a model by name (alias for model())
776
+ * @param modelName - The name of the model to retrieve
777
+ * @returns The model static or undefined if not found
778
+ *
779
+ * @example
780
+ * const User = prorm.getModel('User');
781
+ */
782
+ getModel(modelName: string): ModelStatic<AnyModel> | undefined;
783
+ /**
784
+ * Check if a model is registered with Prorm
785
+ * @param modelName - The name of the model to check
786
+ * @returns True if the model is registered, false otherwise
787
+ *
788
+ * @example
789
+ * const hasUser = prorm.hasModel('User');
790
+ */
791
+ hasModel(modelName: string): boolean;
792
+ /**
793
+ * Get the table name for a model, including schema if defined
794
+ * @param model - The model to get the table name for
795
+ * @returns The full table name with schema (e.g., "schema.tableName" or just "tableName")
796
+ */
797
+ getTableName(model: ModelStatic<AnyModel> | string): string;
798
+ /**
799
+ * Check if a table exists in the database
800
+ * @param tableName - The table name to check (can include schema for PostgreSQL)
801
+ * @returns True if the table exists, false otherwise
802
+ */
803
+ tableExists(tableName: string): Promise<boolean>;
804
+ /**
805
+ * Create a materialized view (PostgreSQL only)
806
+ * @param options - Materialized view options
807
+ * @returns Promise<void>
808
+ *
809
+ * @example
810
+ * await prorm.createMaterializedView({
811
+ * name: 'user_stats',
812
+ * query: 'SELECT user_id, COUNT(*) as order_count FROM orders GROUP BY user_id',
813
+ * uniqueIndex: 'user_stats_user_id_key',
814
+ * });
815
+ */
816
+ createMaterializedView(options: {
817
+ name: string;
818
+ query: string;
819
+ schema?: string;
820
+ ifNotExists?: boolean;
821
+ replace?: boolean;
822
+ withData?: boolean;
823
+ uniqueIndex?: string;
824
+ comment?: string;
825
+ }): Promise<void>;
826
+ /**
827
+ * Refresh a materialized view (PostgreSQL only)
828
+ * @param viewName - Name of the materialized view to refresh
829
+ * @param options - Refresh options
830
+ * @returns Promise<void>
831
+ *
832
+ * @example
833
+ * // Simple refresh
834
+ * await prorm.refreshMaterializedView('user_stats');
835
+ *
836
+ * // Concurrent refresh (requires unique index)
837
+ * await prorm.refreshMaterializedView('user_stats', { concurrently: true });
838
+ *
839
+ * // Refresh without data
840
+ * await prorm.refreshMaterializedView('user_stats', { withNoData: true });
841
+ */
842
+ refreshMaterializedView(viewName: string, options?: {
843
+ concurrently?: boolean;
844
+ withNoData?: boolean;
845
+ }): Promise<void>;
846
+ /**
847
+ * Drop a materialized view (PostgreSQL only)
848
+ * @param viewName - Name of the materialized view to drop
849
+ * @param options - Drop options
850
+ * @returns Promise<void>
851
+ *
852
+ * @example
853
+ * await prorm.dropMaterializedView('user_stats');
854
+ * await prorm.dropMaterializedView('user_stats', { ifExists: true, cascade: true });
855
+ */
856
+ dropMaterializedView(viewName: string, options?: {
857
+ ifExists?: boolean;
858
+ cascade?: boolean;
859
+ }): Promise<void>;
860
+ /**
861
+ * Check if a materialized view exists (PostgreSQL only)
862
+ * @param viewName - Name of the materialized view
863
+ * @returns True if the materialized view exists
864
+ *
865
+ * @example
866
+ * const exists = await prorm.hasMaterializedView('user_stats');
867
+ */
868
+ hasMaterializedView(viewName: string): Promise<boolean>;
869
+ /**
870
+ * Show all materialized views in the database (PostgreSQL only)
871
+ * @returns Array of materialized view names
872
+ *
873
+ * @example
874
+ * const views = await prorm.showMaterializedViews();
875
+ */
876
+ showMaterializedViews(): Promise<string[]>;
877
+ /**
878
+ * Define a new model
879
+ * @param modelName - Name of the model
880
+ * @param attributes - Model attributes
881
+ * @param options - Model options
882
+ */
883
+ define<T = AnyModel>(modelName: string, attributes: Record<string, AttributeOptions>, options?: ModelOptionsType): ModelStatic<any>;
884
+ /**
885
+ * Add a model defined with decorators
886
+ * @param modelClass - The model class (decorated with @Table)
887
+ * @returns The registered model
888
+ *
889
+ * @example
890
+ * ```typescript
891
+ * import { Model, DataTypes } from 'orm';
892
+ * import { Table, Column, PrimaryKey, AutoIncrement } from 'orm/decorators';
893
+ *
894
+ * @Table({ tableName: 'users' })
895
+ * export class User extends Model {
896
+ * @Column(DataTypes.INTEGER)
897
+ * @PrimaryKey
898
+ * @AutoIncrement
899
+ * declare id: number;
900
+ *
901
+ * @Column(DataTypes.STRING)
902
+ * declare name: string;
903
+ * }
904
+ *
905
+ * prorm.addModel(User);
906
+ * ```
907
+ */
908
+ addModel<T = AnyModel>(modelClass: new () => T): ModelStatic<any>;
909
+ /**
910
+ * Create table from model definition
911
+ */
912
+ private createTableFromModel;
913
+ /**
914
+ * Apply replacements to SQL query
915
+ * Supports both named (:param) and positional (?) placeholders
916
+ */
917
+ private applyReplacements;
918
+ /**
919
+ * Determine query type from SQL statement
920
+ */
921
+ private determineQueryType;
922
+ /**
923
+ * Execute a raw query
924
+ * @param sql - The SQL query string with optional placeholders
925
+ * @param options - Query options including replacements
926
+ * @returns Query results (array for SELECT, [rows, created] for INSERT, count for UPDATE/DELETE)
927
+ *
928
+ * @example
929
+ * // Named replacements
930
+ * await prorm.query('SELECT * FROM users WHERE status = :status', {
931
+ * replacements: { status: 'active' }
932
+ * });
933
+ *
934
+ * @example
935
+ * // IN clause with array replacement
936
+ * await prorm.query('SELECT * FROM users WHERE id IN (:ids)', {
937
+ * replacements: { ids: [1, 2, 3] }
938
+ * });
939
+ *
940
+ * @example
941
+ * // Positional replacements
942
+ * await prorm.query('SELECT * FROM users WHERE name = ?', {
943
+ * replacements: ['john']
944
+ * });
945
+ *
946
+ * @example
947
+ * // Map raw results to model instances
948
+ * const users = await prorm.query('SELECT * FROM users', {
949
+ * model: User,
950
+ * mapToModel: true
951
+ * });
952
+ * // Returns ModelInstance objects instead of plain objects
953
+ */
954
+ query(sql: string, options?: QueryOptions): Promise<unknown[] | [unknown[], boolean] | number>;
955
+ /**
956
+ * Create a savepoint within a transaction
957
+ * @param name - Optional savepoint name
958
+ * @param options - Query options including transaction
959
+ * @returns The savepoint name
960
+ */
961
+ createSavepoint(name?: string, options?: QueryOptions): Promise<string>;
962
+ /**
963
+ * Release a savepoint
964
+ * @param name - Savepoint name to release
965
+ * @param options - Query options including transaction
966
+ */
967
+ releaseSavepoint(name: string, options?: QueryOptions): Promise<void>;
968
+ /**
969
+ * Rollback to a savepoint
970
+ * @param name - Savepoint name to rollback to
971
+ * @param options - Query options including transaction
972
+ */
973
+ rollbackToSavepoint(name: string, options?: QueryOptions): Promise<void>;
974
+ /**
975
+ * Execute a raw query and return structured result
976
+ * @param sql - The SQL query string with optional placeholders
977
+ * @param options - Query options including replacements
978
+ * @returns Structured result with rows, count, and isSelect flag
979
+ */
980
+ queryWithMetadata(sql: string, options?: QueryOptions): Promise<RawQueryResult>;
981
+ /**
982
+ * Execute a query within a transaction (callback mode) or return a transaction object (manual mode).
983
+ *
984
+ * Callback mode: `prorm.transaction(async (t) => { ... })`
985
+ * Manual mode: `const t = await prorm.transaction(); await t.commit();`
986
+ */
987
+ transaction<T>(callbackOrOptions?: ((transaction: any) => Promise<T>) | TransactionOptions, options?: TransactionOptions): Promise<T | any>;
988
+ private _savepointCounter;
989
+ private _attachSavepointMethods;
990
+ /**
991
+ * Get the current transaction
992
+ */
993
+ getTransaction(): Transaction | null;
994
+ /**
995
+ * Set the current transaction
996
+ */
997
+ setTransaction(transaction: Transaction | null): void;
998
+ /**
999
+ * Register a hook to be called before a model is defined
1000
+ * @param callback - Function to call before model definition
1001
+ *
1002
+ * @example
1003
+ * prorm.beforeDefine((model, attributes, options) => {
1004
+ * console.log('Defining:', model.name);
1005
+ * });
1006
+ */
1007
+ beforeDefine(callback: HookCallback): void;
1008
+ /**
1009
+ * Register a hook to be called after a model is defined
1010
+ * @param callback - Function to call after model definition
1011
+ *
1012
+ * @example
1013
+ * prorm.afterDefine((model) => {
1014
+ * console.log('Defined:', model.name);
1015
+ * });
1016
+ */
1017
+ afterDefine(callback: HookCallback): void;
1018
+ /**
1019
+ * Register a hook to be called before sync
1020
+ * @param callback - Function to call before sync
1021
+ *
1022
+ * @example
1023
+ * prorm.beforeSync((options) => {
1024
+ * console.log('About to sync with options:', options);
1025
+ * });
1026
+ */
1027
+ beforeSync(callback: HookCallback): void;
1028
+ /**
1029
+ * Register a hook to be called after sync
1030
+ * @param callback - Function to call after sync
1031
+ *
1032
+ * @example
1033
+ * prorm.afterSync((options) => {
1034
+ * console.log('Sync complete with options:', options);
1035
+ * });
1036
+ */
1037
+ afterSync(callback: HookCallback): void;
1038
+ /**
1039
+ * Register a hook to be called before connection
1040
+ * @param callback - Function to call before connecting
1041
+ *
1042
+ * @example
1043
+ * prorm.beforeConnect(() => {
1044
+ * console.log('About to connect to database');
1045
+ * });
1046
+ */
1047
+ beforeConnect(callback: HookCallback): void;
1048
+ /**
1049
+ * Register a hook to be called after connection
1050
+ * @param callback - Function to call after connecting, receives connection object
1051
+ *
1052
+ * @example
1053
+ * prorm.afterConnect((connection) => {
1054
+ * console.log('Connected to database', connection.id);
1055
+ * });
1056
+ */
1057
+ afterConnect(callback: HookCallback): void;
1058
+ /**
1059
+ * Register a hook to be called before disconnection
1060
+ * @param callback - Function to call before disconnecting, receives connection object
1061
+ *
1062
+ * @example
1063
+ * prorm.beforeDisconnect((connection) => {
1064
+ * console.log('About to disconnect', connection.id);
1065
+ * });
1066
+ */
1067
+ beforeDisconnect(callback: HookCallback): void;
1068
+ /**
1069
+ * Register a hook to be called after disconnection
1070
+ * @param callback - Function to call after disconnecting, receives connection object
1071
+ *
1072
+ * @example
1073
+ * prorm.afterDisconnect((connection) => {
1074
+ * console.log('Disconnected from database', connection.id);
1075
+ * });
1076
+ */
1077
+ afterDisconnect(callback: HookCallback): void;
1078
+ /**
1079
+ * Register a hook to be called before destroy
1080
+ * @param callback - Function to call before destroy
1081
+ *
1082
+ * @example
1083
+ * prorm.beforeDestroy((options) => {
1084
+ * console.log('About to destroy records');
1085
+ * });
1086
+ */
1087
+ beforeDestroy(callback: HookCallback): void;
1088
+ /**
1089
+ * Register a hook to be called after destroy
1090
+ * @param callback - Function to call after destroy
1091
+ *
1092
+ * @example
1093
+ * prorm.afterDestroy((options) => {
1094
+ * console.log('Records destroyed');
1095
+ * });
1096
+ */
1097
+ afterDestroy(callback: HookCallback): void;
1098
+ /**
1099
+ * Register a hook to be called before upsert
1100
+ * @param callback - Function to call before upsert
1101
+ *
1102
+ * @example
1103
+ * prorm.beforeUpsert((options) => {
1104
+ * console.log('About to upsert record');
1105
+ * });
1106
+ */
1107
+ beforeUpsert(callback: HookCallback): void;
1108
+ /**
1109
+ * Register a hook to be called after upsert
1110
+ * @param callback - Function to call after upsert
1111
+ *
1112
+ * @example
1113
+ * prorm.afterUpsert((options) => {
1114
+ * console.log('Record upserted');
1115
+ * });
1116
+ */
1117
+ afterUpsert(callback: HookCallback): void;
1118
+ /**
1119
+ * Register a hook to be called before reload
1120
+ * @param callback - Function to call before reload
1121
+ *
1122
+ * @example
1123
+ * prorm.beforeReload((options) => {
1124
+ * console.log('About to reload record');
1125
+ * });
1126
+ */
1127
+ beforeReload(callback: HookCallback): void;
1128
+ /**
1129
+ * Show all tables
1130
+ */
1131
+ showTables(): Promise<string[]>;
1132
+ /**
1133
+ * Alias for showSchemas - Show all schemas
1134
+ * For PostgreSQL, returns all schemas in the database
1135
+ * For MySQL/MariaDB, returns all databases
1136
+ * For SQLite, returns ['main']
1137
+ */
1138
+ showAllSchemas(): Promise<string[]>;
1139
+ /**
1140
+ * Create a PostgreSQL extension
1141
+ * @param extensionName - Name of the extension to create (e.g., 'uuid-ossp', 'postgis', 'pg_trgm')
1142
+ * @param options - Extension options (ifNotExists, schema, version)
1143
+ * @returns Promise that resolves when the extension is created
1144
+ *
1145
+ * @example
1146
+ * // Create the uuid-ossp extension for UUID generation
1147
+ * await prorm.createExtension('uuid-ossp');
1148
+ *
1149
+ * @example
1150
+ * // Create PostGIS extension for spatial data
1151
+ * await prorm.createExtension('postgis', { ifNotExists: true });
1152
+ *
1153
+ * @example
1154
+ * // Create pg_trgm extension with specific version
1155
+ * await prorm.createExtension('pg_trgm', { version: '1.5' });
1156
+ */
1157
+ createExtension(extensionName: string, options?: CreateExtensionOptions): Promise<void>;
1158
+ /**
1159
+ * Drop a PostgreSQL extension
1160
+ * @param extensionName - Name of the extension to drop
1161
+ * @param options - Drop options (ifExists, cascade)
1162
+ * @returns Promise that resolves when the extension is dropped
1163
+ *
1164
+ * @example
1165
+ * // Drop an extension
1166
+ * await prorm.dropExtension('uuid-ossp');
1167
+ *
1168
+ * @example
1169
+ * // Drop extension with cascade (drops dependent objects)
1170
+ * await prorm.dropExtension('postgis', { cascade: true });
1171
+ */
1172
+ dropExtension(extensionName: string, options?: DropExtensionOptions): Promise<void>;
1173
+ /**
1174
+ * Get all installed PostgreSQL extensions
1175
+ * @returns Promise that resolves to an array of extension information
1176
+ *
1177
+ * @example
1178
+ * const extensions = await prorm.getExtensions();
1179
+ * console.log(extensions);
1180
+ * // Output: [
1181
+ * // { name: 'uuid-ossp', defaultVersion: null, installedVersion: '1.0', comment: null },
1182
+ * // { name: 'pg_trgm', defaultVersion: null, installedVersion: '1.5', comment: null }
1183
+ * // ]
1184
+ */
1185
+ getExtensions(): Promise<ExtensionInfo[]>;
1186
+ /**
1187
+ * Check if a PostgreSQL extension is installed
1188
+ * @param extensionName - Name of the extension to check
1189
+ * @returns Promise that resolves to true if the extension is installed
1190
+ *
1191
+ * @example
1192
+ * const hasUuid = await prorm.hasExtension('uuid-ossp');
1193
+ * if (hasUuid) {
1194
+ * console.log('UUID extension is available');
1195
+ * }
1196
+ */
1197
+ hasExtension(extensionName: string): Promise<boolean>;
1198
+ /**
1199
+ * Check if a PostgreSQL extension is installed (alias for hasExtension).
1200
+ * Returns false for non-PostgreSQL dialects instead of throwing.
1201
+ */
1202
+ extensionExists(extensionName: string): Promise<boolean>;
1203
+ /**
1204
+ * Lazily-created ForeignDataManager instance for this Prorm connection.
1205
+ * Provides the full FDW management surface (servers, user mappings, foreign tables).
1206
+ *
1207
+ * @example
1208
+ * await prorm.fdw.createServer('remote_pg', { fdw: 'postgres_fdw', options: { host: 'db2.example.com', dbname: 'sales', port: '5432' } });
1209
+ */
1210
+ get fdw(): ForeignDataManager;
1211
+ /**
1212
+ * Lazily-created UserManager instance for this Prorm connection.
1213
+ * Provides the full user / role / privilege management surface.
1214
+ *
1215
+ * @example
1216
+ * await prorm.users.createUser('app', { host: '%', password: 'secret' });
1217
+ */
1218
+ get users(): UserManager;
1219
+ createUser(username: string, options?: any): Promise<void>;
1220
+ alterUser(username: string, options: any): Promise<void>;
1221
+ dropUser(username: string, options?: any): Promise<void>;
1222
+ getUsers(): Promise<import('./user-management').UserInfo[]>;
1223
+ userExists(username: string, host?: string): Promise<boolean>;
1224
+ grant(options: any): Promise<void>;
1225
+ revoke(options: any): Promise<void>;
1226
+ grantRole(role: string, to: string | string[], options?: any): Promise<void>;
1227
+ revokeRole(role: string, from: string | string[], options?: any): Promise<void>;
1228
+ createRole(roleName: string, options?: any): Promise<void>;
1229
+ dropRole(roleName: string, options?: any): Promise<void>;
1230
+ flushPrivileges(): Promise<void>;
1231
+ showGrants(username: string, host?: string): Promise<any[]>;
1232
+ getRoles(): Promise<string[]>;
1233
+ /**
1234
+ * CREATE FOREIGN SERVER shortcut.
1235
+ *
1236
+ * @example
1237
+ * await prorm.createServer('remote_pg', {
1238
+ * fdw: 'postgres_fdw',
1239
+ * options: { host: 'remotehost', dbname: 'remotedb', port: '5432' },
1240
+ * ifNotExists: true,
1241
+ * });
1242
+ */
1243
+ createServer(name: string, options: ForeignServerOptions): Promise<void>;
1244
+ /**
1245
+ * DROP FOREIGN SERVER shortcut.
1246
+ */
1247
+ dropServer(name: string, options?: {
1248
+ ifExists?: boolean;
1249
+ cascade?: boolean;
1250
+ }): Promise<void>;
1251
+ /**
1252
+ * List all foreign servers visible in the current PostgreSQL database.
1253
+ */
1254
+ getServers(): Promise<ServerInfo[]>;
1255
+ /**
1256
+ * CREATE USER MAPPING shortcut.
1257
+ *
1258
+ * @example
1259
+ * await prorm.createUserMapping({
1260
+ * serverName: 'remote_pg',
1261
+ * user: 'CURRENT_USER',
1262
+ * options: { user: 'remoteuser', password: 'secret' },
1263
+ * });
1264
+ */
1265
+ createUserMapping(options: UserMappingOptions): Promise<void>;
1266
+ /**
1267
+ * DROP USER MAPPING shortcut.
1268
+ */
1269
+ dropUserMapping(serverName: string, user?: string): Promise<void>;
1270
+ /**
1271
+ * CREATE FOREIGN TABLE shortcut.
1272
+ *
1273
+ * @example
1274
+ * await prorm.createForeignTable('remote_orders', {
1275
+ * serverName: 'remote_pg',
1276
+ * columns: {
1277
+ * id: { type: 'INTEGER' },
1278
+ * total: { type: 'NUMERIC(12,2)' },
1279
+ * created_at: { type: 'TIMESTAMP' },
1280
+ * },
1281
+ * options: { schema_name: 'public', table_name: 'orders' },
1282
+ * });
1283
+ */
1284
+ createForeignTable(tableName: string, options: ForeignTableOptions): Promise<void>;
1285
+ /**
1286
+ * IMPORT FOREIGN SCHEMA shortcut.
1287
+ *
1288
+ * @example
1289
+ * await prorm.importForeignSchema('public', 'remote_pg', {
1290
+ * localSchema: 'remote_mirror',
1291
+ * limitTo: ['users', 'orders'],
1292
+ * });
1293
+ */
1294
+ importForeignSchema(remoteSchema: string, serverName: string, options?: ImportForeignSchemaOptions): Promise<void>;
1295
+ /**
1296
+ * Define a foreign table and register a read-only model for it.
1297
+ *
1298
+ * Works like `define()` but issues CREATE FOREIGN TABLE in the database and
1299
+ * returns a model whose `findAll` / `findOne` / `findByPk` are usable for
1300
+ * read-only queries. Write operations (create/update/destroy) are not
1301
+ * prevented at the ORM level but will fail at the database level because
1302
+ * PostgreSQL foreign tables are read-only by default.
1303
+ *
1304
+ * @param tableName - The local foreign table name
1305
+ * @param options - Foreign table options (serverName, columns, etc.)
1306
+ * @returns The model class registered under `tableName`
1307
+ *
1308
+ * @example
1309
+ * const RemoteUser = await prorm.defineForeignTable('remote_users', {
1310
+ * serverName: 'remote_pg',
1311
+ * columns: {
1312
+ * id: { type: 'INTEGER' },
1313
+ * email: { type: 'TEXT' },
1314
+ * name: { type: 'VARCHAR(255)' },
1315
+ * },
1316
+ * ifNotExists: true,
1317
+ * });
1318
+ * const users = await RemoteUser.findAll({ where: { name: 'Alice' } });
1319
+ */
1320
+ defineForeignTable(tableName: string, options: ForeignTableOptions): Promise<any>;
1321
+ /**
1322
+ * Get database version
1323
+ */
1324
+ getDatabaseVersion(): Promise<string>;
1325
+ /**
1326
+ * Get database name
1327
+ */
1328
+ getDatabaseName(): string;
1329
+ /**
1330
+ * Create a database schema
1331
+ * @param name - Name of the schema to create
1332
+ * @returns Promise that resolves when the schema is created
1333
+ *
1334
+ * @example
1335
+ * // Create a new schema
1336
+ * await prorm.createSchema('mySchema');
1337
+ */
1338
+ createSchema(name: string): Promise<void>;
1339
+ /**
1340
+ * Drop a database schema
1341
+ * @param name - Name of the schema to drop
1342
+ * @param options - Options for dropping the schema (cascade, ifExists)
1343
+ * @returns Promise that resolves when the schema is dropped
1344
+ *
1345
+ * @example
1346
+ * // Drop a schema
1347
+ * await prorm.dropSchema('mySchema');
1348
+ *
1349
+ * @example
1350
+ * // Drop schema with cascade (drop all objects in schema)
1351
+ * await prorm.dropSchema('mySchema', { cascade: true });
1352
+ */
1353
+ dropSchema(name: string, options?: {
1354
+ cascade?: boolean;
1355
+ ifExists?: boolean;
1356
+ }): Promise<void>;
1357
+ /**
1358
+ * Show all schemas
1359
+ * @returns Promise that resolves to an array of schema names
1360
+ *
1361
+ * @example
1362
+ * // Get all schemas
1363
+ * const schemas = await prorm.showSchemas();
1364
+ * console.log(schemas); // ['public', 'mySchema', ...]
1365
+ */
1366
+ showSchemas(): Promise<string[]>;
1367
+ /**
1368
+ * Get the full table name with schema prefix
1369
+ * @param tableName - The table name
1370
+ * @param schema - Optional schema name
1371
+ * @param schemaDelimiter - Optional delimiter (default: '.')
1372
+ * @returns Full table name with schema prefix
1373
+ */
1374
+ getTableNameWithSchema(tableName: string, schema?: string, schemaDelimiter?: string): string;
1375
+ /**
1376
+ * Create a database trigger
1377
+ * @param options - Trigger creation options
1378
+ * @returns Promise that resolves when the trigger is created
1379
+ *
1380
+ * @example
1381
+ * // Create an INSERT trigger in PostgreSQL
1382
+ * await prorm.createTrigger({
1383
+ * tableName: 'users',
1384
+ * triggerName: 'set_created_at',
1385
+ * timing: 'BEFORE',
1386
+ * event: 'INSERT',
1387
+ * body: 'NEW.created_at = NOW();',
1388
+ * rowLevel: true
1389
+ * });
1390
+ *
1391
+ * @example
1392
+ * // Create an UPDATE trigger in MySQL
1393
+ * await prorm.createTrigger({
1394
+ * tableName: 'users',
1395
+ * triggerName: 'update_timestamp',
1396
+ * timing: 'BEFORE',
1397
+ * event: 'UPDATE',
1398
+ * body: 'SET NEW.updated_at = NOW();'
1399
+ * });
1400
+ */
1401
+ createTrigger(options: {
1402
+ tableName: string;
1403
+ triggerName: string;
1404
+ timing: 'BEFORE' | 'AFTER' | 'INSTEAD OF';
1405
+ event: 'INSERT' | 'UPDATE' | 'DELETE' | 'INSERT UPDATE' | 'INSERT DELETE' | 'UPDATE DELETE' | 'INSERT UPDATE DELETE';
1406
+ body: string;
1407
+ schema?: string;
1408
+ rowLevel?: boolean;
1409
+ constraint?: string;
1410
+ updateColumns?: string[];
1411
+ functionName?: string;
1412
+ functionArgs?: any[];
1413
+ }): Promise<void>;
1414
+ /**
1415
+ * Drop a database trigger
1416
+ * @param options - Trigger drop options
1417
+ * @returns Promise that resolves when the trigger is dropped
1418
+ *
1419
+ * @example
1420
+ * // Drop a trigger
1421
+ * await prorm.dropTrigger({
1422
+ * tableName: 'users',
1423
+ * triggerName: 'set_created_at'
1424
+ * });
1425
+ *
1426
+ * @example
1427
+ * // Drop trigger with IF EXISTS (PostgreSQL)
1428
+ * await prorm.dropTrigger({
1429
+ * tableName: 'users',
1430
+ * triggerName: 'old_trigger',
1431
+ * ifExists: true
1432
+ * });
1433
+ */
1434
+ dropTrigger(options: {
1435
+ tableName: string;
1436
+ triggerName: string;
1437
+ schema?: string;
1438
+ ifExists?: boolean;
1439
+ cascade?: boolean;
1440
+ constraint?: boolean;
1441
+ }): Promise<void>;
1442
+ /**
1443
+ * Create a custom aggregate function (algorithm) in PostgreSQL
1444
+ * PostgreSQL supports creating custom aggregate functions using CREATE AGGREGATE
1445
+ *
1446
+ * @param options - Algorithm creation options
1447
+ * @returns Promise that resolves when the algorithm is created
1448
+ *
1449
+ * @example
1450
+ * // Create a custom aggregate function in PostgreSQL
1451
+ * await prorm.createAlgorithm({
1452
+ * name: 'my_aggregate',
1453
+ * arguments: ['integer'],
1454
+ * stateType: 'integer',
1455
+ * stateFunction: 's = s + $1',
1456
+ * finalFunction: 's = s'
1457
+ * });
1458
+ *
1459
+ * @example
1460
+ * // Create a custom aggregate with multiple parameters
1461
+ * await prorm.createAlgorithm({
1462
+ * name: 'weighted_avg',
1463
+ * arguments: ['numeric', 'numeric'],
1464
+ * stateType: 'numeric',
1465
+ * stateFunction: 's = s + ($1 * $2)',
1466
+ * finalFunction: 's = s'
1467
+ * });
1468
+ */
1469
+ createAlgorithm(options: {
1470
+ /** Name of the aggregate function to create */
1471
+ name: string;
1472
+ /** Input data types for the aggregate */
1473
+ arguments: string[];
1474
+ /** The state type (intermediate state data type) */
1475
+ stateType: string;
1476
+ /** The state transition function body */
1477
+ stateFunction: string;
1478
+ /** The final function body (optional) */
1479
+ finalFunction?: string;
1480
+ /** The initial condition value (optional) */
1481
+ initialCondition?: string;
1482
+ /** Schema name (optional) */
1483
+ schema?: string;
1484
+ /** If true, replaces existing aggregate (PostgreSQL 9.5+) */
1485
+ replace?: boolean;
1486
+ /** Parallel mode: UNSAFE, SAFE, or RESTRICTED */
1487
+ parallel?: 'UNSAFE' | 'SAFE' | 'RESTRICTED';
1488
+ /** Language for the function (default: sql) */
1489
+ language?: string;
1490
+ }): Promise<void>;
1491
+ /**
1492
+ * Drop a custom aggregate function (algorithm) from PostgreSQL
1493
+ *
1494
+ * @param options - Algorithm drop options
1495
+ * @returns Promise that resolves when the algorithm is dropped
1496
+ *
1497
+ * @example
1498
+ * // Drop an algorithm
1499
+ * await prorm.dropAlgorithm({
1500
+ * name: 'my_aggregate',
1501
+ * arguments: ['integer']
1502
+ * });
1503
+ *
1504
+ * @example
1505
+ * // Drop algorithm with IF EXISTS
1506
+ * await prorm.dropAlgorithm({
1507
+ * name: 'my_aggregate',
1508
+ * arguments: ['integer'],
1509
+ * ifExists: true
1510
+ * });
1511
+ */
1512
+ dropAlgorithm(options: {
1513
+ /** Name of the aggregate function to drop */
1514
+ name: string;
1515
+ /** Input data types for the aggregate */
1516
+ arguments: string[];
1517
+ /** Schema name (optional) */
1518
+ schema?: string;
1519
+ /** If true, uses IF EXISTS (PostgreSQL 9.3+) */
1520
+ ifExists?: boolean;
1521
+ /** If true, CASCADE dependent objects */
1522
+ cascade?: boolean;
1523
+ /** If true, RESTRICT if dependent objects exist */
1524
+ restrict?: boolean;
1525
+ }): Promise<void>;
1526
+ /**
1527
+ * Add a new column to a table
1528
+ */
1529
+ addColumn(tableName: string, columnName: string, attribute: AttributeOptions): Promise<void>;
1530
+ /**
1531
+ * Remove a column from a table
1532
+ */
1533
+ removeColumn(tableName: string, columnName: string): Promise<void>;
1534
+ /**
1535
+ * Change a column definition
1536
+ */
1537
+ changeColumn(tableName: string, columnName: string, attribute: AttributeOptions): Promise<void>;
1538
+ /**
1539
+ * Rename a table
1540
+ */
1541
+ renameTable(oldName: string, newName: string): Promise<void>;
1542
+ /**
1543
+ * Add an index
1544
+ */
1545
+ addIndex(tableName: string, indexName: string, fields: string[], options?: {
1546
+ unique?: boolean;
1547
+ type?: string;
1548
+ }): Promise<void>;
1549
+ /**
1550
+ * Remove an index
1551
+ */
1552
+ removeIndex(tableName: string, indexName: string): Promise<void>;
1553
+ /**
1554
+ * Describe a table
1555
+ */
1556
+ describeTable(tableName: string): Promise<Record<string, unknown>>;
1557
+ /**
1558
+ * Sync all models to database
1559
+ *
1560
+ * @param options - Sync options
1561
+ * @returns Promise that resolves when sync is complete
1562
+ *
1563
+ * @example
1564
+ * // Safe sync - creates missing tables only (default)
1565
+ * await prorm.sync()
1566
+ *
1567
+ * @example
1568
+ * // Force sync - drops all tables and recreates them (destroys data!)
1569
+ * await prorm.sync({ force: true })
1570
+ *
1571
+ * @example
1572
+ * // Alter sync - modifies tables to match models (preserves data)
1573
+ * await prorm.sync({ alter: true })
1574
+ *
1575
+ * @example
1576
+ * // Conditional sync - only syncs if database name matches pattern
1577
+ * await prorm.sync({ match: /test/ })
1578
+ */
1579
+ /**
1580
+ * Create a new database with the specified options.
1581
+ * Supports PostgreSQL, MySQL, and MariaDB.
1582
+ *
1583
+ * @example
1584
+ * // Create database with PostgreSQL
1585
+ * await prorm.createDatabase({
1586
+ * name: 'myapp',
1587
+ * encoding: 'UTF8',
1588
+ * lcCollate: 'en_US.UTF-8',
1589
+ * lcCtype: 'en_US.UTF-8',
1590
+ * template: 'template0',
1591
+ * });
1592
+ *
1593
+ * @example
1594
+ * // Create database with MySQL/MariaDB
1595
+ * await prorm.createDatabase({
1596
+ * name: 'myapp',
1597
+ * encoding: 'UTF8',
1598
+ * collate: 'utf8mb4_unicode_ci',
1599
+ * });
1600
+ */
1601
+ createDatabase(options: {
1602
+ name: string;
1603
+ encoding?: string;
1604
+ lcCollate?: string;
1605
+ lcCtype?: string;
1606
+ template?: string;
1607
+ tablespace?: string;
1608
+ collate?: string;
1609
+ isTemplate?: boolean;
1610
+ }): Promise<void>;
1611
+ /**
1612
+ * Drop a database if it exists.
1613
+ *
1614
+ * @example
1615
+ * await prorm.dropDatabase('olddb');
1616
+ */
1617
+ dropDatabase(name: string): Promise<void>;
1618
+ sync(options?: SyncOptions): Promise<this>;
1619
+ /**
1620
+ * Register a class carrying `@Procedure` / `@SqlFunction` annotations so that
1621
+ * `sync()` creates them.
1622
+ *
1623
+ * Procedures are declared on plain classes rather than models, so there is no
1624
+ * other point at which the ORM would learn about them.
1625
+ */
1626
+ /**
1627
+ * Register an object or key-value store for use by `@ExternalField`.
1628
+ *
1629
+ * Accepts any of the shipped stores (S3, MinIO, R2, GCS, Azure Blob, Redis,
1630
+ * ...) directly - the differing method names are normalized internally - or
1631
+ * any object implementing `ExternalStoreAdapter`.
1632
+ *
1633
+ * ```typescript
1634
+ * const s3 = new S3Store({ region: 'us-east-1' });
1635
+ * await s3.connect();
1636
+ * prorm.registerStore('assets', s3, { defaultBucket: 'avatars' });
1637
+ * ```
1638
+ */
1639
+ registerStore(name: string, store: unknown, options?: RegisterStoreOptions): this;
1640
+ registerProcedures(procedureClass: Function): this;
1641
+ /**
1642
+ * Apply the DDL declared by annotations: `@View`, `@MaterializedView`,
1643
+ * `@Trigger` on model classes, and `@Procedure` / `@SqlFunction` on classes
1644
+ * passed to `registerProcedures()`.
1645
+ *
1646
+ * These registries previously generated correct SQL that nothing executed -
1647
+ * `ViewRegistry`, `getTriggers` and `ProcedureRegistry` were referenced only
1648
+ * from inside `src/decorators/`, so annotating a class produced a string the
1649
+ * user still had to fetch and hand to `prorm.query()` themselves.
1650
+ */
1651
+ private syncSchemaObjects;
1652
+ /**
1653
+ * Bind every queued decorator association whose target model is registered.
1654
+ *
1655
+ * Called after each `addModel()`, and again by `sync()` so that a model graph
1656
+ * registered in any order ends up fully wired before tables are created.
1657
+ * Associations whose target is still unregistered stay queued.
1658
+ */
1659
+ private _flushPendingAssociations;
1660
+ /**
1661
+ * Names of models referenced by a decorator association that were never
1662
+ * registered, so callers can report them rather than silently skipping.
1663
+ */
1664
+ private _unresolvedAssociationTargets;
1665
+ /**
1666
+ * Issue a real `SELECT COUNT(...)` for a model.
1667
+ *
1668
+ * Honors `where`, paranoid filtering, filtering (`required`) includes,
1669
+ * `distinct`/`col` and `group`:
1670
+ * - `col` picks the counted expression (`COUNT("col")`)
1671
+ * - `distinct: true` counts distinct values of `col`, or of the primary key
1672
+ * - `group` returns the number of groups
1673
+ */
1674
+ private _countRows;
1675
+ /**
1676
+ * The view of this instance that the shared eager-loader needs.
1677
+ */
1678
+ private eagerLoadContext;
1679
+ /**
1680
+ * Order models so that every table is created after the tables it references.
1681
+ *
1682
+ * Table creation used to follow `modelDefinitions` insertion order, i.e. the
1683
+ * order the user happened to call `define()` in, while `createTableFromModel`
1684
+ * simultaneously emitted REFERENCES clauses. On any dialect that validates
1685
+ * foreign keys at creation time, defining `Post` before `User` failed. The
1686
+ * ordering is derived from the association graph so declaration order stops
1687
+ * mattering.
1688
+ *
1689
+ * Cycles (two models referencing each other) can't be resolved by ordering
1690
+ * alone; those models are emitted last in declaration order, which is the same
1691
+ * behaviour as before for that case.
1692
+ */
1693
+ private orderModelsByDependency;
1694
+ /**
1695
+ * Default sync mode - creates missing tables only (safe)
1696
+ */
1697
+ private syncCreate;
1698
+ /**
1699
+ * Force sync mode - drops all tables and recreates them
1700
+ */
1701
+ private syncForce;
1702
+ /**
1703
+ * Alter sync mode - modifies tables to match models (preserves data)
1704
+ */
1705
+ private syncAlter;
1706
+ /**
1707
+ * Alter a table to match model definition
1708
+ */
1709
+ private alterTable;
1710
+ /**
1711
+ * Build column definitions from model attributes
1712
+ */
1713
+ private buildColumnDefinitions;
1714
+ /**
1715
+ * Check if a column needs to be changed
1716
+ */
1717
+ private columnNeedsChange;
1718
+ /**
1719
+ * Normalize column type for comparison
1720
+ */
1721
+ private normalizeType;
1722
+ /**
1723
+ * Get the migration configuration
1724
+ */
1725
+ getMigrator(): any;
1726
+ /**
1727
+ * Run pending migrations
1728
+ */
1729
+ migrate(options?: {
1730
+ migration?: string;
1731
+ }): Promise<any>;
1732
+ /**
1733
+ * Revert migrations
1734
+ */
1735
+ migrateUndo(options?: {
1736
+ steps?: number;
1737
+ migration?: string;
1738
+ }): Promise<any>;
1739
+ /**
1740
+ * Get migration status
1741
+ */
1742
+ migrateStatus(): Promise<any>;
1743
+ /**
1744
+ * Create a SQL function expression
1745
+ * @param fnName - The SQL function name (e.g., 'COUNT', 'UPPER', 'YEAR', 'SUM', 'AVG', 'LOWER')
1746
+ * @param args - The arguments to the function (column names, column references, or other functions)
1747
+ * @returns A Fn object that can be used in query attributes
1748
+ *
1749
+ * @example
1750
+ * // COUNT(id) -> COUNT(id)
1751
+ * prorm.fn('COUNT', 'id')
1752
+ *
1753
+ * // UPPER(name) -> UPPER(name)
1754
+ * prorm.fn('UPPER', prorm.col('name'))
1755
+ *
1756
+ * // YEAR(createdAt) -> YEAR(createdAt)
1757
+ * prorm.fn('YEAR', 'createdAt')
1758
+ *
1759
+ * // COUNT with column reference
1760
+ * prorm.fn('COUNT', prorm.col('id'))
1761
+ *
1762
+ * // Nested function: UPPER(LOWER(name))
1763
+ * prorm.fn('UPPER', prorm.fn('LOWER', 'name'))
1764
+ *
1765
+ * // Use in findAll
1766
+ * User.findAll({
1767
+ * attributes: ['role', [prorm.fn('COUNT', prorm.col('id')), 'count']]
1768
+ * })
1769
+ */
1770
+ fn(fnName: string, ...args: (string | Col | Fn | Literal)[]): Fn;
1771
+ /**
1772
+ * Create a column reference for use in SQL functions
1773
+ * @param tableOrColumn - Table name (if second param provided) or column name
1774
+ * @param column - Column name (if first param is table name)
1775
+ * @returns A Col object that can be used as an argument to prorm.fn()
1776
+ *
1777
+ * @example
1778
+ * // Reference a column in a function
1779
+ * prorm.fn('COUNT', prorm.col('id'))
1780
+ *
1781
+ * // Reference with table name: col('User', 'name') -> "User"."name"
1782
+ * prorm.fn('UPPER', prorm.col('User', 'name'))
1783
+ *
1784
+ * // Dot notation: col('table.column') -> "table"."column"
1785
+ * prorm.fn('UPPER', prorm.col('User.name'))
1786
+ *
1787
+ * // Use in findAll
1788
+ * User.findAll({
1789
+ * attributes: ['role', [prorm.fn('COUNT', prorm.col('id')), 'count']]
1790
+ * })
1791
+ */
1792
+ col(tableOrColumn: string, column?: string): Col;
1793
+ /**
1794
+ * Create a literal SQL expression
1795
+ * Use this to inject raw SQL directly into queries
1796
+ * @param sql - The raw SQL expression
1797
+ * @returns A Literal object that will be inserted as-is into the SQL query
1798
+ *
1799
+ * @example
1800
+ * // Use literal in where clause
1801
+ * User.findAll({
1802
+ * where: prorm.literal('COUNT(role) > 1')
1803
+ * })
1804
+ *
1805
+ * // Use literal in attributes for complex expressions
1806
+ * User.findAll({
1807
+ * attributes: [[prorm.literal("'prefix' || name"), 'prefixedName']]
1808
+ * })
1809
+ */
1810
+ /**
1811
+ * Create a type cast expression
1812
+ * Used to cast a value to a specific data type in SQL queries
1813
+ * @param value - The value to cast (column reference, literal, or other expression)
1814
+ * @param type - The target data type (e.g., 'VARCHAR', 'INTEGER', 'DATE', 'BOOLEAN')
1815
+ * @returns A Cast object that can be used in queries
1816
+ *
1817
+ * @example
1818
+ * // Cast a string to integer
1819
+ * prorm.cast(prorm.col('count'), 'INTEGER')
1820
+ *
1821
+ * // Cast a value to date
1822
+ * prorm.cast(prorm.col('timestamp'), 'DATETIME')
1823
+ *
1824
+ * // Cast in where clause
1825
+ * User.findAll({
1826
+ * where: prorm.cast(prorm.col('active'), 'BOOLEAN')
1827
+ * })
1828
+ *
1829
+ * // Use in attributes for type conversion
1830
+ * User.findAll({
1831
+ * attributes: [[prorm.cast(prorm.col('price'), 'VARCHAR'), 'priceStr']]
1832
+ * })
1833
+ */
1834
+ cast(value: string | Col | Fn | Literal, type: string): Cast;
1835
+ /**
1836
+ * UUIDV4 default value for generating UUIDs
1837
+ * Use as defaultValue in model definitions
1838
+ * @returns A Literal that generates a UUID v4
1839
+ *
1840
+ * @example
1841
+ * const User = prorm.define('User', {
1842
+ * id: { type: DataTypes.UUID, defaultValue: Prorm.UUIDV4, primaryKey: true },
1843
+ * uuid: { type: DataTypes.UUID, defaultValue: prorm.UUIDV4 }
1844
+ * });
1845
+ */
1846
+ get UUIDV4(): Literal;
1847
+ /**
1848
+ * Create a where condition for complex queries
1849
+ * Allows creating custom WHERE clauses with operators
1850
+ * @param condition - The condition object or literal SQL
1851
+ * @param replacements - Optional replacements for the condition
1852
+ * @returns A WhereObject for use in find options
1853
+ *
1854
+ * @example
1855
+ * // Simple equality with column reference
1856
+ * prorm.where(prorm.col('name'), 'John')
1857
+ *
1858
+ * // With a comparator operator
1859
+ * prorm.where(prorm.col('age'), { $gt: 18 })
1860
+ *
1861
+ * // Complex condition with literal
1862
+ * prorm.where(prorm.literal('LOWER(name)'), 'john')
1863
+ *
1864
+ * // Using with fn
1865
+ * prorm.where(prorm.fn('YEAR', prorm.col('createdAt')), 2024)
1866
+ */
1867
+ where(col: Col | Fn | Literal, value: unknown): WhereObject;
1868
+ /**
1869
+ * Create an AND condition for combining multiple where conditions
1870
+ * @param conditions - The conditions to combine with AND
1871
+ * @returns An AndOrObject with AND operator
1872
+ *
1873
+ * @example
1874
+ * // Combine multiple conditions
1875
+ * prorm.and(
1876
+ * { name: 'John' },
1877
+ * { age: { $gte: 18 } }
1878
+ * )
1879
+ *
1880
+ * // Use in where clause
1881
+ * User.findAll({
1882
+ * where: prorm.and(
1883
+ * { status: 'active' },
1884
+ * { role: 'admin' }
1885
+ * )
1886
+ * })
1887
+ *
1888
+ * // Nested with or
1889
+ * prorm.and(
1890
+ * { active: true },
1891
+ * prorm.or({ role: 'admin' }, { role: 'moderator' })
1892
+ * )
1893
+ */
1894
+ and(...conditions: unknown[]): AndOrObject;
1895
+ /**
1896
+ * Create an OR condition for combining multiple where conditions
1897
+ * @param conditions - The conditions to combine with OR
1898
+ * @returns An AndOrObject with OR operator
1899
+ *
1900
+ * @example
1901
+ * // Combine multiple conditions
1902
+ * prorm.or(
1903
+ * { name: 'John' },
1904
+ * { name: 'Jane' }
1905
+ * )
1906
+ *
1907
+ * // Use in where clause
1908
+ * User.findAll({
1909
+ * where: prorm.or(
1910
+ * { status: 'active' },
1911
+ * { role: 'admin' }
1912
+ * )
1913
+ * })
1914
+ *
1915
+ * // Complex nested condition
1916
+ * prorm.or(
1917
+ * prorm.and({ status: 'active' }, { role: 'admin' }),
1918
+ * { id: 1 }
1919
+ * )
1920
+ */
1921
+ or(...conditions: unknown[]): AndOrObject;
1922
+ /**
1923
+ * Create a JSON path query for querying JSON columns
1924
+ * Used to query specific paths in JSON columns (PostgreSQL, MySQL JSON)
1925
+ * @param path - The JSON path to query (dot notation or array notation)
1926
+ * @param value - Optional value to compare against
1927
+ * @returns A JsonObject for use in where clauses
1928
+ *
1929
+ * @example
1930
+ * // Query JSON column path
1931
+ * prorm.json('profile.name')
1932
+ *
1933
+ * // Query nested JSON path
1934
+ * prorm.json('settings.theme.color')
1935
+ *
1936
+ * // Query with value comparison
1937
+ * prorm.json('profile.age', 25)
1938
+ *
1939
+ * // Use in where clause
1940
+ * User.findAll({
1941
+ * where: prorm.json('profile.isActive', true)
1942
+ * })
1943
+ *
1944
+ * // Query array element
1945
+ * prorm.json('tags[0]', 'important')
1946
+ */
1947
+ json(path: string, value?: unknown): JsonObject;
1948
+ /**
1949
+ * Static version of the where method - creates a WHERE condition
1950
+ * Can be used without instantiating Prorm
1951
+ * @param col - The column reference (Col, Fn, or Literal)
1952
+ * @param value - The value or condition to compare against
1953
+ * @returns A WhereObject for use in find options
1954
+ */
1955
+ static where(col: Col | Fn | Literal, value: unknown): WhereObject;
1956
+ /**
1957
+ * Static version of the and method - combines conditions with AND
1958
+ * Can be used without instantiating Prorm
1959
+ * @param conditions - The conditions to combine with AND
1960
+ * @returns An AndOrObject with AND operator
1961
+ */
1962
+ static and(...conditions: unknown[]): AndOrObject;
1963
+ /**
1964
+ * Static version of the or method - combines conditions with OR
1965
+ * Can be used without instantiating Prorm
1966
+ * @param conditions - The conditions to combine with OR
1967
+ * @returns An AndOrObject with OR operator
1968
+ */
1969
+ static or(...conditions: unknown[]): AndOrObject;
1970
+ /**
1971
+ * Static version of the json method - creates a JSON path query
1972
+ * Can be used without instantiating Prorm
1973
+ * @param path - The JSON path to query
1974
+ * @param value - Optional value to compare against
1975
+ * @returns A JsonObject for use in where clauses
1976
+ */
1977
+ static json(path: string, value?: unknown): JsonObject;
1978
+ /**
1979
+ * Static version of the validate method - validates a model's values
1980
+ * Can be used without instantiating Prorm
1981
+ * @param values - The values to validate
1982
+ * @param options - Validation options
1983
+ * @returns A promise that resolves with validation errors
1984
+ */
1985
+ static validate(values: Record<string, unknown>, options?: {
1986
+ model?: ModelStatic<AnyModel>;
1987
+ }): Promise<ValidationError | null>;
1988
+ }
1989
+ /**
1990
+ * Represents a SQL function expression
1991
+ * Used with prorm.fn() to create SQL functions like COUNT, UPPER, YEAR, etc.
1992
+ */
1993
+ export interface Fn {
1994
+ /**
1995
+ * The SQL function name (e.g., 'COUNT', 'UPPER', 'YEAR')
1996
+ */
1997
+ fn: string;
1998
+ /**
1999
+ * The arguments to the function (can be column references, literals, or other functions)
2000
+ */
2001
+ args: (string | Col | Fn | Literal)[];
2002
+ }
2003
+ /**
2004
+ * Represents a SQL CAST expression
2005
+ * Used to cast a value to a specific data type
2006
+ */
2007
+ export interface Cast {
2008
+ /**
2009
+ * Type identifier for CAST
2010
+ */
2011
+ $type: 'cast';
2012
+ /**
2013
+ * The value to cast (column reference, literal, or function)
2014
+ */
2015
+ value: string | Col | Fn | Literal;
2016
+ /**
2017
+ * The target data type (e.g., 'VARCHAR', 'INTEGER', 'DATE', 'BOOLEAN')
2018
+ */
2019
+ type: string;
2020
+ }
2021
+ /**
2022
+ * Represents a WHERE condition for complex queries
2023
+ */
2024
+ export interface WhereObject {
2025
+ /**
2026
+ * Type identifier for WHERE
2027
+ */
2028
+ $type: 'where';
2029
+ /**
2030
+ * The column or expression to compare
2031
+ */
2032
+ col: Col | Fn | Literal;
2033
+ /**
2034
+ * The value or condition to compare against
2035
+ */
2036
+ value: unknown;
2037
+ }
2038
+ /**
2039
+ * Represents an AND or OR combination of conditions
2040
+ */
2041
+ export interface AndOrObject {
2042
+ /**
2043
+ * Type identifier - 'and' or 'or'
2044
+ */
2045
+ $type: 'and' | 'or';
2046
+ /**
2047
+ * The conditions to combine
2048
+ */
2049
+ conditions: unknown[];
2050
+ }
2051
+ /**
2052
+ * Represents a JSON path query for JSON columns
2053
+ */
2054
+ export interface JsonObject {
2055
+ /**
2056
+ * Type identifier for JSON
2057
+ */
2058
+ $type: 'json';
2059
+ /**
2060
+ * The JSON path to query (dot notation or array notation)
2061
+ */
2062
+ path: string;
2063
+ /**
2064
+ * Optional value to compare against
2065
+ */
2066
+ value?: unknown;
2067
+ }
2068
+ /**
2069
+ * DataTypes for model definitions
2070
+ */
2071
+ export declare const DataTypes: {
2072
+ STRING: (length?: number) => DataType;
2073
+ CHAR: (length?: number) => DataType;
2074
+ TEXT: (length?: number) => DataType;
2075
+ INTEGER: () => DataType;
2076
+ BIGINT: () => DataType;
2077
+ FLOAT: () => DataType;
2078
+ DOUBLE: () => DataType;
2079
+ DECIMAL: (precision?: number, scale?: number) => DataType;
2080
+ BOOLEAN: () => DataType;
2081
+ DATE: () => DataType;
2082
+ DATEONLY: () => DataType;
2083
+ TIME: () => DataType;
2084
+ BLOB: () => DataType;
2085
+ ENUM: (...values: string[]) => DataType;
2086
+ JSON: () => DataType;
2087
+ JSONB: () => DataType;
2088
+ UUID: () => DataType;
2089
+ };
2090
+ export * from './types';
2091
+ export { Dialect, DialectOptions, ColumnDefinition, TableOptions } from './dialects/dialect';
2092
+ export { SQLiteDialect } from './dialects/sqlite';
2093
+ export { OracleDialect } from './dialects/oracle';