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,820 @@
1
+ /**
2
+ * Model class for the ORM
3
+ * Represents a database table with CRUD operations, validations, and hooks
4
+ *
5
+ * Usage examples:
6
+ *
7
+ * // 1. Define methods in model options
8
+ * const User = prorm.define('User', {
9
+ * firstName: Prorm.STRING,
10
+ * lastName: Prorm.STRING,
11
+ * }, {
12
+ * classMethods: {
13
+ * findByEmail: function(email: string) {
14
+ * return this.findOne({ where: { email } });
15
+ * }
16
+ * },
17
+ * instanceMethods: {
18
+ * getFullName: function() {
19
+ * return this.firstName + ' ' + this.lastName;
20
+ * }
21
+ * }
22
+ * });
23
+ *
24
+ * // 2. Add methods after model definition
25
+ * User.addMethod('classMethod', 'findByUsername', function(username: string) {
26
+ * return this.findOne({ where: { username } });
27
+ * });
28
+ *
29
+ * User.addMethod('instanceMethod', 'getFullName', function() {
30
+ * return this.get('firstName') + ' ' + this.get('lastName');
31
+ * });
32
+ *
33
+ * // Usage:
34
+ * const user = await User.findByEmail('test@example.com');
35
+ * console.log(user.getFullName()); // Instance method call
36
+ * const userByName = await User.findByUsername('john'); // Class method call
37
+ */
38
+ import { ModelStatic, ModelOptions, AttributeOptions, FindOptions, CreateOptions, UpdateOptions, DestroyOptions, SaveOptions, Transaction, HookHandler, ValidationErrorItem, BulkCreateOptions, CountOptions, UpsertOptions, IncrementDecrementOptions, FindOrCreateOptions, ReloadOptions } from '../types';
39
+ import { Prorm } from '../prorm';
40
+ interface ValidationResult {
41
+ valid: boolean;
42
+ errors: ValidationErrorItem[];
43
+ }
44
+ declare class ModelValidator {
45
+ private validations;
46
+ private modelName;
47
+ constructor(validations: Record<string, any>, modelName: string);
48
+ validate(data: Record<string, any>): ValidationResult;
49
+ private validateField;
50
+ }
51
+ declare class ModelInstance<T = any> {
52
+ isNewRecord: boolean;
53
+ isDirty: boolean;
54
+ primaryKey?: string;
55
+ transaction?: Transaction;
56
+ _previousDataValues: Record<string, any>;
57
+ dataValues: Record<string, any>;
58
+ private model;
59
+ private prorm;
60
+ private _changed;
61
+ private _previousChanged;
62
+ private _includes;
63
+ private _validationErrors;
64
+ private _validationCache;
65
+ private _self;
66
+ constructor(model: ModelStatic<any>, prorm: Prorm, values?: Record<string, any>, options?: {
67
+ isNewRecord?: boolean;
68
+ });
69
+ /**
70
+ * Create a Proxy-based instance for backward compatibility
71
+ * Allows accessing fields directly like instance.fieldName
72
+ */
73
+ private static createProxyInstance;
74
+ private castValuesFromDatabase;
75
+ private castValuesForDatabase;
76
+ private getDefaultValues;
77
+ private updatePrimaryKey;
78
+ /**
79
+ * Get the raw value from the instance's dataValues
80
+ * Returns the value directly from the dataValues object without any processing
81
+ *
82
+ * @param key - The attribute name to retrieve
83
+ * @returns The raw value stored in dataValues, or undefined if not set
84
+ *
85
+ * @example
86
+ * // Get raw value
87
+ * const email = user.getDataValue('email');
88
+ */
89
+ getDataValue(key: string): any;
90
+ /**
91
+ * Set a value directly in dataValues, bypassing accessors
92
+ * Sets the value without calling any setters and triggers change tracking
93
+ *
94
+ * @param key - The attribute name to set
95
+ * @param value - The value to set
96
+ *
97
+ * @example
98
+ * // Set raw value directly
99
+ * user.setDataValue('email', 'new@example.com');
100
+ */
101
+ setDataValue(key: string, value: any): void;
102
+ /**
103
+ * Get an attribute value with accessor support
104
+ * Handles virtual fields by calling their getter functions
105
+ *
106
+ * @param key - The attribute name to retrieve
107
+ * @returns The attribute value, or undefined if not set
108
+ *
109
+ * @example
110
+ * // Get attribute value
111
+ * const name = user.get('firstName');
112
+ *
113
+ * @example
114
+ * // Get virtual field value (calls the virtual getter)
115
+ * const fullName = user.get('fullName');
116
+ */
117
+ get(key: string): any;
118
+ /**
119
+ * Get a value at a JSON path within a JSON/JSONB column
120
+ * @example
121
+ * ```typescript
122
+ * // Get nested value from JSON column
123
+ * user.getJsonPath('settings.theme')
124
+ * // Returns: 'dark'
125
+ *
126
+ * // For data column like: { address: { city: 'NYC' } }
127
+ * user.getJsonPath('data.address.city')
128
+ * // Returns: 'NYC'
129
+ * ```
130
+ */
131
+ getJsonPath(path: string): any;
132
+ /**
133
+ * Get the raw value without any processing
134
+ * Returns the value directly from dataValues without virtual getter or JSON parsing
135
+ *
136
+ * @param key - The attribute name to retrieve
137
+ * @returns The raw value from dataValues, or undefined if not set
138
+ *
139
+ * @example
140
+ * // Get raw value without processing
141
+ * const rawEmail = user.getRaw('email');
142
+ */
143
+ getRaw(key: string): any;
144
+ /**
145
+ * Set an attribute value with mutator support
146
+ * Handles virtual field setters and auto-parses JSON strings
147
+ *
148
+ * @param key - The attribute name to set
149
+ * @param value - The value to set
150
+ * @returns The instance for chaining
151
+ *
152
+ * @example
153
+ * // Set a single attribute
154
+ * user.set('email', 'new@example.com');
155
+ *
156
+ * @example
157
+ * // Chain multiple sets
158
+ * user.set('firstName', 'John').set('lastName', 'Doe');
159
+ */
160
+ set(key: string, value: any): ModelInstance<T>;
161
+ /**
162
+ * Set multiple attribute values at once
163
+ * Iterates through the provided key-value pairs and sets each attribute
164
+ *
165
+ * @param values - An object containing attribute names and their values
166
+ * @returns The instance for chaining
167
+ *
168
+ * @example
169
+ * // Set multiple attributes
170
+ * user.setAttributes({
171
+ * firstName: 'John',
172
+ * lastName: 'Doe',
173
+ * email: 'john@example.com'
174
+ * });
175
+ */
176
+ setAttributes(values: Record<string, any>): ModelInstance<T>;
177
+ /**
178
+ * Check if a field has changed since last save
179
+ * Returns a boolean if key is provided, or array of all changed field names otherwise
180
+ *
181
+ * @param key - Optional attribute name to check specific field
182
+ * @returns True if the field has changed, or array of changed field names if no key provided
183
+ *
184
+ * @example
185
+ * // Check specific field
186
+ * const hasChanged = user.changed('email');
187
+ *
188
+ * @example
189
+ * // Get all changed fields
190
+ * const changedFields = user.changed();
191
+ */
192
+ changed(key?: string): boolean | string[];
193
+ /**
194
+ * Get the previous value of a field before changes
195
+ * Returns the value from before the most recent change, or all previous values if no key provided
196
+ *
197
+ * @param key - Optional attribute name to get previous value
198
+ * @returns The previous value, or an object of all previous values if no key provided
199
+ *
200
+ * @example
201
+ * // Get previous value of specific field
202
+ * const oldEmail = user.previous('email');
203
+ *
204
+ * @example
205
+ * // Get all previous values
206
+ * const allPrevious = user.previous();
207
+ */
208
+ previous(key?: string): any;
209
+ /**
210
+ * Check if a specific field has changed
211
+ * @param key - The field name to check
212
+ * @returns true if the field has changed, false otherwise
213
+ */
214
+ isChanged(key: string): boolean;
215
+ /**
216
+ * Get the previous value of a specific field (including recent changes)
217
+ * @param key - The field name
218
+ * @returns The previous value or undefined if not changed
219
+ */
220
+ getPreviousValue(key: string): any;
221
+ /**
222
+ * Get all changed fields with their new and old values
223
+ * @returns Object with changed field names as keys and {previous, current} as values
224
+ */
225
+ getChangedFields(): Record<string, {
226
+ previous: any;
227
+ current: any;
228
+ }>;
229
+ /**
230
+ * Check if the record has any modifications
231
+ * @returns true if any field has been modified
232
+ */
233
+ isDirtyRecord(): boolean;
234
+ /**
235
+ * Check if the record or a specific field has changes
236
+ * @param key - Optional field name to check specific field
237
+ * @returns true if the record has any changes, or if the specific field has changed
238
+ */
239
+ hasChanges(key?: string): boolean;
240
+ /**
241
+ * Validate the instance and return boolean result synchronously
242
+ * Uses caching to improve performance on repeated calls
243
+ * @returns true if validation passes, false if there are errors
244
+ *
245
+ * @example
246
+ * if (user.isValid()) {
247
+ * console.log('Valid!');
248
+ * }
249
+ */
250
+ isValid(): boolean;
251
+ /**
252
+ * Get only the changed fields with their new (current) values
253
+ * @returns Object with field names as keys and new values
254
+ */
255
+ getChanges(): Record<string, any>;
256
+ /**
257
+ * Reset all change tracking (mark as not dirty)
258
+ * Typically called after save
259
+ */
260
+ resetChangeTracking(): void;
261
+ /**
262
+ * Get a snapshot of the current values
263
+ * @returns Copy of dataValues
264
+ */
265
+ getSnapshot(): Record<string, any>;
266
+ /**
267
+ * Restore values from a snapshot
268
+ * @param snapshot - The snapshot to restore from
269
+ */
270
+ restoreFromSnapshot(snapshot: Record<string, any>): void;
271
+ /**
272
+ * Get the diff between current and previous values
273
+ * @returns Object with all differences
274
+ */
275
+ getDiff(): Record<string, {
276
+ from: any;
277
+ to: any;
278
+ }>;
279
+ /**
280
+ * Reset all changes and restore original values
281
+ * @returns void
282
+ *
283
+ * @example
284
+ * user.name = 'New Name';
285
+ * user.reset(); // Reverts to original values
286
+ */
287
+ reset(): void;
288
+ getInclude(alias: string): ModelInstance[] | undefined;
289
+ setInclude(alias: string, instances: ModelInstance[]): void;
290
+ toJSON(options?: {
291
+ includeAll?: boolean;
292
+ exclude?: string[];
293
+ include?: string[];
294
+ /** Only include these specific attributes */
295
+ attributes?: string[];
296
+ /** When true, bypass all transformations (no virtual fields, no hidden filtering) */
297
+ raw?: boolean;
298
+ /** Clone the result before returning (prevents mutation) */
299
+ clone?: boolean;
300
+ /** Handle duplicate column names from joined tables */
301
+ duplicateColumns?: Record<string, string>;
302
+ /** Map of table aliases to their model for resolving duplicate columns */
303
+ includedModels?: Map<string, ModelStatic<any>>;
304
+ }): Record<string, any>;
305
+ private buildJSONResult;
306
+ private getAttributesToInclude;
307
+ private invokeToJSONHook;
308
+ /**
309
+ * Validate the instance
310
+ *
311
+ * @param options - Can be:
312
+ * - undefined or null: validate all fields
313
+ * - string[]: validate specific fields (e.g., ['email', 'name'])
314
+ * - object: { fields?: string[], hooks?: boolean }
315
+ * - fields: specific fields to validate
316
+ * - hooks: whether to run beforeValidate/afterValidate hooks (default: false)
317
+ *
318
+ * @returns Promise<{ valid: boolean, errors: ValidationErrorItem[] }>
319
+ *
320
+ * @example
321
+ * // Validate all fields
322
+ * const result = await user.validate();
323
+ * if (!result.valid) console.log(result.errors);
324
+ *
325
+ * @example
326
+ * // Validate specific fields
327
+ * const result = await user.validate(['email', 'name']);
328
+ *
329
+ * @example
330
+ * // Validate with hooks
331
+ * const result = await user.validate({ hooks: true });
332
+ */
333
+ validate(options?: string[] | {
334
+ fields?: string[];
335
+ hooks?: boolean;
336
+ }): Promise<{
337
+ valid: boolean;
338
+ errors: ValidationErrorItem[];
339
+ }>;
340
+ /**
341
+ * Validate synchronously
342
+ *
343
+ * @param options - Optional field names to validate or options object
344
+ * @returns ValidationResult - Object with valid status and errors
345
+ *
346
+ * @example
347
+ * const result = user.validateSync();
348
+ *
349
+ * @example
350
+ * // Validate specific fields
351
+ * const result = user.validateSync(['email', 'name']);
352
+ */
353
+ validateSync(options?: string[] | {
354
+ fields?: string[];
355
+ }): {
356
+ valid: boolean;
357
+ errors: ValidationErrorItem[];
358
+ };
359
+ /**
360
+ * Validate a specific field on the instance
361
+ *
362
+ * @param field - The field name to validate
363
+ * @returns ValidationErrorItem[] - Array of validation errors (empty if valid)
364
+ *
365
+ * @example
366
+ * const errors = user.validateField('email');
367
+ * if (errors.length > 0) console.log(errors[0].message);
368
+ */
369
+ validateField(field: string): ValidationErrorItem[];
370
+ isValidSync(): boolean;
371
+ getValidationErrors(): Promise<ValidationErrorItem[]>;
372
+ save(options?: SaveOptions): Promise<this>;
373
+ /**
374
+ * Reload the instance from the database.
375
+ * This fetches the current data from the database and updates the instance,
376
+ * overwriting any local changes.
377
+ *
378
+ * @param options - Reload options
379
+ * @returns Promise resolving to this instance
380
+ *
381
+ * @example
382
+ * const user = await User.findByPk(1);
383
+ * user.name = 'New Name';
384
+ * await user.reload(); // Reloads from DB, overwrites local changes
385
+ *
386
+ * @example
387
+ * // Reload with specific attributes
388
+ * await user.reload({ attributes: ['id', 'name', 'email'] });
389
+ */
390
+ reload(options?: ReloadOptions): Promise<this>;
391
+ destroy(options?: DestroyOptions): Promise<void>;
392
+ restore(options?: any): Promise<void>;
393
+ /**
394
+ * Reload the instance from the database.
395
+ * Re-fetches the record using the primary key and updates dataValues with fresh data.
396
+ * Resets all changed fields.
397
+ *
398
+ * @param options - Options for reload
399
+ * @param options.attributes - Optional array of attribute names to reload.
400
+ * If not provided, reloads all attributes.
401
+ * @param options.transaction - Optional transaction to use
402
+ * @param options.logging - Optional custom logging function
403
+ * @param options hooks - Whether to run hooks (default: true)
404
+ *
405
+ * @returns The reloaded instance
406
+ *
407
+ * @example
408
+ * // Reload only specific attributes
409
+ * await user.reload({ attributes: ['id', 'name'] });
410
+ */
411
+ /**
412
+ * Increment one or more numeric fields on the instance.
413
+ *
414
+ * @param fields - The field(s) to increment. Can be:
415
+ * - A single field name: 'age'
416
+ * - An array of field names: ['age', 'score']
417
+ * - An object with field names as keys and increment values: { age: 1, score: 5 }
418
+ * @param options - Options including:
419
+ * - by: The amount to increment by (default: 1)
420
+ * - transaction: Transaction to use
421
+ * - logging: Custom logging function
422
+ * - hooks: Whether to run hooks
423
+ *
424
+ * @returns The updated instance
425
+ *
426
+ * @example
427
+ * // Increment a single field by 1 (default)
428
+ * await user.increment('age');
429
+ *
430
+ * @example
431
+ * // Increment a field by a specific amount
432
+ * await user.increment('age', { by: 5 });
433
+ *
434
+ * @example
435
+ * // Increment multiple fields by 1 each
436
+ * await user.increment(['age', 'score']);
437
+ *
438
+ * @example
439
+ * // Increment multiple fields by different amounts
440
+ * await user.increment({ age: 1, score: 5 });
441
+ *
442
+ * @example
443
+ * // Increment with transaction
444
+ * await user.increment('balance', { by: 100, transaction });
445
+ */
446
+ increment(fields: string | string[] | Record<string, number>, options?: IncrementDecrementOptions): Promise<this>;
447
+ /**
448
+ * Decrement one or more numeric fields on the instance.
449
+ *
450
+ * @param fields - The field(s) to decrement. Can be:
451
+ * - A single field name: 'age'
452
+ * - An array of field names: ['age', 'score']
453
+ * - An object with field names as keys and decrement values: { age: 1, score: 5 }
454
+ * @param options - Options including:
455
+ * - by: The amount to decrement by (default: 1)
456
+ * - transaction: Transaction to use
457
+ * - logging: Custom logging function
458
+ * - hooks: Whether to run hooks
459
+ *
460
+ * @returns The updated instance
461
+ *
462
+ * @example
463
+ * // Decrement a single field by 1 (default)
464
+ * await user.decrement('age');
465
+ *
466
+ * @example
467
+ * // Decrement a field by a specific amount
468
+ * await user.decrement('balance', { by: 100 });
469
+ *
470
+ * @example
471
+ * // Decrement multiple fields by 1 each
472
+ * await user.decrement(['age', 'score']);
473
+ *
474
+ * @example
475
+ * // Decrement multiple fields by different amounts
476
+ * await user.decrement({ age: 1, score: 5 });
477
+ *
478
+ * @example
479
+ * // Decrement with transaction
480
+ * await user.decrement('balance', { by: 50, transaction });
481
+ */
482
+ decrement(fields: string | string[] | Record<string, number>, options?: IncrementDecrementOptions): Promise<this>;
483
+ /**
484
+ * Internal method to handle increment/decrement operations
485
+ */
486
+ private _incrementDecrement;
487
+ /**
488
+ * Run a raw query from instance context
489
+ * Uses the model's connection for executing custom queries
490
+ *
491
+ * @param sql - SQL query to execute
492
+ * @param options - Query options including replacements, raw mode, and transaction
493
+ * @returns Query result
494
+ *
495
+ * @example
496
+ * // Run a raw query on an instance
497
+ * const user = await User.findById(1);
498
+ * const result = await user.$query('SELECT * FROM orders WHERE user_id = ?', {
499
+ * replacements: [user.id]
500
+ * });
501
+ *
502
+ * @example
503
+ * // Run raw query with model mapping
504
+ * const orders = await user.$query('SELECT * FROM orders WHERE user_id = ?', {
505
+ * replacements: [user.id],
506
+ * model: Order
507
+ * });
508
+ */
509
+ $query(sql: string, options?: {
510
+ replacements?: Record<string, unknown> | unknown[];
511
+ raw?: boolean;
512
+ model?: ModelStatic<any>;
513
+ transaction?: Transaction;
514
+ }): Promise<any>;
515
+ private runHook;
516
+ /**
517
+ * Get a related instance for a hasOne or belongsTo association
518
+ *
519
+ * @param associationName - The name of the association (e.g., 'profile', 'address')
520
+ * @param options - Find options to pass to the query
521
+ * @returns The associated instance or null
522
+ *
523
+ * @example
524
+ * const profile = await user.getRelated('profile');
525
+ * const address = await user.getRelated('address', { where: { active: true } });
526
+ */
527
+ getRelated(associationName: string, options?: FindOptions): Promise<ModelInstance<any> | null>;
528
+ /**
529
+ * Set a related instance for a hasOne or belongsTo association
530
+ *
531
+ * @param associationName - The name of the association (e.g., 'profile', 'address')
532
+ * @param value - The instance to set, null to remove association, or a foreign key value
533
+ * @param options - Options including save: false to skip saving
534
+ * @returns The updated instance
535
+ *
536
+ * @example
537
+ * await user.setRelated('profile', newProfile);
538
+ * await user.setRelated('address', null); // Remove association
539
+ * await user.setRelated('address', 5); // Set by foreign key value
540
+ */
541
+ setRelated(associationName: string, value: ModelInstance<any> | null | number | string, options?: {
542
+ save?: boolean;
543
+ }): Promise<this>;
544
+ /**
545
+ * Create and associate a new related instance
546
+ *
547
+ * @param associationName - The name of the association (e.g., 'profile', 'address')
548
+ * @param values - The values to create the new instance with
549
+ * @param options - Create options
550
+ * @returns The created associated instance
551
+ *
552
+ * @example
553
+ * const profile = await user.createRelated('profile', { bio: 'Hello world' });
554
+ * const address = await user.createRelated('address', { city: 'NYC', country: 'USA' });
555
+ */
556
+ createRelated(associationName: string, values?: Record<string, any>, options?: CreateOptions): Promise<ModelInstance<any>>;
557
+ /**
558
+ * Check if an associated instance exists
559
+ *
560
+ * @param associationName - The name of the association (e.g., 'profile', 'address')
561
+ * @param options - Count options
562
+ * @returns True if associated record exists
563
+ *
564
+ * @example
565
+ * const hasProfile = await user.hasRelated('profile');
566
+ * const hasAddress = await user.hasRelated('address');
567
+ */
568
+ hasRelated(associationName: string, options?: FindOptions): Promise<boolean>;
569
+ }
570
+ /**
571
+ * Create a Model class for a given table
572
+ */
573
+ export declare function createModel<T extends Record<string, any>>(prorm: Prorm, modelName: string, attributes: Record<string, AttributeOptions>, options?: ModelOptions): ModelStatic<any>;
574
+ /**
575
+ * Base Model class for decorator-based model definitions
576
+ *
577
+ * This class can be extended to create models using TypeScript decorators:
578
+ *
579
+ * @example
580
+ * ```typescript
581
+ * import { Model, DataTypes } from 'orm';
582
+ * import { Table, Attribute, PrimaryKey, AutoIncrement } from 'orm/decorators';
583
+ *
584
+ * @Table({ tableName: 'users' })
585
+ * export class User extends Model {
586
+ * @Attribute(DataTypes.INTEGER)
587
+ * @PrimaryKey
588
+ * @AutoIncrement
589
+ * declare id: number;
590
+ *
591
+ * @Attribute(DataTypes.STRING)
592
+ * declare name: string;
593
+ * }
594
+ *
595
+ * // Then initialize with prorm:
596
+ * prorm.addModel(User);
597
+ * await User.sync();
598
+ * ```
599
+ */
600
+ declare class ModelClass {
601
+ static prorm?: Prorm;
602
+ static modelName?: string;
603
+ static tableName?: string;
604
+ static schema?: string;
605
+ static rawAttributes?: Record<string, any>;
606
+ static associations?: Record<string, any>;
607
+ static options?: ModelOptions;
608
+ static primaryKeyAttribute?: string;
609
+ static _scopes?: Record<string, any>;
610
+ /**
611
+ * Associations declared via User.hasMany(...)/.belongsTo(...)/etc before the model
612
+ * has been registered with prorm.addModel(). Queued here and replayed by
613
+ * Prorm.addModel() once the model (and its prorm/models[name] entry) exists, so
614
+ * association calls can be made either before or after addModel().
615
+ */
616
+ static _pendingAssociations?: Array<{
617
+ type: 'hasOne' | 'hasMany' | 'belongsTo' | 'belongsToMany';
618
+ target: any;
619
+ options?: any;
620
+ }>;
621
+ private static _queuePendingAssociation;
622
+ /**
623
+ * Scopes added via User.addScope(...) before the model has been registered with
624
+ * prorm.addModel(). Merged into the model's options.scopes by Prorm.addModel() so
625
+ * addScope() can be called either before or after addModel().
626
+ */
627
+ static _pendingScopes?: Record<string, any>;
628
+ static addScope(scopeName: string, scopeDef: any): void;
629
+ static hasMany(target: any, options?: any): any;
630
+ static belongsTo(target: any, options?: any): any;
631
+ static hasOne(target: any, options?: any): any;
632
+ static belongsToMany(target: any, options?: any): any;
633
+ static getAttributes(): string[];
634
+ static getTableName(): string;
635
+ static getPrimaryKeyAttribute(): string | undefined;
636
+ static findOne(findOptions?: FindOptions): Promise<ModelInstance | null>;
637
+ static findAll(findOptions?: FindOptions): Promise<ModelInstance[]>;
638
+ static findByPk(id: number | string, options?: FindOptions): Promise<ModelInstance | null>;
639
+ static findOrCreate(options: FindOrCreateOptions): Promise<[ModelInstance, boolean]>;
640
+ static findOrBuild(options: FindOrCreateOptions): Promise<[ModelInstance, boolean]>;
641
+ static findOrInitialize(options: FindOrCreateOptions): Promise<[ModelInstance, boolean]>;
642
+ /**
643
+ * Get the model attribute name for a database column (static version)
644
+ * @param columnName - The database column name
645
+ * @returns The model attribute name (or the column name if no mapping exists)
646
+ *
647
+ * @example
648
+ * User.getAttributeName('first_name'); // 'firstName' if field: 'first_name' is set
649
+ * User.getAttributeName('id'); // 'id'
650
+ */
651
+ static getAttributeName(columnName: string): string;
652
+ static build(values?: Record<string, any>, options?: Record<string, any>): ModelInstance;
653
+ static create(values?: Record<string, any>, options?: CreateOptions): Promise<any>;
654
+ static update(values: Record<string, any>, options: UpdateOptions): Promise<[number, any]>;
655
+ static destroy(options: DestroyOptions): Promise<number>;
656
+ static count(options?: CountOptions): Promise<number>;
657
+ static bulkCreate(records: Record<string, any>[], options?: BulkCreateOptions): Promise<ModelInstance[]>;
658
+ static upsert(values: Record<string, any>, options?: UpsertOptions): Promise<[ModelInstance, boolean]>;
659
+ static hook(hookName: string, handler: HookHandler): typeof ModelClass;
660
+ static addHook(hookName: string, handler: HookHandler): typeof ModelClass;
661
+ static beforeCreate(handler: HookHandler): typeof ModelClass;
662
+ static afterCreate(handler: HookHandler): typeof ModelClass;
663
+ static beforeUpdate(handler: HookHandler): typeof ModelClass;
664
+ static afterUpdate(handler: HookHandler): typeof ModelClass;
665
+ static beforeDestroy(handler: HookHandler): typeof ModelClass;
666
+ static afterDestroy(handler: HookHandler): typeof ModelClass;
667
+ /**
668
+ * Check if a hook is registered on the model
669
+ * @param hookName - The name of the hook (e.g., 'beforeCreate', 'afterSave')
670
+ * @returns True if the hook is registered, false otherwise
671
+ */
672
+ static hasHook(hookName: string): boolean;
673
+ /**
674
+ * Check if a hook is registered on the model (alias for hasHook)
675
+ * @param hookName - The name of the hook (e.g., 'beforeCreate', 'afterSave')
676
+ * @returns True if the hook is registered, false otherwise
677
+ */
678
+ static hasHooks(hookName: string): boolean;
679
+ /**
680
+ * Remove a hook from the model
681
+ * @param hookName - The name of the hook (e.g., 'beforeCreate', 'afterSave')
682
+ * @param hookOrHookId - Optional: The specific hook callback function OR hook ID to remove. If not provided, removes all hooks of this type
683
+ * @returns The model for chaining
684
+ */
685
+ static removeHook(hookName: string, hookOrHookId?: string | HookHandler): typeof ModelClass;
686
+ }
687
+ export { ModelClass as Model, ModelInstance, ModelValidator };
688
+ export type { ValidationResult };
689
+ declare const _default: {
690
+ createModel: typeof createModel;
691
+ ModelClass: typeof ModelClass;
692
+ Op: {
693
+ readonly and: symbol;
694
+ readonly or: symbol;
695
+ readonly not: symbol;
696
+ readonly eq: symbol;
697
+ readonly is: symbol;
698
+ readonly ne: symbol;
699
+ readonly gt: symbol;
700
+ readonly gte: symbol;
701
+ readonly lt: symbol;
702
+ readonly lte: symbol;
703
+ readonly like: symbol;
704
+ readonly notLike: symbol;
705
+ readonly iLike: symbol;
706
+ readonly notILike: symbol;
707
+ readonly startsWith: symbol;
708
+ readonly notStartsWith: symbol;
709
+ readonly endsWith: symbol;
710
+ readonly notEndsWith: symbol;
711
+ readonly substring: symbol;
712
+ readonly notSubstring: symbol;
713
+ readonly col: symbol;
714
+ readonly in: symbol;
715
+ readonly notIn: symbol;
716
+ readonly between: symbol;
717
+ readonly notBetween: symbol;
718
+ readonly isNull: symbol;
719
+ readonly isNotNull: symbol;
720
+ readonly exists: symbol;
721
+ readonly notExists: symbol;
722
+ readonly regexp: symbol;
723
+ readonly notRegexp: symbol;
724
+ readonly iRegexp: symbol;
725
+ readonly notIRegexp: symbol;
726
+ readonly any: symbol;
727
+ readonly all: symbol;
728
+ readonly containsKey: symbol;
729
+ readonly containsKeyPath: symbol;
730
+ readonly containsPath: symbol;
731
+ readonly strictLeft: symbol;
732
+ readonly strictRight: symbol;
733
+ readonly noExtendRight: symbol;
734
+ readonly noExtendLeft: symbol;
735
+ readonly adj: symbol;
736
+ readonly notAdj: symbol;
737
+ readonly arrayContains: symbol;
738
+ readonly arrayContainedBy: symbol;
739
+ readonly arrayOverlaps: symbol;
740
+ readonly arrayAny: symbol;
741
+ readonly arrayAll: symbol;
742
+ readonly contains: symbol;
743
+ readonly containedBy: symbol;
744
+ readonly keyExists: symbol;
745
+ readonly overlap: symbol;
746
+ readonly match: symbol;
747
+ readonly $json: symbol;
748
+ readonly jsonPath: symbol;
749
+ readonly jsonContains: symbol;
750
+ readonly jsonHasKey: symbol;
751
+ readonly jsonbExtract: symbol;
752
+ readonly jsonbExtractText: symbol;
753
+ readonly jsonbExtractPath: symbol;
754
+ readonly jsonbExtractPathText: symbol;
755
+ readonly jsonConcat: symbol;
756
+ readonly jsonDelete: symbol;
757
+ readonly jsonDeletePath: symbol;
758
+ readonly jsonPathExists: symbol;
759
+ readonly jsonPathQuery: symbol;
760
+ readonly jsonTypeOf: symbol;
761
+ readonly json: (path: string) => symbol;
762
+ readonly key: (pathOrOptions: string | {
763
+ path: string;
764
+ value?: any;
765
+ }) => Record<string, any>;
766
+ readonly literal: (value: string) => import("..").LiteralValue;
767
+ readonly cast: (value: any, type: string) => import("./operators").CastExpression;
768
+ readonly extract: (field: any, part: import("..").ExtractPart) => import("./operators").ExtractExpression;
769
+ readonly conv: (value: any, from: string | null | undefined, to: string) => import("./operators").ConvExpression;
770
+ readonly where: (column: {
771
+ $col: string;
772
+ } | string, operator: any, value?: any) => {
773
+ $where: {
774
+ $col: string;
775
+ [key: string]: any;
776
+ };
777
+ } | Record<string, any>;
778
+ readonly asc: (field: string) => import("./operators").OrderExpression;
779
+ readonly desc: (field: string) => import("./operators").OrderExpression;
780
+ readonly random: () => import("./operators").OrderExpression;
781
+ readonly isNotNullPredicate: (value: any) => boolean;
782
+ readonly matchAgainst: (columns: string | string[], options?: {
783
+ mode?: "natural" | "boolean";
784
+ }) => {
785
+ $match: {
786
+ columns: string[];
787
+ mode: "natural" | "boolean";
788
+ };
789
+ };
790
+ readonly matchFulltext: (columns: string | string[]) => {
791
+ $match: {
792
+ columns: string[];
793
+ mode: "natural";
794
+ };
795
+ };
796
+ readonly toTsvector: (column: string, config?: string) => {
797
+ $tsvector: {
798
+ column: string;
799
+ config: string;
800
+ };
801
+ };
802
+ readonly toTsquery: (query: string, config?: string) => {
803
+ $tsquery: {
804
+ query: string;
805
+ config: string;
806
+ };
807
+ };
808
+ readonly stDistance: symbol;
809
+ readonly stWithin: symbol;
810
+ readonly stContains: symbol;
811
+ readonly stIntersects: symbol;
812
+ readonly stDWithin: symbol;
813
+ readonly stCrosses: symbol;
814
+ readonly stOverlaps: symbol;
815
+ readonly stTouches: symbol;
816
+ readonly stEquals: symbol;
817
+ readonly stIsValid: symbol;
818
+ };
819
+ };
820
+ export default _default;