ts-prorm-orm 1.1.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (460) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/README.md +194 -72
  3. package/dist/audit/history-query.d.ts +35 -0
  4. package/dist/audit/index.d.ts +16 -0
  5. package/dist/audit/logger.d.ts +126 -0
  6. package/dist/cache/cache-manager.d.ts +341 -0
  7. package/dist/cache/index.d.ts +8 -0
  8. package/dist/cache/redis-cluster-cache.d.ts +164 -0
  9. package/dist/cache/redis-cluster-cache.js +19 -36
  10. package/dist/cli/cloud.d.ts +55 -0
  11. package/dist/cli/cloud.js +318 -0
  12. package/dist/cli/commands/auth.d.ts +2 -0
  13. package/dist/cli/commands/auth.js +345 -0
  14. package/dist/cli/commands/billing.d.ts +2 -0
  15. package/dist/cli/commands/billing.js +135 -0
  16. package/dist/cli/commands/code.d.ts +2 -0
  17. package/dist/cli/commands/code.js +168 -0
  18. package/dist/cli/commands/config.d.ts +2 -0
  19. package/dist/cli/commands/config.js +154 -0
  20. package/dist/cli/commands/db.d.ts +2 -0
  21. package/dist/cli/commands/db.js +189 -0
  22. package/dist/cli/commands/index.d.ts +1 -0
  23. package/dist/cli/commands/index.js +22 -0
  24. package/dist/cli/commands/keys.d.ts +2 -0
  25. package/dist/cli/commands/keys.js +100 -0
  26. package/dist/cli/commands/misc.d.ts +2 -0
  27. package/dist/cli/commands/misc.js +282 -0
  28. package/dist/cli/commands/pull.d.ts +2 -0
  29. package/dist/cli/commands/pull.js +306 -0
  30. package/dist/cli/commands/runners.d.ts +2 -0
  31. package/dist/cli/commands/runners.js +218 -0
  32. package/dist/cli/commands/scaffold.d.ts +2 -0
  33. package/dist/cli/commands/scaffold.js +383 -0
  34. package/dist/cli/commands/secrets.d.ts +2 -0
  35. package/dist/cli/commands/secrets.js +162 -0
  36. package/dist/cli/commands/store.d.ts +2 -0
  37. package/dist/cli/commands/store.js +274 -0
  38. package/dist/cli/commands/system.d.ts +10 -0
  39. package/dist/cli/commands/system.js +169 -0
  40. package/dist/cli/commands/teams.d.ts +2 -0
  41. package/dist/cli/commands/teams.js +189 -0
  42. package/dist/cli/commands/user.d.ts +2 -0
  43. package/dist/cli/commands/user.js +171 -0
  44. package/dist/cli/framework.d.ts +103 -0
  45. package/dist/cli/framework.js +436 -0
  46. package/dist/cli/io.d.ts +26 -0
  47. package/dist/cli/io.js +181 -0
  48. package/dist/cli/keychain.d.ts +10 -0
  49. package/dist/cli/keychain.js +101 -0
  50. package/dist/cli/prompt.d.ts +20 -0
  51. package/dist/cli/prompt.js +111 -0
  52. package/dist/cli.d.ts +214 -0
  53. package/dist/cli.js +72 -5
  54. package/dist/compliance/audit-trail.d.ts +66 -0
  55. package/dist/compliance/backup-verification.d.ts +279 -0
  56. package/dist/compliance/breach-detector.d.ts +197 -0
  57. package/dist/compliance/consent-record.d.ts +107 -0
  58. package/dist/compliance/consent-versioning.d.ts +169 -0
  59. package/dist/compliance/cross-border-log.d.ts +254 -0
  60. package/dist/compliance/data-classifier.d.ts +127 -0
  61. package/dist/compliance/data-lineage.d.ts +268 -0
  62. package/dist/compliance/data-masker.d.ts +110 -0
  63. package/dist/compliance/data-portability.d.ts +98 -0
  64. package/dist/compliance/data-retention.d.ts +108 -0
  65. package/dist/compliance/dsar-workflow.d.ts +175 -0
  66. package/dist/compliance/field-encryption.d.ts +84 -0
  67. package/dist/compliance/immutable-record.d.ts +84 -0
  68. package/dist/compliance/index.d.ts +93 -0
  69. package/dist/compliance/privacy-impact-assessment.d.ts +196 -0
  70. package/dist/compliance/pseudonymization.d.ts +96 -0
  71. package/dist/compliance/query-firewall.d.ts +661 -0
  72. package/dist/compliance/rate-limiter.d.ts +203 -0
  73. package/dist/compliance/right-to-erasure.d.ts +96 -0
  74. package/dist/compliance/row-level-security.d.ts +152 -0
  75. package/dist/compliance/security-decorator.d.ts +388 -0
  76. package/dist/compliance/security-monitor.d.ts +170 -0
  77. package/dist/compliance/sensitive-data-discovery.d.ts +151 -0
  78. package/dist/compliance/session-isolation.d.ts +286 -0
  79. package/dist/compliance/tls-enforcer.d.ts +51 -0
  80. package/dist/compliance/worm-storage.d.ts +225 -0
  81. package/dist/connection-manager.d.ts +130 -0
  82. package/dist/connection-pool.d.ts +311 -0
  83. package/dist/decorators/audit.d.ts +49 -0
  84. package/dist/decorators/check.d.ts +218 -0
  85. package/dist/decorators/collate.d.ts +346 -0
  86. package/dist/decorators/comment.d.ts +51 -0
  87. package/dist/decorators/database-settings.d.ts +193 -0
  88. package/dist/decorators/default.d.ts +148 -0
  89. package/dist/decorators/encryption.d.ts +175 -0
  90. package/dist/decorators/engine.d.ts +97 -0
  91. package/dist/decorators/fk-constraints.d.ts +387 -0
  92. package/dist/decorators/foreign-table.d.ts +57 -0
  93. package/dist/decorators/generated.d.ts +232 -0
  94. package/dist/decorators/hstore.d.ts +96 -0
  95. package/dist/decorators/index.d.ts +57 -0
  96. package/dist/decorators/index.js +14 -30
  97. package/dist/decorators/json-column.d.ts +47 -0
  98. package/dist/decorators/jsonb.d.ts +83 -0
  99. package/dist/decorators/orm-decorators.d.ts +274 -0
  100. package/dist/decorators/permissions.d.ts +192 -0
  101. package/dist/decorators/procedure.d.ts +168 -0
  102. package/dist/decorators/procedure.js +31 -7
  103. package/dist/decorators/query-options.d.ts +527 -0
  104. package/dist/decorators/range.d.ts +122 -0
  105. package/dist/decorators/set-column.d.ts +43 -0
  106. package/dist/decorators/spatial.d.ts +60 -0
  107. package/dist/decorators/storage.d.ts +561 -0
  108. package/dist/decorators/timezone.d.ts +319 -0
  109. package/dist/decorators/trigger.d.ts +50 -0
  110. package/dist/decorators/uuid.d.ts +102 -0
  111. package/dist/decorators/view.d.ts +213 -0
  112. package/dist/diagrams/chen-diagram.d.ts +70 -0
  113. package/dist/diagrams/chen-diagram.js +33 -31
  114. package/dist/diagrams/class-diagram.d.ts +78 -0
  115. package/dist/diagrams/class-diagram.js +23 -27
  116. package/dist/diagrams/dependency-diagram.d.ts +82 -0
  117. package/dist/diagrams/dependency-diagram.js +18 -9
  118. package/dist/diagrams/er-diagram.d.ts +82 -0
  119. package/dist/diagrams/er-diagram.js +174 -231
  120. package/dist/diagrams/flow-diagram.d.ts +70 -0
  121. package/dist/diagrams/flow-diagram.js +23 -18
  122. package/dist/diagrams/gantt-diagram.d.ts +67 -0
  123. package/dist/diagrams/gantt-diagram.js +20 -18
  124. package/dist/diagrams/index-diagram.d.ts +61 -0
  125. package/dist/diagrams/index-diagram.js +36 -31
  126. package/dist/diagrams/index.d.ts +155 -0
  127. package/dist/diagrams/index.js +7 -1
  128. package/dist/diagrams/migration-diagram.d.ts +67 -0
  129. package/dist/diagrams/migration-diagram.js +45 -57
  130. package/dist/diagrams/model-diagram.d.ts +85 -0
  131. package/dist/diagrams/model-diagram.js +225 -287
  132. package/dist/diagrams/package-diagram.d.ts +69 -0
  133. package/dist/diagrams/package-diagram.js +30 -32
  134. package/dist/diagrams/palette.d.ts +138 -0
  135. package/dist/diagrams/palette.js +134 -25
  136. package/dist/diagrams/relational-diagram.d.ts +82 -0
  137. package/dist/diagrams/relational-diagram.js +51 -59
  138. package/dist/diagrams/schemadoc-diagram.d.ts +57 -0
  139. package/dist/diagrams/schemadoc-diagram.js +36 -28
  140. package/dist/diagrams/sequence-diagram.d.ts +61 -0
  141. package/dist/diagrams/sequence-diagram.js +20 -11
  142. package/dist/diagrams/state-diagram.d.ts +85 -0
  143. package/dist/diagrams/state-diagram.js +21 -17
  144. package/dist/diagrams/svg-dom.d.ts +62 -0
  145. package/dist/diagrams/svg-dom.js +11 -0
  146. package/dist/diagrams/tree-diagram.d.ts +47 -0
  147. package/dist/diagrams/tree-diagram.js +19 -10
  148. package/dist/dialects/clickhouse/index.d.ts +660 -0
  149. package/dist/dialects/clickhouse/index.js +107 -2
  150. package/dist/dialects/cockroachdb/index.d.ts +1708 -0
  151. package/dist/dialects/cockroachdb/index.js +139 -10
  152. package/dist/dialects/cratedb/index.d.ts +262 -0
  153. package/dist/dialects/cratedb/index.js +148 -0
  154. package/dist/dialects/databricks/index.d.ts +397 -0
  155. package/dist/dialects/databricks/index.js +233 -11
  156. package/dist/dialects/db2/index.d.ts +729 -0
  157. package/dist/dialects/db2/index.js +152 -2
  158. package/dist/dialects/dialect.d.ts +1653 -0
  159. package/dist/dialects/duckdb/index.d.ts +440 -0
  160. package/dist/dialects/duckdb/index.js +21 -37
  161. package/dist/dialects/exasol/index.d.ts +197 -0
  162. package/dist/dialects/exasol/index.js +14 -0
  163. package/dist/dialects/firebird/index.d.ts +286 -0
  164. package/dist/dialects/firebird/index.js +135 -0
  165. package/dist/dialects/greenplum/index.d.ts +336 -0
  166. package/dist/dialects/greenplum/index.js +168 -0
  167. package/dist/dialects/hana/index.d.ts +512 -0
  168. package/dist/dialects/hana/index.js +17 -35
  169. package/dist/dialects/mariadb/index.d.ts +1241 -0
  170. package/dist/dialects/mariadb/index.js +181 -43
  171. package/dist/dialects/mssql/index.d.ts +729 -0
  172. package/dist/dialects/mssql/index.js +76 -7
  173. package/dist/dialects/mysql/index.d.ts +1233 -0
  174. package/dist/dialects/mysql/index.js +87 -19
  175. package/dist/dialects/oracle/index.d.ts +1222 -0
  176. package/dist/dialects/oracle/index.js +210 -9
  177. package/dist/dialects/postgres/index.d.ts +1598 -0
  178. package/dist/dialects/postgres/index.js +34 -13
  179. package/dist/dialects/query-stream-helper.d.ts +58 -0
  180. package/dist/dialects/questdb/index.d.ts +430 -0
  181. package/dist/dialects/questdb/index.js +292 -0
  182. package/dist/dialects/redshift/index.d.ts +933 -0
  183. package/dist/dialects/redshift/index.js +17 -5
  184. package/dist/dialects/singlestore/index.d.ts +233 -0
  185. package/dist/dialects/singlestore/index.js +53 -0
  186. package/dist/dialects/snowflake/index.d.ts +727 -0
  187. package/dist/dialects/snowflake/index.js +154 -5
  188. package/dist/dialects/spanner/index.d.ts +660 -0
  189. package/dist/dialects/spanner/index.js +43 -21
  190. package/dist/dialects/sqlite/index.d.ts +1133 -0
  191. package/dist/dialects/sqlite/index.js +168 -30
  192. package/dist/dialects/tidb/index.d.ts +226 -0
  193. package/dist/dialects/tidb/index.js +10 -0
  194. package/dist/dialects/timescaledb/index.d.ts +286 -0
  195. package/dist/dialects/timescaledb/index.js +179 -0
  196. package/dist/dialects/trino/index.d.ts +230 -0
  197. package/dist/dialects/trino/index.js +85 -10
  198. package/dist/dialects/turso/index.d.ts +98 -0
  199. package/dist/dialects/turso/index.js +10 -0
  200. package/dist/dialects/vertica/index.d.ts +321 -0
  201. package/dist/dialects/vertica/index.js +161 -0
  202. package/dist/dialects/yugabytedb/index.d.ts +276 -0
  203. package/dist/dialects/yugabytedb/index.js +121 -0
  204. package/dist/errors/index.d.ts +378 -0
  205. package/dist/errors/index.js +29 -1
  206. package/dist/errors/utils.d.ts +53 -0
  207. package/dist/errors.d.ts +5 -0
  208. package/dist/extensions/catalog/cloud-warehouse-features.d.ts +27 -0
  209. package/dist/extensions/catalog/mssql-features.d.ts +20 -0
  210. package/dist/extensions/catalog/mysql-mariadb-plugins.d.ts +18 -0
  211. package/dist/extensions/catalog/oracle-db2-features.d.ts +17 -0
  212. package/dist/extensions/catalog/postgres-extensions.d.ts +15 -0
  213. package/dist/extensions/index.d.ts +34 -0
  214. package/dist/extensions/types.d.ts +43 -0
  215. package/dist/external-fields/adapters.d.ts +50 -0
  216. package/dist/external-fields/adapters.js +227 -0
  217. package/dist/external-fields/decorator.d.ts +77 -0
  218. package/dist/external-fields/decorator.js +80 -0
  219. package/dist/external-fields/index.d.ts +10 -0
  220. package/dist/external-fields/index.js +19 -0
  221. package/dist/external-fields/runtime.d.ts +39 -0
  222. package/dist/external-fields/runtime.js +221 -0
  223. package/dist/foreign-data.d.ts +168 -0
  224. package/dist/graph/base-graph-dialect.d.ts +250 -0
  225. package/dist/graph/base-graph-dialect.js +539 -0
  226. package/dist/graph/dgraph/index.d.ts +65 -0
  227. package/dist/graph/dgraph/index.js +559 -0
  228. package/dist/graph/gremlin/index.d.ts +59 -0
  229. package/dist/graph/gremlin/index.js +378 -0
  230. package/dist/graph/index.d.ts +60 -0
  231. package/dist/graph/index.js +67 -0
  232. package/dist/graph/neo4j/index.d.ts +50 -0
  233. package/dist/graph/neo4j/index.js +462 -0
  234. package/dist/graph/types.d.ts +213 -0
  235. package/dist/graph/types.js +234 -0
  236. package/dist/hooks/hooks-manager.d.ts +189 -0
  237. package/dist/hooks/index.d.ts +8 -0
  238. package/dist/index.d.ts +713 -0
  239. package/dist/index.js +36 -4
  240. package/dist/logging.d.ts +183 -0
  241. package/dist/migrations/index.d.ts +9 -0
  242. package/dist/migrations/migration.d.ts +143 -0
  243. package/dist/migrations/migrator.d.ts +199 -0
  244. package/dist/migrations/prormmigration.d.ts +131 -0
  245. package/dist/migrations/query-interface.d.ts +335 -0
  246. package/dist/migrations/seeder.d.ts +167 -0
  247. package/dist/models/associations.d.ts +131 -0
  248. package/dist/models/associations.js +7 -2
  249. package/dist/models/constraints.d.ts +175 -0
  250. package/dist/models/data-types.d.ts +1656 -0
  251. package/dist/models/decorators.d.ts +328 -0
  252. package/dist/models/decorators.js +61 -82
  253. package/dist/models/eager-load.d.ts +86 -0
  254. package/dist/models/eager-load.js +369 -0
  255. package/dist/models/index.d.ts +13 -0
  256. package/dist/models/indexes.d.ts +325 -0
  257. package/dist/models/methods.d.ts +419 -0
  258. package/dist/models/model-manager.d.ts +76 -0
  259. package/dist/models/model.d.ts +820 -0
  260. package/dist/models/model.js +15 -101
  261. package/dist/models/operators.d.ts +29 -0
  262. package/dist/models/scopes.d.ts +71 -0
  263. package/dist/models/typescript-types.d.ts +177 -0
  264. package/dist/nosql/aerospike/index.d.ts +126 -0
  265. package/dist/nosql/allegrograph/index.d.ts +86 -0
  266. package/dist/nosql/arangodb/index.d.ts +285 -0
  267. package/dist/nosql/arangodb/index.js +274 -2
  268. package/dist/nosql/arangodb/where.d.ts +38 -0
  269. package/dist/nosql/arangodb/where.js +94 -0
  270. package/dist/nosql/azure-blob/index.d.ts +104 -0
  271. package/dist/nosql/beanstalkd/index.d.ts +88 -0
  272. package/dist/nosql/beequeue/index.d.ts +99 -0
  273. package/dist/nosql/bigchaindb/index.d.ts +113 -0
  274. package/dist/nosql/bigtable/index.d.ts +144 -0
  275. package/dist/nosql/blazegraph/index.d.ts +88 -0
  276. package/dist/nosql/bullmq/index.d.ts +83 -0
  277. package/dist/nosql/cassandra/index.d.ts +119 -0
  278. package/dist/nosql/chroma/index.d.ts +151 -0
  279. package/dist/nosql/cloudflare-kv/index.d.ts +120 -0
  280. package/dist/nosql/coherence/index.d.ts +91 -0
  281. package/dist/nosql/cosmosdb/index.d.ts +78 -0
  282. package/dist/nosql/couchbase/index.d.ts +103 -0
  283. package/dist/nosql/dax/index.d.ts +118 -0
  284. package/dist/nosql/deno-kv/index.d.ts +109 -0
  285. package/dist/nosql/dgraph/index.d.ts +80 -0
  286. package/dist/nosql/doris/index.d.ts +88 -0
  287. package/dist/nosql/druid/index.d.ts +95 -0
  288. package/dist/nosql/dynamodb/index.d.ts +643 -0
  289. package/dist/nosql/dynamodb/index.js +423 -0
  290. package/dist/nosql/elasticsearch/index.d.ts +239 -0
  291. package/dist/nosql/etcd/index.d.ts +243 -0
  292. package/dist/nosql/eventhubs/index.d.ts +89 -0
  293. package/dist/nosql/eventstore/index.d.ts +102 -0
  294. package/dist/nosql/faunadb/index.d.ts +141 -0
  295. package/dist/nosql/faunadb/index.js +329 -0
  296. package/dist/nosql/firestore/index.d.ts +67 -0
  297. package/dist/nosql/fluree/index.d.ts +88 -0
  298. package/dist/nosql/fuseki/index.d.ts +94 -0
  299. package/dist/nosql/gcs/index.d.ts +62 -0
  300. package/dist/nosql/gearman/index.d.ts +77 -0
  301. package/dist/nosql/geode/index.d.ts +93 -0
  302. package/dist/nosql/graphdb/index.d.ts +86 -0
  303. package/dist/nosql/graylog/index.d.ts +118 -0
  304. package/dist/nosql/gridgain/index.d.ts +78 -0
  305. package/dist/nosql/hazelcast/index.d.ts +73 -0
  306. package/dist/nosql/hbase/index.d.ts +123 -0
  307. package/dist/nosql/ignite/index.d.ts +80 -0
  308. package/dist/nosql/immudb/index.d.ts +131 -0
  309. package/dist/nosql/index.d.ts +215 -0
  310. package/dist/nosql/infinispan/index.d.ts +95 -0
  311. package/dist/nosql/influxdb/flux-compiler.d.ts +23 -0
  312. package/dist/nosql/influxdb/flux-compiler.js +170 -0
  313. package/dist/nosql/influxdb/index.d.ts +300 -0
  314. package/dist/nosql/influxdb/index.js +0 -0
  315. package/dist/nosql/kafka/index.d.ts +113 -0
  316. package/dist/nosql/keyspaces/index.d.ts +122 -0
  317. package/dist/nosql/kinesis/index.d.ts +121 -0
  318. package/dist/nosql/leveldb/index.d.ts +112 -0
  319. package/dist/nosql/leveldb/index.js +103 -1
  320. package/dist/nosql/lmdb/index.d.ts +76 -0
  321. package/dist/nosql/loki/index.d.ts +126 -0
  322. package/dist/nosql/marklogic/index.d.ts +76 -0
  323. package/dist/nosql/materialize/index.d.ts +91 -0
  324. package/dist/nosql/meilisearch/index.d.ts +76 -0
  325. package/dist/nosql/memcached/index.d.ts +138 -0
  326. package/dist/nosql/milvus/index.d.ts +167 -0
  327. package/dist/nosql/minio/index.d.ts +122 -0
  328. package/dist/nosql/momento/index.d.ts +99 -0
  329. package/dist/nosql/mongodb/index.d.ts +265 -0
  330. package/dist/nosql/mongodb/index.js +139 -0
  331. package/dist/nosql/mongodb/where.d.ts +8 -0
  332. package/dist/nosql/mongodb/where.js +181 -0
  333. package/dist/nosql/nats/index.d.ts +139 -0
  334. package/dist/nosql/nedb/index.d.ts +79 -0
  335. package/dist/nosql/neo4j/index.d.ts +217 -0
  336. package/dist/nosql/neo4j/index.js +26 -14
  337. package/dist/nosql/neptune/index.d.ts +234 -0
  338. package/dist/nosql/neptune/index.js +23 -9
  339. package/dist/nosql/nsq/index.d.ts +93 -0
  340. package/dist/nosql/opensearch/index.d.ts +97 -0
  341. package/dist/nosql/orientdb/index.d.ts +72 -0
  342. package/dist/nosql/papertrail/index.d.ts +120 -0
  343. package/dist/nosql/pinecone/index.d.ts +148 -0
  344. package/dist/nosql/pinot/index.d.ts +90 -0
  345. package/dist/nosql/pouchdb/index.d.ts +95 -0
  346. package/dist/nosql/prometheus/index.d.ts +112 -0
  347. package/dist/nosql/provendb/index.d.ts +143 -0
  348. package/dist/nosql/provendb/index.js +262 -0
  349. package/dist/nosql/pubsub/index.d.ts +83 -0
  350. package/dist/nosql/pulsar/index.d.ts +105 -0
  351. package/dist/nosql/qdrant/index.d.ts +231 -0
  352. package/dist/nosql/qldb/index.d.ts +182 -0
  353. package/dist/nosql/qldb/index.js +302 -1
  354. package/dist/nosql/r2/index.d.ts +160 -0
  355. package/dist/nosql/rabbitmq/index.d.ts +131 -0
  356. package/dist/nosql/ravendb/index.d.ts +138 -0
  357. package/dist/nosql/ravendb/index.js +323 -9
  358. package/dist/nosql/ravendb/where.d.ts +38 -0
  359. package/dist/nosql/ravendb/where.js +94 -0
  360. package/dist/nosql/redis/index.d.ts +267 -0
  361. package/dist/nosql/redis/index.js +19 -5
  362. package/dist/nosql/redpanda/index.d.ts +117 -0
  363. package/dist/nosql/resque/index.d.ts +91 -0
  364. package/dist/nosql/rethinkdb/index.d.ts +194 -0
  365. package/dist/nosql/rethinkdb/index.js +290 -0
  366. package/dist/nosql/rethinkdb/where.d.ts +38 -0
  367. package/dist/nosql/rethinkdb/where.js +94 -0
  368. package/dist/nosql/rocksdb/document-layer.d.ts +162 -0
  369. package/dist/nosql/rocksdb/document-layer.js +338 -0
  370. package/dist/nosql/rocksdb/index.d.ts +112 -0
  371. package/dist/nosql/rocksdb/index.js +103 -1
  372. package/dist/nosql/rocksdb/where-match.d.ts +21 -0
  373. package/dist/nosql/rocksdb/where-match.js +238 -0
  374. package/dist/nosql/rockset/index.d.ts +84 -0
  375. package/dist/nosql/s3/index.d.ts +170 -0
  376. package/dist/nosql/scylladb/index.d.ts +117 -0
  377. package/dist/nosql/signoz/index.d.ts +116 -0
  378. package/dist/nosql/sns/index.d.ts +99 -0
  379. package/dist/nosql/solr/index.d.ts +129 -0
  380. package/dist/nosql/splunk/index.d.ts +125 -0
  381. package/dist/nosql/sqs/index.d.ts +116 -0
  382. package/dist/nosql/stardog/index.d.ts +86 -0
  383. package/dist/nosql/starrocks/index.d.ts +89 -0
  384. package/dist/nosql/store.d.ts +23 -0
  385. package/dist/nosql/sumologic/index.d.ts +119 -0
  386. package/dist/nosql/surrealdb/index.d.ts +156 -0
  387. package/dist/nosql/surrealdb/index.js +174 -1
  388. package/dist/nosql/surrealdb/query-compiler.d.ts +26 -0
  389. package/dist/nosql/surrealdb/query-compiler.js +193 -0
  390. package/dist/nosql/terminusdb/index.d.ts +95 -0
  391. package/dist/nosql/tigergraph/index.d.ts +314 -0
  392. package/dist/nosql/typesense/index.d.ts +82 -0
  393. package/dist/nosql/unqlite/index.d.ts +68 -0
  394. package/dist/nosql/upstash/index.d.ts +80 -0
  395. package/dist/nosql/vercel-kv/index.d.ts +82 -0
  396. package/dist/nosql/victoriametrics/index.d.ts +129 -0
  397. package/dist/nosql/virtuoso/index.d.ts +87 -0
  398. package/dist/nosql/weaviate/index.d.ts +196 -0
  399. package/dist/operators/index.d.ts +7 -0
  400. package/dist/operators.d.ts +2947 -0
  401. package/dist/operators.js +46 -1
  402. package/dist/prisma-migrate/index.d.ts +28 -0
  403. package/dist/prisma-migrate/migration-generator.d.ts +21 -0
  404. package/dist/prisma-migrate/model-generator.d.ts +12 -0
  405. package/dist/prisma-migrate/relations.d.ts +28 -0
  406. package/dist/prisma-migrate/schema-parser.d.ts +42 -0
  407. package/dist/prisma-migrate/type-mapper.d.ts +20 -0
  408. package/dist/prorm.d.ts +2093 -0
  409. package/dist/prorm.js +721 -302
  410. package/dist/query-builders/cte-builder.d.ts +104 -0
  411. package/dist/query-builders/functions/aggregate.d.ts +199 -0
  412. package/dist/query-builders/functions/conditional.d.ts +195 -0
  413. package/dist/query-builders/functions/datetime.d.ts +202 -0
  414. package/dist/query-builders/functions/fulltext.d.ts +220 -0
  415. package/dist/query-builders/functions/index.d.ts +17 -0
  416. package/dist/query-builders/functions/json.d.ts +157 -0
  417. package/dist/query-builders/functions/math.d.ts +215 -0
  418. package/dist/query-builders/functions/string.d.ts +233 -0
  419. package/dist/query-builders/functions/window.d.ts +209 -0
  420. package/dist/query-builders/include-builder.d.ts +85 -0
  421. package/dist/query-builders/index-expression-builder.d.ts +153 -0
  422. package/dist/query-builders/index.d.ts +121 -0
  423. package/dist/query-builders/index.js +10 -0
  424. package/dist/query-builders/insert-builder.d.ts +62 -0
  425. package/dist/query-builders/model-helpers.d.ts +28 -0
  426. package/dist/query-builders/order-limit-builder.d.ts +84 -0
  427. package/dist/query-builders/sql-compiler.d.ts +562 -0
  428. package/dist/query-builders/subquery-builder.d.ts +133 -0
  429. package/dist/query-builders/update-builder.d.ts +71 -0
  430. package/dist/query-builders/view-builder.d.ts +189 -0
  431. package/dist/query-builders/where-builder.d.ts +124 -0
  432. package/dist/query-interface.d.ts +407 -0
  433. package/dist/query-interface.js +84 -0
  434. package/dist/query-optimizers/batch-optimizer.d.ts +175 -0
  435. package/dist/query-optimizers/explain-plans.d.ts +187 -0
  436. package/dist/query-optimizers/index.d.ts +27 -0
  437. package/dist/query-optimizers/prepared-statement-cache.d.ts +252 -0
  438. package/dist/query-optimizers/query-hints.d.ts +201 -0
  439. package/dist/query-optimizers/query-optimizer.d.ts +162 -0
  440. package/dist/query-optimizers/slow-query-logger.d.ts +186 -0
  441. package/dist/replica-manager.d.ts +235 -0
  442. package/dist/schema/index.d.ts +7 -0
  443. package/dist/schema/migration-generator.d.ts +74 -0
  444. package/dist/schema/schema-differ.d.ts +114 -0
  445. package/dist/schema/types.d.ts +246 -0
  446. package/dist/schema-objects.d.ts +78 -0
  447. package/dist/schema-objects.js +203 -0
  448. package/dist/sql-constants.d.ts +240 -0
  449. package/dist/sqlite-advanced.d.ts +572 -0
  450. package/dist/streams/index.d.ts +5 -0
  451. package/dist/streams/transforms.d.ts +120 -0
  452. package/dist/transaction.d.ts +221 -0
  453. package/dist/types/index.d.ts +3123 -0
  454. package/dist/user-management.d.ts +141 -0
  455. package/dist/utils/date.d.ts +149 -0
  456. package/dist/utils/index.d.ts +359 -0
  457. package/dist/utils/string.d.ts +88 -0
  458. package/dist/validators/index.d.ts +7 -0
  459. package/dist/validators/validator.d.ts +306 -0
  460. package/package.json +20 -5
@@ -0,0 +1,274 @@
1
+ /**
2
+ * ORM Decorators Registry
3
+ *
4
+ * Central registry of all decorator names used in the ORM.
5
+ * Useful for documentation, tooling, and reflection-based operations.
6
+ *
7
+ * Usage:
8
+ *
9
+ * import { ORMDecorators } from './orm-decorators';
10
+ *
11
+ * // Access decorator names
12
+ * console.log(ORMDecorators.Table); // 'Table'
13
+ * console.log(ORMDecorators.Column); // 'Column'
14
+ */
15
+ /**
16
+ * All ORM decorator names organized by category.
17
+ *
18
+ * This constant provides a centralized registry of decorator names
19
+ * used throughout the ORM for documentation, tooling, and reflection.
20
+ */
21
+ export declare const ORMDecorators: {
22
+ /** Model/table decorator */
23
+ readonly Table: "Table";
24
+ /** Schema/database schema decorator */
25
+ readonly Schema: "Schema";
26
+ /** Column/property decorator */
27
+ readonly Column: "Column";
28
+ /** Primary key decorator */
29
+ readonly PrimaryKey: "PrimaryKey";
30
+ /** Check constraint decorator */
31
+ readonly Check: "Check";
32
+ /** Unique constraint decorator */
33
+ readonly Unique: "Unique";
34
+ /** Default value decorator */
35
+ readonly Default: "Default";
36
+ /** Foreign key decorator */
37
+ readonly ForeignKey: "ForeignKey";
38
+ /** Index decorator */
39
+ readonly Index: "Index";
40
+ /** Partition decorator */
41
+ readonly Partition: "Partition";
42
+ /** BelongsTo association decorator */
43
+ readonly BelongsTo: "BelongsTo";
44
+ /** HasOne association decorator */
45
+ readonly HasOne: "HasOne";
46
+ /** HasMany association decorator */
47
+ readonly HasMany: "HasMany";
48
+ /** Many-to-many (junction) association decorator */
49
+ readonly BelongsToMany: "BelongsToMany";
50
+ /** Before create hook */
51
+ readonly BeforeCreate: "BeforeCreate";
52
+ /** Before bulk create hook */
53
+ readonly BeforeBulkCreate: "BeforeBulkCreate";
54
+ /** Before update hook */
55
+ readonly BeforeUpdate: "BeforeUpdate";
56
+ /** Before bulk update hook */
57
+ readonly BeforeBulkUpdate: "BeforeBulkUpdate";
58
+ /** Before delete hook */
59
+ readonly BeforeDelete: "BeforeDelete";
60
+ /** Before bulk delete hook */
61
+ readonly BeforeBulkDelete: "BeforeBulkDelete";
62
+ /** Before find hook */
63
+ readonly BeforeFind: "BeforeFind";
64
+ /** Before find after expand options hook */
65
+ readonly BeforeFindAfterExpandOptions: "BeforeFindAfterExpandOptions";
66
+ /** Before find after distribution hook */
67
+ readonly BeforeFindAfterSetup: "BeforeFindAfterSetup";
68
+ /** Before init hook */
69
+ readonly BeforeInit: "BeforeInit";
70
+ /** Before connect hook */
71
+ readonly BeforeConnect: "BeforeConnect";
72
+ /** Before query hook */
73
+ readonly BeforeQuery: "BeforeQuery";
74
+ /** Before sync hook */
75
+ readonly BeforeSync: "BeforeSync";
76
+ /** After create hook */
77
+ readonly AfterCreate: "AfterCreate";
78
+ /** After bulk create hook */
79
+ readonly AfterBulkCreate: "AfterBulkCreate";
80
+ /** After update hook */
81
+ readonly AfterUpdate: "AfterUpdate";
82
+ /** After bulk update hook */
83
+ readonly AfterBulkUpdate: "AfterBulkUpdate";
84
+ /** After delete hook */
85
+ readonly AfterDelete: "AfterDelete";
86
+ /** After bulk delete hook */
87
+ readonly AfterBulkDelete: "AfterBulkDelete";
88
+ /** After find hook */
89
+ readonly AfterFind: "AfterFind";
90
+ /** After init hook */
91
+ readonly AfterInit: "AfterInit";
92
+ /** After connect hook */
93
+ readonly AfterConnect: "AfterConnect";
94
+ /** After query hook */
95
+ readonly AfterQuery: "AfterQuery";
96
+ /** After sync hook */
97
+ readonly AfterSync: "AfterSync";
98
+ /** Virtual/computed column decorator */
99
+ readonly Virtual: "Virtual";
100
+ /** Generated column decorator */
101
+ readonly Generated: "Generated";
102
+ /** Identity/auto-increment decorator */
103
+ readonly Identity: "Identity";
104
+ /** Default scope decorator */
105
+ readonly DefaultScope: "DefaultScope";
106
+ /** Named scopes decorator */
107
+ readonly Scopes: "Scopes";
108
+ /** Scope decorator (single) */
109
+ readonly Scope: "Scope";
110
+ /** Paranoid (soft delete) decorator */
111
+ readonly Paranoid: "Paranoid";
112
+ /** CreatedAt timestamp decorator */
113
+ readonly CreatedAt: "CreatedAt";
114
+ /** UpdatedAt timestamp decorator */
115
+ readonly UpdatedAt: "UpdatedAt";
116
+ /** DeletedAt timestamp decorator */
117
+ readonly DeletedAt: "DeletedAt";
118
+ /** Version (optimistic locking) decorator */
119
+ readonly Version: "Version";
120
+ /** Trigger decorator */
121
+ readonly Trigger: "Trigger";
122
+ /** Stored procedure decorator */
123
+ readonly Procedure: "Procedure";
124
+ /** SQL function decorator */
125
+ readonly Function: "Function";
126
+ /** Function: 'Function' (alias for clarity) */
127
+ readonly SqlFunction: "SqlFunction";
128
+ /** Sequence decorator */
129
+ readonly Sequence: "Sequence";
130
+ /** Extension decorator */
131
+ readonly Extension: "Extension";
132
+ /** Row-level security decorator */
133
+ readonly RowLevelSecurity: "RowLevelSecurity";
134
+ /** Policy decorator */
135
+ readonly Policy: "Policy";
136
+ /** Table inheritance decorator */
137
+ readonly Inheritance: "Inheritance";
138
+ /** Partition decorator (PostgreSQL specific) */
139
+ readonly PartitionPostgres: "Partition";
140
+ /** Event decorator (MySQL/MariaDB) */
141
+ readonly Event: "Event";
142
+ /** Stored routine decorator */
143
+ readonly Routine: "Routine";
144
+ /** Foreign table decorator (SQLite FDW) */
145
+ readonly ForeignTable: "ForeignTable";
146
+ /** View decorator */
147
+ readonly View: "View";
148
+ /** Foreign key checks setting decorator */
149
+ readonly ForeignKeyChecks: "ForeignKeyChecks";
150
+ /** Database setting decorator */
151
+ readonly DatabaseSetting: "DatabaseSetting";
152
+ /** Comment decorator */
153
+ readonly Comment: "Comment";
154
+ /** Secure field decorator */
155
+ readonly Secure: "Secure";
156
+ /** Secure field decorator (alias) */
157
+ readonly SecureField: "SecureField";
158
+ /** Permission decorator */
159
+ readonly Permission: "Permission";
160
+ /** Can view decorator */
161
+ readonly CanView: "CanView";
162
+ /** Cannot view decorator */
163
+ readonly CannotView: "CannotView";
164
+ /** Can write decorator */
165
+ readonly CanWrite: "CanWrite";
166
+ /** Cannot write decorator */
167
+ readonly CannotWrite: "CannotWrite";
168
+ /** Audit decorator */
169
+ readonly Audit: "Audit";
170
+ /** AuditChange decorator */
171
+ readonly AuditChange: "AuditChange";
172
+ /** AuditLog decorator */
173
+ readonly AuditLog: "AuditLog";
174
+ /** Validate decorator */
175
+ readonly Validate: "Validate";
176
+ /** Is decorator (validation rule) */
177
+ readonly Is: "Is";
178
+ /** IsAlpha decorator */
179
+ readonly IsAlpha: "IsAlpha";
180
+ /** IsAlphanumeric decorator */
181
+ readonly IsAlphanumeric: "IsAlphanumeric";
182
+ /** IsNumeric decorator */
183
+ readonly IsNumeric: "IsNumeric";
184
+ /** IsEmail decorator */
185
+ readonly IsEmail: "IsEmail";
186
+ /** IsURL decorator */
187
+ readonly IsURL: "IsURL";
188
+ /** IsIP decorator */
189
+ readonly IsIP: "IsIP";
190
+ /** IsDate decorator */
191
+ readonly IsDate: "IsDate";
192
+ /** IsInt decorator */
193
+ readonly IsInt: "IsInt";
194
+ /** IsFloat decorator */
195
+ readonly IsFloat: "IsFloat";
196
+ /** IsBoolean decorator */
197
+ readonly IsBoolean: "IsBoolean";
198
+ /** IsUUID decorator */
199
+ readonly IsUUID: "IsUUID";
200
+ /** IsJSON decorator */
201
+ readonly IsJSON: "IsJSON";
202
+ /** IsNull decorator */
203
+ readonly IsNull: "IsNull";
204
+ /** NotEmpty decorator */
205
+ readonly NotEmpty: "NotEmpty";
206
+ /** Len decorator (length validation) */
207
+ readonly Len: "Len";
208
+ /** Min decorator */
209
+ readonly Min: "Min";
210
+ /** Max decorator */
211
+ readonly Max: "Max";
212
+ /** IsIn decorator */
213
+ readonly IsIn: "IsIn";
214
+ /** NotIn decorator */
215
+ readonly NotIn: "NotIn";
216
+ /** Regexp decorator */
217
+ readonly Regexp: "Regexp";
218
+ /** NotRegexp decorator */
219
+ readonly NotRegexp: "NotRegexp";
220
+ /** IsCreditCard decorator */
221
+ readonly IsCreditCard: "IsCreditCard";
222
+ /** IsISBN decorator */
223
+ readonly IsISBN: "IsISBN";
224
+ /** IsMobilePhone decorator */
225
+ readonly IsMobilePhone: "IsMobilePhone";
226
+ /** IsPostalCode decorator */
227
+ readonly IsPostalCode: "IsPostalCode";
228
+ /** IsCurrency decorator */
229
+ readonly IsCurrency: "IsCurrency";
230
+ /** IsOctal decorator */
231
+ readonly IsOctal: "IsOctal";
232
+ /** IsDivisibleBy decorator */
233
+ readonly IsDivisibleBy: "IsDivisibleBy";
234
+ /** Index (alias for backward compatibility) */
235
+ readonly IndexAlt: "Index";
236
+ /** Raw decorator for raw SQL */
237
+ readonly Raw: "Raw";
238
+ };
239
+ /**
240
+ * Type of the ORMDecorators constant - all decorator names as a union type
241
+ */
242
+ export type ORMDecoratorName = (typeof ORMDecorators)[keyof typeof ORMDecorators];
243
+ /**
244
+ * Get all decorator names as an array
245
+ */
246
+ export declare const ALL_DECORATORS: ("Default" | "Version" | "AuditLog" | "SqlFunction" | "Procedure" | "Column" | "Table" | "PrimaryKey" | "Unique" | "ForeignKey" | "Schema" | "Check" | "Index" | "Partition" | "BelongsTo" | "HasOne" | "HasMany" | "BelongsToMany" | "BeforeCreate" | "BeforeBulkCreate" | "BeforeUpdate" | "BeforeBulkUpdate" | "BeforeDelete" | "BeforeBulkDelete" | "BeforeFind" | "BeforeFindAfterExpandOptions" | "BeforeFindAfterSetup" | "BeforeInit" | "BeforeConnect" | "BeforeQuery" | "BeforeSync" | "AfterCreate" | "AfterBulkCreate" | "AfterUpdate" | "AfterBulkUpdate" | "AfterDelete" | "AfterBulkDelete" | "AfterFind" | "AfterInit" | "AfterConnect" | "AfterQuery" | "AfterSync" | "Virtual" | "Generated" | "Identity" | "DefaultScope" | "Scopes" | "Scope" | "Paranoid" | "CreatedAt" | "UpdatedAt" | "DeletedAt" | "Trigger" | "Function" | "Sequence" | "Extension" | "RowLevelSecurity" | "Policy" | "Inheritance" | "Event" | "Routine" | "ForeignTable" | "View" | "ForeignKeyChecks" | "DatabaseSetting" | "Comment" | "Secure" | "SecureField" | "Permission" | "CanView" | "CannotView" | "CanWrite" | "CannotWrite" | "Audit" | "AuditChange" | "Validate" | "Is" | "IsAlpha" | "IsAlphanumeric" | "IsNumeric" | "IsEmail" | "IsURL" | "IsIP" | "IsDate" | "IsInt" | "IsFloat" | "IsBoolean" | "IsUUID" | "IsJSON" | "IsNull" | "NotEmpty" | "Len" | "Min" | "Max" | "IsIn" | "NotIn" | "Regexp" | "NotRegexp" | "IsCreditCard" | "IsISBN" | "IsMobilePhone" | "IsPostalCode" | "IsCurrency" | "IsOctal" | "IsDivisibleBy" | "Raw")[];
247
+ /**
248
+ * Get all model definition decorators
249
+ */
250
+ export declare const MODEL_DECORATORS: readonly ["Table", "Schema", "Column", "PrimaryKey"];
251
+ /**
252
+ * Get all constraint decorators
253
+ */
254
+ export declare const CONSTRAINT_DECORATORS: readonly ["Check", "Unique", "Default", "ForeignKey", "Index", "Partition"];
255
+ /**
256
+ * Get all association decorators
257
+ */
258
+ export declare const ASSOCIATION_DECORATORS: readonly ["BelongsTo", "HasOne", "HasMany", "BelongsToMany"];
259
+ /**
260
+ * Get all hook decorators (before and after)
261
+ */
262
+ export declare const HOOK_DECORATORS: readonly ["BeforeCreate", "BeforeBulkCreate", "BeforeUpdate", "BeforeBulkUpdate", "BeforeDelete", "BeforeBulkDelete", "BeforeFind", "BeforeFindAfterExpandOptions", "BeforeFindAfterSetup", "BeforeInit", "BeforeConnect", "BeforeQuery", "BeforeSync", "AfterCreate", "AfterBulkCreate", "AfterUpdate", "AfterBulkUpdate", "AfterDelete", "AfterBulkDelete", "AfterFind", "AfterInit", "AfterConnect", "AfterQuery", "AfterSync"];
263
+ /**
264
+ * Get all validation decorators
265
+ */
266
+ export declare const VALIDATION_DECORATORS: readonly ["Validate", "Is", "IsAlpha", "IsAlphanumeric", "IsNumeric", "IsEmail", "IsURL", "IsIP", "IsDate", "IsInt", "IsFloat", "IsBoolean", "IsUUID", "IsJSON", "IsNull", "NotEmpty", "Len", "Min", "Max", "IsIn", "NotIn", "Regexp", "NotRegexp", "IsCreditCard", "IsISBN", "IsMobilePhone", "IsPostalCode", "IsCurrency", "IsOctal", "IsDivisibleBy"];
267
+ /**
268
+ * Get all PostgreSQL-specific decorators
269
+ */
270
+ export declare const POSTGRES_DECORATORS: readonly ["Trigger", "Procedure", "Function", "SqlFunction", "Sequence", "Extension", "RowLevelSecurity", "Policy", "Inheritance"];
271
+ /**
272
+ * Get all database setting decorators
273
+ */
274
+ export declare const SETTINGS_DECORATORS: readonly ["ForeignKeyChecks", "DatabaseSetting"];
@@ -0,0 +1,192 @@
1
+ /**
2
+ * Permission / access-control decorators for the ORM.
3
+ *
4
+ * These decorators let you annotate model classes and individual fields with
5
+ * access rules — which roles can read, write, or are completely blocked from
6
+ * a field or an entire model. At query time you call filterByPermissions()
7
+ * to strip out any fields the current user is not allowed to see.
8
+ *
9
+ * ──────────────────────────────────────────────────────────────────────────
10
+ * Quick Reference
11
+ * ──────────────────────────────────────────────────────────────────────────
12
+ *
13
+ * @CanView('admin', 'manager') — only these roles can read the field/model
14
+ * @CannotView('guest') — these roles are DENIED read access
15
+ * @CanWrite('admin') — only these roles can write the field
16
+ * @CannotWrite('guest') — these roles are DENIED write access
17
+ * @Permission({ ... }) — full control with explicit allow/deny lists
18
+ *
19
+ * ──────────────────────────────────────────────────────────────────────────
20
+ * Example
21
+ * ──────────────────────────────────────────────────────────────────────────
22
+ *
23
+ * // Field-level permissions (applied via static registration):
24
+ * PermissionRegistry.addFieldRule(User, 'ssn', { canView: ['admin'] });
25
+ * PermissionRegistry.addFieldRule(User, 'salary', { canView: ['admin', 'hr'] });
26
+ * PermissionRegistry.addFieldRule(User, 'password', { canView: [] }); // nobody
27
+ *
28
+ * // Class-level permission (applied via decorator):
29
+ * @CanView('admin', 'manager')
30
+ * class AuditLog extends Model { ... }
31
+ *
32
+ * // At request time:
33
+ * const currentRole = 'guest';
34
+ * const user = await User.findOne({ where: { id: 1 } });
35
+ * const safeUser = filterByPermissions(user, currentRole);
36
+ * // safeUser.ssn === undefined, safeUser.salary === undefined
37
+ *
38
+ * // Or get the allowed attribute list for a findAll() call:
39
+ * const attrs = getAllowedAttributes(User, currentRole);
40
+ * const users = await User.findAll({ attributes: attrs });
41
+ */
42
+ export interface PermissionRule {
43
+ /**
44
+ * Roles that are explicitly ALLOWED to read this field/model.
45
+ * If this array is present (even empty), only roles in this list can read.
46
+ * A '*' entry means "any role".
47
+ */
48
+ canView?: string[];
49
+ /**
50
+ * Roles that are explicitly DENIED read access, regardless of canView.
51
+ */
52
+ cannotView?: string[];
53
+ /**
54
+ * Roles that are explicitly ALLOWED to write this field.
55
+ * If this array is present, only roles in this list can write.
56
+ */
57
+ canWrite?: string[];
58
+ /**
59
+ * Roles that are explicitly DENIED write access.
60
+ */
61
+ cannotWrite?: string[];
62
+ }
63
+ export interface PermissionOptions extends PermissionRule {
64
+ /**
65
+ * Human-readable description of the permission rule (for docs/tooling).
66
+ */
67
+ description?: string;
68
+ }
69
+ export declare const PermissionRegistry: {
70
+ /**
71
+ * Register or update a permission rule for a specific field on a model.
72
+ *
73
+ * @param target - The model class constructor
74
+ * @param fieldName - The attribute/field name
75
+ * @param rule - The access rule
76
+ */
77
+ addFieldRule(target: Function, fieldName: string, rule: PermissionRule): void;
78
+ /**
79
+ * Get the rule for a specific field (or undefined if none).
80
+ */
81
+ getFieldRule(target: Function, fieldName: string): PermissionRule | undefined;
82
+ /**
83
+ * Get all field rules registered on a model.
84
+ */
85
+ getAllFieldRules(target: Function): Map<string, PermissionRule>;
86
+ /**
87
+ * Register or update a model-level permission rule (applies to ALL fields).
88
+ */
89
+ addModelRule(target: Function, rule: PermissionRule): void;
90
+ /**
91
+ * Get the model-level rule (or undefined if none).
92
+ */
93
+ getModelRule(target: Function): PermissionRule | undefined;
94
+ };
95
+ /**
96
+ * Check whether a given role can VIEW a field on a model.
97
+ *
98
+ * Resolution order:
99
+ * 1. Field-level cannotView → deny if role is listed
100
+ * 2. Field-level canView → allow only if role is listed (or '*' present)
101
+ * 3. Model-level cannotView → deny if role is listed
102
+ * 4. Model-level canView → allow only if role is listed (or '*' present)
103
+ * 5. Default: allow
104
+ *
105
+ * @param ModelClass - The model constructor
106
+ * @param fieldName - The attribute name to check
107
+ * @param role - The current user's role
108
+ */
109
+ export declare function canViewField(ModelClass: Function, fieldName: string, role: string): boolean;
110
+ /**
111
+ * Check whether a given role can WRITE a field on a model.
112
+ */
113
+ export declare function canWriteField(ModelClass: Function, fieldName: string, role: string): boolean;
114
+ /**
115
+ * Return the list of field names on a model that `role` is allowed to VIEW.
116
+ *
117
+ * Useful for passing to `findAll({ attributes: ... })` to prevent loading
118
+ * restricted data at the database level.
119
+ *
120
+ * @param ModelClass - The model constructor
121
+ * @param role - The current user's role
122
+ * @param allAttributes - The full list of attribute names. If omitted,
123
+ * the registry's field rules are used as the universe
124
+ * (only fields with explicit rules are considered).
125
+ */
126
+ export declare function getAllowedAttributes(ModelClass: Function, role: string, allAttributes?: string[]): string[];
127
+ /**
128
+ * Strip restricted fields from a plain object or model instance.
129
+ *
130
+ * Returns a new plain object with only the fields `role` is allowed to see.
131
+ * Does not mutate the original.
132
+ *
133
+ * @param instance - A model instance or plain record object
134
+ * @param role - The current user's role
135
+ * @param ModelClass - The model class (defaults to instance.constructor)
136
+ */
137
+ export declare function filterByPermissions(instance: any, role: string, ModelClass?: Function): Record<string, any>;
138
+ /**
139
+ * Strip restricted fields from a plain object for WRITE operations.
140
+ * Removes any fields the role is not allowed to write.
141
+ */
142
+ export declare function filterWriteByPermissions(data: Record<string, any>, role: string, ModelClass: Function): Record<string, any>;
143
+ /**
144
+ * Allow only the listed roles to VIEW the decorated class (all fields) or
145
+ * use PermissionRegistry.addFieldRule() for per-field control.
146
+ *
147
+ * @CanView('admin', 'manager')
148
+ * class AuditLog extends Model { ... }
149
+ */
150
+ export declare function CanView(...roles: string[]): (target: Function) => void;
151
+ /**
152
+ * Deny the listed roles from viewing the decorated class.
153
+ *
154
+ * @CannotView('guest', 'public')
155
+ * class SensitiveReport extends Model { ... }
156
+ */
157
+ export declare function CannotView(...roles: string[]): (target: Function) => void;
158
+ /**
159
+ * Allow only the listed roles to WRITE to the decorated class.
160
+ *
161
+ * @CanWrite('admin')
162
+ * class Settings extends Model { ... }
163
+ */
164
+ export declare function CanWrite(...roles: string[]): (target: Function) => void;
165
+ /**
166
+ * Deny the listed roles from writing to the decorated class.
167
+ */
168
+ export declare function CannotWrite(...roles: string[]): (target: Function) => void;
169
+ /**
170
+ * Full permission decorator — applies read and write rules at the model level.
171
+ *
172
+ * @Permission({ canView: ['admin', 'manager'], canWrite: ['admin'] })
173
+ * class Invoice extends Model { ... }
174
+ */
175
+ export declare function Permission(options: PermissionOptions): (target: Function) => void;
176
+ /**
177
+ * A higher-order helper that wraps a controller function and automatically
178
+ * applies permission filtering on the result.
179
+ *
180
+ * Example:
181
+ *
182
+ * const getUser = withPermissions(User, async (id: number) => {
183
+ * return User.findByPk(id);
184
+ * });
185
+ *
186
+ * const safeUser = await getUser(1, 'guest');
187
+ * // safeUser has only the fields 'guest' is allowed to see
188
+ *
189
+ * @param ModelClass - The model class whose permissions to apply
190
+ * @param fn - The async controller function (last arg must be role string)
191
+ */
192
+ export declare function withPermissions<T extends (...args: any[]) => Promise<any>>(ModelClass: Function, fn: T): (...args: [...Parameters<T>, string]) => Promise<Record<string, any> | null>;
@@ -0,0 +1,168 @@
1
+ /**
2
+ * TypeScript decorators for SQL Stored Procedures and SQL Functions.
3
+ *
4
+ * @Procedure — annotate a class method (or standalone function wrapper) so
5
+ * it is understood by the ORM as a stored procedure.
6
+ * The ORM can generate the CREATE PROCEDURE SQL and register
7
+ * a callable wrapper on your Prorm instance.
8
+ *
9
+ * @SqlFunction — like @Procedure but for database functions that RETURN a
10
+ * value and can be called inside SELECT / WHERE clauses.
11
+ *
12
+ * Both decorators store metadata in a registry. Register the class with
13
+ * `prorm.registerProcedures(MyProcedures)` and `sync()` will issue the DDL;
14
+ * `ProcedureRegistry.getSQL(target, method)` returns it if you'd rather run it
15
+ * yourself, and `ProcedureRegistry.call(prorm, target, method, args)` invokes it.
16
+ *
17
+ * Scope note: the `body` option is SQL, and deliberately so. These decorators
18
+ * generate the CREATE PROCEDURE envelope - name, parameter list, language,
19
+ * volatility, schema qualification and dialect differences - but the routine's
20
+ * body is procedural SQL (PL/pgSQL, MySQL's compound statements, PL/SQL) with
21
+ * no ORM-level equivalent. Everything a query can express belongs in a model
22
+ * method instead; reach for a stored procedure only when you specifically need
23
+ * logic to live in the database.
24
+ *
25
+ * Example:
26
+ *
27
+ * class UserProcedures {
28
+ * @Procedure({
29
+ * name: 'get_user_by_email',
30
+ * params: [{ name: 'p_email', type: 'VARCHAR(255)', mode: 'IN' }],
31
+ * dialect: 'mysql',
32
+ * body: `BEGIN SELECT * FROM users WHERE email = p_email; END`,
33
+ * })
34
+ * getUserByEmail(email: string) {}
35
+ *
36
+ * @SqlFunction({
37
+ * name: 'full_name',
38
+ * params: [
39
+ * { name: 'first', type: 'TEXT' },
40
+ * { name: 'last', type: 'TEXT' },
41
+ * ],
42
+ * returns: 'TEXT',
43
+ * dialect: 'postgres',
44
+ * body: `SELECT first || ' ' || last`,
45
+ * language: 'SQL',
46
+ * })
47
+ * fullName(first: string, last: string): string { return ''; }
48
+ * }
49
+ *
50
+ * // Generate and run the DDL
51
+ * const sql = ProcedureRegistry.getSQL(UserProcedures, 'getUserByEmail');
52
+ * await prorm.query(sql);
53
+ *
54
+ * // Or use the auto-call helper
55
+ * const rows = await ProcedureRegistry.call(prorm, UserProcedures, 'getUserByEmail', ['john@example.com']);
56
+ */
57
+ import type { Prorm } from '../prorm';
58
+ export type ProcedureParamMode = 'IN' | 'OUT' | 'INOUT';
59
+ export interface ProcedureParam {
60
+ /** SQL parameter name */
61
+ name: string;
62
+ /** SQL type string, e.g. 'VARCHAR(255)', 'INTEGER', 'TEXT' */
63
+ type: string;
64
+ /** Parameter mode (default: IN) */
65
+ mode?: ProcedureParamMode;
66
+ }
67
+ export interface ProcedureOptions {
68
+ /**
69
+ * The name of the stored procedure in the database.
70
+ * Defaults to the method name if not provided.
71
+ */
72
+ name?: string;
73
+ /** Input/output parameters */
74
+ params?: ProcedureParam[];
75
+ /**
76
+ * The SQL body of the procedure (everything inside BEGIN...END or $$...$$).
77
+ * If omitted, the generated DDL will have an empty body placeholder.
78
+ */
79
+ body?: string;
80
+ /**
81
+ * Target dialect. Controls the DDL syntax that is generated.
82
+ * One of: 'mysql' | 'mariadb' | 'postgres' | 'sqlite'
83
+ * Defaults to 'mysql'.
84
+ */
85
+ dialect?: 'mysql' | 'mariadb' | 'postgres' | 'sqlite';
86
+ /** Optional schema prefix, e.g. 'public' */
87
+ schema?: string;
88
+ /**
89
+ * If true, generates CREATE OR REPLACE PROCEDURE (Postgres) or
90
+ * DROP PROCEDURE IF EXISTS + CREATE PROCEDURE (MySQL).
91
+ * Default: false.
92
+ */
93
+ replace?: boolean;
94
+ }
95
+ export interface SqlFunctionOptions extends Omit<ProcedureOptions, 'params'> {
96
+ /** Input parameters (functions never have OUT params) */
97
+ params?: Omit<ProcedureParam, 'mode'>[];
98
+ /**
99
+ * SQL return type, e.g. 'TEXT', 'INTEGER', 'TABLE(id INT, name TEXT)'.
100
+ * Required for functions.
101
+ */
102
+ returns: string;
103
+ /**
104
+ * Procedural language. Default: 'plpgsql' for postgres, 'SQL' for simple expressions.
105
+ */
106
+ language?: string;
107
+ /**
108
+ * Set DETERMINISTIC / IMMUTABLE / STABLE / VOLATILE hint.
109
+ * MySQL: 'DETERMINISTIC' | 'NOT DETERMINISTIC'
110
+ * Postgres: 'IMMUTABLE' | 'STABLE' | 'VOLATILE'
111
+ */
112
+ volatility?: string;
113
+ }
114
+ interface ProcedureMeta {
115
+ kind: 'procedure' | 'function';
116
+ methodKey: string;
117
+ options: ProcedureOptions | SqlFunctionOptions;
118
+ }
119
+ /**
120
+ * Mark a method as a SQL stored procedure.
121
+ *
122
+ * The decorated method is a no-op at runtime — use ProcedureRegistry.call()
123
+ * to execute the actual database procedure.
124
+ */
125
+ export declare function Procedure(options?: ProcedureOptions): (target: any, propertyKey: string, _descriptor: PropertyDescriptor) => void;
126
+ /**
127
+ * Mark a method as a SQL function (returns a value, usable in SELECT/WHERE).
128
+ *
129
+ * The decorated method is a no-op at runtime — use ProcedureRegistry.call()
130
+ * to execute the actual database function.
131
+ */
132
+ export declare function SqlFunction(options: SqlFunctionOptions): (target: any, propertyKey: string, _descriptor: PropertyDescriptor) => void;
133
+ export declare const ProcedureRegistry: {
134
+ /**
135
+ * Get all registered procedures/functions on a class.
136
+ */
137
+ getAll(target: Function): ProcedureMeta[];
138
+ /**
139
+ * Get a single procedure/function meta by method name.
140
+ */
141
+ get(target: Function, methodKey: string): ProcedureMeta | undefined;
142
+ /**
143
+ * Generate the CREATE PROCEDURE / CREATE FUNCTION SQL for a registered method.
144
+ *
145
+ * @param target - The class constructor
146
+ * @param methodKey - The method name
147
+ * @param dialect - Override the dialect stored in the decorator options
148
+ */
149
+ getSQL(target: Function, methodKey: string, dialect?: "mysql" | "mariadb" | "postgres" | "sqlite"): string;
150
+ /**
151
+ * Generate DDL for every procedure/function on a class and execute them.
152
+ *
153
+ * @param prorm - Prorm instance
154
+ * @param target - The class constructor
155
+ * @param dialect - Override dialect
156
+ */
157
+ createAll(prorm: Prorm, target: Function, dialect?: "mysql" | "mariadb" | "postgres" | "sqlite"): Promise<void>;
158
+ /**
159
+ * Call a stored procedure.
160
+ *
161
+ * @param prorm - Prorm instance
162
+ * @param target - The class constructor that has the @Procedure decorator
163
+ * @param methodKey - The method name
164
+ * @param args - Arguments to pass (positional, matched to params order)
165
+ */
166
+ call(prorm: Prorm, target: Function, methodKey: string, args?: any[]): Promise<any>;
167
+ };
168
+ export {};