@opensaas/stack-core 0.43.0 → 0.44.0-alpha.2

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 (641) hide show
  1. package/CHANGELOG.md +2753 -0
  2. package/README.md +182 -115
  3. package/dist/.build-hash +1 -0
  4. package/dist/access/declared-dependencies.d.ts +102 -88
  5. package/dist/access/declared-dependencies.d.ts.map +1 -1
  6. package/dist/access/declared-dependencies.js +83 -71
  7. package/dist/access/declared-dependencies.js.map +1 -1
  8. package/dist/access/depth-limits.d.ts +4 -0
  9. package/dist/access/depth-limits.d.ts.map +1 -1
  10. package/dist/access/depth-limits.js +4 -0
  11. package/dist/access/depth-limits.js.map +1 -1
  12. package/dist/access/engine.d.ts +68 -20
  13. package/dist/access/engine.d.ts.map +1 -1
  14. package/dist/access/engine.js +151 -37
  15. package/dist/access/engine.js.map +1 -1
  16. package/dist/access/errors.d.ts +33 -48
  17. package/dist/access/errors.d.ts.map +1 -1
  18. package/dist/access/errors.js +73 -63
  19. package/dist/access/errors.js.map +1 -1
  20. package/dist/access/field-access.d.ts +76 -5
  21. package/dist/access/field-access.d.ts.map +1 -1
  22. package/dist/access/field-access.js +235 -61
  23. package/dist/access/field-access.js.map +1 -1
  24. package/dist/access/field-visibility.d.ts +50 -4
  25. package/dist/access/field-visibility.d.ts.map +1 -1
  26. package/dist/access/field-visibility.js +143 -160
  27. package/dist/access/field-visibility.js.map +1 -1
  28. package/dist/access/index.d.ts +5 -12
  29. package/dist/access/index.d.ts.map +1 -1
  30. package/dist/access/index.js +6 -19
  31. package/dist/access/index.js.map +1 -1
  32. package/dist/access/orm-client.d.ts +19 -0
  33. package/dist/access/orm-client.d.ts.map +1 -0
  34. package/dist/access/orm-client.js +37 -0
  35. package/dist/access/orm-client.js.map +1 -0
  36. package/dist/access/query-validation.d.ts +7 -129
  37. package/dist/access/query-validation.d.ts.map +1 -1
  38. package/dist/access/query-validation.js +12 -314
  39. package/dist/access/query-validation.js.map +1 -1
  40. package/dist/access/system-fields.d.ts +2 -0
  41. package/dist/access/system-fields.d.ts.map +1 -0
  42. package/dist/access/system-fields.js +7 -0
  43. package/dist/access/system-fields.js.map +1 -0
  44. package/dist/access/transaction-registry.d.ts +25 -2
  45. package/dist/access/transaction-registry.d.ts.map +1 -1
  46. package/dist/access/transaction-registry.js +34 -17
  47. package/dist/access/transaction-registry.js.map +1 -1
  48. package/dist/access/types.d.ts +217 -131
  49. package/dist/access/types.d.ts.map +1 -1
  50. package/dist/config/field-kind.d.ts +66 -0
  51. package/dist/config/field-kind.d.ts.map +1 -0
  52. package/dist/config/field-kind.js +63 -0
  53. package/dist/config/field-kind.js.map +1 -0
  54. package/dist/config/hook-only-fields.d.ts +3 -0
  55. package/dist/config/hook-only-fields.d.ts.map +1 -0
  56. package/dist/config/hook-only-fields.js +17 -0
  57. package/dist/config/hook-only-fields.js.map +1 -0
  58. package/dist/config/index.d.ts +3 -1
  59. package/dist/config/index.d.ts.map +1 -1
  60. package/dist/config/index.js +6 -3
  61. package/dist/config/index.js.map +1 -1
  62. package/dist/config/mcp-tool-names.d.ts +3 -0
  63. package/dist/config/mcp-tool-names.d.ts.map +1 -0
  64. package/dist/config/mcp-tool-names.js +25 -0
  65. package/dist/config/mcp-tool-names.js.map +1 -0
  66. package/dist/config/nav-count.d.ts.map +1 -1
  67. package/dist/config/nav-count.js +4 -4
  68. package/dist/config/nav-count.js.map +1 -1
  69. package/dist/config/plugin-engine.d.ts +8 -2
  70. package/dist/config/plugin-engine.d.ts.map +1 -1
  71. package/dist/config/plugin-engine.js +102 -38
  72. package/dist/config/plugin-engine.js.map +1 -1
  73. package/dist/config/types.d.ts +1035 -611
  74. package/dist/config/types.d.ts.map +1 -1
  75. package/dist/context/apply-defaults.d.ts +18 -1
  76. package/dist/context/apply-defaults.d.ts.map +1 -1
  77. package/dist/context/apply-defaults.js +30 -4
  78. package/dist/context/apply-defaults.js.map +1 -1
  79. package/dist/context/engine-context.d.ts +73 -0
  80. package/dist/context/engine-context.d.ts.map +1 -0
  81. package/dist/context/engine-context.js +67 -0
  82. package/dist/context/engine-context.js.map +1 -0
  83. package/dist/context/hook-pipeline.d.ts +9 -2
  84. package/dist/context/hook-pipeline.d.ts.map +1 -1
  85. package/dist/context/hook-pipeline.js +5 -4
  86. package/dist/context/hook-pipeline.js.map +1 -1
  87. package/dist/context/index.d.ts +98 -89
  88. package/dist/context/index.d.ts.map +1 -1
  89. package/dist/context/index.js +917 -722
  90. package/dist/context/index.js.map +1 -1
  91. package/dist/context/junction.d.ts +59 -0
  92. package/dist/context/junction.d.ts.map +1 -0
  93. package/dist/context/junction.js +126 -0
  94. package/dist/context/junction.js.map +1 -0
  95. package/dist/context/plugin-field-read.d.ts +33 -0
  96. package/dist/context/plugin-field-read.d.ts.map +1 -0
  97. package/dist/context/plugin-field-read.js +41 -0
  98. package/dist/context/plugin-field-read.js.map +1 -0
  99. package/dist/context/plugin-field-write.d.ts +104 -0
  100. package/dist/context/plugin-field-write.d.ts.map +1 -0
  101. package/dist/context/plugin-field-write.js +184 -0
  102. package/dist/context/plugin-field-write.js.map +1 -0
  103. package/dist/context/relationship-input.d.ts +146 -0
  104. package/dist/context/relationship-input.d.ts.map +1 -0
  105. package/dist/context/relationship-input.js +453 -0
  106. package/dist/context/relationship-input.js.map +1 -0
  107. package/dist/context/transaction-boundary.d.ts +54 -28
  108. package/dist/context/transaction-boundary.d.ts.map +1 -1
  109. package/dist/context/transaction-boundary.js +87 -169
  110. package/dist/context/transaction-boundary.js.map +1 -1
  111. package/dist/context/write-pipeline.d.ts +33 -51
  112. package/dist/context/write-pipeline.d.ts.map +1 -1
  113. package/dist/context/write-pipeline.js +372 -185
  114. package/dist/context/write-pipeline.js.map +1 -1
  115. package/dist/contract/dependencies.d.ts +88 -0
  116. package/dist/contract/dependencies.d.ts.map +1 -0
  117. package/dist/contract/dependencies.js +237 -0
  118. package/dist/contract/dependencies.js.map +1 -0
  119. package/dist/contract/derive.d.ts +49 -0
  120. package/dist/contract/derive.d.ts.map +1 -0
  121. package/dist/contract/derive.js +629 -0
  122. package/dist/contract/derive.js.map +1 -0
  123. package/dist/contract/fixtures/contract-configs.d.ts +64 -0
  124. package/dist/contract/fixtures/contract-configs.d.ts.map +1 -0
  125. package/dist/contract/fixtures/contract-configs.js +345 -0
  126. package/dist/contract/fixtures/contract-configs.js.map +1 -0
  127. package/dist/contract/id-boundary.d.ts +53 -0
  128. package/dist/contract/id-boundary.d.ts.map +1 -0
  129. package/dist/contract/id-boundary.js +76 -0
  130. package/dist/contract/id-boundary.js.map +1 -0
  131. package/dist/contract/index.d.ts +8 -0
  132. package/dist/contract/index.d.ts.map +1 -0
  133. package/dist/contract/index.js +11 -0
  134. package/dist/contract/index.js.map +1 -0
  135. package/dist/contract/prisma.d.ts +58 -0
  136. package/dist/contract/prisma.d.ts.map +1 -0
  137. package/dist/contract/prisma.js +294 -0
  138. package/dist/contract/prisma.js.map +1 -0
  139. package/dist/contract/relation-graph.d.ts +70 -0
  140. package/dist/contract/relation-graph.d.ts.map +1 -0
  141. package/dist/contract/relation-graph.js +113 -0
  142. package/dist/contract/relation-graph.js.map +1 -0
  143. package/dist/contract/types.d.ts +153 -0
  144. package/dist/contract/types.d.ts.map +1 -0
  145. package/dist/contract/types.js +2 -0
  146. package/dist/contract/types.js.map +1 -0
  147. package/dist/db/client.d.ts +55 -0
  148. package/dist/db/client.d.ts.map +1 -0
  149. package/dist/db/client.js +73 -0
  150. package/dist/db/client.js.map +1 -0
  151. package/dist/db/dev-database.d.ts +124 -0
  152. package/dist/db/dev-database.d.ts.map +1 -0
  153. package/dist/db/dev-database.js +291 -0
  154. package/dist/db/dev-database.js.map +1 -0
  155. package/dist/db/password-front.d.ts +10 -0
  156. package/dist/db/password-front.d.ts.map +1 -0
  157. package/dist/db/password-front.js +147 -0
  158. package/dist/db/password-front.js.map +1 -0
  159. package/dist/db/process-identity.d.ts +36 -0
  160. package/dist/db/process-identity.d.ts.map +1 -0
  161. package/dist/db/process-identity.js +114 -0
  162. package/dist/db/process-identity.js.map +1 -0
  163. package/dist/db/state-file.d.ts +54 -0
  164. package/dist/db/state-file.d.ts.map +1 -0
  165. package/dist/db/state-file.js +91 -0
  166. package/dist/db/state-file.js.map +1 -0
  167. package/dist/db/url.d.ts +89 -0
  168. package/dist/db/url.d.ts.map +1 -0
  169. package/dist/db/url.js +118 -0
  170. package/dist/db/url.js.map +1 -0
  171. package/dist/extend.d.ts +13 -2
  172. package/dist/extend.d.ts.map +1 -1
  173. package/dist/extend.js +24 -1
  174. package/dist/extend.js.map +1 -1
  175. package/dist/fields/index.d.ts +87 -42
  176. package/dist/fields/index.d.ts.map +1 -1
  177. package/dist/fields/index.js +462 -678
  178. package/dist/fields/index.js.map +1 -1
  179. package/dist/filter/collect.d.ts +3 -4
  180. package/dist/filter/collect.d.ts.map +1 -1
  181. package/dist/filter/collect.js +2 -2
  182. package/dist/filter/collect.js.map +1 -1
  183. package/dist/filter/index.d.ts +1 -2
  184. package/dist/filter/index.d.ts.map +1 -1
  185. package/dist/filter/index.js +0 -1
  186. package/dist/filter/index.js.map +1 -1
  187. package/dist/filter/map.d.ts +12 -5
  188. package/dist/filter/map.d.ts.map +1 -1
  189. package/dist/filter/map.js +47 -19
  190. package/dist/filter/map.js.map +1 -1
  191. package/dist/filter/types.d.ts +10 -24
  192. package/dist/filter/types.d.ts.map +1 -1
  193. package/dist/filter/types.js +2 -11
  194. package/dist/filter/types.js.map +1 -1
  195. package/dist/hooks/index.d.ts +22 -31
  196. package/dist/hooks/index.d.ts.map +1 -1
  197. package/dist/hooks/index.js +33 -37
  198. package/dist/hooks/index.js.map +1 -1
  199. package/dist/hooks/transition-guard.d.ts +61 -0
  200. package/dist/hooks/transition-guard.d.ts.map +1 -0
  201. package/dist/hooks/transition-guard.js +93 -0
  202. package/dist/hooks/transition-guard.js.map +1 -0
  203. package/dist/index.d.ts +52 -16
  204. package/dist/index.d.ts.map +1 -1
  205. package/dist/index.js +105 -51
  206. package/dist/index.js.map +1 -1
  207. package/dist/internal.d.ts +4 -2
  208. package/dist/internal.d.ts.map +1 -1
  209. package/dist/internal.js +16 -0
  210. package/dist/internal.js.map +1 -1
  211. package/dist/lib/case-utils.d.ts +0 -1
  212. package/dist/lib/case-utils.d.ts.map +1 -1
  213. package/dist/lib/case-utils.js +0 -3
  214. package/dist/lib/case-utils.js.map +1 -1
  215. package/dist/lib/client-safe-error.d.ts +9 -0
  216. package/dist/lib/client-safe-error.d.ts.map +1 -0
  217. package/dist/lib/client-safe-error.js +23 -0
  218. package/dist/lib/client-safe-error.js.map +1 -0
  219. package/dist/lib/database-errors.d.ts +78 -0
  220. package/dist/lib/database-errors.d.ts.map +1 -0
  221. package/dist/lib/database-errors.js +148 -0
  222. package/dist/lib/database-errors.js.map +1 -0
  223. package/dist/lib/null-prototype-registry.d.ts +9 -0
  224. package/dist/lib/null-prototype-registry.d.ts.map +1 -0
  225. package/dist/lib/null-prototype-registry.js +11 -0
  226. package/dist/lib/null-prototype-registry.js.map +1 -0
  227. package/dist/lib/prisma-errors.d.ts +30 -32
  228. package/dist/lib/prisma-errors.d.ts.map +1 -1
  229. package/dist/lib/prisma-errors.js +86 -46
  230. package/dist/lib/prisma-errors.js.map +1 -1
  231. package/dist/lib/process-global.d.ts +23 -0
  232. package/dist/lib/process-global.d.ts.map +1 -0
  233. package/dist/lib/process-global.js +33 -0
  234. package/dist/lib/process-global.js.map +1 -0
  235. package/dist/lib/warn-once.d.ts +7 -0
  236. package/dist/lib/warn-once.d.ts.map +1 -0
  237. package/dist/lib/warn-once.js +13 -0
  238. package/dist/lib/warn-once.js.map +1 -0
  239. package/dist/mcp/advertise.d.ts +16 -0
  240. package/dist/mcp/advertise.d.ts.map +1 -0
  241. package/dist/mcp/advertise.js +25 -0
  242. package/dist/mcp/advertise.js.map +1 -0
  243. package/dist/mcp/arguments.d.ts +10 -0
  244. package/dist/mcp/arguments.d.ts.map +1 -0
  245. package/dist/mcp/arguments.js +143 -0
  246. package/dist/mcp/arguments.js.map +1 -0
  247. package/dist/mcp/field-schema.d.ts +50 -5
  248. package/dist/mcp/field-schema.d.ts.map +1 -1
  249. package/dist/mcp/field-schema.js +137 -14
  250. package/dist/mcp/field-schema.js.map +1 -1
  251. package/dist/mcp/handler.d.ts +16 -5
  252. package/dist/mcp/handler.d.ts.map +1 -1
  253. package/dist/mcp/handler.js +404 -126
  254. package/dist/mcp/handler.js.map +1 -1
  255. package/dist/mcp/index.d.ts +1 -0
  256. package/dist/mcp/index.d.ts.map +1 -1
  257. package/dist/mcp/index.js +1 -0
  258. package/dist/mcp/index.js.map +1 -1
  259. package/dist/mcp/projection.d.ts +42 -34
  260. package/dist/mcp/projection.d.ts.map +1 -1
  261. package/dist/mcp/projection.js +246 -200
  262. package/dist/mcp/projection.js.map +1 -1
  263. package/dist/mcp/tool-error.d.ts +8 -0
  264. package/dist/mcp/tool-error.d.ts.map +1 -0
  265. package/dist/mcp/tool-error.js +11 -0
  266. package/dist/mcp/tool-error.js.map +1 -0
  267. package/dist/mcp/types.d.ts +3 -2
  268. package/dist/mcp/types.d.ts.map +1 -1
  269. package/dist/mcp/where-id-boundary.d.ts +28 -0
  270. package/dist/mcp/where-id-boundary.d.ts.map +1 -0
  271. package/dist/mcp/where-id-boundary.js +187 -0
  272. package/dist/mcp/where-id-boundary.js.map +1 -0
  273. package/dist/origin.d.ts +147 -0
  274. package/dist/origin.d.ts.map +1 -0
  275. package/dist/origin.js +191 -0
  276. package/dist/origin.js.map +1 -0
  277. package/dist/query/relationship-options.d.ts +35 -6
  278. package/dist/query/relationship-options.d.ts.map +1 -1
  279. package/dist/query/relationship-options.js +33 -23
  280. package/dist/query/relationship-options.js.map +1 -1
  281. package/dist/secured/aggregate.d.ts +32 -0
  282. package/dist/secured/aggregate.d.ts.map +1 -0
  283. package/dist/secured/aggregate.js +31 -0
  284. package/dist/secured/aggregate.js.map +1 -0
  285. package/dist/secured/include.d.ts +320 -0
  286. package/dist/secured/include.d.ts.map +1 -0
  287. package/dist/secured/include.js +650 -0
  288. package/dist/secured/include.js.map +1 -0
  289. package/dist/secured/lock.d.ts +127 -0
  290. package/dist/secured/lock.d.ts.map +1 -0
  291. package/dist/secured/lock.js +275 -0
  292. package/dist/secured/lock.js.map +1 -0
  293. package/dist/secured/lower.d.ts +82 -0
  294. package/dist/secured/lower.d.ts.map +1 -0
  295. package/dist/secured/lower.js +162 -0
  296. package/dist/secured/lower.js.map +1 -0
  297. package/dist/secured/operators.d.ts +7 -0
  298. package/dist/secured/operators.d.ts.map +1 -0
  299. package/dist/secured/operators.js +18 -0
  300. package/dist/secured/operators.js.map +1 -0
  301. package/dist/secured/read.d.ts +208 -0
  302. package/dist/secured/read.d.ts.map +1 -0
  303. package/dist/secured/read.js +1245 -0
  304. package/dist/secured/read.js.map +1 -0
  305. package/dist/secured/select.d.ts +87 -0
  306. package/dist/secured/select.d.ts.map +1 -0
  307. package/dist/secured/select.js +250 -0
  308. package/dist/secured/select.js.map +1 -0
  309. package/dist/secured/vector.d.ts +58 -0
  310. package/dist/secured/vector.d.ts.map +1 -0
  311. package/dist/secured/vector.js +113 -0
  312. package/dist/secured/vector.js.map +1 -0
  313. package/dist/secured/vocabulary.d.ts +227 -0
  314. package/dist/secured/vocabulary.d.ts.map +1 -0
  315. package/dist/secured/vocabulary.js +578 -0
  316. package/dist/secured/vocabulary.js.map +1 -0
  317. package/dist/secured/write.d.ts +58 -0
  318. package/dist/secured/write.d.ts.map +1 -0
  319. package/dist/secured/write.js +87 -0
  320. package/dist/secured/write.js.map +1 -0
  321. package/dist/testing/context.d.ts +236 -0
  322. package/dist/testing/context.d.ts.map +1 -0
  323. package/dist/testing/context.js +457 -0
  324. package/dist/testing/context.js.map +1 -0
  325. package/dist/testing/escape.d.ts +83 -0
  326. package/dist/testing/escape.d.ts.map +1 -0
  327. package/dist/testing/escape.js +148 -0
  328. package/dist/testing/escape.js.map +1 -0
  329. package/dist/testing/extensions.d.ts +48 -0
  330. package/dist/testing/extensions.d.ts.map +1 -0
  331. package/dist/testing/extensions.js +107 -0
  332. package/dist/testing/extensions.js.map +1 -0
  333. package/dist/testing/index.d.ts +5 -0
  334. package/dist/testing/index.d.ts.map +1 -0
  335. package/dist/testing/index.js +11 -0
  336. package/dist/testing/index.js.map +1 -0
  337. package/dist/testing/plans.d.ts +64 -0
  338. package/dist/testing/plans.d.ts.map +1 -0
  339. package/dist/testing/plans.js +47 -0
  340. package/dist/testing/plans.js.map +1 -0
  341. package/dist/types/context.d.ts +110 -0
  342. package/dist/types/context.d.ts.map +1 -0
  343. package/dist/types/context.js +2 -0
  344. package/dist/types/context.js.map +1 -0
  345. package/dist/types/contract.d.ts +198 -0
  346. package/dist/types/contract.d.ts.map +1 -0
  347. package/dist/types/contract.js +2 -0
  348. package/dist/types/contract.js.map +1 -0
  349. package/dist/types/index.d.ts +6 -0
  350. package/dist/types/index.d.ts.map +1 -0
  351. package/dist/types/index.js +11 -0
  352. package/dist/types/index.js.map +1 -0
  353. package/dist/types/inputs.d.ts +83 -0
  354. package/dist/types/inputs.d.ts.map +1 -0
  355. package/dist/types/inputs.js +2 -0
  356. package/dist/types/inputs.js.map +1 -0
  357. package/dist/types/rows.d.ts +76 -0
  358. package/dist/types/rows.d.ts.map +1 -0
  359. package/dist/types/rows.js +2 -0
  360. package/dist/types/rows.js.map +1 -0
  361. package/dist/types/secured-list.d.ts +396 -0
  362. package/dist/types/secured-list.d.ts.map +1 -0
  363. package/dist/types/secured-list.js +2 -0
  364. package/dist/types/secured-list.js.map +1 -0
  365. package/dist/unsafe.d.ts +162 -0
  366. package/dist/unsafe.d.ts.map +1 -0
  367. package/dist/unsafe.js +177 -0
  368. package/dist/unsafe.js.map +1 -0
  369. package/dist/validation/config-refusal.d.ts +16 -0
  370. package/dist/validation/config-refusal.d.ts.map +1 -0
  371. package/dist/validation/config-refusal.js +2 -0
  372. package/dist/validation/config-refusal.js.map +1 -0
  373. package/dist/validation/database-config.d.ts +19 -0
  374. package/dist/validation/database-config.d.ts.map +1 -0
  375. package/dist/validation/database-config.js +237 -0
  376. package/dist/validation/database-config.js.map +1 -0
  377. package/dist/validation/default-value.d.ts +21 -0
  378. package/dist/validation/default-value.d.ts.map +1 -0
  379. package/dist/validation/default-value.js +72 -0
  380. package/dist/validation/default-value.js.map +1 -0
  381. package/dist/validation/extension-packs.d.ts +11 -0
  382. package/dist/validation/extension-packs.d.ts.map +1 -0
  383. package/dist/validation/extension-packs.js +53 -0
  384. package/dist/validation/extension-packs.js.map +1 -0
  385. package/dist/validation/field-config.d.ts +35 -21
  386. package/dist/validation/field-config.d.ts.map +1 -1
  387. package/dist/validation/field-config.js +51 -41
  388. package/dist/validation/field-config.js.map +1 -1
  389. package/dist/validation/field-names.d.ts +15 -0
  390. package/dist/validation/field-names.d.ts.map +1 -0
  391. package/dist/validation/field-names.js +155 -0
  392. package/dist/validation/field-names.js.map +1 -0
  393. package/dist/validation/identifier-names.d.ts +4 -0
  394. package/dist/validation/identifier-names.d.ts.map +1 -0
  395. package/dist/validation/identifier-names.js +39 -0
  396. package/dist/validation/identifier-names.js.map +1 -0
  397. package/dist/validation/needs-closure.d.ts +20 -30
  398. package/dist/validation/needs-closure.d.ts.map +1 -1
  399. package/dist/validation/needs-closure.js +29 -105
  400. package/dist/validation/needs-closure.js.map +1 -1
  401. package/dist/validation/relations.d.ts +17 -0
  402. package/dist/validation/relations.d.ts.map +1 -0
  403. package/dist/validation/relations.js +268 -0
  404. package/dist/validation/relations.js.map +1 -0
  405. package/dist/validation/schema.d.ts.map +1 -1
  406. package/dist/validation/schema.js +1 -3
  407. package/dist/validation/schema.js.map +1 -1
  408. package/dist/where/like.d.ts +32 -0
  409. package/dist/where/like.d.ts.map +1 -0
  410. package/dist/where/like.js +42 -0
  411. package/dist/where/like.js.map +1 -0
  412. package/package.json +70 -8
  413. package/.turbo/turbo-build.log +0 -4
  414. package/CLAUDE.md +0 -609
  415. package/dist/access/access-filter.d.ts +0 -241
  416. package/dist/access/access-filter.d.ts.map +0 -1
  417. package/dist/access/access-filter.js +0 -692
  418. package/dist/access/access-filter.js.map +0 -1
  419. package/dist/access/access-filter.test.d.ts +0 -2
  420. package/dist/access/access-filter.test.d.ts.map +0 -1
  421. package/dist/access/access-filter.test.js +0 -1256
  422. package/dist/access/access-filter.test.js.map +0 -1
  423. package/dist/access/declared-dependencies.test.d.ts +0 -2
  424. package/dist/access/declared-dependencies.test.d.ts.map +0 -1
  425. package/dist/access/declared-dependencies.test.js +0 -226
  426. package/dist/access/declared-dependencies.test.js.map +0 -1
  427. package/dist/access/denied-relation-visibility.test.d.ts +0 -2
  428. package/dist/access/denied-relation-visibility.test.d.ts.map +0 -1
  429. package/dist/access/denied-relation-visibility.test.js +0 -114
  430. package/dist/access/denied-relation-visibility.test.js.map +0 -1
  431. package/dist/access/engine.test.d.ts +0 -2
  432. package/dist/access/engine.test.d.ts.map +0 -1
  433. package/dist/access/engine.test.js +0 -56
  434. package/dist/access/engine.test.js.map +0 -1
  435. package/dist/access/field-access.test.d.ts +0 -2
  436. package/dist/access/field-access.test.d.ts.map +0 -1
  437. package/dist/access/field-access.test.js +0 -635
  438. package/dist/access/field-access.test.js.map +0 -1
  439. package/dist/access/multi-column-read-write.test.d.ts +0 -2
  440. package/dist/access/multi-column-read-write.test.d.ts.map +0 -1
  441. package/dist/access/multi-column-read-write.test.js +0 -183
  442. package/dist/access/multi-column-read-write.test.js.map +0 -1
  443. package/dist/access/relationship-count.d.ts +0 -98
  444. package/dist/access/relationship-count.d.ts.map +0 -1
  445. package/dist/access/relationship-count.js +0 -262
  446. package/dist/access/relationship-count.js.map +0 -1
  447. package/dist/access/relationship-count.test.d.ts +0 -2
  448. package/dist/access/relationship-count.test.d.ts.map +0 -1
  449. package/dist/access/relationship-count.test.js +0 -247
  450. package/dist/access/relationship-count.test.js.map +0 -1
  451. package/dist/access/relationship-label-filter.d.ts +0 -45
  452. package/dist/access/relationship-label-filter.d.ts.map +0 -1
  453. package/dist/access/relationship-label-filter.js +0 -22
  454. package/dist/access/relationship-label-filter.js.map +0 -1
  455. package/dist/access/relationship-label-filter.test.d.ts +0 -2
  456. package/dist/access/relationship-label-filter.test.d.ts.map +0 -1
  457. package/dist/access/relationship-label-filter.test.js +0 -89
  458. package/dist/access/relationship-label-filter.test.js.map +0 -1
  459. package/dist/access/synthetic-include-read.test.d.ts +0 -2
  460. package/dist/access/synthetic-include-read.test.d.ts.map +0 -1
  461. package/dist/access/synthetic-include-read.test.js +0 -121
  462. package/dist/access/synthetic-include-read.test.js.map +0 -1
  463. package/dist/context/nested-operations.d.ts +0 -74
  464. package/dist/context/nested-operations.d.ts.map +0 -1
  465. package/dist/context/nested-operations.js +0 -847
  466. package/dist/context/nested-operations.js.map +0 -1
  467. package/dist/fields/calendar-day.test.d.ts +0 -2
  468. package/dist/fields/calendar-day.test.d.ts.map +0 -1
  469. package/dist/fields/calendar-day.test.js +0 -246
  470. package/dist/fields/calendar-day.test.js.map +0 -1
  471. package/dist/fields/format-prisma-default.d.ts +0 -35
  472. package/dist/fields/format-prisma-default.d.ts.map +0 -1
  473. package/dist/fields/format-prisma-default.js +0 -49
  474. package/dist/fields/format-prisma-default.js.map +0 -1
  475. package/dist/fields/format-prisma-default.test.d.ts +0 -2
  476. package/dist/fields/format-prisma-default.test.d.ts.map +0 -1
  477. package/dist/fields/format-prisma-default.test.js +0 -54
  478. package/dist/fields/format-prisma-default.test.js.map +0 -1
  479. package/dist/fields/relationship-foreign-key.test.d.ts +0 -2
  480. package/dist/fields/relationship-foreign-key.test.d.ts.map +0 -1
  481. package/dist/fields/relationship-foreign-key.test.js +0 -18
  482. package/dist/fields/relationship-foreign-key.test.js.map +0 -1
  483. package/dist/fields/select.test.d.ts +0 -2
  484. package/dist/fields/select.test.d.ts.map +0 -1
  485. package/dist/fields/select.test.js +0 -279
  486. package/dist/fields/select.test.js.map +0 -1
  487. package/dist/fields/text-keystone-compat.test.d.ts +0 -2
  488. package/dist/fields/text-keystone-compat.test.d.ts.map +0 -1
  489. package/dist/fields/text-keystone-compat.test.js +0 -93
  490. package/dist/fields/text-keystone-compat.test.js.map +0 -1
  491. package/dist/filter/filter.test.d.ts +0 -2
  492. package/dist/filter/filter.test.d.ts.map +0 -1
  493. package/dist/filter/filter.test.js +0 -431
  494. package/dist/filter/filter.test.js.map +0 -1
  495. package/dist/filter/serialize.test.d.ts +0 -2
  496. package/dist/filter/serialize.test.d.ts.map +0 -1
  497. package/dist/filter/serialize.test.js +0 -83
  498. package/dist/filter/serialize.test.js.map +0 -1
  499. package/dist/index.test.d.ts +0 -2
  500. package/dist/index.test.d.ts.map +0 -1
  501. package/dist/index.test.js +0 -33
  502. package/dist/index.test.js.map +0 -1
  503. package/dist/lib/case-utils.test.d.ts +0 -2
  504. package/dist/lib/case-utils.test.d.ts.map +0 -1
  505. package/dist/lib/case-utils.test.js +0 -123
  506. package/dist/lib/case-utils.test.js.map +0 -1
  507. package/dist/query/index.d.ts +0 -127
  508. package/dist/query/index.d.ts.map +0 -1
  509. package/dist/query/index.js +0 -179
  510. package/dist/query/index.js.map +0 -1
  511. package/dist/query/index.test.d.ts +0 -2
  512. package/dist/query/index.test.d.ts.map +0 -1
  513. package/dist/query/index.test.js +0 -632
  514. package/dist/query/index.test.js.map +0 -1
  515. package/dist/query/relationship-options.test.d.ts +0 -2
  516. package/dist/query/relationship-options.test.d.ts.map +0 -1
  517. package/dist/query/relationship-options.test.js +0 -150
  518. package/dist/query/relationship-options.test.js.map +0 -1
  519. package/dist/validation/field-config.test.d.ts +0 -2
  520. package/dist/validation/field-config.test.d.ts.map +0 -1
  521. package/dist/validation/field-config.test.js +0 -159
  522. package/dist/validation/field-config.test.js.map +0 -1
  523. package/dist/validation/schema.test.d.ts +0 -2
  524. package/dist/validation/schema.test.d.ts.map +0 -1
  525. package/dist/validation/schema.test.js +0 -409
  526. package/dist/validation/schema.test.js.map +0 -1
  527. package/docs/type-distribution-fix.md +0 -136
  528. package/src/access/access-filter.test.ts +0 -1919
  529. package/src/access/access-filter.ts +0 -1041
  530. package/src/access/declared-dependencies.test.ts +0 -277
  531. package/src/access/declared-dependencies.ts +0 -220
  532. package/src/access/denied-relation-visibility.test.ts +0 -173
  533. package/src/access/depth-limits.ts +0 -27
  534. package/src/access/engine.test.ts +0 -67
  535. package/src/access/engine.ts +0 -193
  536. package/src/access/errors.ts +0 -242
  537. package/src/access/field-access.test.ts +0 -792
  538. package/src/access/field-access.ts +0 -353
  539. package/src/access/field-transforms.ts +0 -68
  540. package/src/access/field-visibility.ts +0 -569
  541. package/src/access/index.ts +0 -82
  542. package/src/access/multi-column-read-write.test.ts +0 -305
  543. package/src/access/query-validation.ts +0 -486
  544. package/src/access/relationship-count.test.ts +0 -344
  545. package/src/access/relationship-count.ts +0 -346
  546. package/src/access/relationship-label-filter.test.ts +0 -128
  547. package/src/access/relationship-label-filter.ts +0 -63
  548. package/src/access/synthetic-include-read.test.ts +0 -179
  549. package/src/access/transaction-registry.ts +0 -58
  550. package/src/access/types.ts +0 -391
  551. package/src/config/index.ts +0 -177
  552. package/src/config/label.ts +0 -51
  553. package/src/config/nav-count.ts +0 -77
  554. package/src/config/plugin-engine.ts +0 -261
  555. package/src/config/types.ts +0 -3270
  556. package/src/context/apply-defaults.ts +0 -47
  557. package/src/context/hook-pipeline.ts +0 -137
  558. package/src/context/index.ts +0 -1737
  559. package/src/context/nested-operations.ts +0 -1470
  560. package/src/context/transaction-boundary.ts +0 -485
  561. package/src/context/write-pipeline.ts +0 -732
  562. package/src/extend.ts +0 -28
  563. package/src/fields/calendar-day.test.ts +0 -291
  564. package/src/fields/format-prisma-default.test.ts +0 -64
  565. package/src/fields/format-prisma-default.ts +0 -64
  566. package/src/fields/index.ts +0 -1901
  567. package/src/fields/relationship-foreign-key.test.ts +0 -29
  568. package/src/fields/select.test.ts +0 -336
  569. package/src/fields/text-keystone-compat.test.ts +0 -126
  570. package/src/filter/collect.ts +0 -108
  571. package/src/filter/filter.test.ts +0 -538
  572. package/src/filter/index.ts +0 -26
  573. package/src/filter/map.ts +0 -63
  574. package/src/filter/parse.ts +0 -99
  575. package/src/filter/serialize.test.ts +0 -115
  576. package/src/filter/serialize.ts +0 -73
  577. package/src/filter/types.ts +0 -120
  578. package/src/hooks/index.ts +0 -752
  579. package/src/index.test.ts +0 -50
  580. package/src/index.ts +0 -192
  581. package/src/internal.ts +0 -61
  582. package/src/lib/case-utils.test.ts +0 -159
  583. package/src/lib/case-utils.ts +0 -68
  584. package/src/lib/prisma-errors.ts +0 -86
  585. package/src/mcp/constants.ts +0 -24
  586. package/src/mcp/field-schema.ts +0 -84
  587. package/src/mcp/handler.ts +0 -633
  588. package/src/mcp/index.ts +0 -7
  589. package/src/mcp/projection.ts +0 -497
  590. package/src/mcp/types.ts +0 -18
  591. package/src/query/index.test.ts +0 -830
  592. package/src/query/index.ts +0 -352
  593. package/src/query/relationship-options.test.ts +0 -194
  594. package/src/query/relationship-options.ts +0 -78
  595. package/src/utils/password.ts +0 -80
  596. package/src/validation/field-config.test.ts +0 -199
  597. package/src/validation/field-config.ts +0 -139
  598. package/src/validation/needs-closure.ts +0 -188
  599. package/src/validation/schema.test.ts +0 -487
  600. package/src/validation/schema.ts +0 -51
  601. package/tests/access-relationships.test.ts +0 -646
  602. package/tests/access.test.ts +0 -590
  603. package/tests/apply-defaults.test.ts +0 -119
  604. package/tests/bare-read-scalars.test.ts +0 -147
  605. package/tests/computed-field-selective-evaluation.test.ts +0 -418
  606. package/tests/config.test.ts +0 -242
  607. package/tests/context.test.ts +0 -3146
  608. package/tests/default-value-create.test.ts +0 -299
  609. package/tests/field-hooks.test.ts +0 -410
  610. package/tests/field-types.test.ts +0 -1291
  611. package/tests/hook-context-secured.test.ts +0 -424
  612. package/tests/hook-pipeline.test.ts +0 -233
  613. package/tests/hooks.test.ts +0 -481
  614. package/tests/interactive-transaction.test.ts +0 -444
  615. package/tests/label.test.ts +0 -135
  616. package/tests/mcp-fields-projection-access.test.ts +0 -250
  617. package/tests/mcp-handler.test.ts +0 -1411
  618. package/tests/multi-column-validation-ordering.test.ts +0 -305
  619. package/tests/nav-count.test.ts +0 -189
  620. package/tests/needs-declared-dependencies.test.ts +0 -503
  621. package/tests/nested-access-and-hooks.test.ts +0 -2566
  622. package/tests/nested-operation-registry.test.ts +0 -317
  623. package/tests/nested-write-hooks.test.ts +0 -864
  624. package/tests/nested-write-synthetic-relation.test.ts +0 -437
  625. package/tests/password-type-distribution.test.ts +0 -154
  626. package/tests/password-types.test.ts +0 -174
  627. package/tests/password.test.ts +0 -263
  628. package/tests/plugin-engine.test.ts +0 -1155
  629. package/tests/prisma-errors.test.ts +0 -141
  630. package/tests/resolve-chain.test.ts +0 -411
  631. package/tests/singleton.test.ts +0 -421
  632. package/tests/sudo.test.ts +0 -676
  633. package/tests/to-one-include-access-filter.test.ts +0 -172
  634. package/tests/transaction-boundary-hooks.test.ts +0 -710
  635. package/tests/transaction-boundary-outermost.test.ts +0 -530
  636. package/tests/virtual-fields.test.ts +0 -421
  637. package/tests/with-session.test.ts +0 -243
  638. package/tests/write-pipeline.test.ts +0 -617
  639. package/tsconfig.json +0 -12
  640. package/tsconfig.tsbuildinfo +0 -1
  641. package/vitest.config.ts +0 -69
@@ -1,391 +0,0 @@
1
- import type { Fragment, FieldSelection, ResultOf } from '../query/index.js'
2
- import type { TransactionRegistry } from './transaction-registry.js'
3
-
4
- /**
5
- * Session interface - can be augmented by developers to add custom fields
6
- *
7
- * By default, Session is a permissive object that can contain any properties.
8
- * To get type safety and autocomplete, use module augmentation:
9
- *
10
- * @example
11
- * ```typescript
12
- * // types/session.d.ts
13
- * import '@opensaas/stack-core'
14
- *
15
- * declare module '@opensaas/stack-core' {
16
- * interface Session {
17
- * userId: string
18
- * email: string
19
- * role: 'admin' | 'user'
20
- * }
21
- * }
22
- * ```
23
- *
24
- * After augmentation, session will be fully typed everywhere:
25
- * - Access control functions
26
- * - Hooks (resolveInput, validateInput, etc.)
27
- * - Context object
28
- *
29
- * @example
30
- * ```typescript
31
- * // With augmentation, this is fully typed:
32
- * const isAdmin: AccessControl = ({ session }) => {
33
- * return session?.role === 'admin' // ✅ Autocomplete works
34
- * }
35
- * ```
36
- */
37
- export interface Session {
38
- [key: string]: unknown
39
- }
40
-
41
- export type PrismaModelDelegate = {
42
- findUnique: (args: unknown) => Promise<unknown>
43
- findFirst: (args: unknown) => Promise<unknown>
44
- findMany: (args: unknown) => Promise<unknown[]>
45
- create: (args: unknown) => Promise<unknown>
46
- update: (args: unknown) => Promise<unknown>
47
- delete: (args: unknown) => Promise<unknown>
48
- count: (args?: unknown) => Promise<number>
49
- }
50
-
51
- // Uses `any` because Prisma generates highly complex client types that are difficult
52
- // to constrain here; actual type safety comes from the TPrisma generic parameter.
53
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
54
- export type PrismaClientLike = any
55
-
56
- // ─────────────────────────────────────────────────────────────
57
- // Augmented find operation types — add `query` overload to findMany / findUnique
58
- // ─────────────────────────────────────────────────────────────
59
-
60
- /**
61
- * Extra query arguments accepted when a `query` Fragment is provided alongside
62
- * `context.db.<list>.findMany({ query: myFragment, ... })`.
63
- */
64
- export type FindManyQueryArgs = {
65
- where?: Record<string, unknown>
66
- orderBy?: Record<string, 'asc' | 'desc'> | Array<Record<string, 'asc' | 'desc'>>
67
- take?: number
68
- skip?: number
69
- }
70
-
71
- /**
72
- * Overloaded `findMany` that accepts an optional `query` Fragment.
73
- *
74
- * - **With `query`**: builds the Prisma `include` from the fragment, executes the
75
- * query, applies access control, and returns records shaped to `ResultOf<fragment>[]`.
76
- * - **Without `query`**: behaves exactly like the original Prisma `findMany`.
77
- *
78
- * TypeScript resolves the return type from the presence (or absence) of `query`
79
- * in the argument object — no explicit type annotation is needed.
80
- *
81
- * @example
82
- * ```ts
83
- * // Narrowed return type from fragment
84
- * const posts = await context.db.post.findMany({
85
- * query: postFragment,
86
- * where: { published: true },
87
- * orderBy: { createdAt: 'desc' },
88
- * take: 10,
89
- * })
90
- * // posts: ResultOf<typeof postFragment>[]
91
- *
92
- * // Original Prisma behaviour (no fragment)
93
- * const posts = await context.db.post.findMany({ where: { published: true } })
94
- * // posts: Post[]
95
- * ```
96
- */
97
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
98
- export interface AugmentedFindMany<TOriginal extends (...args: any[]) => any> {
99
- <TItem, TFields extends FieldSelection<TItem>>(
100
- args: FindManyQueryArgs & { query: Fragment<TItem, TFields> },
101
- ): Promise<ResultOf<Fragment<TItem, TFields>>[]>
102
- (...args: Parameters<TOriginal>): ReturnType<TOriginal>
103
- // Trailing, non-generic member mirroring the generated `{List}Crud['findMany']`'s
104
- // own third member (#1287) — see that member's doc comment in
105
- // `packages/cli/src/generator/types.ts` (`generateListCrudInterface`) for why it
106
- // exists (closing assignability to a plain structural seam, and giving
107
- // `Parameters<>` something concrete to resolve to) and why it must stay last
108
- // and omit `select`/`include`/`query`. Without this, `AccessControlledDB` and
109
- // the generated `CustomDB` carry different overload arities (#1328).
110
- (args?: Omit<Parameters<TOriginal>[0], 'select' | 'include' | 'query'>): ReturnType<TOriginal>
111
- }
112
-
113
- /**
114
- * Extra query arguments accepted when a `query` Fragment is provided alongside
115
- * `context.db.<list>.findFirst({ query: myFragment, ... })`.
116
- */
117
- export type FindFirstQueryArgs = {
118
- where?: Record<string, unknown>
119
- orderBy?: Record<string, 'asc' | 'desc'> | Array<Record<string, 'asc' | 'desc'>>
120
- skip?: number
121
- }
122
-
123
- /**
124
- * Overloaded `findFirst` that accepts an optional `query` Fragment.
125
- *
126
- * `findFirst` is sugar over the access-controlled `findMany` (`take: 1`), so it
127
- * applies the exact same query-access checks and access-controlled include
128
- * building, then returns the first matching record or `null`.
129
- *
130
- * - **With `query`**: builds the Prisma `include` from the fragment, executes the
131
- * query, applies access control, and returns a record shaped to `ResultOf<fragment>`
132
- * or `null`.
133
- * - **Without `query`**: behaves exactly like the original Prisma `findFirst`.
134
- *
135
- * @example
136
- * ```ts
137
- * const post = await context.db.post.findFirst({
138
- * where: { published: true },
139
- * orderBy: { createdAt: 'desc' },
140
- * query: postFragment,
141
- * })
142
- * // post: ResultOf<typeof postFragment> | null
143
- * ```
144
- */
145
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
146
- export interface AugmentedFindFirst<TOriginal extends (...args: any[]) => any> {
147
- <TItem, TFields extends FieldSelection<TItem>>(
148
- args: FindFirstQueryArgs & { query: Fragment<TItem, TFields> },
149
- ): Promise<ResultOf<Fragment<TItem, TFields>> | null>
150
- (...args: Parameters<TOriginal>): ReturnType<TOriginal>
151
- // Trailing, non-generic member — see the identical comment on
152
- // `AugmentedFindMany` above (#1287, #1328).
153
- (args?: Omit<Parameters<TOriginal>[0], 'select' | 'include' | 'query'>): ReturnType<TOriginal>
154
- }
155
-
156
- /**
157
- * Overloaded `findUnique` that accepts an optional `query` Fragment.
158
- *
159
- * - **With `query`**: builds the Prisma `include` from the fragment, executes the
160
- * query, applies access control, and returns a record shaped to `ResultOf<fragment>`
161
- * or `null`.
162
- * - **Without `query`**: behaves exactly like the original Prisma `findUnique`.
163
- *
164
- * @example
165
- * ```ts
166
- * const post = await context.db.post.findUnique({
167
- * where: { id: postId },
168
- * query: postFragment,
169
- * })
170
- * // post: ResultOf<typeof postFragment> | null
171
- * ```
172
- */
173
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
174
- export interface AugmentedFindUnique<TOriginal extends (...args: any[]) => any> {
175
- <TItem, TFields extends FieldSelection<TItem>>(args: {
176
- where: Record<string, unknown>
177
- query: Fragment<TItem, TFields>
178
- }): Promise<ResultOf<Fragment<TItem, TFields>> | null>
179
- (...args: Parameters<TOriginal>): ReturnType<TOriginal>
180
- // Trailing, non-generic member — see the identical comment on
181
- // `AugmentedFindMany` above (#1287, #1328). `findUnique`'s `where` is
182
- // required (not optional), so this member keeps it required via `Pick`
183
- // rather than `Omit` + optional `args`.
184
- (args: Pick<Parameters<TOriginal>[0], 'where'>): ReturnType<TOriginal>
185
- }
186
-
187
- export type AccessControlledDB<TPrisma extends PrismaClientLike> = {
188
- [K in keyof TPrisma]: TPrisma[K] extends {
189
- // Uses `any` here to check the property exists with any signature, a standard
190
- // TypeScript pattern for verifying Prisma model shape in a conditional type.
191
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
192
- findUnique: any
193
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
194
- findFirst: any
195
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
196
- findMany: any
197
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
198
- create: any
199
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
200
- update: any
201
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
202
- delete: any
203
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
204
- count: any
205
- }
206
- ? {
207
- findUnique: AugmentedFindUnique<TPrisma[K]['findUnique']>
208
- findFirst: AugmentedFindFirst<TPrisma[K]['findFirst']>
209
- findMany: AugmentedFindMany<TPrisma[K]['findMany']>
210
- create: TPrisma[K]['create']
211
- update: TPrisma[K]['update']
212
- delete: TPrisma[K]['delete']
213
- count: TPrisma[K]['count']
214
- // Batch operations - run individual operations in a loop to ensure hooks and access control
215
- createMany: Parameters<TPrisma[K]['create']>[0] extends { data: infer TData }
216
- ? (args: { data: TData[] }) => Promise<Awaited<ReturnType<TPrisma[K]['create']>>[]>
217
- : never
218
- updateMany: Parameters<TPrisma[K]['update']>[0] extends { data: infer TData }
219
- ? Parameters<TPrisma[K]['findMany']>[0] extends { where?: infer TWhere }
220
- ? (args: {
221
- where?: TWhere
222
- data: TData
223
- }) => Promise<Awaited<ReturnType<TPrisma[K]['update']>>[]>
224
- : never
225
- : never
226
- }
227
- : never
228
- } & {
229
- // Add index signature for runtime string access (e.g., db[getDbKey(listName)])
230
- // Uses `any` because models can have any shape from Prisma schema
231
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
232
- [key: string]: any
233
- }
234
-
235
- export type StorageUtils = {
236
- uploadFile: (
237
- providerName: string,
238
- file: File,
239
- buffer: Buffer,
240
- options?: unknown,
241
- ) => Promise<unknown>
242
-
243
- uploadImage: (
244
- providerName: string,
245
- file: File,
246
- buffer: Buffer,
247
- options?: unknown,
248
- ) => Promise<unknown>
249
-
250
- deleteFile: (providerName: string, filename: string) => Promise<void>
251
-
252
- deleteImage: (metadata: unknown) => Promise<void>
253
- }
254
-
255
- // Uses `interface` rather than `type` so consumers can extend it via module augmentation.
256
- export interface AccessContext<
257
- TPrisma extends PrismaClientLike = PrismaClientLike,
258
- // See the identical `TDb` doc on `StackContext` (context/index.ts) — #1232.
259
- TDb = AccessControlledDB<TPrisma>,
260
- > {
261
- session: Session | null
262
- prisma: TPrisma
263
- db: TDb
264
- storage: StorageUtils
265
- plugins: Record<string, unknown>
266
- _isSudo: boolean
267
- /**
268
- * The resolve chain: the ordered sequence of `resolveOutput` hook
269
- * `(listKey, fieldKey)` pairs a read has entered on the way to here. A
270
- * top-level read starts with an empty chain. Each hook invocation is given
271
- * a NEW context whose chain extends this one by its own pair — the chain is
272
- * never mutated in place, so concurrent hook invocations (e.g. sibling rows
273
- * in a to-many relation processed via `Promise.all`) never observe each
274
- * other's chain. A hook that would re-enter a pair already on its own chain
275
- * is refused (`ResolveOutputCycleError`) rather than left to recurse
276
- * forever; a chain longer than `RESOLVE_CHAIN_MAX_LENGTH` is a separate,
277
- * non-fatal cost limit. See ADR-0023 and the "Resolve chain" glossary entry
278
- * in CONTEXT.md.
279
- */
280
- _resolveOutputChain: readonly { listKey: string; fieldKey: string }[]
281
- /**
282
- * Present when this context is JOINED into an enclosing transaction it did
283
- * not open (ADR-0028, #899) — set by `context.transaction()`, or by the
284
- * Write Pipeline when it opens the transaction the current write's hooks
285
- * are rebound into. A write reached through a context carrying this defers
286
- * its `afterTransaction` bracket to the registry instead of firing it at
287
- * write time; `undefined` for a top-level context with no owner. Threaded
288
- * through the same context-rebind path as `plugins`/`_resolveOutputChain`.
289
- * @internal
290
- */
291
- _transactionOwner?: TransactionRegistry
292
- }
293
-
294
- export type PrismaFilter<T = Record<string, unknown>> = Partial<Record<keyof T, unknown>>
295
-
296
- /**
297
- * Can return:
298
- * - boolean: true = allow, false = deny
299
- * - PrismaFilter: Prisma where clause to filter results
300
- */
301
- export type AccessControl<T = Record<string, unknown>> = (args: {
302
- session: Session | null
303
- item?: T // Present for update/delete operations
304
- context: AccessContext
305
- }) => boolean | PrismaFilter<T> | Promise<boolean | PrismaFilter<T>>
306
-
307
- /**
308
- * The per-operation argument shapes a `FieldAccessControl` function is called
309
- * with — the discriminated union `FieldAccessControl` wraps, and the source
310
- * of truth `FieldAccess`'s individual `read`/`create`/`update` members are
311
- * picked from (via `Extract`) below. Keeping this as its own named type is
312
- * what lets both sides reference the exact same three call shapes instead of
313
- * two independently-maintained descriptions drifting apart.
314
- */
315
- type FieldAccessControlArgs<TItem, TCreateInput, TUpdateInput> =
316
- | {
317
- session: Session | null
318
- // Field Visibility (phase 2 of the two-phase read) always evaluates
319
- // `read` rules against an already-fetched row — see
320
- // `resolveReadableFieldValue` in `field-visibility.ts`, the sole
321
- // caller of `checkFieldAccess` for this operation. Unlike `create`
322
- // (where no row exists yet), there is no case where `item` is absent
323
- // here, so it is required rather than optional.
324
- item: TItem
325
- context: AccessContext
326
- inputData?: undefined
327
- operation: 'read'
328
- }
329
- | {
330
- session: Session | null
331
- item?: undefined
332
- context: AccessContext
333
- inputData: TCreateInput
334
- operation: 'create'
335
- }
336
- | {
337
- session: Session | null
338
- item: TItem
339
- context: AccessContext
340
- inputData: TUpdateInput
341
- operation: 'update'
342
- }
343
-
344
- /**
345
- * For create/update operations, receives inputData to validate incoming values.
346
- *
347
- * Unlike operation-level `AccessControl`, this returns `boolean` only. Field
348
- * access is a per-field visibility decision, not a row filter — a denied
349
- * field is removed, never used to scope which rows are returned (see the
350
- * "Field-level access" glossary entry in `CONTEXT.md`, ADR-0001, and
351
- * ADR-0030). A rule that needs to depend on the row or the write payload
352
- * should evaluate the condition itself and return a boolean, e.g.
353
- * `({ item, session }) => item?.ownerId === session?.userId`. The runtime
354
- * evaluator (`checkFieldAccess`) enforces this: a rule that somehow returns
355
- * anything other than `true`/`false` (bypassing this type) throws rather than
356
- * defaulting to allow.
357
- *
358
- * This is the general, all-operations union — useful for a single function
359
- * reused across more than one of `FieldAccess`'s `read`/`create`/`update`
360
- * slots, narrowing on `operation` to tell the call shapes apart. A function
361
- * written for exactly one slot doesn't need to: `FieldAccess` picks each
362
- * slot's own single-operation shape out of this union (see below), so e.g. a
363
- * `read`-only rule sees `item` as always present with no narrowing required.
364
- */
365
- export type FieldAccessControl<
366
- TItem = Record<string, unknown>,
367
- TCreateInput = Record<string, unknown>,
368
- TUpdateInput = Record<string, unknown>,
369
- > = (args: FieldAccessControlArgs<TItem, TCreateInput, TUpdateInput>) => boolean | Promise<boolean>
370
-
371
- /**
372
- * `read` is typed from the single `operation: 'read'` member of
373
- * `FieldAccessControlArgs`, not the full `FieldAccessControl` union — so a
374
- * rule written directly for this slot sees `item` as always present (never
375
- * `TItem | undefined`) with no narrowing, cast, or `any` needed. A function
376
- * typed as the broader `FieldAccessControl` union remains assignable here
377
- * (and to `create`/`update`) — accepting more call shapes than the slot
378
- * requires is a valid substitute, same as anywhere else function parameters
379
- * are contravariant.
380
- */
381
- export type FieldAccess<
382
- TItem = Record<string, unknown>,
383
- TCreateInput = Record<string, unknown>,
384
- TUpdateInput = Record<string, unknown>,
385
- > = {
386
- read?: (
387
- args: Extract<FieldAccessControlArgs<TItem, TCreateInput, TUpdateInput>, { operation: 'read' }>,
388
- ) => boolean | Promise<boolean>
389
- create?: FieldAccessControl<TItem, TCreateInput, TUpdateInput>
390
- update?: FieldAccessControl<TItem, TCreateInput, TUpdateInput>
391
- }
@@ -1,177 +0,0 @@
1
- import type {
2
- OpenSaasConfig,
3
- ListConfig,
4
- ListConfigInput,
5
- OperationAccess,
6
- ListAccessControl,
7
- } from './types.js'
8
- import { executePlugins } from './plugin-engine.js'
9
- import type { AccessControl } from '../access/types.js'
10
-
11
- function normalizeListAccess<T>(
12
- access: ListAccessControl<T> | undefined,
13
- ): { operation?: OperationAccess<T> } | undefined {
14
- if (!access) return undefined
15
-
16
- if (typeof access === 'function') {
17
- const fn = access as AccessControl<T>
18
- return {
19
- operation: {
20
- query: fn,
21
- create: fn,
22
- update: fn,
23
- delete: fn,
24
- },
25
- }
26
- }
27
-
28
- return access
29
- }
30
-
31
- /**
32
- * Define an OpenSaas config, executing `plugins` if present.
33
- *
34
- * Returns synchronously when there are no plugins (backward compatible);
35
- * returns a `Promise` when plugins are present, since plugin execution is
36
- * async.
37
- */
38
- export function config(userConfig: OpenSaasConfig): OpenSaasConfig | Promise<OpenSaasConfig> {
39
- if (!userConfig.plugins || userConfig.plugins.length === 0) {
40
- return userConfig
41
- }
42
-
43
- return executePlugins(userConfig)
44
- }
45
-
46
- /**
47
- * Define a list with type safety.
48
- *
49
- * `ListConfigInput<TTypeInfo>` accepts raw field configs; the return type
50
- * `ListConfig<TTypeInfo>` injects `TTypeInfo` so hook/field callbacks (e.g.
51
- * `resolveInput`'s `item`) are properly typed once `TTypeInfo` is supplied
52
- * from generated types.
53
- *
54
- * @example
55
- * ```typescript
56
- * // Basic usage (before generation)
57
- * Post: list({
58
- * fields: { title: text() },
59
- * hooks: {
60
- * resolveInput: async ({ resolvedData }) => {
61
- * // resolvedData: Record<string, unknown>
62
- * return resolvedData
63
- * }
64
- * }
65
- * })
66
- *
67
- * // With TypeInfo (after generation)
68
- * import type { Lists } from './.opensaas/lists'
69
- *
70
- * Post: list<Lists.Post.TypeInfo>({
71
- * fields: { title: text() },
72
- * hooks: {
73
- * resolveInput: async ({ operation, resolvedData, item }) => {
74
- * if (operation === 'create') {
75
- * // resolvedData: Prisma.PostCreateInput
76
- * // item: undefined
77
- * } else {
78
- * // resolvedData: Prisma.PostUpdateInput
79
- * // item: Post
80
- * }
81
- * return resolvedData
82
- * }
83
- * }
84
- * })
85
- *
86
- * // Or as a typed constant
87
- * const Post: Lists.Post = list({
88
- * fields: { title: text() },
89
- * hooks: { ... }
90
- * })
91
- *
92
- * // Access control shorthand
93
- * const isAdmin = ({ session }) => session?.role === 'admin'
94
- *
95
- * Settings: list({
96
- * access: isAdmin, // Applies to all operations
97
- * isSingleton: true,
98
- * fields: { ... }
99
- * })
100
- * ```
101
- */
102
- export function list<TTypeInfo extends import('./types.js').TypeInfo>(
103
- config: ListConfigInput<TTypeInfo>,
104
- ): ListConfig<TTypeInfo> {
105
- const normalizedConfig = {
106
- ...config,
107
- access: normalizeListAccess(config.access),
108
- }
109
-
110
- // Runtime shape is unchanged; the cast only narrows the TS type to inject TTypeInfo.
111
- return normalizedConfig as ListConfig<TTypeInfo>
112
- }
113
-
114
- export type {
115
- OpenSaasConfig,
116
- OutputConfig,
117
- ListConfig,
118
- ListConfigInput,
119
- ListAccessControl,
120
- FieldConfig,
121
- BaseFieldConfig,
122
- TextField,
123
- IntegerField,
124
- CheckboxField,
125
- TimestampField,
126
- PasswordField,
127
- SelectField,
128
- RelationshipField,
129
- PrismaRelationResult,
130
- MultiColumnPrismaResult,
131
- JsonField,
132
- VirtualField,
133
- TypeDescriptor,
134
- TypeInfo,
135
- OperationAccess,
136
- Hooks,
137
- FieldHooks,
138
- FieldsWithTypeInfo,
139
- DatabaseConfig,
140
- ListIndex,
141
- ListIndexFieldRef,
142
- SessionConfig,
143
- UIConfig,
144
- ListUIConfig,
145
- ListViewUIConfig,
146
- BulkAction,
147
- BulkActionContext,
148
- BulkActionResult,
149
- BulkActionVariant,
150
- ItemViewUIConfig,
151
- RelationshipItemViewConfig,
152
- ThemeConfig,
153
- ThemePreset,
154
- ThemeColors,
155
- ThemeFonts,
156
- ThemeShadows,
157
- McpConfig,
158
- McpToolsConfig,
159
- McpAuthConfig,
160
- ListMcpConfig,
161
- McpCustomTool,
162
- FileMetadata,
163
- ImageMetadata,
164
- ImageTransformationResult,
165
- Plugin,
166
- PluginContext,
167
- GeneratedFiles,
168
- ResolveInputHookArgs,
169
- ValidateHookArgs,
170
- BeforeOperationHookArgs,
171
- AfterOperationHookArgs,
172
- FieldResolveInputHookArgs,
173
- FieldValidateHookArgs,
174
- FieldBeforeOperationHookArgs,
175
- FieldAfterOperationHookArgs,
176
- FieldResolveOutputHookArgs,
177
- } from './types.js'
@@ -1,51 +0,0 @@
1
- import type { ListConfig } from './types.js'
2
-
3
- /**
4
- * Resolve the field name used as a list's Label field: `ui.labelField` if
5
- * set, else `name`, else `title`, else `id`.
6
- *
7
- * @throws if `ui.labelField` names a field not declared on the list, or a
8
- * relationship field (the Label field must be a scalar).
9
- */
10
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- ListConfig must accept any TypeInfo
11
- export function getLabelFieldName(listConfig: ListConfig<any>): string {
12
- const configured = listConfig.ui?.labelField
13
-
14
- if (configured !== undefined) {
15
- const field = listConfig.fields[configured]
16
- if (!field) {
17
- throw new Error(
18
- `ui.labelField "${configured}" does not reference a field declared on this list.`,
19
- )
20
- }
21
- if (field.type === 'relationship') {
22
- throw new Error(
23
- `ui.labelField "${configured}" must reference a scalar field, not a relationship.`,
24
- )
25
- }
26
- return configured
27
- }
28
-
29
- if ('name' in listConfig.fields) return 'name'
30
- if ('title' in listConfig.fields) return 'title'
31
- return 'id'
32
- }
33
-
34
- /**
35
- * Render a row's Label field ({@link getLabelFieldName}) as text, falling
36
- * back to `item.id` when the value is `null`/`undefined`.
37
- */
38
- export function getItemLabel(
39
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- ListConfig must accept any TypeInfo
40
- listConfig: ListConfig<any>,
41
- item: Record<string, unknown>,
42
- ): string {
43
- const fieldName = getLabelFieldName(listConfig)
44
- const value = Object.prototype.hasOwnProperty.call(item, fieldName) ? item[fieldName] : undefined
45
-
46
- if (value === undefined || value === null) {
47
- return String(item.id)
48
- }
49
-
50
- return String(value)
51
- }
@@ -1,77 +0,0 @@
1
- import type { AccessContext } from '../access/types.js'
2
- import { getDbKey } from '../lib/case-utils.js'
3
- import type { ListConfig, OpenSaasConfig, TypeInfo } from './types.js'
4
-
5
- /**
6
- * The minimal shape a `context.db[list]` delegate needs for a nav count. The
7
- * access-controlled DB carries an `any` index signature, so this narrows the
8
- * lookup to just the access-scoped `count` we call.
9
- */
10
- type CountDelegate = {
11
- count?: (args?: { where?: unknown }) => Promise<number>
12
- }
13
-
14
- /**
15
- * Whether a list's query access is **statically denied** — provably no session
16
- * can read any row, without evaluating a session-dependent function.
17
- *
18
- * Mirrors the list view's `canDeleteList` static check (issue #733): absent
19
- * access is deny-by-default (matching the access engine), so only an explicit
20
- * `false` counts as statically denied here — a function or `true` falls
21
- * through to a real per-row check via the secured context.
22
- *
23
- * A statically-denied list must render no nav count at all: a `0` there would
24
- * imply "this list is empty" when the truth is "you may see none of it".
25
- */
26
- export function isListQueryStaticallyDenied(
27
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- ListConfig must accept any TypeInfo
28
- listConfig: ListConfig<any>,
29
- ): boolean {
30
- const queryAccess = listConfig.access?.operation?.query
31
- if (queryAccess === undefined) return true
32
- if (typeof queryAccess === 'boolean') return !queryAccess
33
- return false
34
- }
35
-
36
- /**
37
- * Resolve the access-scoped nav counts for lists that opt in via
38
- * `ui.navCount` (issue #735). A list gets an entry only if it opts in, isn't
39
- * a singleton (no meaningful count), and isn't {@link isListQueryStaticallyDenied}
40
- * — everything else is omitted from the map, never zeroed.
41
- *
42
- * Each count is read through the secured `context.db`, so it reflects
43
- * exactly what the current session may see.
44
- */
45
- export async function resolveNavCounts(
46
- context: AccessContext,
47
- config: OpenSaasConfig,
48
- ): Promise<Record<string, number>> {
49
- const counts: Record<string, number> = {}
50
- const lists = config.lists ?? {}
51
-
52
- const optedIn = Object.keys(lists).filter((listKey) => {
53
- const listConfig = lists[listKey] as ListConfig<TypeInfo> | undefined
54
- if (!listConfig) return false
55
- if (listConfig.ui?.navCount !== true) return false
56
- if (listConfig.isSingleton) return false
57
- return !isListQueryStaticallyDenied(listConfig)
58
- })
59
-
60
- await Promise.all(
61
- optedIn.map(async (listKey) => {
62
- const delegate: CountDelegate | undefined = context.db?.[getDbKey(listKey)]
63
- if (!delegate?.count) return
64
- // A single list's count failing (a DB hiccup, a throwing access filter or
65
- // hook) must not blank the whole admin chrome — `AdminUI` awaits this
66
- // before rendering the shell. Degrade like the sibling `ListView`: log and
67
- // omit just that badge. Other lists' counts are unaffected.
68
- try {
69
- counts[listKey] = await delegate.count()
70
- } catch (error) {
71
- console.error(`Failed to resolve nav count for ${listKey}:`, error)
72
- }
73
- }),
74
- )
75
-
76
- return counts
77
- }