@selvajs/selva 4.21.0-beta.11 → 4.21.0-beta.13

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 (288) hide show
  1. package/build/adapter-node.js +2 -2
  2. package/build/client/_app/immutable/assets/0.DOeHn583.css +2 -0
  3. package/build/client/_app/immutable/assets/0.DOeHn583.css.br +0 -0
  4. package/build/client/_app/immutable/assets/0.DOeHn583.css.gz +0 -0
  5. package/build/client/_app/immutable/assets/rhino3dm.CWOyICcB.wasm +0 -0
  6. package/build/client/_app/immutable/assets/rhino3dm.CWOyICcB.wasm.br +0 -0
  7. package/build/client/_app/immutable/assets/rhino3dm.CWOyICcB.wasm.gz +0 -0
  8. package/build/client/_app/immutable/chunks/2rFska3d.js +1 -0
  9. package/build/client/_app/immutable/chunks/2rFska3d.js.br +1 -0
  10. package/build/client/_app/immutable/chunks/2rFska3d.js.gz +0 -0
  11. package/build/client/_app/immutable/chunks/{B3BHv1lE.js → 5M5n6ftO.js} +59 -58
  12. package/build/client/_app/immutable/chunks/5M5n6ftO.js.br +0 -0
  13. package/build/client/_app/immutable/chunks/5M5n6ftO.js.gz +0 -0
  14. package/build/client/_app/immutable/chunks/71J-lVIC.js +7 -0
  15. package/build/client/_app/immutable/chunks/71J-lVIC.js.br +0 -0
  16. package/build/client/_app/immutable/chunks/71J-lVIC.js.gz +0 -0
  17. package/build/client/_app/immutable/chunks/{Dqy8nTaG.js → BCbumNc2.js} +1 -1
  18. package/build/client/_app/immutable/chunks/BCbumNc2.js.br +0 -0
  19. package/build/client/_app/immutable/chunks/BCbumNc2.js.gz +0 -0
  20. package/build/client/_app/immutable/chunks/BEzPIk5e.js +1 -0
  21. package/build/client/_app/immutable/chunks/BEzPIk5e.js.br +0 -0
  22. package/build/client/_app/immutable/chunks/BEzPIk5e.js.gz +0 -0
  23. package/build/client/_app/immutable/chunks/B_4x1b7P.js +1 -0
  24. package/build/client/_app/immutable/chunks/B_4x1b7P.js.br +0 -0
  25. package/build/client/_app/immutable/chunks/B_4x1b7P.js.gz +0 -0
  26. package/build/client/_app/immutable/chunks/{BAhtiTKe.js → Bs2bQTgl.js} +1 -1
  27. package/build/client/_app/immutable/chunks/Bs2bQTgl.js.br +0 -0
  28. package/build/client/_app/immutable/chunks/Bs2bQTgl.js.gz +0 -0
  29. package/build/client/_app/immutable/chunks/{cUJB_11K.js → CzHxHvr2.js} +1 -1
  30. package/build/client/_app/immutable/chunks/CzHxHvr2.js.br +0 -0
  31. package/build/client/_app/immutable/chunks/CzHxHvr2.js.gz +0 -0
  32. package/build/client/_app/immutable/chunks/Db9exncB.js +1 -0
  33. package/build/client/_app/immutable/chunks/Db9exncB.js.br +0 -0
  34. package/build/client/_app/immutable/chunks/Db9exncB.js.gz +0 -0
  35. package/build/client/_app/immutable/chunks/{BEPlNI5E.js → FIoX_cjM.js} +1 -1
  36. package/build/client/_app/immutable/chunks/FIoX_cjM.js.br +0 -0
  37. package/build/client/_app/immutable/chunks/FIoX_cjM.js.gz +0 -0
  38. package/build/client/_app/immutable/chunks/{CmlXAF26.js → aBYenH6-.js} +1 -1
  39. package/build/client/_app/immutable/chunks/aBYenH6-.js.br +0 -0
  40. package/build/client/_app/immutable/chunks/aBYenH6-.js.gz +0 -0
  41. package/build/client/_app/immutable/entry/{app.B3im90t6.js → app.BP5swwM7.js} +2 -2
  42. package/build/client/_app/immutable/entry/app.BP5swwM7.js.br +0 -0
  43. package/build/client/_app/immutable/entry/app.BP5swwM7.js.gz +0 -0
  44. package/build/client/_app/immutable/nodes/{1.DWd6YbcT.js → 1.DmBjtFLw.js} +1 -1
  45. package/build/client/_app/immutable/nodes/1.DmBjtFLw.js.br +0 -0
  46. package/build/client/_app/immutable/nodes/1.DmBjtFLw.js.gz +0 -0
  47. package/build/client/_app/immutable/nodes/{2.bCPP2ncY.js → 2.CWOFnTAV.js} +1 -1
  48. package/build/client/_app/immutable/nodes/2.CWOFnTAV.js.br +0 -0
  49. package/build/client/_app/immutable/nodes/2.CWOFnTAV.js.gz +0 -0
  50. package/build/client/_app/immutable/nodes/{20.DI5Eri_M.js → 20.4vwwwrQ_.js} +1 -1
  51. package/build/client/_app/immutable/nodes/20.4vwwwrQ_.js.br +0 -0
  52. package/build/client/_app/immutable/nodes/20.4vwwwrQ_.js.gz +0 -0
  53. package/build/client/_app/immutable/nodes/21.C1xtue6U.js +1 -0
  54. package/build/client/_app/immutable/nodes/21.C1xtue6U.js.br +0 -0
  55. package/build/client/_app/immutable/nodes/21.C1xtue6U.js.gz +0 -0
  56. package/build/client/_app/immutable/nodes/{25.BRm8FzmQ.js → 25.DR2ojPn5.js} +22 -22
  57. package/build/client/_app/immutable/nodes/25.DR2ojPn5.js.br +0 -0
  58. package/build/client/_app/immutable/nodes/25.DR2ojPn5.js.gz +0 -0
  59. package/build/client/_app/immutable/nodes/{3.Ctd9OGCk.js → 3.GtVSkcEP.js} +1 -1
  60. package/build/client/_app/immutable/nodes/{3.Ctd9OGCk.js.br → 3.GtVSkcEP.js.br} +0 -0
  61. package/build/client/_app/immutable/nodes/3.GtVSkcEP.js.gz +0 -0
  62. package/build/client/_app/immutable/nodes/{30.B6pd-F-z.js → 30.Cd56Qv6o.js} +5 -6
  63. package/build/client/_app/immutable/nodes/30.Cd56Qv6o.js.br +0 -0
  64. package/build/client/_app/immutable/nodes/30.Cd56Qv6o.js.gz +0 -0
  65. package/build/client/_app/immutable/nodes/{5.BUX4zZQj.js → 5.wbpOzblK.js} +1 -1
  66. package/build/client/_app/immutable/nodes/5.wbpOzblK.js.br +0 -0
  67. package/build/client/_app/immutable/nodes/5.wbpOzblK.js.gz +0 -0
  68. package/build/client/_app/immutable/nodes/{6.BpjtFwPi.js → 6.B2HdJrZB.js} +1 -1
  69. package/build/client/_app/immutable/nodes/6.B2HdJrZB.js.br +0 -0
  70. package/build/client/_app/immutable/nodes/6.B2HdJrZB.js.gz +0 -0
  71. package/build/client/_app/immutable/nodes/{7.hBM6C-wN.js → 7.BuWU0YDv.js} +1 -1
  72. package/build/client/_app/immutable/nodes/7.BuWU0YDv.js.br +0 -0
  73. package/build/client/_app/immutable/nodes/7.BuWU0YDv.js.gz +0 -0
  74. package/build/client/_app/version.json +1 -1
  75. package/build/client/_app/version.json.br +0 -0
  76. package/build/client/_app/version.json.gz +0 -0
  77. package/build/runtime-meta.json +1 -1
  78. package/build/server/.vite/manifest.json +145 -137
  79. package/build/server/_app/immutable/assets/_layout.DOeHn583.css +2 -0
  80. package/build/server/_app/immutable/assets/rhino3dm.CWOyICcB.wasm +0 -0
  81. package/build/server/chunks/access.js +63 -48
  82. package/build/server/chunks/access.js.map +1 -1
  83. package/build/server/chunks/access2.server.js +1 -1
  84. package/build/server/chunks/api-errors.js +3 -3
  85. package/build/server/chunks/api.js +1 -1
  86. package/build/server/chunks/boot.server.js +1 -1
  87. package/build/server/chunks/bootHealth.server.js +1 -1
  88. package/build/server/chunks/create-project.js +1 -1
  89. package/build/server/chunks/delete-with-blobs.js +1 -1
  90. package/build/server/chunks/{schema-extraction.js → errors.js} +31 -24
  91. package/build/server/chunks/errors.js.map +1 -0
  92. package/build/server/chunks/grasshopper.js +17 -10
  93. package/build/server/chunks/grasshopper.js.map +1 -1
  94. package/build/server/chunks/handlers.js +82 -75
  95. package/build/server/chunks/handlers.js.map +1 -1
  96. package/build/server/chunks/http.js +1 -1
  97. package/build/server/chunks/http2.js +1 -1
  98. package/build/server/chunks/instance.js +3 -3
  99. package/build/server/chunks/instanceAdmins.server.js +2 -2
  100. package/build/server/chunks/internal.js +1 -1
  101. package/build/server/chunks/{keepalive-vtcjhAV3.js → keepalive-DbmLH4v1.js} +5 -4
  102. package/build/server/chunks/keepalive-DbmLH4v1.js.map +1 -0
  103. package/build/server/chunks/limits.js +1 -1
  104. package/build/server/chunks/liveSolve.server.js +1 -1
  105. package/build/server/chunks/localeContext.svelte.js +74 -0
  106. package/build/server/chunks/localeContext.svelte.js.map +1 -1
  107. package/build/server/chunks/{visibility.js → logging.js} +262 -3
  108. package/build/server/chunks/logging.js.map +1 -0
  109. package/build/server/chunks/openapi.js +1 -1
  110. package/build/server/chunks/ops.js +64 -1
  111. package/build/server/chunks/ops.js.map +1 -1
  112. package/build/server/chunks/package.js +1 -1
  113. package/build/server/chunks/package.js.map +1 -1
  114. package/build/server/chunks/presets.server.js +1 -1
  115. package/build/server/chunks/providers.server.js +448 -317
  116. package/build/server/chunks/providers.server.js.map +1 -1
  117. package/build/server/chunks/remote-definition.js +1 -1
  118. package/build/server/chunks/resolve-server.js +1 -1
  119. package/build/server/chunks/rhino3dm.js +5 -0
  120. package/build/server/chunks/rhino3dm.js.map +1 -0
  121. package/build/server/chunks/safe-url.js +2 -2
  122. package/build/server/chunks/schema.js +1 -1
  123. package/build/server/chunks/schema.js.map +1 -1
  124. package/build/server/chunks/selfUpdate.server.js +1 -1
  125. package/build/server/chunks/server-config-write.js +1 -1
  126. package/build/server/chunks/server2.js +5 -1
  127. package/build/server/chunks/server2.js.map +1 -1
  128. package/build/server/chunks/solve.server.js +5 -4
  129. package/build/server/chunks/solve.server.js.map +1 -1
  130. package/build/server/chunks/sveltekit.js +2 -2
  131. package/build/server/chunks/tokens.js +2 -2
  132. package/build/server/entries/endpoints/api/admin/compute/_server.ts.js +1 -1
  133. package/build/server/entries/endpoints/api/admin/compute/actions/_server.ts.js +1 -1
  134. package/build/server/entries/endpoints/api/admin/compute/status/_server.ts.js +1 -1
  135. package/build/server/entries/endpoints/api/admin/orgs/_id_/_server.ts.js +1 -1
  136. package/build/server/entries/endpoints/api/admin/orgs/_server.ts.js +2 -2
  137. package/build/server/entries/endpoints/api/admin/projects/_id_/_server.ts.js +1 -1
  138. package/build/server/entries/endpoints/api/admin/projects/_id_/grants/_grantId_/_server.ts.js +1 -1
  139. package/build/server/entries/endpoints/api/admin/projects/_id_/grants/_server.ts.js +1 -1
  140. package/build/server/entries/endpoints/api/admin/projects/_server.ts.js +1 -1
  141. package/build/server/entries/endpoints/api/admin/system/health/_server.ts.js +1 -1
  142. package/build/server/entries/endpoints/api/admin/system/throughput/_server.ts.js +1 -1
  143. package/build/server/entries/endpoints/api/admin/system/update/_server.ts.js +1 -1
  144. package/build/server/entries/endpoints/api/admin/users/_id_/_server.ts.js +1 -1
  145. package/build/server/entries/endpoints/api/admin/users/_id_/disable/_server.ts.js +1 -1
  146. package/build/server/entries/endpoints/api/admin/users/_server.ts.js +2 -2
  147. package/build/server/entries/endpoints/api/diag/throughput/_server.ts.js +1 -1
  148. package/build/server/entries/endpoints/api/files/_...path_/_server.ts.js +2 -3
  149. package/build/server/entries/endpoints/api/files/_...path_/_server.ts.js.map +1 -1
  150. package/build/server/entries/endpoints/api/v1/compute/_server.ts.js +1 -1
  151. package/build/server/entries/endpoints/api/v1/compute/schema/_server.ts.js +3 -3
  152. package/build/server/entries/endpoints/api/v1/definitions/_guid_/_server.ts.js +1 -1
  153. package/build/server/entries/endpoints/api/v1/definitions/_guid_/image/_server.ts.js +1 -1
  154. package/build/server/entries/endpoints/api/v1/definitions/_guid_/publish/_server.ts.js +1 -1
  155. package/build/server/entries/endpoints/api/v1/definitions/_guid_/schema/_server.ts.js +1 -1
  156. package/build/server/entries/endpoints/api/v1/definitions/_guid_/share-links/_linkId_/_server.ts.js +1 -1
  157. package/build/server/entries/endpoints/api/v1/definitions/_guid_/share-links/_server.ts.js +1 -1
  158. package/build/server/entries/endpoints/api/v1/definitions/_guid_/solve/_server.ts.js +1 -1
  159. package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_server.ts.js +1 -1
  160. package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_versionId_/_server.ts.js +1 -1
  161. package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_versionId_/changes/_server.ts.js +1 -1
  162. package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_versionId_/inventory/_server.ts.js +1 -1
  163. package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_versionId_/schema/_server.ts.js +1 -1
  164. package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_versionId_/scripts/_scriptId_/_server.ts.js +1 -1
  165. package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/check/_server.ts.js +1 -1
  166. package/build/server/entries/endpoints/api/v1/definitions/_server.ts.js +1 -1
  167. package/build/server/entries/endpoints/api/v1/me/_server.ts.js +1 -1
  168. package/build/server/entries/endpoints/api/v1/me/starred/_guid_/_server.ts.js +1 -1
  169. package/build/server/entries/endpoints/api/v1/me/token/_server.ts.js +1 -1
  170. package/build/server/entries/endpoints/api/v1/orgs/_orgId_/_server.ts.js +1 -1
  171. package/build/server/entries/endpoints/api/v1/orgs/_orgId_/assets/_kind_/_server.ts.js +1 -1
  172. package/build/server/entries/endpoints/api/v1/orgs/_orgId_/compute/_server.ts.js +1 -1
  173. package/build/server/entries/endpoints/api/v1/orgs/_orgId_/invites/_id_/_server.ts.js +1 -1
  174. package/build/server/entries/endpoints/api/v1/orgs/_orgId_/invites/_id_/resend/_server.ts.js +1 -1
  175. package/build/server/entries/endpoints/api/v1/orgs/_orgId_/invites/_server.ts.js +1 -1
  176. package/build/server/entries/endpoints/api/v1/orgs/_orgId_/members/_server.ts.js +1 -1
  177. package/build/server/entries/endpoints/api/v1/orgs/_orgId_/members/_userId_/_server.ts.js +1 -1
  178. package/build/server/entries/endpoints/api/v1/orgs/_orgId_/tokens/_server.ts.js +1 -1
  179. package/build/server/entries/endpoints/api/v1/orgs/_orgId_/tokens/_tokenId_/_server.ts.js +1 -1
  180. package/build/server/entries/endpoints/api/v1/projects/_id_/_server.ts.js +1 -1
  181. package/build/server/entries/endpoints/api/v1/projects/_id_/members/_server.ts.js +1 -1
  182. package/build/server/entries/endpoints/api/v1/projects/_id_/members/_userId_/_server.ts.js +1 -1
  183. package/build/server/entries/endpoints/api/v1/projects/_id_/reclaim/_server.ts.js +1 -1
  184. package/build/server/entries/endpoints/api/v1/projects/_server.ts.js +1 -1
  185. package/build/server/entries/endpoints/api/v1/solve/_solveId_/cancel/_server.ts.js +2 -2
  186. package/build/server/entries/endpoints/api/v1/solve-events/_server.ts.js +2 -2
  187. package/build/server/entries/endpoints/api/v1/solve-events/_solveId_/_server.ts.js +1 -1
  188. package/build/server/entries/endpoints/auth/email/callback/_server.ts.js +1 -1
  189. package/build/server/entries/endpoints/auth/supabase/callback/_server.ts.js +1 -1
  190. package/build/server/entries/endpoints/auth/supabase/start/_server.ts.js +1 -1
  191. package/build/server/entries/endpoints/mcp/_server.ts.js +14 -8
  192. package/build/server/entries/endpoints/mcp/_server.ts.js.map +1 -1
  193. package/build/server/entries/hooks.server.js +37 -3
  194. package/build/server/entries/hooks.server.js.map +1 -1
  195. package/build/server/entries/pages/accept-invite/_page.server.ts.js +1 -1
  196. package/build/server/entries/pages/admin/_page.server.ts.js +1 -1
  197. package/build/server/entries/pages/admin/organizations/_page.server.ts.js +4 -9
  198. package/build/server/entries/pages/admin/organizations/_page.server.ts.js.map +1 -1
  199. package/build/server/entries/pages/docs/api/_page.server.ts.js +1 -1
  200. package/build/server/entries/pages/library/_guid_/_page.server.ts.js +8 -7
  201. package/build/server/entries/pages/library/_guid_/_page.server.ts.js.map +1 -1
  202. package/build/server/entries/pages/library/_guid_/_page.svelte.js +9874 -3725
  203. package/build/server/entries/pages/library/_guid_/_page.svelte.js.map +1 -1
  204. package/build/server/entries/pages/library/_page.server.ts.js +1 -2
  205. package/build/server/entries/pages/library/_page.server.ts.js.map +1 -1
  206. package/build/server/entries/pages/oauth/authorize/_page.server.ts.js +2 -2
  207. package/build/server/entries/pages/projects/_page.server.ts.js +2 -2
  208. package/build/server/entries/pages/projects/_page.svelte.js +10 -4
  209. package/build/server/entries/pages/projects/_page.svelte.js.map +1 -1
  210. package/build/server/entries/pages/setup/_page.server.ts.js +1 -1
  211. package/build/server/entries/pages/team/_page.server.ts.js +1 -1
  212. package/build/server/entries/pages/team/_page.server.ts.js.map +1 -1
  213. package/build/server/entries/pages/team/members/_page.server.ts.js +4 -2
  214. package/build/server/entries/pages/team/members/_page.server.ts.js.map +1 -1
  215. package/build/server/entries/pages/team/members/_page.svelte.js +6 -5
  216. package/build/server/entries/pages/team/members/_page.svelte.js.map +1 -1
  217. package/build/server/entries/pages/team/projects/_page.server.ts.js +5 -12
  218. package/build/server/entries/pages/team/projects/_page.server.ts.js.map +1 -1
  219. package/build/server/entries/pages/team/reclaim/_page.server.ts.js +6 -13
  220. package/build/server/entries/pages/team/reclaim/_page.server.ts.js.map +1 -1
  221. package/build/server/manifest-full.js +1 -1
  222. package/build/server/manifest.js +1 -1
  223. package/build/server/nodes/0.js +2 -2
  224. package/build/server/nodes/1.js +1 -1
  225. package/build/server/nodes/2.js +1 -1
  226. package/build/server/nodes/20.js +1 -1
  227. package/build/server/nodes/21.js +1 -1
  228. package/build/server/nodes/25.js +1 -1
  229. package/build/server/nodes/3.js +1 -1
  230. package/build/server/nodes/30.js +1 -1
  231. package/build/server/nodes/5.js +1 -1
  232. package/build/server/nodes/6.js +1 -1
  233. package/build/server/nodes/7.js +1 -1
  234. package/build/server/server.js +1 -1
  235. package/package.json +13 -13
  236. package/templates/.env.example +18 -1
  237. package/build/client/_app/immutable/assets/0.DJ150bSr.css +0 -2
  238. package/build/client/_app/immutable/assets/0.DJ150bSr.css.br +0 -0
  239. package/build/client/_app/immutable/assets/0.DJ150bSr.css.gz +0 -0
  240. package/build/client/_app/immutable/chunks/B3BHv1lE.js.br +0 -0
  241. package/build/client/_app/immutable/chunks/B3BHv1lE.js.gz +0 -0
  242. package/build/client/_app/immutable/chunks/BAhtiTKe.js.br +0 -0
  243. package/build/client/_app/immutable/chunks/BAhtiTKe.js.gz +0 -0
  244. package/build/client/_app/immutable/chunks/BEPlNI5E.js.br +0 -0
  245. package/build/client/_app/immutable/chunks/BEPlNI5E.js.gz +0 -0
  246. package/build/client/_app/immutable/chunks/CmlXAF26.js.br +0 -0
  247. package/build/client/_app/immutable/chunks/CmlXAF26.js.gz +0 -0
  248. package/build/client/_app/immutable/chunks/DQbsDiDJ.js +0 -1
  249. package/build/client/_app/immutable/chunks/DQbsDiDJ.js.br +0 -1
  250. package/build/client/_app/immutable/chunks/DQbsDiDJ.js.gz +0 -0
  251. package/build/client/_app/immutable/chunks/DW5EJMC7.js +0 -1
  252. package/build/client/_app/immutable/chunks/DW5EJMC7.js.br +0 -0
  253. package/build/client/_app/immutable/chunks/DW5EJMC7.js.gz +0 -0
  254. package/build/client/_app/immutable/chunks/Dqy8nTaG.js.br +0 -0
  255. package/build/client/_app/immutable/chunks/Dqy8nTaG.js.gz +0 -0
  256. package/build/client/_app/immutable/chunks/cUJB_11K.js.br +0 -0
  257. package/build/client/_app/immutable/chunks/cUJB_11K.js.gz +0 -0
  258. package/build/client/_app/immutable/entry/app.B3im90t6.js.br +0 -0
  259. package/build/client/_app/immutable/entry/app.B3im90t6.js.gz +0 -0
  260. package/build/client/_app/immutable/nodes/1.DWd6YbcT.js.br +0 -0
  261. package/build/client/_app/immutable/nodes/1.DWd6YbcT.js.gz +0 -0
  262. package/build/client/_app/immutable/nodes/2.bCPP2ncY.js.br +0 -0
  263. package/build/client/_app/immutable/nodes/2.bCPP2ncY.js.gz +0 -0
  264. package/build/client/_app/immutable/nodes/20.DI5Eri_M.js.br +0 -0
  265. package/build/client/_app/immutable/nodes/20.DI5Eri_M.js.gz +0 -0
  266. package/build/client/_app/immutable/nodes/21.BI8SjY_r.js +0 -1
  267. package/build/client/_app/immutable/nodes/21.BI8SjY_r.js.br +0 -1
  268. package/build/client/_app/immutable/nodes/21.BI8SjY_r.js.gz +0 -0
  269. package/build/client/_app/immutable/nodes/25.BRm8FzmQ.js.br +0 -0
  270. package/build/client/_app/immutable/nodes/25.BRm8FzmQ.js.gz +0 -0
  271. package/build/client/_app/immutable/nodes/3.Ctd9OGCk.js.gz +0 -0
  272. package/build/client/_app/immutable/nodes/30.B6pd-F-z.js.br +0 -0
  273. package/build/client/_app/immutable/nodes/30.B6pd-F-z.js.gz +0 -0
  274. package/build/client/_app/immutable/nodes/5.BUX4zZQj.js.br +0 -0
  275. package/build/client/_app/immutable/nodes/5.BUX4zZQj.js.gz +0 -0
  276. package/build/client/_app/immutable/nodes/6.BpjtFwPi.js.br +0 -0
  277. package/build/client/_app/immutable/nodes/6.BpjtFwPi.js.gz +0 -0
  278. package/build/client/_app/immutable/nodes/7.hBM6C-wN.js.br +0 -0
  279. package/build/client/_app/immutable/nodes/7.hBM6C-wN.js.gz +0 -0
  280. package/build/server/_app/immutable/assets/_layout.DJ150bSr.css +0 -2
  281. package/build/server/chunks/definitions.js +0 -263
  282. package/build/server/chunks/definitions.js.map +0 -1
  283. package/build/server/chunks/keepalive-vtcjhAV3.js.map +0 -1
  284. package/build/server/chunks/schema-extraction.js.map +0 -1
  285. package/build/server/chunks/visibility.js.map +0 -1
  286. /package/build/client/_app/immutable/nodes/{0.Bu9WQ0W_.js → 0.CXQcjMDK.js} +0 -0
  287. /package/build/client/_app/immutable/nodes/{0.Bu9WQ0W_.js.br → 0.CXQcjMDK.js.br} +0 -0
  288. /package/build/client/_app/immutable/nodes/{0.Bu9WQ0W_.js.gz → 0.CXQcjMDK.js.gz} +0 -0
@@ -1,4 +1,4 @@
1
- import { K as canCreateDefinition, Q as canView, U as outsideTokenOrg, W as scopeAllows, Y as canEditDefinition, o as projectAccessInputFromRowsWith } from "./access.js";
1
+ import { $ as canView, G as scopeAllows, W as outsideTokenOrg, X as canEditDefinition, o as projectAccessInputFromRowsWith, q as canCreateDefinition } from "./access.js";
2
2
  import { t as SYSTEM_CONTEXT } from "./context.js";
3
3
  /** For adapters paging by offset. Junk and negatives read as the first page. */
4
4
  function decodeOffsetCursor(cursor) {
@@ -222,6 +222,265 @@ async function loadVisibleVersion(ctx, guid, versionId, deps) {
222
222
  if (!version || version.definitionId !== record.guid) return null;
223
223
  return version;
224
224
  }
225
- export { loadVisibleDefinition as a, resolveAccessibleProjects as c, encodeOffsetCursor as d, listAll as f, listVisibleDefinitions as i, clampPageLimit as l, getVisibleDefinition as n, loadVisibleVersion as o, walkPages as p, listEditableDefinitionsByDocument as r, mayUploadToDefinition as s, canCreateDefinitionInOrg as t, decodeOffsetCursor as u };
225
+ // ../server/src/logging/PinoLogger.ts
226
+ /**
227
+ * Field names scrubbed before a record is written, by both backends. A backstop
228
+ * for accidents, NOT a licence to log objects: call sites are required not to
229
+ * log secrets in the first place (see `LogFields`). This catches the case where
230
+ * a whole object is spread into fields and happens to carry a credential.
231
+ *
232
+ * It matches by FIELD NAME, and only at the top level or one level deep. It will
233
+ * not catch personal data: an email nested in a payload sails straight through,
234
+ * and a log line reaches a collector that erasure can never reach.
235
+ */
236
+ var REDACTED_KEYS = [
237
+ "token",
238
+ "sessionToken",
239
+ "refreshToken",
240
+ "apiKey",
241
+ "api_key",
242
+ "password",
243
+ "authorization",
244
+ "Authorization",
245
+ "cookie",
246
+ "secret"
247
+ ];
248
+ var CENSOR = "[redacted]";
249
+ var REDACTED = new Set(REDACTED_KEYS);
250
+ var REDACTED_PATHS = [...REDACTED_KEYS, ...REDACTED_KEYS.map((k) => `*.${k}`)];
251
+ /** {@link REDACTED_KEYS} applied the way pino applies its paths, on a copy. */
252
+ function redact(fields) {
253
+ const out = {};
254
+ for (const [key, value] of Object.entries(fields)) out[key] = REDACTED.has(key) ? CENSOR : redactOneLevel(value);
255
+ return out;
256
+ }
257
+ function redactOneLevel(value) {
258
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return value;
259
+ if (!Object.keys(value).some((k) => REDACTED.has(k))) return value;
260
+ return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, REDACTED.has(k) ? CENSOR : v]));
261
+ }
262
+ /**
263
+ * Minimal `ILogger` over `console.*`, used when pino isn't installed. Renders
264
+ * as `LEVEL message {fields}` — greppable, and honest about not being
265
+ * machine-parseable. `child` fields merge eagerly so correlation still works.
266
+ */
267
+ var ConsoleLogger = class ConsoleLogger {
268
+ bound;
269
+ minLevel;
270
+ constructor(bound = {}, minLevel = "info") {
271
+ this.bound = bound;
272
+ this.minLevel = minLevel;
273
+ }
274
+ static ORDER = {
275
+ debug: 10,
276
+ info: 20,
277
+ warn: 30,
278
+ error: 40
279
+ };
280
+ write(level, message, fields) {
281
+ if (ConsoleLogger.ORDER[level] < ConsoleLogger.ORDER[this.minLevel]) return;
282
+ const merged = {
283
+ ...this.bound,
284
+ ...fields
285
+ };
286
+ const suffix = Object.keys(merged).length > 0 ? ` ${renderFields(merged)}` : "";
287
+ const line = `${level.toUpperCase()} ${message}${suffix}`;
288
+ if (level === "error") console.error(line);
289
+ else if (level === "warn") console.warn(line);
290
+ else console.info(line);
291
+ }
292
+ debug(message, fields) {
293
+ this.write("debug", message, fields);
294
+ }
295
+ info(message, fields) {
296
+ this.write("info", message, fields);
297
+ }
298
+ warn(message, fields) {
299
+ this.write("warn", message, fields);
300
+ }
301
+ error(message, fields) {
302
+ this.write("error", message, fields);
303
+ }
304
+ child(fields) {
305
+ return new ConsoleLogger({
306
+ ...this.bound,
307
+ ...fields
308
+ }, this.minLevel);
309
+ }
310
+ };
311
+ /** Fields can hold anything, including cycles. Never let rendering throw. */
312
+ function renderFields(fields) {
313
+ try {
314
+ return JSON.stringify(redact(fields)) ?? String(fields);
315
+ } catch {
316
+ return "[unserializable]";
317
+ }
318
+ }
319
+ var PinoLogger = class PinoLogger {
320
+ pino;
321
+ constructor(pino) {
322
+ this.pino = pino;
323
+ }
324
+ debug(message, fields) {
325
+ try {
326
+ this.pino.debug(fields ?? {}, message);
327
+ } catch {}
328
+ }
329
+ info(message, fields) {
330
+ try {
331
+ this.pino.info(fields ?? {}, message);
332
+ } catch {}
333
+ }
334
+ warn(message, fields) {
335
+ try {
336
+ this.pino.warn(fields ?? {}, message);
337
+ } catch {}
338
+ }
339
+ error(message, fields) {
340
+ try {
341
+ this.pino.error(fields ?? {}, message);
342
+ } catch {}
343
+ }
344
+ child(fields) {
345
+ try {
346
+ return new PinoLogger(this.pino.child(fields));
347
+ } catch {
348
+ return this;
349
+ }
350
+ }
351
+ };
352
+ /** Build the app's root logger. Never throws, never returns `null`. */
353
+ async function createLogger(opts = {}) {
354
+ const level = opts.level ?? "info";
355
+ try {
356
+ const factory = await loadPinoFactory();
357
+ if (!factory) return new ConsoleLogger(opts.base ?? {}, level);
358
+ return new PinoLogger(factory({
359
+ level,
360
+ base: opts.base,
361
+ redact: {
362
+ paths: REDACTED_PATHS,
363
+ censor: CENSOR
364
+ },
365
+ transport: opts.pretty ? {
366
+ target: "pino-pretty",
367
+ options: {
368
+ colorize: true,
369
+ ignore: "pid,hostname"
370
+ }
371
+ } : void 0
372
+ }));
373
+ } catch (err) {
374
+ console.warn(`[Logger] pino was found but could not be initialized; falling back to console logging. ${String(err)}`);
375
+ return new ConsoleLogger(opts.base ?? {}, level);
376
+ }
377
+ }
378
+ /**
379
+ * Load pino's factory, or `null` when it isn't installed.
380
+ *
381
+ * Don't inline the specifier. A literal `import('pino')` is statically
382
+ * analyzable, so Vite applied browser-field mapping to this server build and
383
+ * resolved it to pino's `server_false` browser shim — a stub whose factory
384
+ * throws, turning "use pino" into a silent fall back to the console. Computing
385
+ * the specifier defeats that and leaves the import to Node at runtime.
386
+ * `@vite-ignore` alone was NOT enough: it silenced the warning and the rewrite
387
+ * still happened.
388
+ */
389
+ async function loadPinoFactory() {
390
+ const specifier = "pino";
391
+ try {
392
+ const mod = await import(
393
+ /* @vite-ignore */
394
+ specifier
395
+ );
396
+ const factory = mod.default ?? mod;
397
+ return typeof factory === "function" ? factory : null;
398
+ } catch {
399
+ return null;
400
+ }
401
+ }
402
+ // ../server/src/logging/requestId.ts
403
+ /**
404
+ * Request-id resolution for log correlation. Every record on a request path
405
+ * carries the same `requestId`, so an operator handed one id can reconstruct
406
+ * that request's whole story.
407
+ *
408
+ * Inbound ids are TRUSTED when present. Selva runs behind a reverse proxy
409
+ * (Caddy/nginx) that mints a request id for its own access logs; minting a
410
+ * second one here would split one request across two ids and kill cross-tier
411
+ * correlation. The trade — a direct caller picks their own id — is fine, because
412
+ * the id is only ever a log field and an echoed response header, never an
413
+ * authorization or uniqueness input.
414
+ *
415
+ * That trust is why {@link sanitizeRequestId} exists: an attacker-chosen id is
416
+ * untrusted content. Unbounded or newline-carrying values would let a caller
417
+ * forge log lines (log injection) or bloat every record on the request.
418
+ */
419
+ /** Header carrying a caller/proxy-supplied id. The de-facto standard spelling. */
420
+ var REQUEST_ID_HEADER = "x-request-id";
421
+ /** Long enough for a UUID or a W3C trace-id, short enough to bound a record. */
422
+ var MAX_REQUEST_ID_LENGTH = 128;
423
+ /**
424
+ * Characters allowed through verbatim. Strict on purpose: UUIDs, ULIDs, hex
425
+ * trace-ids and nginx's `$request_id` all fit. Everything else — whitespace,
426
+ * control chars, quotes, CR/LF — is dropped rather than escaped, since no
427
+ * legitimate id needs them and dropping can't be un-escaped downstream.
428
+ */
429
+ var UNSAFE_REQUEST_ID_CHARS = /[^A-Za-z0-9._:-]/g;
430
+ /** Returns `null` when nothing usable survives, so the caller generates instead. */
431
+ function sanitizeRequestId(raw) {
432
+ if (!raw) return null;
433
+ const cleaned = raw.replace(UNSAFE_REQUEST_ID_CHARS, "").slice(0, MAX_REQUEST_ID_LENGTH);
434
+ return cleaned.length > 0 ? cleaned : null;
435
+ }
436
+ /**
437
+ * Reuse the proxy's id when it survives sanitization, otherwise mint a UUID.
438
+ *
439
+ * @param generate injectable so tests get deterministic ids
440
+ */
441
+ function resolveRequestId(headers, generate = randomId) {
442
+ return sanitizeRequestId(headers.get("x-request-id")) ?? generate();
443
+ }
444
+ /**
445
+ * Render a thrown value into a log field.
446
+ *
447
+ * Not every rejection is an `Error` — provider adapters sometimes reject with a
448
+ * plain `{ message, status }`, which would stringify to a useless
449
+ * `[object Object]` and destroy the only record of the failure. Errors keep
450
+ * their stack; anything else is JSON-serialized, with `String()` as the last
451
+ * resort for cycles and exotic values.
452
+ *
453
+ * A `code` / `statusCode` carried on the error (ComputeError, ProviderError,
454
+ * Node's ECONNREFUSED-style errors) is appended as a `[code=… status=…]` tag —
455
+ * it classifies the failure and stacks alone don't show it.
456
+ */
457
+ function renderThrown(error) {
458
+ if (error instanceof Error) {
459
+ const base = error.stack ?? error.message;
460
+ const code = error.code;
461
+ const statusCode = error.statusCode;
462
+ const tags = [];
463
+ if (typeof code === "string" || typeof code === "number") tags.push(`code=${code}`);
464
+ if (typeof statusCode === "number") tags.push(`status=${statusCode}`);
465
+ return tags.length > 0 ? `${base} [${tags.join(" ")}]` : base;
466
+ }
467
+ try {
468
+ return JSON.stringify(error) ?? String(error);
469
+ } catch {
470
+ return String(error);
471
+ }
472
+ }
473
+ /**
474
+ * `crypto.randomUUID` exists in every runtime Selva targets (Node 22+, workers,
475
+ * modern browsers); the `Math.random` branch only covers non-secure contexts
476
+ * where it is missing. Not a weakness: these ids need to be collision-free
477
+ * enough to correlate logs, never unguessable.
478
+ */
479
+ function randomId() {
480
+ const c = globalThis.crypto;
481
+ if (c && typeof c.randomUUID === "function") return c.randomUUID();
482
+ return `req-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
483
+ }
484
+ export { listAll as _, createLogger as a, listEditableDefinitionsByDocument as c, loadVisibleVersion as d, mayUploadToDefinition as f, encodeOffsetCursor as g, decodeOffsetCursor as h, ConsoleLogger as i, listVisibleDefinitions as l, clampPageLimit as m, renderThrown as n, canCreateDefinitionInOrg as o, resolveAccessibleProjects as p, resolveRequestId as r, getVisibleDefinition as s, REQUEST_ID_HEADER as t, loadVisibleDefinition as u, walkPages as v };
226
485
 
227
- //# sourceMappingURL=visibility.js.map
486
+ //# sourceMappingURL=logging.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logging.js","names":[],"sources":["../../../../platform/src/pagination.ts","../../../../server/src/definitions/visibility.ts","../../../../server/src/logging/PinoLogger.ts","../../../../server/src/logging/requestId.ts"],"sourcesContent":["/**\n * Cursor-paginated list options. Adapters default `limit` to `DEFAULT_PAGE_LIMIT` and\n * clamp it to `MAX_PAGE_LIMIT` (`clampPageLimit`). Order is `createdAt` desc unless the\n * store documents another; a store with one fixed order may ignore `orderBy`.\n *\n * Cursors are opaque — adapters may use row ids, offsets, or keyset encodings.\n * Callers must not inspect them.\n */\nexport interface ListOptions {\n\tlimit?: number;\n\tcursor?: string;\n\torderBy?: 'createdAt' | 'updatedAt' | 'name';\n\t/** Default: 'desc'. */\n\torderDir?: 'asc' | 'desc';\n}\n\nexport interface Page<T> {\n\titems: T[];\n\tnextCursor?: string;\n}\n\nexport const DEFAULT_PAGE_LIMIT = 50;\nexport const MAX_PAGE_LIMIT = 200;\n\n/** For adapters paging by offset. Junk and negatives read as the first page. */\nexport function decodeOffsetCursor(cursor: string | undefined): number {\n\tconst offset = cursor ? parseInt(cursor, 10) : 0;\n\treturn Number.isFinite(offset) && offset >= 0 ? offset : 0;\n}\n\nexport function encodeOffsetCursor(offset: number): string {\n\treturn String(offset);\n}\n\ntype PageFetcher<T> = (page: { limit: number; cursor?: string }) => Promise<Page<T>>;\n\n/**\n * Every page of a list, in order. One call stops at `MAX_PAGE_LIMIT` without saying so, which is\n * fatal for a read that must see every row. Break out of the loop to stop reading.\n */\nexport async function* walkPages<T>(fetchPage: PageFetcher<T>): AsyncGenerator<Page<T>> {\n\tlet cursor: string | undefined;\n\tdo {\n\t\tconst page = await fetchPage({ limit: MAX_PAGE_LIMIT, cursor });\n\t\tyield page;\n\t\tcursor = page.nextCursor;\n\t} while (cursor);\n}\n\n/** Every row of a list, across all its pages. */\nexport async function listAll<T>(fetchPage: PageFetcher<T>): Promise<T[]> {\n\tconst items: T[] = [];\n\tfor await (const page of walkPages(fetchPage)) items.push(...page.items);\n\treturn items;\n}\n\n/** The effective page size for a requested limit. */\nexport function clampPageLimit(limit: number | undefined): number {\n\tconst requested = limit ?? DEFAULT_PAGE_LIMIT;\n\tif (!Number.isFinite(requested)) return DEFAULT_PAGE_LIMIT;\n\treturn Math.min(Math.max(1, Math.floor(requested)), MAX_PAGE_LIMIT);\n}\n","/**\n * Visibility-filtered definition reads, shared by the library page load and\n * `GET /api/v1/definitions`.\n *\n * **This is a tenancy boundary.** The project scan runs as `SYSTEM_CONTEXT` so\n * cross-org `public` projects are reachable when `ALLOW_CROSS_ORG_PUBLIC` is on;\n * `canView` over the fetched membership rows is the only thing keeping another\n * org's projects out of the result. The definition list itself is then filtered\n * *in the query* via `projectIds`, so the cursor is applied after visibility\n * rather than over a page that gets thinned afterwards.\n *\n * Cost is constant in the number of orgs and projects: three bulk membership\n * reads regardless of N. Anything added here must keep that property — a\n * per-project `await` inside a loop reintroduces the N+1 this replaced.\n */\n\nimport {\n\tSYSTEM_CONTEXT,\n\tcanCreateDefinition,\n\tcanEditDefinition,\n\tcanView,\n\toutsideTokenOrg,\n\tscopeAllows,\n\twalkPages\n} from '@selvajs/platform';\nimport type {\n\tDefinitionListOptions,\n\tDefinitionRecord,\n\tDefinitionVersion,\n\tOrgMember,\n\tPage,\n\tPlatformProjectGrant,\n\tProject,\n\tProjectMember,\n\tRequestContext\n} from '@selvajs/platform';\nimport { projectAccessInputFromRowsWith } from '../access/index.js';\nimport type { SelvaDeps } from '../api/deps.js';\n\n/** Upper bound on the org/project scan. Visibility needs the whole set. */\nconst SCAN_LIMIT = 200;\n\n/**\n * The stores this module reads. Required at every call site.\n *\n * These used to fall back to a host's composition root, which welded this\n * tenancy boundary to one app's boot — anything importing it started the whole\n * application. Handlers pass `req.deps`; page loads pass their own equivalent.\n * That is what lets a second host on a different provider set reuse this\n * boundary instead of rebuilding it.\n */\nexport type VisibilityDeps = Pick<\n\tSelvaDeps,\n\t'orgs' | 'projects' | 'platformProjectGrants' | 'definitionMeta' | 'flag'\n>;\n\n/**\n * The caller's accessible project set plus the membership rows it was derived\n * from, so a caller needing a second rule (`canEdit` on the projects page)\n * can evaluate it with no further I/O.\n */\nexport interface AccessibleProjectSet {\n\tprojects: Project[];\n\t/** Every project the scan saw, keyed by id — for name lookups on rows. */\n\tallById: Map<string, Project>;\n\t/** The caller's project-membership row per scanned project (`null` = not a member). */\n\tmemberByProjectId: Map<string, ProjectMember | null>;\n\t/** The caller's org-membership row per scanned org (`null` = not a member). */\n\torgMemberByOrgId: Map<string, OrgMember | null>;\n\t/** Grants per scanned `platform` project; absent for every other visibility. */\n\tgrantsByProjectId: Map<string, PlatformProjectGrant[]>;\n}\n\n/**\n * Resolve the caller's accessible project set in a constant number of queries.\n * Platform grants are fetched only for `platform`-visibility projects —\n * `canView` short-circuits before reading them for every other visibility.\n */\nexport async function resolveAccessibleProjects(\n\tctx: RequestContext,\n\tdeps: VisibilityDeps\n): Promise<AccessibleProjectSet> {\n\tconst orgs = deps.orgs;\n\tconst projectStore = deps.projects;\n\tconst grantStore = deps.platformProjectGrants;\n\n\tconst orgsPage = await orgs.listOrgs(SYSTEM_CONTEXT, { limit: SCAN_LIMIT });\n\t// An API token sees its own org only, cross-org public projects included.\n\tconst orgIds = orgsPage.items.map((o) => o.id).filter((id) => !outsideTokenOrg(ctx, id));\n\n\tconst projectPages = await Promise.all(\n\t\torgIds.map((orgId) => projectStore.listProjects(SYSTEM_CONTEXT, orgId, { limit: SCAN_LIMIT }))\n\t);\n\tconst allProjects = projectPages.flatMap((p) => p.items);\n\tconst projectIds = allProjects.map((p) => p.id);\n\tconst platformProjectIds = allProjects\n\t\t.filter((p) => p.visibility === 'platform')\n\t\t.map((p) => p.id);\n\n\tconst [orgMemberByOrgId, memberByProjectId, grantsByProjectId] = await Promise.all([\n\t\torgs.getOrgMembersFor(SYSTEM_CONTEXT, orgIds, ctx.userId),\n\t\tprojectStore.getProjectMembersFor(SYSTEM_CONTEXT, projectIds, ctx.userId),\n\t\tplatformProjectIds.length\n\t\t\t? grantStore.listByProjects(SYSTEM_CONTEXT, platformProjectIds)\n\t\t\t: Promise.resolve(new Map<string, PlatformProjectGrant[]>())\n\t]);\n\n\tconst projects = allProjects.filter((project) =>\n\t\tcanView(\n\t\t\tprojectAccessInputFromRowsWith({ deps }, ctx, project, {\n\t\t\t\tmember: memberByProjectId.get(project.id) ?? null,\n\t\t\t\torgMember: orgMemberByOrgId.get(project.orgId) ?? null,\n\t\t\t\tplatformGrants: grantsByProjectId.get(project.id) ?? []\n\t\t\t})\n\t\t)\n\t);\n\n\treturn {\n\t\tprojects,\n\t\tallById: new Map(allProjects.map((p) => [p.id, p])),\n\t\tmemberByProjectId,\n\t\torgMemberByOrgId,\n\t\tgrantsByProjectId\n\t};\n}\n\n/**\n * Whether the caller may create a definition in at least one project of\n * `orgId`, by the same rule `requireCanCreateDefinition` applies. Reads the\n * org's projects a page at a time and stops at the first that passes.\n */\nexport async function canCreateDefinitionInOrg(\n\tctx: RequestContext,\n\torgId: string,\n\tdeps: VisibilityDeps\n): Promise<boolean> {\n\tconst orgMember =\n\t\t(await deps.orgs.getOrgMembersFor(SYSTEM_CONTEXT, [orgId], ctx.userId)).get(orgId) ?? null;\n\tconst pages = walkPages((page) => deps.projects.listProjects(SYSTEM_CONTEXT, orgId, page));\n\tfor await (const page of pages) {\n\t\tconst platformIds = page.items.filter((p) => p.visibility === 'platform').map((p) => p.id);\n\t\tconst [members, grants] = await Promise.all([\n\t\t\tdeps.projects.getProjectMembersFor(\n\t\t\t\tSYSTEM_CONTEXT,\n\t\t\t\tpage.items.map((p) => p.id),\n\t\t\t\tctx.userId\n\t\t\t),\n\t\t\tplatformIds.length\n\t\t\t\t? deps.platformProjectGrants.listByProjects(SYSTEM_CONTEXT, platformIds)\n\t\t\t\t: Promise.resolve(new Map<string, PlatformProjectGrant[]>())\n\t\t]);\n\t\tconst allowed = page.items.some((project) =>\n\t\t\tcanCreateDefinition(\n\t\t\t\tprojectAccessInputFromRowsWith({ deps }, ctx, project, {\n\t\t\t\t\tmember: members.get(project.id) ?? null,\n\t\t\t\t\torgMember,\n\t\t\t\t\tplatformGrants: grants.get(project.id) ?? []\n\t\t\t\t})\n\t\t\t)\n\t\t);\n\t\tif (allowed) return true;\n\t}\n\treturn false;\n}\n\nexport interface ListVisibleDefinitionsResult extends Page<DefinitionRecord> {\n\t/** For resolving a definition's `projectId` to a name. */\n\tprojects: Project[];\n}\n\n/**\n * `opts.projectId` narrows to one project; a caller who cannot view it gets an\n * empty page rather than a 403, so this never reveals that a project exists.\n */\nexport async function listVisibleDefinitions(\n\tctx: RequestContext,\n\topts: DefinitionListOptions & { projectId?: string } = {},\n\tdeps: VisibilityDeps\n): Promise<ListVisibleDefinitionsResult> {\n\tconst { projectId, ...listOpts } = opts;\n\tconst { projects } = await resolveAccessibleProjects(ctx, deps);\n\n\tconst scoped = projectId ? projects.filter((p) => p.id === projectId) : projects;\n\t// An empty id set matches nothing, which is what a caller with no visible\n\t// projects should get — not an unfiltered listing.\n\tconst page = await deps.definitionMeta.list(ctx, {\n\t\t...listOpts,\n\t\tprojectIds: scoped.map((p) => p.id)\n\t});\n\n\treturn { items: page.items, nextCursor: page.nextCursor, projects: scoped };\n}\n\n/**\n * Editable definitions whose `sourceDocumentId` is `documentId`: the ones the\n * caller could upload a new version of, by {@link mayUploadToDefinition}.\n *\n * Commons projects are scanned too, since a caller owns their own uploads there\n * without edit rights on the project; rows they can't edit are dropped after\n * the query, so a page can come back short while `nextCursor` stays valid.\n */\nexport async function listEditableDefinitionsByDocument(\n\tctx: RequestContext,\n\tdocumentId: string,\n\topts: DefinitionListOptions & { projectId?: string },\n\tdeps: VisibilityDeps\n): Promise<Page<DefinitionRecord>> {\n\tconst { projectId, ...listOpts } = opts;\n\tconst set = await resolveAccessibleProjects(ctx, deps);\n\tconst rowsFor = (project: Project) => ({\n\t\tmember: set.memberByProjectId.get(project.id) ?? null,\n\t\torgMember: set.orgMemberByOrgId.get(project.orgId) ?? null,\n\t\tplatformGrants: set.grantsByProjectId.get(project.id) ?? []\n\t});\n\tconst candidates = set.projects.filter(\n\t\t(p) =>\n\t\t\t(!projectId || p.id === projectId) &&\n\t\t\tcanCreateDefinition(projectAccessInputFromRowsWith({ deps }, ctx, p, rowsFor(p)))\n\t);\n\n\tconst page = await deps.definitionMeta.list(ctx, {\n\t\t...listOpts,\n\t\tsourceDocumentId: documentId,\n\t\tprojectIds: candidates.map((p) => p.id)\n\t});\n\tconst items = page.items.filter((record) => {\n\t\tconst project = set.allById.get(record.projectId);\n\t\treturn project\n\t\t\t? mayUploadToDefinition(ctx, { record, project, ...rowsFor(project) }, deps)\n\t\t\t: false;\n\t});\n\treturn { items, nextCursor: page.nextCursor };\n}\n\n/** A visible definition and the caller's rows that decided it. */\nexport interface VisibleDefinition {\n\trecord: DefinitionRecord;\n\tproject: Project;\n\tmember: ProjectMember | null;\n\torgMember: OrgMember | null;\n}\n\n/**\n * One definition, or `null` when the caller cannot view its project.\n *\n * Returns `null` rather than throwing 403 so callers surface a 404: a public\n * API that answers \"forbidden\" for a guid the caller cannot see turns\n * `/definitions/{guid}` into a cross-tenant existence oracle.\n */\nexport async function getVisibleDefinition(\n\tctx: RequestContext,\n\tguid: string,\n\tdeps: VisibilityDeps\n): Promise<DefinitionRecord | null> {\n\treturn (await loadVisibleDefinition(ctx, guid, deps))?.record ?? null;\n}\n\n/** {@link getVisibleDefinition} with the rows it read, for a second rule over the same caller. */\nexport async function loadVisibleDefinition(\n\tctx: RequestContext,\n\tguid: string,\n\tdeps: VisibilityDeps\n): Promise<VisibleDefinition | null> {\n\tconst meta = deps.definitionMeta;\n\tconst projectStore = deps.projects;\n\n\tconst record = await meta.get(ctx, guid);\n\tif (!record) return null;\n\n\tconst project = await projectStore.getProject(SYSTEM_CONTEXT, record.projectId);\n\tif (!project || outsideTokenOrg(ctx, project.orgId)) return null;\n\n\tconst [orgMembers, projectMembers, grants] = await Promise.all([\n\t\tdeps.orgs.getOrgMembersFor(SYSTEM_CONTEXT, [project.orgId], ctx.userId),\n\t\tprojectStore.getProjectMembersFor(SYSTEM_CONTEXT, [project.id], ctx.userId),\n\t\tproject.visibility === 'platform'\n\t\t\t? deps.platformProjectGrants.listByProject(SYSTEM_CONTEXT, project.id)\n\t\t\t: Promise.resolve([] as PlatformProjectGrant[])\n\t]);\n\n\tconst member = projectMembers.get(project.id) ?? null;\n\tconst orgMember = orgMembers.get(project.orgId) ?? null;\n\tconst allowed = canView(\n\t\tprojectAccessInputFromRowsWith({ deps }, ctx, project, {\n\t\t\tmember,\n\t\t\torgMember,\n\t\t\tplatformGrants: grants\n\t\t})\n\t);\n\treturn allowed ? { record, project, member, orgMember } : null;\n}\n\n/**\n * May the caller upload a version of this definition and make one live? The\n * rule `requireEditableDefinition` applies, and for an API token its `upload`\n * scope on the definition, which is what those routes check.\n */\nexport function mayUploadToDefinition(\n\tctx: RequestContext,\n\t{ record, project, member, orgMember }: VisibleDefinition,\n\tdeps: Pick<VisibilityDeps, 'flag'>\n): boolean {\n\treturn (\n\t\tscopeAllows(ctx, 'upload', { definitionId: record.guid, projectId: project.id }) &&\n\t\tcanEditDefinition({\n\t\t\tproject,\n\t\t\tdefinition: record,\n\t\t\tmember,\n\t\t\torgMember,\n\t\t\tuserId: ctx.userId,\n\t\t\tplatformPermissions: ctx.platformPermissions,\n\t\t\tenablePlatformProjects: deps.flag('ENABLE_PLATFORM_PROJECTS')\n\t\t})\n\t);\n}\n\n/**\n * One version of a definition the caller can view, including its cached\n * `schema`. `null` when the definition is invisible, the version is missing, or\n * the version belongs to a different definition — a caller must not be able to\n * read an arbitrary version by pairing it with a guid they can see.\n */\nexport async function loadVisibleVersion(\n\tctx: RequestContext,\n\tguid: string,\n\tversionId: string,\n\tdeps: VisibilityDeps\n): Promise<DefinitionVersion | null> {\n\tconst record = await getVisibleDefinition(ctx, guid, deps);\n\tif (!record) return null;\n\n\tconst version = await deps.definitionMeta.getVersion(ctx, versionId);\n\tif (!version || version.definitionId !== record.guid) return null;\n\treturn version;\n}\n","import type { ILogger, LogFields, LogLevel } from '@selvajs/platform';\n\n/**\n * `ILogger` backed by pino, with a console-backed fallback.\n *\n * pino is an OPTIONAL peer dependency, imported dynamically so the base install\n * ships without it. Unlike `@sentry/node` next door, absence must NOT degrade to\n * silence — an operator who never configured a logging backend still needs\n * warnings and errors on stdout, so {@link createLogger} falls back to\n * {@link ConsoleLogger} rather than returning `null`.\n *\n * pino earns its place by writing newline-delimited JSON with a stable schema:\n * what every log collector expects, and what console template literals can't\n * produce.\n */\n\n/** The slice of pino's surface used here — a hard import would make it mandatory. */\ninterface PinoLike {\n\tdebug(obj: object, msg?: string): void;\n\tinfo(obj: object, msg?: string): void;\n\twarn(obj: object, msg?: string): void;\n\terror(obj: object, msg?: string): void;\n\tchild(bindings: object): PinoLike;\n}\n\ntype PinoFactory = (options: {\n\tlevel: string;\n\tbase: object | undefined;\n\tredact?: { paths: string[]; censor: string };\n\ttransport?: { target: string; options: object };\n}) => PinoLike;\n\n/**\n * Field names scrubbed before a record is written, by both backends. A backstop\n * for accidents, NOT a licence to log objects: call sites are required not to\n * log secrets in the first place (see `LogFields`). This catches the case where\n * a whole object is spread into fields and happens to carry a credential.\n *\n * It matches by FIELD NAME, and only at the top level or one level deep. It will\n * not catch personal data: an email nested in a payload sails straight through,\n * and a log line reaches a collector that erasure can never reach.\n */\nconst REDACTED_KEYS = [\n\t'token',\n\t'sessionToken',\n\t'refreshToken',\n\t'apiKey',\n\t'api_key',\n\t'password',\n\t'authorization',\n\t'Authorization',\n\t'cookie',\n\t// A freshly minted API token is returned as `secret`.\n\t'secret'\n];\n\nconst CENSOR = '[redacted]';\nconst REDACTED = new Set(REDACTED_KEYS);\nconst REDACTED_PATHS = [...REDACTED_KEYS, ...REDACTED_KEYS.map((k) => `*.${k}`)];\n\n/** {@link REDACTED_KEYS} applied the way pino applies its paths, on a copy. */\nfunction redact(fields: LogFields): LogFields {\n\tconst out: LogFields = {};\n\tfor (const [key, value] of Object.entries(fields)) {\n\t\tout[key] = REDACTED.has(key) ? CENSOR : redactOneLevel(value);\n\t}\n\treturn out;\n}\n\nfunction redactOneLevel(value: unknown): unknown {\n\tif (value === null || typeof value !== 'object' || Array.isArray(value)) return value;\n\tif (!Object.keys(value).some((k) => REDACTED.has(k))) return value;\n\treturn Object.fromEntries(\n\t\tObject.entries(value).map(([k, v]) => [k, REDACTED.has(k) ? CENSOR : v])\n\t);\n}\n\n/**\n * Minimal `ILogger` over `console.*`, used when pino isn't installed. Renders\n * as `LEVEL message {fields}` — greppable, and honest about not being\n * machine-parseable. `child` fields merge eagerly so correlation still works.\n */\nexport class ConsoleLogger implements ILogger {\n\tconstructor(\n\t\tprivate readonly bound: LogFields = {},\n\t\tprivate readonly minLevel: LogLevel = 'info'\n\t) {}\n\n\tprivate static readonly ORDER: Record<LogLevel, number> = {\n\t\tdebug: 10,\n\t\tinfo: 20,\n\t\twarn: 30,\n\t\terror: 40\n\t};\n\n\tprivate write(level: LogLevel, message: string, fields?: LogFields): void {\n\t\tif (ConsoleLogger.ORDER[level] < ConsoleLogger.ORDER[this.minLevel]) return;\n\t\tconst merged = { ...this.bound, ...fields };\n\t\tconst suffix = Object.keys(merged).length > 0 ? ` ${renderFields(merged)}` : '';\n\t\tconst line = `${level.toUpperCase()} ${message}${suffix}`;\n\t\t// Split stderr/stdout the way an operator expects. `info` carries debug\n\t\t// too — both land on stdout, and the line already spells out its level.\n\t\tif (level === 'error') console.error(line);\n\t\telse if (level === 'warn') console.warn(line);\n\t\telse console.info(line);\n\t}\n\n\tdebug(message: string, fields?: LogFields): void {\n\t\tthis.write('debug', message, fields);\n\t}\n\tinfo(message: string, fields?: LogFields): void {\n\t\tthis.write('info', message, fields);\n\t}\n\twarn(message: string, fields?: LogFields): void {\n\t\tthis.write('warn', message, fields);\n\t}\n\terror(message: string, fields?: LogFields): void {\n\t\tthis.write('error', message, fields);\n\t}\n\tchild(fields: LogFields): ILogger {\n\t\treturn new ConsoleLogger({ ...this.bound, ...fields }, this.minLevel);\n\t}\n}\n\n/** Fields can hold anything, including cycles. Never let rendering throw. */\nfunction renderFields(fields: LogFields): string {\n\ttry {\n\t\treturn JSON.stringify(redact(fields)) ?? String(fields);\n\t} catch {\n\t\treturn '[unserializable]';\n\t}\n}\n\nclass PinoLogger implements ILogger {\n\tconstructor(private readonly pino: PinoLike) {}\n\n\t// pino takes (fields, message); ILogger takes (message, fields). The flip is\n\t// deliberate — the message is what a human scans for first.\n\tdebug(message: string, fields?: LogFields): void {\n\t\ttry {\n\t\t\tthis.pino.debug(fields ?? {}, message);\n\t\t} catch {\n\t\t\t/* logging must never throw */\n\t\t}\n\t}\n\tinfo(message: string, fields?: LogFields): void {\n\t\ttry {\n\t\t\tthis.pino.info(fields ?? {}, message);\n\t\t} catch {\n\t\t\t/* logging must never throw */\n\t\t}\n\t}\n\twarn(message: string, fields?: LogFields): void {\n\t\ttry {\n\t\t\tthis.pino.warn(fields ?? {}, message);\n\t\t} catch {\n\t\t\t/* logging must never throw */\n\t\t}\n\t}\n\terror(message: string, fields?: LogFields): void {\n\t\ttry {\n\t\t\tthis.pino.error(fields ?? {}, message);\n\t\t} catch {\n\t\t\t/* logging must never throw */\n\t\t}\n\t}\n\tchild(fields: LogFields): ILogger {\n\t\ttry {\n\t\t\treturn new PinoLogger(this.pino.child(fields));\n\t\t} catch {\n\t\t\treturn this;\n\t\t}\n\t}\n}\n\nexport interface CreateLoggerOptions {\n\t/** Minimum level written; records below it are dropped. Defaults to `info`. */\n\tlevel?: LogLevel;\n\t/**\n\t * Pretty-print via `pino-pretty` instead of JSON — for local development;\n\t * production wants JSON for the collector. Asking for this without\n\t * `pino-pretty` installed drops the whole logger to {@link ConsoleLogger}.\n\t */\n\tpretty?: boolean;\n\t/** Fields stamped on every record (e.g. service name, release). */\n\tbase?: LogFields;\n}\n\n/** Build the app's root logger. Never throws, never returns `null`. */\nexport async function createLogger(opts: CreateLoggerOptions = {}): Promise<ILogger> {\n\tconst level = opts.level ?? 'info';\n\ttry {\n\t\tconst factory = await loadPinoFactory();\n\t\tif (!factory) return new ConsoleLogger(opts.base ?? {}, level);\n\t\tconst pino = factory({\n\t\t\tlevel,\n\t\t\tbase: opts.base,\n\t\t\tredact: { paths: REDACTED_PATHS, censor: CENSOR },\n\t\t\ttransport: opts.pretty\n\t\t\t\t? { target: 'pino-pretty', options: { colorize: true, ignore: 'pid,hostname' } }\n\t\t\t\t: undefined\n\t\t});\n\t\treturn new PinoLogger(pino);\n\t} catch (err) {\n\t\t// pino resolved but wouldn't construct — a real misconfiguration (e.g.\n\t\t// `pretty: true` with pino-pretty absent). Worth complaining about, unlike\n\t\t// a merely absent package: the operator asked for something they didn't get.\n\t\tconsole.warn(\n\t\t\t`[Logger] pino was found but could not be initialized; falling back to console logging. ${String(err)}`\n\t\t);\n\t\treturn new ConsoleLogger(opts.base ?? {}, level);\n\t}\n}\n\n/**\n * Load pino's factory, or `null` when it isn't installed.\n *\n * Don't inline the specifier. A literal `import('pino')` is statically\n * analyzable, so Vite applied browser-field mapping to this server build and\n * resolved it to pino's `server_false` browser shim — a stub whose factory\n * throws, turning \"use pino\" into a silent fall back to the console. Computing\n * the specifier defeats that and leaves the import to Node at runtime.\n * `@vite-ignore` alone was NOT enough: it silenced the warning and the rewrite\n * still happened.\n */\nasync function loadPinoFactory(): Promise<PinoFactory | null> {\n\tconst specifier = 'pino';\n\ttry {\n\t\tconst mod = await import(/* @vite-ignore */ specifier);\n\t\tconst factory = ((mod as { default?: unknown }).default ?? mod) as PinoFactory;\n\t\treturn typeof factory === 'function' ? factory : null;\n\t} catch {\n\t\t// Not installed — the expected path on a base install, where the console\n\t\t// fallback is intended. Quiet on purpose: complaining at boot about an\n\t\t// optional package nobody asked for is noise.\n\t\treturn null;\n\t}\n}\n","/**\n * Request-id resolution for log correlation. Every record on a request path\n * carries the same `requestId`, so an operator handed one id can reconstruct\n * that request's whole story.\n *\n * Inbound ids are TRUSTED when present. Selva runs behind a reverse proxy\n * (Caddy/nginx) that mints a request id for its own access logs; minting a\n * second one here would split one request across two ids and kill cross-tier\n * correlation. The trade — a direct caller picks their own id — is fine, because\n * the id is only ever a log field and an echoed response header, never an\n * authorization or uniqueness input.\n *\n * That trust is why {@link sanitizeRequestId} exists: an attacker-chosen id is\n * untrusted content. Unbounded or newline-carrying values would let a caller\n * forge log lines (log injection) or bloat every record on the request.\n */\n\n/** Header carrying a caller/proxy-supplied id. The de-facto standard spelling. */\nexport const REQUEST_ID_HEADER = 'x-request-id';\n\n/** Long enough for a UUID or a W3C trace-id, short enough to bound a record. */\nconst MAX_REQUEST_ID_LENGTH = 128;\n\n/**\n * Characters allowed through verbatim. Strict on purpose: UUIDs, ULIDs, hex\n * trace-ids and nginx's `$request_id` all fit. Everything else — whitespace,\n * control chars, quotes, CR/LF — is dropped rather than escaped, since no\n * legitimate id needs them and dropping can't be un-escaped downstream.\n */\nconst UNSAFE_REQUEST_ID_CHARS = /[^A-Za-z0-9._:-]/g;\n\n/** Returns `null` when nothing usable survives, so the caller generates instead. */\nexport function sanitizeRequestId(raw: string | null | undefined): string | null {\n\tif (!raw) return null;\n\tconst cleaned = raw.replace(UNSAFE_REQUEST_ID_CHARS, '').slice(0, MAX_REQUEST_ID_LENGTH);\n\treturn cleaned.length > 0 ? cleaned : null;\n}\n\n/**\n * Reuse the proxy's id when it survives sanitization, otherwise mint a UUID.\n *\n * @param generate injectable so tests get deterministic ids\n */\nexport function resolveRequestId(headers: Headers, generate: () => string = randomId): string {\n\treturn sanitizeRequestId(headers.get(REQUEST_ID_HEADER)) ?? generate();\n}\n\n/**\n * Render a thrown value into a log field.\n *\n * Not every rejection is an `Error` — provider adapters sometimes reject with a\n * plain `{ message, status }`, which would stringify to a useless\n * `[object Object]` and destroy the only record of the failure. Errors keep\n * their stack; anything else is JSON-serialized, with `String()` as the last\n * resort for cycles and exotic values.\n *\n * A `code` / `statusCode` carried on the error (ComputeError, ProviderError,\n * Node's ECONNREFUSED-style errors) is appended as a `[code=… status=…]` tag —\n * it classifies the failure and stacks alone don't show it.\n */\nexport function renderThrown(error: unknown): string {\n\tif (error instanceof Error) {\n\t\tconst base = error.stack ?? error.message;\n\t\tconst code = (error as { code?: unknown }).code;\n\t\tconst statusCode = (error as { statusCode?: unknown }).statusCode;\n\t\tconst tags: string[] = [];\n\t\tif (typeof code === 'string' || typeof code === 'number') tags.push(`code=${code}`);\n\t\tif (typeof statusCode === 'number') tags.push(`status=${statusCode}`);\n\t\treturn tags.length > 0 ? `${base} [${tags.join(' ')}]` : base;\n\t}\n\ttry {\n\t\treturn JSON.stringify(error) ?? String(error);\n\t} catch {\n\t\treturn String(error);\n\t}\n}\n\n/**\n * `crypto.randomUUID` exists in every runtime Selva targets (Node 22+, workers,\n * modern browsers); the `Math.random` branch only covers non-secure contexts\n * where it is missing. Not a weakness: these ids need to be collision-free\n * enough to correlate logs, never unguessable.\n */\nfunction randomId(): string {\n\tconst c: Crypto | undefined = globalThis.crypto;\n\tif (c && typeof c.randomUUID === 'function') return c.randomUUID();\n\treturn `req-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;\n}\n"],"mappings":";;;AAyBA,SAAgB,mBAAmB,QAAoC;CACtE,MAAM,SAAS,SAAS,SAAS,QAAQ,EAAE,IAAI;CAC/C,OAAO,OAAO,SAAS,MAAM,KAAK,UAAU,IAAI,SAAS;AAC1D;AAEA,SAAgB,mBAAmB,QAAwB;CAC1D,OAAO,OAAO,MAAM;AACrB;;;;;AAQA,gBAAuB,UAAa,WAAoD;CACvF,IAAI;CACJ,GAAG;EACF,MAAM,OAAO,MAAM,UAAU;GAAE,OAAA;GAAuB;EAAO,CAAC;EAC9D,MAAM;EACN,SAAS,KAAK;CACf,SAAS;AACV;;AAGA,eAAsB,QAAW,WAAyC;CACzE,MAAM,QAAa,CAAC;CACpB,WAAW,MAAM,QAAQ,UAAU,SAAS,GAAG,MAAM,KAAK,GAAG,KAAK,KAAK;CACvE,OAAO;AACR;;AAGA,SAAgB,eAAe,OAAmC;CACjE,MAAM,YAAY,SAAA;CAClB,IAAI,CAAC,OAAO,SAAS,SAAS,GAAG,OAAA;CACjC,OAAO,KAAK,IAAI,KAAK,IAAI,GAAG,KAAK,MAAM,SAAS,CAAC,GAAA,GAAiB;AACnE;;;;;;;;;;;;;;;;;;ACrBA,IAAM,aAAa;;;;;;AAsCnB,eAAsB,0BACrB,KACA,MACgC;CAChC,MAAM,OAAO,KAAK;CAClB,MAAM,eAAe,KAAK;CAC1B,MAAM,aAAa,KAAK;CAIxB,MAAM,UAAS,MAFQ,KAAK,SAAS,g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S,IAAI,GAAG,KAAK,IAAI,KAAK,KAAK,GAAG,EAAE,KAAK;CAC1D;CACA,IAAI;EACH,OAAO,KAAK,UAAU,KAAK,KAAK,OAAO,KAAK;CAC7C,QAAQ;EACP,OAAO,OAAO,KAAK;CACpB;AACD;;;;;;;AAQA,SAAS,WAAmB;CAC3B,MAAM,IAAwB,WAAW;CACzC,IAAI,KAAK,OAAO,EAAE,eAAe,YAAY,OAAO,EAAE,WAAW;CACjE,OAAO,OAAO,KAAK,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,GAAG,KAAK,OAAO,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,MAAM,GAAG,EAAE;AAChF"}
@@ -1,4 +1,4 @@
1
- import { k as ApiErrorCode } from "./access.js";
1
+ import { O as ApiErrorCode } from "./access.js";
2
2
  import "./api.js";
3
3
  import { t as V1_ENDPOINTS } from "./registry.js";
4
4
  import { z } from "zod";
@@ -1,3 +1,5 @@
1
+ import { L as RETENTION_SETTINGS, tt as readSetting } from "./access.js";
2
+ import { t as SYSTEM_CONTEXT } from "./context.js";
1
3
  import { t as COMPUTE_REQUEST_MAX_BYTES } from "./limits.js";
2
4
  // ../server/src/ops/deploymentConfig.ts
3
5
  /**
@@ -145,6 +147,67 @@ function checkClientAddress(env) {
145
147
  function checkDeploymentConfig(env) {
146
148
  return [checkClientAddress(env), checkBodySizeLimit(env)];
147
149
  }
148
- export { checkDeploymentConfig as t };
150
+ // ../server/src/ops/retention.ts
151
+ var DAY_MS = 864e5;
152
+ /**
153
+ * `SELVA_AUDIT_RETENTION_DAYS` and `SELVA_SOLVE_METRICS_RETENTION_DAYS`. Unset, 0
154
+ * or invalid keeps the table forever: the boot config check reports an invalid value.
155
+ */
156
+ function resolveRetentionPolicy(env) {
157
+ const days = (key) => {
158
+ const value = readSetting(RETENTION_SETTINGS.find((s) => s.key === key), env);
159
+ return typeof value === "number" && value > 0 ? value : void 0;
160
+ };
161
+ return {
162
+ auditEventsDays: days("SELVA_AUDIT_RETENTION_DAYS"),
163
+ solveMetricsDays: days("SELVA_SOLVE_METRICS_RETENTION_DAYS")
164
+ };
165
+ }
166
+ function retentionCutoffs(policy, now) {
167
+ const before = (days) => days ? /* @__PURE__ */ new Date(now - days * DAY_MS) : void 0;
168
+ return {
169
+ auditEventsBefore: before(policy.auditEventsDays),
170
+ solveMetricsBefore: before(policy.solveMetricsDays)
171
+ };
172
+ }
173
+ /**
174
+ * Purges at start and then daily. Inert when the policy keeps everything or the
175
+ * provider has no `purgeExpired`. Every instance may run one: the purge is idempotent.
176
+ */
177
+ function startRetentionJanitor(options) {
178
+ const { data, policy, logger, intervalMs = DAY_MS, now = Date.now } = options;
179
+ const enabled = !!data.purgeExpired && (policy.auditEventsDays !== void 0 || policy.solveMetricsDays !== void 0);
180
+ let running;
181
+ async function purge() {
182
+ if (!enabled) return void 0;
183
+ try {
184
+ const result = await data.purgeExpired(SYSTEM_CONTEXT, retentionCutoffs(policy, now()));
185
+ if (result.auditEvents || result.solveMetrics) logger.info("Retention purge deleted expired rows", {
186
+ component: "retention",
187
+ auditEvents: result.auditEvents,
188
+ solveMetrics: result.solveMetrics
189
+ });
190
+ return result;
191
+ } catch (err) {
192
+ logger.error("Retention purge failed", {
193
+ component: "retention",
194
+ err: err instanceof Error ? err.message : String(err)
195
+ });
196
+ return;
197
+ }
198
+ }
199
+ const runOnce = () => running ??= purge().finally(() => running = void 0);
200
+ let timer;
201
+ if (enabled) {
202
+ runOnce();
203
+ timer = setInterval(() => void runOnce(), intervalMs);
204
+ timer.unref?.();
205
+ }
206
+ return {
207
+ runOnce,
208
+ stop: () => clearInterval(timer)
209
+ };
210
+ }
211
+ export { startRetentionJanitor as n, checkDeploymentConfig as r, resolveRetentionPolicy as t };
149
212
 
150
213
  //# sourceMappingURL=ops.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ops.js","names":[],"sources":["../../../../server/src/ops/deploymentConfig.ts"],"sourcesContent":["/**\n * Reverse-proxy and body-limit configuration rules, evaluated against a plain\n * env bag. Pure predicates — no filesystem, no network, no process.\n *\n * These settings are read by adapter-node, not by Selva, so getting them wrong\n * is invisible: nothing throws, nothing logs, and the deployment serves traffic\n * while a whole class of requests fails. `selva doctor` reports them on the\n * host; the admin health panel runs the same rules so an operator who never\n * opens a shell still sees them.\n *\n * `packages/cli/src/checks/config.js` carries a duplicate of every rule here.\n * Duplicated because the CLI is dependency-free by design — it scaffolds the\n * deployment that installs this runtime, so it cannot import from it. A shared\n * fixture table (`ops/__tests__/deployment-config-fixtures.js`) is asserted by\n * both test suites, so a rule changed on one side fails CI on the other.\n */\n\nimport { COMPUTE_REQUEST_MAX_BYTES } from '../compute/limits.js';\n\n/** Neutral severity. Callers map it onto their own presentation. */\nexport type ConfigVerdict = 'ok' | 'warn' | 'fail';\n\nexport interface ConfigFinding {\n\tid: string;\n\tlabel: string;\n\tverdict: ConfigVerdict;\n\tsummary: string;\n\t/** Concrete next step. Absent when the verdict is `ok`. */\n\tremediation?: string;\n}\n\n/** Just the vars these rules read. Values are raw strings, as they come from `.env`. */\nexport interface DeploymentEnv {\n\tORIGIN?: string;\n\tADDRESS_HEADER?: string;\n\tXFF_DEPTH?: string;\n\tHOST?: string;\n\tBODY_SIZE_LIMIT?: string;\n\t// Callers hand over a whole env bag (`process.env`, `$env/dynamic/private`),\n\t// which carries far more than these keys. Without this, an env bag typed as a\n\t// bare index signature has no declared property in common with an all-optional\n\t// interface, and TS's weak-type check rejects it at every call site.\n\t[key: string]: string | undefined;\n}\n\n/**\n * Parse a `BODY_SIZE_LIMIT` the way adapter-node does, so this agrees with the\n * thing that actually rejects the request.\n *\n * The quirk is load-bearing: adapter-node reads only the LAST character as the\n * suffix, so `60mb` parses as the digits `60m` and happens to mean 60 MB, while\n * `60xy` silently becomes NaN. Returns bytes, or null when the value is one\n * adapter-node can't use.\n */\nexport function parseBodySizeLimit(raw: string | undefined | null): number | null {\n\tif (raw == null || raw === '') return null;\n\tconst value = String(raw).trim();\n\tif (value === '') return null;\n\n\tconst units: Record<string, number> = { K: 1024, M: 1024 * 1024, G: 1024 * 1024 * 1024 };\n\tconst multiplier = units[value.at(-1)!.toUpperCase()] ?? 1;\n\tconst bytes = Number(multiplier !== 1 ? value.slice(0, -1) : value) * multiplier;\n\tif (!Number.isFinite(bytes) || bytes <= 0) return null;\n\treturn bytes;\n}\n\nconst asMb = (bytes: number) => `${Math.round(bytes / (1024 * 1024))} MB`;\n\n/**\n * BODY_SIZE_LIMIT has to clear the compute request cap, or adapter-node's global\n * backstop rejects the upload first — with a non-JSON body the app never sees\n * and cannot log. Unset is the dangerous case, not a neutral one: adapter-node\n * falls back to 512 KB, so every upload 413s on a deployment that looks fine.\n */\nexport function checkBodySizeLimit(env: DeploymentEnv): ConfigFinding {\n\tconst base = { id: 'body-size-limit', label: 'Upload size limit' };\n\tconst raw = env.BODY_SIZE_LIMIT;\n\tconst requestCap = COMPUTE_REQUEST_MAX_BYTES;\n\n\tif (raw == null || raw === '') {\n\t\treturn {\n\t\t\t...base,\n\t\t\tverdict: 'fail',\n\t\t\tsummary:\n\t\t\t\t'BODY_SIZE_LIMIT is unset — adapter-node falls back to 512 KB, so uploads over ' +\n\t\t\t\t'that fail with an opaque 413 no app log records.',\n\t\t\tremediation: `Set BODY_SIZE_LIMIT to at least ${asMb(requestCap)} (the compute request cap) and restart.`\n\t\t};\n\t}\n\n\tconst bytes = parseBodySizeLimit(raw);\n\tif (bytes === null) {\n\t\treturn {\n\t\t\t...base,\n\t\t\tverdict: 'fail',\n\t\t\tsummary: `BODY_SIZE_LIMIT=\"${raw}\" — adapter-node cannot parse this and throws on boot.`,\n\t\t\tremediation: 'Use a byte count or a single K/M/G suffix, e.g. \"256M\".'\n\t\t};\n\t}\n\n\tif (bytes < requestCap) {\n\t\treturn {\n\t\t\t...base,\n\t\t\tverdict: 'warn',\n\t\t\tsummary:\n\t\t\t\t`BODY_SIZE_LIMIT=${raw} (${asMb(bytes)}) is below the ` +\n\t\t\t\t`${asMb(requestCap)} a solve may send — larger solves fail with 413 before Selva sees them.`,\n\t\t\tremediation: `Raise BODY_SIZE_LIMIT to at least ${asMb(requestCap)} and restart.`\n\t\t};\n\t}\n\n\treturn {\n\t\t...base,\n\t\tverdict: 'ok',\n\t\tsummary: `BODY_SIZE_LIMIT=${raw} clears the compute request cap.`\n\t};\n}\n\n/**\n * `ADDRESS_HEADER` / `XFF_DEPTH` are read by adapter-node, not by Selva, and\n * unset they are invisible: nothing fails, nothing logs, and the deployment\n * looks healthy.\n *\n * What actually happens is that `getClientAddress()` returns the socket peer,\n * which behind a reverse proxy is the proxy — `127.0.0.1` for every request\n * from every user. Login rate limiting keys on that, so the whole instance\n * shares one bucket: five failed logins from anywhere return 429 to everyone,\n * and only a *successful* login clears a bucket, which nobody can then reach.\n *\n * `ORIGIN` is the proxy tell. It is only needed when the app is served under a\n * public URL it can't derive from its own socket, so its presence means a proxy\n * is terminating requests. Without it we say nothing: on a directly-reachable\n * app these settings are a footgun, since `X-Forwarded-For` is client-supplied\n * and anyone could then pick their own rate-limit bucket.\n */\nexport function checkClientAddress(env: DeploymentEnv): ConfigFinding {\n\tconst base = { id: 'client-address', label: 'Client IP behind proxy' };\n\tconst header = env.ADDRESS_HEADER;\n\tconst depth = env.XFF_DEPTH;\n\n\tif (!env.ORIGIN) {\n\t\treturn {\n\t\t\t...base,\n\t\t\tverdict: 'ok',\n\t\t\tsummary: 'ADDRESS_HEADER is not needed — ORIGIN is unset, so no reverse proxy is in play.'\n\t\t};\n\t}\n\n\tif (!header) {\n\t\treturn {\n\t\t\t...base,\n\t\t\tverdict: 'fail',\n\t\t\tsummary:\n\t\t\t\t'ADDRESS_HEADER is unset while ORIGIN is set — every request looks like it came from ' +\n\t\t\t\t'the proxy, so all users share ONE login rate-limit bucket. Five failed logins from ' +\n\t\t\t\t'anyone locks out the whole instance for 15 minutes.',\n\t\t\tremediation:\n\t\t\t\t'Set ADDRESS_HEADER=X-Forwarded-For and XFF_DEPTH=<number of proxies>, then restart. ' +\n\t\t\t\t'To count your proxies, see docs/self-hosting/deployment/reverse-proxy.md.'\n\t\t};\n\t}\n\n\tif (header.toLowerCase() === 'x-forwarded-for' && !depth) {\n\t\treturn {\n\t\t\t...base,\n\t\t\tverdict: 'warn',\n\t\t\tsummary:\n\t\t\t\t`ADDRESS_HEADER=${header} but XFF_DEPTH is unset. X-Forwarded-For is a ` +\n\t\t\t\t'client-appendable list, so a caller can prepend fake entries — adapter-node needs ' +\n\t\t\t\t'the proxy count to know which entry is real.',\n\t\t\tremediation:\n\t\t\t\t'Set XFF_DEPTH=1 for a single reverse proxy, 2 if a CDN or load balancer sits in ' +\n\t\t\t\t'front of it. Unsure? docs/self-hosting/deployment/reverse-proxy.md shows how to ' +\n\t\t\t\t'read the header the app actually receives.'\n\t\t};\n\t}\n\n\tif (depth !== undefined && !/^[1-9][0-9]*$/.test(depth)) {\n\t\treturn {\n\t\t\t...base,\n\t\t\tverdict: 'fail',\n\t\t\tsummary: `XFF_DEPTH=\"${depth}\" is not a positive integer.`,\n\t\t\tremediation: 'It counts proxies from the outside in — use 1 for a single reverse proxy.'\n\t\t};\n\t}\n\n\t// A trusted address header is only safe if every request passes through the\n\t// proxy: on a public bind a direct caller sets the header itself and picks\n\t// its own rate-limit bucket.\n\tconst host = env.HOST ?? '0.0.0.0';\n\tif (!['127.0.0.1', 'localhost', '::1'].includes(host)) {\n\t\treturn {\n\t\t\t...base,\n\t\t\tverdict: 'warn',\n\t\t\tsummary:\n\t\t\t\t`ADDRESS_HEADER=${header} is trusted but HOST=${host} leaves the app reachable ` +\n\t\t\t\t'without the proxy, so a direct caller can set the header and pick its own ' +\n\t\t\t\t'rate-limit bucket.',\n\t\t\tremediation:\n\t\t\t\t'Set HOST=127.0.0.1 and keep port 3000 closed in the firewall. Ignore this only ' +\n\t\t\t\t'if the proxy runs on another host and network isolation keeps everything else out.'\n\t\t};\n\t}\n\n\treturn {\n\t\t...base,\n\t\tverdict: 'ok',\n\t\tsummary: `ADDRESS_HEADER=${header}${depth ? ` (XFF_DEPTH=${depth})` : ''}.`\n\t};\n}\n\n/** Every deployment-config rule, in report order. */\nexport function checkDeploymentConfig(env: DeploymentEnv): ConfigFinding[] {\n\treturn [checkClientAddress(env), checkBodySizeLimit(env)];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,SAAgB,mBAAmB,KAA+C;CACjF,IAAI,OAAO,QAAQ,QAAQ,IAAI,OAAO;CACtC,MAAM,QAAQ,OAAO,GAAG,CAAC,CAAC,KAAK;CAC/B,IAAI,UAAU,IAAI,OAAO;CAGzB,MAAM,aAAa;EADqB,GAAG;EAAM,GAAG;EAAa,GAAG;CACjD,EAAM,MAAM,GAAG,EAAE,CAAC,CAAE,YAAY,MAAM;CACzD,MAAM,QAAQ,OAAO,eAAe,IAAI,MAAM,MAAM,GAAG,EAAE,IAAI,KAAK,IAAI;CACtE,IAAI,CAAC,OAAO,SAAS,KAAK,KAAK,SAAS,GAAG,OAAO;CAClD,OAAO;AACR;AAEA,IAAM,QAAQ,UAAkB,GAAG,KAAK,MAAM,QAAS,OAAY,EAAE;;;;;;;AAQrE,SAAgB,mBAAmB,KAAmC;CACrE,MAAM,OAAO;EAAE,IAAI;EAAmB,OAAO;CAAoB;CACjE,MAAM,MAAM,IAAI;CAChB,MAAM,aAAa;CAEnB,IAAI,OAAO,QAAQ,QAAQ,IAC1B,OAAO;EACN,GAAG;EACH,SAAS;EACT,SACC;EAED,aAAa,mCAAmC,KAAK,UAAU,EAAE;CAClE;CAGD,MAAM,QAAQ,mBAAmB,GAAG;CACpC,IAAI,UAAU,MACb,OAAO;EACN,GAAG;EACH,SAAS;EACT,SAAS,oBAAoB,IAAI;EACjC,aAAa;CACd;CAGD,IAAI,QAAQ,YACX,OAAO;EACN,GAAG;EACH,SAAS;EACT,SACC,mBAAmB,IAAI,IAAI,KAAK,KAAK,EAAE,iBACpC,KAAK,UAAU,EAAE;EACrB,aAAa,qCAAqC,KAAK,UAAU,EAAE;CACpE;CAGD,OAAO;EACN,GAAG;EACH,SAAS;EACT,SAAS,mBAAmB,IAAI;CACjC;AACD;;;;;;;;;;;;;;;;;;AAmBA,SAAgB,mBAAmB,KAAmC;CACrE,MAAM,OAAO;EAAE,IAAI;EAAkB,OAAO;CAAyB;CACrE,MAAM,SAAS,IAAI;CACnB,MAAM,QAAQ,IAAI;CAElB,IAAI,CAAC,IAAI,QACR,OAAO;EACN,GAAG;EACH,SAAS;EACT,SAAS;CACV;CAGD,IAAI,CAAC,QACJ,OAAO;EACN,GAAG;EACH,SAAS;EACT,SACC;EAGD,aACC;CAEF;CAGD,IAAI,OAAO,YAAY,MAAM,qBAAqB,CAAC,OAClD,OAAO;EACN,GAAG;EACH,SAAS;EACT,SACC,kBAAkB,OAAO;EAG1B,aACC;CAGF;CAGD,IAAI,UAAU,KAAA,KAAa,CAAC,gBAAgB,KAAK,KAAK,GACrD,OAAO;EACN,GAAG;EACH,SAAS;EACT,SAAS,cAAc,MAAM;EAC7B,aAAa;CACd;CAMD,MAAM,OAAO,IAAI,QAAQ;CACzB,IAAI,CAAC;EAAC;EAAa;EAAa;CAAK,CAAC,CAAC,SAAS,IAAI,GACnD,OAAO;EACN,GAAG;EACH,SAAS;EACT,SACC,kBAAkB,OAAO,uBAAuB,KAAK;EAGtD,aACC;CAEF;CAGD,OAAO;EACN,GAAG;EACH,SAAS;EACT,SAAS,kBAAkB,SAAS,QAAQ,eAAe,MAAM,KAAK,GAAG;CAC1E;AACD;;AAGA,SAAgB,sBAAsB,KAAqC;CAC1E,OAAO,CAAC,mBAAmB,GAAG,GAAG,mBAAmB,GAAG,CAAC;AACzD"}
1
+ {"version":3,"file":"ops.js","names":[],"sources":["../../../../server/src/ops/deploymentConfig.ts","../../../../server/src/ops/retention.ts"],"sourcesContent":["/**\n * Reverse-proxy and body-limit configuration rules, evaluated against a plain\n * env bag. Pure predicates — no filesystem, no network, no process.\n *\n * These settings are read by adapter-node, not by Selva, so getting them wrong\n * is invisible: nothing throws, nothing logs, and the deployment serves traffic\n * while a whole class of requests fails. `selva doctor` reports them on the\n * host; the admin health panel runs the same rules so an operator who never\n * opens a shell still sees them.\n *\n * `packages/cli/src/checks/config.js` carries a duplicate of every rule here.\n * Duplicated because the CLI is dependency-free by design — it scaffolds the\n * deployment that installs this runtime, so it cannot import from it. A shared\n * fixture table (`ops/__tests__/deployment-config-fixtures.js`) is asserted by\n * both test suites, so a rule changed on one side fails CI on the other.\n */\n\nimport { COMPUTE_REQUEST_MAX_BYTES } from '../compute/limits.js';\n\n/** Neutral severity. Callers map it onto their own presentation. */\nexport type ConfigVerdict = 'ok' | 'warn' | 'fail';\n\nexport interface ConfigFinding {\n\tid: string;\n\tlabel: string;\n\tverdict: ConfigVerdict;\n\tsummary: string;\n\t/** Concrete next step. Absent when the verdict is `ok`. */\n\tremediation?: string;\n}\n\n/** Just the vars these rules read. Values are raw strings, as they come from `.env`. */\nexport interface DeploymentEnv {\n\tORIGIN?: string;\n\tADDRESS_HEADER?: string;\n\tXFF_DEPTH?: string;\n\tHOST?: string;\n\tBODY_SIZE_LIMIT?: string;\n\t// Callers hand over a whole env bag (`process.env`, `$env/dynamic/private`),\n\t// which carries far more than these keys. Without this, an env bag typed as a\n\t// bare index signature has no declared property in common with an all-optional\n\t// interface, and TS's weak-type check rejects it at every call site.\n\t[key: string]: string | undefined;\n}\n\n/**\n * Parse a `BODY_SIZE_LIMIT` the way adapter-node does, so this agrees with the\n * thing that actually rejects the request.\n *\n * The quirk is load-bearing: adapter-node reads only the LAST character as the\n * suffix, so `60mb` parses as the digits `60m` and happens to mean 60 MB, while\n * `60xy` silently becomes NaN. Returns bytes, or null when the value is one\n * adapter-node can't use.\n */\nexport function parseBodySizeLimit(raw: string | undefined | null): number | null {\n\tif (raw == null || raw === '') return null;\n\tconst value = String(raw).trim();\n\tif (value === '') return null;\n\n\tconst units: Record<string, number> = { K: 1024, M: 1024 * 1024, G: 1024 * 1024 * 1024 };\n\tconst multiplier = units[value.at(-1)!.toUpperCase()] ?? 1;\n\tconst bytes = Number(multiplier !== 1 ? value.slice(0, -1) : value) * multiplier;\n\tif (!Number.isFinite(bytes) || bytes <= 0) return null;\n\treturn bytes;\n}\n\nconst asMb = (bytes: number) => `${Math.round(bytes / (1024 * 1024))} MB`;\n\n/**\n * BODY_SIZE_LIMIT has to clear the compute request cap, or adapter-node's global\n * backstop rejects the upload first — with a non-JSON body the app never sees\n * and cannot log. Unset is the dangerous case, not a neutral one: adapter-node\n * falls back to 512 KB, so every upload 413s on a deployment that looks fine.\n */\nexport function checkBodySizeLimit(env: DeploymentEnv): ConfigFinding {\n\tconst base = { id: 'body-size-limit', label: 'Upload size limit' };\n\tconst raw = env.BODY_SIZE_LIMIT;\n\tconst requestCap = COMPUTE_REQUEST_MAX_BYTES;\n\n\tif (raw == null || raw === '') {\n\t\treturn {\n\t\t\t...base,\n\t\t\tverdict: 'fail',\n\t\t\tsummary:\n\t\t\t\t'BODY_SIZE_LIMIT is unset — adapter-node falls back to 512 KB, so uploads over ' +\n\t\t\t\t'that fail with an opaque 413 no app log records.',\n\t\t\tremediation: `Set BODY_SIZE_LIMIT to at least ${asMb(requestCap)} (the compute request cap) and restart.`\n\t\t};\n\t}\n\n\tconst bytes = parseBodySizeLimit(raw);\n\tif (bytes === null) {\n\t\treturn {\n\t\t\t...base,\n\t\t\tverdict: 'fail',\n\t\t\tsummary: `BODY_SIZE_LIMIT=\"${raw}\" — adapter-node cannot parse this and throws on boot.`,\n\t\t\tremediation: 'Use a byte count or a single K/M/G suffix, e.g. \"256M\".'\n\t\t};\n\t}\n\n\tif (bytes < requestCap) {\n\t\treturn {\n\t\t\t...base,\n\t\t\tverdict: 'warn',\n\t\t\tsummary:\n\t\t\t\t`BODY_SIZE_LIMIT=${raw} (${asMb(bytes)}) is below the ` +\n\t\t\t\t`${asMb(requestCap)} a solve may send — larger solves fail with 413 before Selva sees them.`,\n\t\t\tremediation: `Raise BODY_SIZE_LIMIT to at least ${asMb(requestCap)} and restart.`\n\t\t};\n\t}\n\n\treturn {\n\t\t...base,\n\t\tverdict: 'ok',\n\t\tsummary: `BODY_SIZE_LIMIT=${raw} clears the compute request cap.`\n\t};\n}\n\n/**\n * `ADDRESS_HEADER` / `XFF_DEPTH` are read by adapter-node, not by Selva, and\n * unset they are invisible: nothing fails, nothing logs, and the deployment\n * looks healthy.\n *\n * What actually happens is that `getClientAddress()` returns the socket peer,\n * which behind a reverse proxy is the proxy — `127.0.0.1` for every request\n * from every user. Login rate limiting keys on that, so the whole instance\n * shares one bucket: five failed logins from anywhere return 429 to everyone,\n * and only a *successful* login clears a bucket, which nobody can then reach.\n *\n * `ORIGIN` is the proxy tell. It is only needed when the app is served under a\n * public URL it can't derive from its own socket, so its presence means a proxy\n * is terminating requests. Without it we say nothing: on a directly-reachable\n * app these settings are a footgun, since `X-Forwarded-For` is client-supplied\n * and anyone could then pick their own rate-limit bucket.\n */\nexport function checkClientAddress(env: DeploymentEnv): ConfigFinding {\n\tconst base = { id: 'client-address', label: 'Client IP behind proxy' };\n\tconst header = env.ADDRESS_HEADER;\n\tconst depth = env.XFF_DEPTH;\n\n\tif (!env.ORIGIN) {\n\t\treturn {\n\t\t\t...base,\n\t\t\tverdict: 'ok',\n\t\t\tsummary: 'ADDRESS_HEADER is not needed — ORIGIN is unset, so no reverse proxy is in play.'\n\t\t};\n\t}\n\n\tif (!header) {\n\t\treturn {\n\t\t\t...base,\n\t\t\tverdict: 'fail',\n\t\t\tsummary:\n\t\t\t\t'ADDRESS_HEADER is unset while ORIGIN is set — every request looks like it came from ' +\n\t\t\t\t'the proxy, so all users share ONE login rate-limit bucket. Five failed logins from ' +\n\t\t\t\t'anyone locks out the whole instance for 15 minutes.',\n\t\t\tremediation:\n\t\t\t\t'Set ADDRESS_HEADER=X-Forwarded-For and XFF_DEPTH=<number of proxies>, then restart. ' +\n\t\t\t\t'To count your proxies, see docs/self-hosting/deployment/reverse-proxy.md.'\n\t\t};\n\t}\n\n\tif (header.toLowerCase() === 'x-forwarded-for' && !depth) {\n\t\treturn {\n\t\t\t...base,\n\t\t\tverdict: 'warn',\n\t\t\tsummary:\n\t\t\t\t`ADDRESS_HEADER=${header} but XFF_DEPTH is unset. X-Forwarded-For is a ` +\n\t\t\t\t'client-appendable list, so a caller can prepend fake entries — adapter-node needs ' +\n\t\t\t\t'the proxy count to know which entry is real.',\n\t\t\tremediation:\n\t\t\t\t'Set XFF_DEPTH=1 for a single reverse proxy, 2 if a CDN or load balancer sits in ' +\n\t\t\t\t'front of it. Unsure? docs/self-hosting/deployment/reverse-proxy.md shows how to ' +\n\t\t\t\t'read the header the app actually receives.'\n\t\t};\n\t}\n\n\tif (depth !== undefined && !/^[1-9][0-9]*$/.test(depth)) {\n\t\treturn {\n\t\t\t...base,\n\t\t\tverdict: 'fail',\n\t\t\tsummary: `XFF_DEPTH=\"${depth}\" is not a positive integer.`,\n\t\t\tremediation: 'It counts proxies from the outside in — use 1 for a single reverse proxy.'\n\t\t};\n\t}\n\n\t// A trusted address header is only safe if every request passes through the\n\t// proxy: on a public bind a direct caller sets the header itself and picks\n\t// its own rate-limit bucket.\n\tconst host = env.HOST ?? '0.0.0.0';\n\tif (!['127.0.0.1', 'localhost', '::1'].includes(host)) {\n\t\treturn {\n\t\t\t...base,\n\t\t\tverdict: 'warn',\n\t\t\tsummary:\n\t\t\t\t`ADDRESS_HEADER=${header} is trusted but HOST=${host} leaves the app reachable ` +\n\t\t\t\t'without the proxy, so a direct caller can set the header and pick its own ' +\n\t\t\t\t'rate-limit bucket.',\n\t\t\tremediation:\n\t\t\t\t'Set HOST=127.0.0.1 and keep port 3000 closed in the firewall. Ignore this only ' +\n\t\t\t\t'if the proxy runs on another host and network isolation keeps everything else out.'\n\t\t};\n\t}\n\n\treturn {\n\t\t...base,\n\t\tverdict: 'ok',\n\t\tsummary: `ADDRESS_HEADER=${header}${depth ? ` (XFF_DEPTH=${depth})` : ''}.`\n\t};\n}\n\n/** Every deployment-config rule, in report order. */\nexport function checkDeploymentConfig(env: DeploymentEnv): ConfigFinding[] {\n\treturn [checkClientAddress(env), checkBodySizeLimit(env)];\n}\n","import {\n\tSYSTEM_CONTEXT,\n\ttype IDataProvider,\n\ttype ILogger,\n\ttype PurgeResult,\n\ttype RetentionCutoffs\n} from '@selvajs/platform';\nimport { readSetting, type EnvRecord } from '@selvajs/platform/config';\nimport { RETENTION_SETTINGS } from '../config/settings.js';\n\nconst DAY_MS = 24 * 60 * 60 * 1000;\n\n/** Days each table is kept; undefined keeps it forever. */\nexport interface RetentionPolicy {\n\tauditEventsDays?: number;\n\tsolveMetricsDays?: number;\n}\n\n/**\n * `SELVA_AUDIT_RETENTION_DAYS` and `SELVA_SOLVE_METRICS_RETENTION_DAYS`. Unset, 0\n * or invalid keeps the table forever: the boot config check reports an invalid value.\n */\nexport function resolveRetentionPolicy(env: EnvRecord): RetentionPolicy {\n\tconst days = (key: string) => {\n\t\tconst value = readSetting(\n\t\t\tRETENTION_SETTINGS.find((s) => s.key === key)!,\n\t\t\tenv\n\t\t);\n\t\treturn typeof value === 'number' && value > 0 ? value : undefined;\n\t};\n\treturn {\n\t\tauditEventsDays: days('SELVA_AUDIT_RETENTION_DAYS'),\n\t\tsolveMetricsDays: days('SELVA_SOLVE_METRICS_RETENTION_DAYS')\n\t};\n}\n\nexport function retentionCutoffs(policy: RetentionPolicy, now: number): RetentionCutoffs {\n\tconst before = (days?: number) => (days ? new Date(now - days * DAY_MS) : undefined);\n\treturn {\n\t\tauditEventsBefore: before(policy.auditEventsDays),\n\t\tsolveMetricsBefore: before(policy.solveMetricsDays)\n\t};\n}\n\nexport interface RetentionJanitor {\n\t/** One purge now. Undefined when there is nothing to purge or it failed (logged). */\n\trunOnce(): Promise<PurgeResult | undefined>;\n\tstop(): void;\n}\n\n/**\n * Purges at start and then daily. Inert when the policy keeps everything or the\n * provider has no `purgeExpired`. Every instance may run one: the purge is idempotent.\n */\nexport function startRetentionJanitor(options: {\n\tdata: Pick<IDataProvider, 'purgeExpired'>;\n\tpolicy: RetentionPolicy;\n\tlogger: ILogger;\n\tintervalMs?: number;\n\tnow?: () => number;\n}): RetentionJanitor {\n\tconst { data, policy, logger, intervalMs = DAY_MS, now = Date.now } = options;\n\tconst enabled =\n\t\t!!data.purgeExpired &&\n\t\t(policy.auditEventsDays !== undefined || policy.solveMetricsDays !== undefined);\n\n\tlet running: Promise<PurgeResult | undefined> | undefined;\n\tasync function purge(): Promise<PurgeResult | undefined> {\n\t\tif (!enabled) return undefined;\n\t\ttry {\n\t\t\tconst result = await data.purgeExpired!(SYSTEM_CONTEXT, retentionCutoffs(policy, now()));\n\t\t\tif (result.auditEvents || result.solveMetrics) {\n\t\t\t\tlogger.info('Retention purge deleted expired rows', {\n\t\t\t\t\tcomponent: 'retention',\n\t\t\t\t\tauditEvents: result.auditEvents,\n\t\t\t\t\tsolveMetrics: result.solveMetrics\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tlogger.error('Retention purge failed', {\n\t\t\t\tcomponent: 'retention',\n\t\t\t\terr: err instanceof Error ? err.message : String(err)\n\t\t\t});\n\t\t\treturn undefined;\n\t\t}\n\t}\n\t// A slow purge must not overlap the next tick.\n\tconst runOnce = () => (running ??= purge().finally(() => (running = undefined)));\n\n\tlet timer: ReturnType<typeof setInterval> | undefined;\n\tif (enabled) {\n\t\tvoid runOnce();\n\t\ttimer = setInterval(() => void runOnce(), intervalMs);\n\t\t// Otherwise the timer holds the process open past shutdown.\n\t\ttimer.unref?.();\n\t}\n\treturn { runOnce, stop: () => clearInterval(timer) };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,SAAgB,mBAAmB,KAA+C;CACjF,IAAI,OAAO,QAAQ,QAAQ,IAAI,OAAO;CACtC,MAAM,QAAQ,OAAO,GAAG,CAAC,CAAC,KAAK;CAC/B,IAAI,UAAU,IAAI,OAAO;CAGzB,MAAM,aAAa;EADqB,GAAG;EAAM,GAAG;EAAa,GAAG;CACjD,EAAM,MAAM,GAAG,EA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AA,KAAa,OAAO,qBAAqB,KAAA;CAEtE,IAAI;CACJ,eAAe,QAA0C;EACxD,IAAI,CAAC,SAAS,OAAO,KAAA;EACrB,IAAI;GACH,MAAM,SAAS,MAAM,KAAK,aAAc,gBAAgB,iBAAiB,QAAQ,IAAI,CAAC,CAAC;GACvF,IAAI,OAAO,eAAe,OAAO,cAChC,OAAO,KAAK,wCAAwC;IACnD,WAAW;IACX,aAAa,OAAO;IACpB,cAAc,OAAO;GACtB,CAAC;GAEF,OAAO;EACR,SAAS,KAAK;GACb,OAAO,MAAM,0BAA0B;IACtC,WAAW;IACX,KAAK,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;GACrD,CAAC;GACD;EACD;CACD;CAEA,MAAM,gBAAiB,YAAY,MAAM,CAAC,CAAC,cAAe,UAAU,KAAA,CAAU;CAE9E,IAAI;CACJ,IAAI,SAAS;EACZ,QAAa;EACb,QAAQ,kBAAkB,KAAK,QAAQ,GAAG,UAAU;EAEpD,MAAM,QAAQ;CACf;CACA,OAAO;EAAE;EAAS,YAAY,cAAc,KAAK;CAAE;AACpD"}
@@ -1,6 +1,6 @@
1
1
  var package_default = {
2
2
  name: "@selvajs/selva",
3
- version: "4.21.0-beta.11",
3
+ version: "4.21.0-beta.13",
4
4
  description: "Selva — self-contained Grasshopper-driven web app. Install, configure via .env, deploy.",
5
5
  license: "MIT",
6
6
  author: "VektorNode",
@@ -1 +1 @@
1
- {"version":3,"file":"package.js","names":[],"sources":["../../../package.json"],"sourcesContent":["{\n\t\"name\": \"@selvajs/selva\",\n\t\"version\": \"4.21.0-beta.11\",\n\t\"description\": \"Selva — self-contained Grasshopper-driven web app. Install, configure via .env, deploy.\",\n\t\"license\": \"MIT\",\n\t\"author\": \"VektorNode\",\n\t\"homepage\": \"https://selva.dev\",\n\t\"bugs\": \"https://github.com/VektorNode/selva/issues\",\n\t\"keywords\": [\n\t\t\"grasshopper\",\n\t\t\"rhino\",\n\t\t\"rhino-compute\",\n\t\t\"parametric-design\",\n\t\t\"web-app\",\n\t\t\"sveltekit\"\n\t],\n\t\"publishConfig\": {\n\t\t\"access\": \"public\"\n\t},\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"git+https://github.com/VektorNode/selva.git\",\n\t\t\"directory\": \"packages/selva\"\n\t},\n\t\"type\": \"module\",\n\t\"main\": \"./build/index.js\",\n\t\"files\": [\n\t\t\"build\",\n\t\t\"templates\"\n\t],\n\t\"engines\": {\n\t\t\"node\": \">=24.0.0\"\n\t},\n\t\"selva\": {\n\t\t\"dataFormat\": 3\n\t},\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"dev:lan\": \"vite dev --host\",\n\t\t\"build\": \"rimraf build && vite build && node ./scripts/generate-templates.js && node ./scripts/write-runtime-meta.js\",\n\t\t\"preview\": \"vite preview\",\n\t\t\"start\": \"node build/index.js\",\n\t\t\"clean\": \"rimraf build templates\",\n\t\t\"prepare\": \"svelte-kit sync || echo ''\",\n\t\t\"check\": \"svelte-kit sync && svelte-check --tsconfig ./tsconfig.json\",\n\t\t\"test\": \"vitest run\",\n\t\t\"test:watch\": \"vitest\",\n\t\t\"openapi:generate\": \"node scripts/generate-openapi.js\",\n\t\t\"test:e2e\": \"playwright test\",\n\t\t\"lint\": \"eslint .\",\n\t\t\"lint:types\": \"eslint . --config eslint.typed.config.js\",\n\t\t\"generate:cli-config\": \"node scripts/generate-cli-config.js\"\n\t},\n\t\"dependencies\": {\n\t\t\"@lucide/svelte\": \"catalog:\",\n\t\t\"@supabase/supabase-js\": \"catalog:\",\n\t\t\"@sveltejs/kit\": \"catalog:\",\n\t\t\"bits-ui\": \"catalog:\",\n\t\t\"clsx\": \"catalog:\",\n\t\t\"mode-watcher\": \"catalog:\",\n\t\t\"nodemailer\": \"catalog:\",\n\t\t\"pino\": \"^10.4.0\",\n\t\t\"rhino3dm\": \"catalog:\",\n\t\t\"sharp\": \"catalog:\",\n\t\t\"tailwind-merge\": \"catalog:\",\n\t\t\"tailwind-variants\": \"catalog:\",\n\t\t\"three\": \"catalog:\",\n\t\t\"zod\": \"catalog:\"\n\t},\n\t\"optionalDependencies\": {\n\t\t\"@sentry/node\": \"^11.10.0\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@playwright/test\": \"catalog:\",\n\t\t\"@selvajs/compute\": \"workspace:*\",\n\t\t\"@selvajs/config\": \"workspace:*\",\n\t\t\"@selvajs/header-auth-provider\": \"workspace:*\",\n\t\t\"@selvajs/local-provider\": \"workspace:*\",\n\t\t\"@selvajs/mcp\": \"workspace:*\",\n\t\t\"@selvajs/notifications\": \"workspace:*\",\n\t\t\"@selvajs/platform\": \"workspace:*\",\n\t\t\"@selvajs/schemas\": \"workspace:*\",\n\t\t\"@selvajs/server\": \"workspace:*\",\n\t\t\"@selvajs/solve\": \"workspace:*\",\n\t\t\"@selvajs/supabase-provider\": \"workspace:*\",\n\t\t\"@selvajs/ui\": \"workspace:*\",\n\t\t\"@selvajs/visualization\": \"workspace:*\",\n\t\t\"@sveltejs/adapter-node\": \"catalog:\",\n\t\t\"@types/nodemailer\": \"catalog:\",\n\t\t\"@types/three\": \"catalog:\",\n\t\t\"rimraf\": \"catalog:\",\n\t\t\"tw-animate-css\": \"catalog:\",\n\t\t\"vitest\": \"catalog:\"\n\t},\n\t\"imports\": {\n\t\t\"#lib/*\": \"./src/lib/*\"\n\t}\n}\n"],"mappings":""}
1
+ {"version":3,"file":"package.js","names":[],"sources":["../../../package.json"],"sourcesContent":["{\n\t\"name\": \"@selvajs/selva\",\n\t\"version\": \"4.21.0-beta.13\",\n\t\"description\": \"Selva — self-contained Grasshopper-driven web app. Install, configure via .env, deploy.\",\n\t\"license\": \"MIT\",\n\t\"author\": \"VektorNode\",\n\t\"homepage\": \"https://selva.dev\",\n\t\"bugs\": \"https://github.com/VektorNode/selva/issues\",\n\t\"keywords\": [\n\t\t\"grasshopper\",\n\t\t\"rhino\",\n\t\t\"rhino-compute\",\n\t\t\"parametric-design\",\n\t\t\"web-app\",\n\t\t\"sveltekit\"\n\t],\n\t\"publishConfig\": {\n\t\t\"access\": \"public\"\n\t},\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"git+https://github.com/VektorNode/selva.git\",\n\t\t\"directory\": \"packages/selva\"\n\t},\n\t\"type\": \"module\",\n\t\"main\": \"./build/index.js\",\n\t\"files\": [\n\t\t\"build\",\n\t\t\"templates\"\n\t],\n\t\"engines\": {\n\t\t\"node\": \">=24.0.0\"\n\t},\n\t\"selva\": {\n\t\t\"dataFormat\": 3\n\t},\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"dev:lan\": \"vite dev --host\",\n\t\t\"build\": \"rimraf build && vite build && node ./scripts/generate-templates.js && node ./scripts/write-runtime-meta.js\",\n\t\t\"preview\": \"vite preview\",\n\t\t\"start\": \"node build/index.js\",\n\t\t\"clean\": \"rimraf build templates\",\n\t\t\"prepare\": \"svelte-kit sync || echo ''\",\n\t\t\"check\": \"svelte-kit sync && svelte-check --tsconfig ./tsconfig.json\",\n\t\t\"test\": \"vitest run\",\n\t\t\"test:watch\": \"vitest\",\n\t\t\"openapi:generate\": \"node scripts/generate-openapi.js\",\n\t\t\"test:e2e\": \"playwright test\",\n\t\t\"lint\": \"eslint .\",\n\t\t\"lint:types\": \"eslint . --config eslint.typed.config.js\",\n\t\t\"generate:cli-config\": \"node scripts/generate-cli-config.js\"\n\t},\n\t\"dependencies\": {\n\t\t\"@lucide/svelte\": \"catalog:\",\n\t\t\"@supabase/supabase-js\": \"catalog:\",\n\t\t\"@sveltejs/kit\": \"catalog:\",\n\t\t\"bits-ui\": \"catalog:\",\n\t\t\"clsx\": \"catalog:\",\n\t\t\"mode-watcher\": \"catalog:\",\n\t\t\"nodemailer\": \"catalog:\",\n\t\t\"pino\": \"^10.4.0\",\n\t\t\"rhino3dm\": \"catalog:\",\n\t\t\"sharp\": \"catalog:\",\n\t\t\"tailwind-merge\": \"catalog:\",\n\t\t\"tailwind-variants\": \"catalog:\",\n\t\t\"three\": \"catalog:\",\n\t\t\"zod\": \"catalog:\"\n\t},\n\t\"optionalDependencies\": {\n\t\t\"@sentry/node\": \"^11.10.0\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@playwright/test\": \"catalog:\",\n\t\t\"@selvajs/compute\": \"workspace:*\",\n\t\t\"@selvajs/config\": \"workspace:*\",\n\t\t\"@selvajs/header-auth-provider\": \"workspace:*\",\n\t\t\"@selvajs/local-provider\": \"workspace:*\",\n\t\t\"@selvajs/mcp\": \"workspace:*\",\n\t\t\"@selvajs/notifications\": \"workspace:*\",\n\t\t\"@selvajs/platform\": \"workspace:*\",\n\t\t\"@selvajs/schemas\": \"workspace:*\",\n\t\t\"@selvajs/server\": \"workspace:*\",\n\t\t\"@selvajs/solve\": \"workspace:*\",\n\t\t\"@selvajs/supabase-provider\": \"workspace:*\",\n\t\t\"@selvajs/ui\": \"workspace:*\",\n\t\t\"@selvajs/visualization\": \"workspace:*\",\n\t\t\"@sveltejs/adapter-node\": \"catalog:\",\n\t\t\"@types/nodemailer\": \"catalog:\",\n\t\t\"@types/three\": \"catalog:\",\n\t\t\"rimraf\": \"catalog:\",\n\t\t\"tw-animate-css\": \"catalog:\",\n\t\t\"vitest\": \"catalog:\"\n\t},\n\t\"imports\": {\n\t\t\"#lib/*\": \"./src/lib/*\"\n\t}\n}\n"],"mappings":""}
@@ -1,5 +1,5 @@
1
- import { n as toApiRequest } from "./sveltekit.js";
2
1
  import { Z as mayHoldApiTokens } from "./handlers.js";
2
+ import { n as toApiRequest } from "./sveltekit.js";
3
3
  import { t as requestMemo } from "./requestMemo.server.js";
4
4
  import { t as ACCESS_PRESETS } from "./apiTokens.js";
5
5
  // src/lib/server/apiTokens/presets.server.ts