@selvajs/selva 4.20.1-beta.4 → 4.21.0-beta.10

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 (302) hide show
  1. package/build/adapter-node.js +1 -1
  2. package/build/client/_app/immutable/assets/0.CqqJCiiV.css +2 -0
  3. package/build/client/_app/immutable/assets/0.CqqJCiiV.css.br +0 -0
  4. package/build/client/_app/immutable/assets/0.CqqJCiiV.css.gz +0 -0
  5. package/build/client/_app/immutable/chunks/{CzfnuBzq.js → BAhtiTKe.js} +1 -1
  6. package/build/client/_app/immutable/chunks/BAhtiTKe.js.br +0 -0
  7. package/build/client/_app/immutable/chunks/BAhtiTKe.js.gz +0 -0
  8. package/build/client/_app/immutable/chunks/{qi43d-TM.js → CKbHmAlc.js} +1 -1
  9. package/build/client/_app/immutable/chunks/CKbHmAlc.js.br +0 -0
  10. package/build/client/_app/immutable/chunks/CKbHmAlc.js.gz +0 -0
  11. package/build/client/_app/immutable/chunks/{C6Y_BUwr.js → CmlXAF26.js} +1 -1
  12. package/build/client/_app/immutable/chunks/CmlXAF26.js.br +0 -0
  13. package/build/client/_app/immutable/chunks/CmlXAF26.js.gz +0 -0
  14. package/build/client/_app/immutable/chunks/Cv7GBWJh.js +2 -0
  15. package/build/client/_app/immutable/chunks/Cv7GBWJh.js.br +0 -0
  16. package/build/client/_app/immutable/chunks/Cv7GBWJh.js.gz +0 -0
  17. package/build/client/_app/immutable/chunks/{BDYCH-_Q.js → D5j4-ZO1.js} +1 -1
  18. package/build/client/_app/immutable/chunks/D5j4-ZO1.js.br +0 -0
  19. package/build/client/_app/immutable/chunks/D5j4-ZO1.js.gz +0 -0
  20. package/build/client/_app/immutable/chunks/DW5EJMC7.js +1 -0
  21. package/build/client/_app/immutable/chunks/DW5EJMC7.js.br +0 -0
  22. package/build/client/_app/immutable/chunks/DW5EJMC7.js.gz +0 -0
  23. package/build/client/_app/immutable/chunks/{D-uUm_OB.js → DptnDNFA.js} +61 -56
  24. package/build/client/_app/immutable/chunks/DptnDNFA.js.br +0 -0
  25. package/build/client/_app/immutable/chunks/{D-uUm_OB.js.gz → DptnDNFA.js.gz} +0 -0
  26. package/build/client/_app/immutable/chunks/DvJo0Zn0.js +1 -0
  27. package/build/client/_app/immutable/chunks/DvJo0Zn0.js.br +1 -0
  28. package/build/client/_app/immutable/chunks/DvJo0Zn0.js.gz +0 -0
  29. package/build/client/_app/immutable/chunks/{DzxE3j6C.js → qXnHMKD9.js} +1 -1
  30. package/build/client/_app/immutable/chunks/qXnHMKD9.js.br +0 -0
  31. package/build/client/_app/immutable/chunks/qXnHMKD9.js.gz +0 -0
  32. package/build/client/_app/immutable/entry/{app.BpT6WkO1.js → app.DPbjEDd3.js} +2 -2
  33. package/build/client/_app/immutable/entry/app.DPbjEDd3.js.br +0 -0
  34. package/build/client/_app/immutable/entry/app.DPbjEDd3.js.gz +0 -0
  35. package/build/client/_app/immutable/nodes/{1.D3kiiIk_.js → 1.DWd6YbcT.js} +1 -1
  36. package/build/client/_app/immutable/nodes/1.DWd6YbcT.js.br +0 -0
  37. package/build/client/_app/immutable/nodes/1.DWd6YbcT.js.gz +0 -0
  38. package/build/client/_app/immutable/nodes/15._hpTnSzc.js +36 -0
  39. package/build/client/_app/immutable/nodes/15._hpTnSzc.js.br +0 -0
  40. package/build/client/_app/immutable/nodes/15._hpTnSzc.js.gz +0 -0
  41. package/build/client/_app/immutable/nodes/{2.CUNbzjI_.js → 2.CS32Eh9m.js} +1 -1
  42. package/build/client/_app/immutable/nodes/2.CS32Eh9m.js.br +0 -0
  43. package/build/client/_app/immutable/nodes/2.CS32Eh9m.js.gz +0 -0
  44. package/build/client/_app/immutable/nodes/{20.9OIre0ah.js → 20.CVaxGEhZ.js} +1 -1
  45. package/build/client/_app/immutable/nodes/20.CVaxGEhZ.js.br +0 -0
  46. package/build/client/_app/immutable/nodes/20.CVaxGEhZ.js.gz +0 -0
  47. package/build/client/_app/immutable/nodes/21.DpKe0-GH.js +1 -0
  48. package/build/client/_app/immutable/nodes/21.DpKe0-GH.js.br +0 -0
  49. package/build/client/_app/immutable/nodes/21.DpKe0-GH.js.gz +0 -0
  50. package/build/client/_app/immutable/nodes/24.DkL5kHzA.js +3 -0
  51. package/build/client/_app/immutable/nodes/24.DkL5kHzA.js.br +0 -0
  52. package/build/client/_app/immutable/nodes/24.DkL5kHzA.js.gz +0 -0
  53. package/build/client/_app/immutable/nodes/{25.DW1_vMxq.js → 25.DiYmTwXC.js} +2 -2
  54. package/build/client/_app/immutable/nodes/25.DiYmTwXC.js.br +0 -0
  55. package/build/client/_app/immutable/nodes/25.DiYmTwXC.js.gz +0 -0
  56. package/build/client/_app/immutable/nodes/26.7nAJpm5P.js +5 -0
  57. package/build/client/_app/immutable/nodes/26.7nAJpm5P.js.br +0 -0
  58. package/build/client/_app/immutable/nodes/26.7nAJpm5P.js.gz +0 -0
  59. package/build/client/_app/immutable/nodes/{3.3Z4QUsQQ.js → 3.Ctd9OGCk.js} +1 -1
  60. package/build/client/_app/immutable/nodes/3.Ctd9OGCk.js.br +0 -0
  61. package/build/client/_app/immutable/nodes/3.Ctd9OGCk.js.gz +0 -0
  62. package/build/client/_app/immutable/nodes/{5.DmA9lTA-.js → 5.Wh_w3RkZ.js} +1 -1
  63. package/build/client/_app/immutable/nodes/5.Wh_w3RkZ.js.br +2 -0
  64. package/build/client/_app/immutable/nodes/5.Wh_w3RkZ.js.gz +0 -0
  65. package/build/client/_app/immutable/nodes/{6.D6WLqCgl.js → 6.C-DiUI5R.js} +1 -1
  66. package/build/client/_app/immutable/nodes/6.C-DiUI5R.js.br +0 -0
  67. package/build/client/_app/immutable/nodes/6.C-DiUI5R.js.gz +0 -0
  68. package/build/client/_app/immutable/nodes/{7.CNuRjkv2.js → 7.B8yubYrv.js} +1 -1
  69. package/build/client/_app/immutable/nodes/7.B8yubYrv.js.br +0 -0
  70. package/build/client/_app/immutable/nodes/7.B8yubYrv.js.gz +0 -0
  71. package/build/client/_app/version.json +1 -1
  72. package/build/client/_app/version.json.br +0 -0
  73. package/build/client/_app/version.json.gz +0 -0
  74. package/build/runtime-meta.json +1 -1
  75. package/build/server/.vite/manifest.json +35 -45
  76. package/build/server/_app/immutable/assets/_layout.CqqJCiiV.css +2 -0
  77. package/build/server/chunks/DefinitionCard.js +3 -0
  78. package/build/server/chunks/DefinitionCard.js.map +1 -1
  79. package/build/server/chunks/access.js +15 -3
  80. package/build/server/chunks/access.js.map +1 -1
  81. package/build/server/chunks/api-errors.js +18 -3
  82. package/build/server/chunks/api-errors.js.map +1 -1
  83. package/build/server/chunks/api.js +9 -2
  84. package/build/server/chunks/api.js.map +1 -1
  85. package/build/server/chunks/auth-bootstrap.server.js +63 -39
  86. package/build/server/chunks/auth-bootstrap.server.js.map +1 -1
  87. package/build/server/chunks/boot.server.js +1 -1
  88. package/build/server/chunks/bootHealth.server.js +23 -23
  89. package/build/server/chunks/bootHealth.server.js.map +1 -1
  90. package/build/server/chunks/computeRateLimit.server.js +2 -2
  91. package/build/server/chunks/delete-with-blobs.js +1 -1
  92. package/build/server/chunks/engine.server.js +52 -5
  93. package/build/server/chunks/engine.server.js.map +1 -1
  94. package/build/server/chunks/grasshopper.js +217 -162
  95. package/build/server/chunks/grasshopper.js.map +1 -1
  96. package/build/server/chunks/handlers.js +70 -60
  97. package/build/server/chunks/handlers.js.map +1 -1
  98. package/build/server/chunks/http.js +24 -24
  99. package/build/server/chunks/http.js.map +1 -1
  100. package/build/server/chunks/http2.js +1 -1
  101. package/build/server/chunks/instance.js +3 -3
  102. package/build/server/chunks/instanceAdmins.server.js +31 -16
  103. package/build/server/chunks/instanceAdmins.server.js.map +1 -1
  104. package/build/server/chunks/internal.js +1 -1
  105. package/build/server/chunks/{abort-Bfrdupaj.js → keepalive-vtcjhAV3.js} +6 -3
  106. package/build/server/chunks/keepalive-vtcjhAV3.js.map +1 -0
  107. package/build/server/chunks/liveSolve.server.js +1 -1
  108. package/build/server/chunks/localeContext.svelte.js +14 -0
  109. package/build/server/chunks/localeContext.svelte.js.map +1 -1
  110. package/build/server/chunks/oauth.js +70 -24
  111. package/build/server/chunks/oauth.js.map +1 -1
  112. package/build/server/chunks/{outcome-DNrffAXp.js → outcome-D28FgvFK.js} +9 -6
  113. package/build/server/chunks/outcome-D28FgvFK.js.map +1 -0
  114. package/build/server/chunks/package.js +2 -1
  115. package/build/server/chunks/package.js.map +1 -1
  116. package/build/server/chunks/permissions.server.js +1 -1
  117. package/build/server/chunks/presets.server.js +1 -1
  118. package/build/server/chunks/providers.server.js +324 -121
  119. package/build/server/chunks/providers.server.js.map +1 -1
  120. package/build/server/chunks/registry.js +1 -1
  121. package/build/server/chunks/resolve-server.js +1 -1
  122. package/build/server/chunks/schema-extraction.js +75 -8
  123. package/build/server/chunks/schema-extraction.js.map +1 -1
  124. package/build/server/chunks/schema.js +1 -1
  125. package/build/server/chunks/schema.js.map +1 -1
  126. package/build/server/chunks/server-config-write.js +6 -6
  127. package/build/server/chunks/server-config-write.js.map +1 -1
  128. package/build/server/chunks/server2.js +2 -2
  129. package/build/server/chunks/server2.js.map +1 -1
  130. package/build/server/chunks/serverStats.server.js +1 -1
  131. package/build/server/chunks/signInMaxAge.server.js +1 -1
  132. package/build/server/chunks/solve.server.js +34 -8
  133. package/build/server/chunks/solve.server.js.map +1 -1
  134. package/build/server/chunks/sveltekit.js +4 -5
  135. package/build/server/chunks/sveltekit.js.map +1 -1
  136. package/build/server/chunks/update-outcome.js +11 -0
  137. package/build/server/chunks/update-outcome.js.map +1 -1
  138. package/build/server/chunks/updateCheck.server.js +24 -12
  139. package/build/server/chunks/updateCheck.server.js.map +1 -1
  140. package/build/server/entries/endpoints/.well-known/oauth-authorization-server/_server.ts.js +6 -3
  141. package/build/server/entries/endpoints/.well-known/oauth-authorization-server/_server.ts.js.map +1 -1
  142. package/build/server/entries/endpoints/.well-known/oauth-protected-resource/_server.ts.js +6 -3
  143. package/build/server/entries/endpoints/.well-known/oauth-protected-resource/_server.ts.js.map +1 -1
  144. package/build/server/entries/endpoints/.well-known/oauth-protected-resource/mcp/_server.ts.js +6 -3
  145. package/build/server/entries/endpoints/.well-known/oauth-protected-resource/mcp/_server.ts.js.map +1 -1
  146. package/build/server/entries/endpoints/api/admin/compute/_server.ts.js +1 -1
  147. package/build/server/entries/endpoints/api/admin/compute/actions/_server.ts.js +1 -1
  148. package/build/server/entries/endpoints/api/admin/compute/status/_server.ts.js +1 -1
  149. package/build/server/entries/endpoints/api/admin/orgs/_id_/_server.ts.js +1 -1
  150. package/build/server/entries/endpoints/api/admin/orgs/_server.ts.js +1 -1
  151. package/build/server/entries/endpoints/api/admin/projects/_id_/_server.ts.js +1 -1
  152. package/build/server/entries/endpoints/api/admin/projects/_id_/grants/_grantId_/_server.ts.js +1 -1
  153. package/build/server/entries/endpoints/api/admin/projects/_id_/grants/_server.ts.js +1 -1
  154. package/build/server/entries/endpoints/api/admin/projects/_server.ts.js +1 -1
  155. package/build/server/entries/endpoints/api/admin/system/health/_server.ts.js +9 -2
  156. package/build/server/entries/endpoints/api/admin/system/health/_server.ts.js.map +1 -1
  157. package/build/server/entries/endpoints/api/admin/system/update/_server.ts.js +59 -15
  158. package/build/server/entries/endpoints/api/admin/system/update/_server.ts.js.map +1 -1
  159. package/build/server/entries/endpoints/api/admin/users/_id_/_server.ts.js +42 -16
  160. package/build/server/entries/endpoints/api/admin/users/_id_/_server.ts.js.map +1 -1
  161. package/build/server/entries/endpoints/api/admin/users/_id_/disable/_server.ts.js +24 -13
  162. package/build/server/entries/endpoints/api/admin/users/_id_/disable/_server.ts.js.map +1 -1
  163. package/build/server/entries/endpoints/api/admin/users/_server.ts.js +2 -2
  164. package/build/server/entries/endpoints/api/files/_...path_/_server.ts.js +1 -1
  165. package/build/server/entries/endpoints/api/v1/compute/_server.ts.js +15 -6
  166. package/build/server/entries/endpoints/api/v1/compute/_server.ts.js.map +1 -1
  167. package/build/server/entries/endpoints/api/v1/compute/schema/_server.ts.js +3 -3
  168. package/build/server/entries/endpoints/api/v1/definitions/_guid_/_server.ts.js +1 -1
  169. package/build/server/entries/endpoints/api/v1/definitions/_guid_/image/_server.ts.js +1 -1
  170. package/build/server/entries/endpoints/api/v1/definitions/_guid_/publish/_server.ts.js +1 -1
  171. package/build/server/entries/endpoints/api/v1/definitions/_guid_/schema/_server.ts.js +1 -1
  172. package/build/server/entries/endpoints/api/v1/definitions/_guid_/share-links/_linkId_/_server.ts.js +1 -1
  173. package/build/server/entries/endpoints/api/v1/definitions/_guid_/share-links/_server.ts.js +1 -1
  174. package/build/server/entries/endpoints/api/v1/definitions/_guid_/solve/_server.ts.js +5 -4
  175. package/build/server/entries/endpoints/api/v1/definitions/_guid_/solve/_server.ts.js.map +1 -1
  176. package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_server.ts.js +1 -1
  177. package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_versionId_/_server.ts.js +1 -1
  178. package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_versionId_/schema/_server.ts.js +1 -1
  179. package/build/server/entries/endpoints/api/v1/me/_server.ts.js +1 -1
  180. package/build/server/entries/endpoints/api/v1/me/starred/_guid_/_server.ts.js +1 -1
  181. package/build/server/entries/endpoints/api/v1/me/token/_server.ts.js +1 -1
  182. package/build/server/entries/endpoints/api/v1/orgs/_orgId_/_server.ts.js +1 -1
  183. package/build/server/entries/endpoints/api/v1/orgs/_orgId_/members/_server.ts.js +1 -1
  184. package/build/server/entries/endpoints/api/v1/orgs/_orgId_/tokens/_server.ts.js +1 -1
  185. package/build/server/entries/endpoints/api/v1/orgs/_orgId_/tokens/_tokenId_/_server.ts.js +1 -1
  186. package/build/server/entries/endpoints/api/v1/projects/_id_/_server.ts.js +1 -1
  187. package/build/server/entries/endpoints/api/v1/projects/_id_/members/_server.ts.js +1 -1
  188. package/build/server/entries/endpoints/api/v1/projects/_id_/members/_userId_/_server.ts.js +1 -1
  189. package/build/server/entries/endpoints/api/v1/projects/_id_/reclaim/_server.ts.js +1 -1
  190. package/build/server/entries/endpoints/api/v1/solve/_solveId_/cancel/_server.ts.js +1 -1
  191. package/build/server/entries/endpoints/api/v1/solve-events/_server.ts.js +1 -1
  192. package/build/server/entries/endpoints/auth/email/callback/_server.ts.js +2 -2
  193. package/build/server/entries/endpoints/auth/email/callback/_server.ts.js.map +1 -1
  194. package/build/server/entries/endpoints/auth/supabase/callback/_server.ts.js +2 -2
  195. package/build/server/entries/endpoints/auth/supabase/callback/_server.ts.js.map +1 -1
  196. package/build/server/entries/endpoints/docs/api/openapi.yaml/_server.ts.js +1 -1
  197. package/build/server/entries/endpoints/mcp/_server.ts.js +43 -13
  198. package/build/server/entries/endpoints/mcp/_server.ts.js.map +1 -1
  199. package/build/server/entries/endpoints/oauth/register/_server.ts.js +1 -1
  200. package/build/server/entries/endpoints/oauth/token/_server.ts.js +1 -1
  201. package/build/server/entries/hooks.server.js +25 -6
  202. package/build/server/entries/hooks.server.js.map +1 -1
  203. package/build/server/entries/pages/admin/compute/_page.server.ts.js +1 -2
  204. package/build/server/entries/pages/admin/compute/_page.server.ts.js.map +1 -1
  205. package/build/server/entries/pages/admin/system/_page.server.ts.js +8 -3
  206. package/build/server/entries/pages/admin/system/_page.server.ts.js.map +1 -1
  207. package/build/server/entries/pages/admin/system/_page.svelte.js +18 -2
  208. package/build/server/entries/pages/admin/system/_page.svelte.js.map +1 -1
  209. package/build/server/entries/pages/library/_guid_/_page.server.ts.js +198 -99
  210. package/build/server/entries/pages/library/_guid_/_page.server.ts.js.map +1 -1
  211. package/build/server/entries/pages/library/_guid_/_page.svelte.js +693 -40
  212. package/build/server/entries/pages/library/_guid_/_page.svelte.js.map +1 -1
  213. package/build/server/entries/pages/oauth/authorize/_page.server.ts.js +3 -2
  214. package/build/server/entries/pages/oauth/authorize/_page.server.ts.js.map +1 -1
  215. package/build/server/entries/pages/oauth/authorize/_page.svelte.js +8 -1
  216. package/build/server/entries/pages/oauth/authorize/_page.svelte.js.map +1 -1
  217. package/build/server/entries/pages/projects/_page.svelte.js +2 -0
  218. package/build/server/entries/pages/projects/_page.svelte.js.map +1 -1
  219. package/build/server/entries/pages/setup/_page.server.ts.js +62 -8
  220. package/build/server/entries/pages/setup/_page.server.ts.js.map +1 -1
  221. package/build/server/entries/pages/setup/_page.svelte.js +52 -33
  222. package/build/server/entries/pages/setup/_page.svelte.js.map +1 -1
  223. package/build/server/entries/pages/team/tokens/_page.server.ts.js +1 -1
  224. package/build/server/manifest-full.js +1 -1
  225. package/build/server/manifest.js +1 -1
  226. package/build/server/nodes/0.js +2 -2
  227. package/build/server/nodes/1.js +1 -1
  228. package/build/server/nodes/15.js +1 -1
  229. package/build/server/nodes/2.js +1 -1
  230. package/build/server/nodes/20.js +1 -1
  231. package/build/server/nodes/21.js +1 -1
  232. package/build/server/nodes/24.js +1 -1
  233. package/build/server/nodes/25.js +1 -1
  234. package/build/server/nodes/26.js +1 -1
  235. package/build/server/nodes/3.js +1 -1
  236. package/build/server/nodes/5.js +1 -1
  237. package/build/server/nodes/6.js +1 -1
  238. package/build/server/nodes/7.js +1 -1
  239. package/build/server/server.js +1 -1
  240. package/package.json +16 -13
  241. package/templates/.env.example +15 -7
  242. package/build/client/_app/immutable/assets/0.2jDm0bqh.css +0 -2
  243. package/build/client/_app/immutable/assets/0.2jDm0bqh.css.br +0 -0
  244. package/build/client/_app/immutable/assets/0.2jDm0bqh.css.gz +0 -0
  245. package/build/client/_app/immutable/chunks/BDYCH-_Q.js.br +0 -0
  246. package/build/client/_app/immutable/chunks/BDYCH-_Q.js.gz +0 -0
  247. package/build/client/_app/immutable/chunks/C6Y_BUwr.js.br +0 -0
  248. package/build/client/_app/immutable/chunks/C6Y_BUwr.js.gz +0 -0
  249. package/build/client/_app/immutable/chunks/CzfnuBzq.js.br +0 -0
  250. package/build/client/_app/immutable/chunks/CzfnuBzq.js.gz +0 -0
  251. package/build/client/_app/immutable/chunks/D-uUm_OB.js.br +0 -0
  252. package/build/client/_app/immutable/chunks/D84F7w9g.js +0 -1
  253. package/build/client/_app/immutable/chunks/D84F7w9g.js.br +0 -1
  254. package/build/client/_app/immutable/chunks/D84F7w9g.js.gz +0 -0
  255. package/build/client/_app/immutable/chunks/DQsP4nZb.js +0 -1
  256. package/build/client/_app/immutable/chunks/DQsP4nZb.js.br +0 -0
  257. package/build/client/_app/immutable/chunks/DQsP4nZb.js.gz +0 -0
  258. package/build/client/_app/immutable/chunks/DzeQucGI.js +0 -2
  259. package/build/client/_app/immutable/chunks/DzeQucGI.js.br +0 -0
  260. package/build/client/_app/immutable/chunks/DzeQucGI.js.gz +0 -0
  261. package/build/client/_app/immutable/chunks/DzxE3j6C.js.br +0 -0
  262. package/build/client/_app/immutable/chunks/DzxE3j6C.js.gz +0 -0
  263. package/build/client/_app/immutable/chunks/qi43d-TM.js.br +0 -0
  264. package/build/client/_app/immutable/chunks/qi43d-TM.js.gz +0 -0
  265. package/build/client/_app/immutable/entry/app.BpT6WkO1.js.br +0 -0
  266. package/build/client/_app/immutable/entry/app.BpT6WkO1.js.gz +0 -0
  267. package/build/client/_app/immutable/nodes/1.D3kiiIk_.js.br +0 -0
  268. package/build/client/_app/immutable/nodes/1.D3kiiIk_.js.gz +0 -0
  269. package/build/client/_app/immutable/nodes/15.BXIV1QfS.js +0 -32
  270. package/build/client/_app/immutable/nodes/15.BXIV1QfS.js.br +0 -0
  271. package/build/client/_app/immutable/nodes/15.BXIV1QfS.js.gz +0 -0
  272. package/build/client/_app/immutable/nodes/2.CUNbzjI_.js.br +0 -0
  273. package/build/client/_app/immutable/nodes/2.CUNbzjI_.js.gz +0 -0
  274. package/build/client/_app/immutable/nodes/20.9OIre0ah.js.br +0 -0
  275. package/build/client/_app/immutable/nodes/20.9OIre0ah.js.gz +0 -0
  276. package/build/client/_app/immutable/nodes/21.BkNlRItr.js +0 -1
  277. package/build/client/_app/immutable/nodes/21.BkNlRItr.js.br +0 -0
  278. package/build/client/_app/immutable/nodes/21.BkNlRItr.js.gz +0 -0
  279. package/build/client/_app/immutable/nodes/24.CPSunfJJ.js +0 -3
  280. package/build/client/_app/immutable/nodes/24.CPSunfJJ.js.br +0 -0
  281. package/build/client/_app/immutable/nodes/24.CPSunfJJ.js.gz +0 -0
  282. package/build/client/_app/immutable/nodes/25.DW1_vMxq.js.br +0 -0
  283. package/build/client/_app/immutable/nodes/25.DW1_vMxq.js.gz +0 -0
  284. package/build/client/_app/immutable/nodes/26.CqaMEm_t.js +0 -6
  285. package/build/client/_app/immutable/nodes/26.CqaMEm_t.js.br +0 -0
  286. package/build/client/_app/immutable/nodes/26.CqaMEm_t.js.gz +0 -0
  287. package/build/client/_app/immutable/nodes/3.3Z4QUsQQ.js.br +0 -0
  288. package/build/client/_app/immutable/nodes/3.3Z4QUsQQ.js.gz +0 -0
  289. package/build/client/_app/immutable/nodes/5.DmA9lTA-.js.br +0 -1
  290. package/build/client/_app/immutable/nodes/5.DmA9lTA-.js.gz +0 -0
  291. package/build/client/_app/immutable/nodes/6.D6WLqCgl.js.br +0 -0
  292. package/build/client/_app/immutable/nodes/6.D6WLqCgl.js.gz +0 -0
  293. package/build/client/_app/immutable/nodes/7.CNuRjkv2.js.br +0 -0
  294. package/build/client/_app/immutable/nodes/7.CNuRjkv2.js.gz +0 -0
  295. package/build/server/_app/immutable/assets/_layout.2jDm0bqh.css +0 -2
  296. package/build/server/chunks/abort-Bfrdupaj.js.map +0 -1
  297. package/build/server/chunks/computeLimits.js +0 -33
  298. package/build/server/chunks/computeLimits.js.map +0 -1
  299. package/build/server/chunks/outcome-DNrffAXp.js.map +0 -1
  300. /package/build/client/_app/immutable/nodes/{0.CYdyv5To.js → 0.Ds0zeDAg.js} +0 -0
  301. /package/build/client/_app/immutable/nodes/{0.CYdyv5To.js.br → 0.Ds0zeDAg.js.br} +0 -0
  302. /package/build/client/_app/immutable/nodes/{0.CYdyv5To.js.gz → 0.Ds0zeDAg.js.gz} +0 -0
@@ -1,4 +1,4 @@
1
- import { _ as UpdateOrgMemberBodySchema, c as AddProjectMemberBodySchema, d as CreateProjectBodySchema, f as CreateShareLinkBodySchema, g as UpdateDefinitionBodySchema, h as SolveBodySchema, l as CreateApiTokenBodySchema, m as PublishVersionBodySchema, p as OrgComputePatchBodySchema, u as CreateInviteBodySchema, v as UpdateProjectBodySchema, y as UpdateProjectMemberBodySchema } from "./api.js";
1
+ import { _ as UpdateDefinitionBodySchema, b as UpdateProjectMemberBodySchema, c as AddProjectMemberBodySchema, d as CreateProjectBodySchema, f as CreateShareLinkBodySchema, h as SolveBodySchema, l as CreateApiTokenBodySchema, m as PublishVersionBodySchema, p as OrgComputePatchBodySchema, u as CreateInviteBodySchema, v as UpdateOrgMemberBodySchema, y as UpdateProjectBodySchema } from "./api.js";
2
2
  // src/lib/server/api/v1/registry.ts
3
3
  /**
4
4
  * The v1 contract as data: one entry per method+path, naming its body validator,
@@ -1,5 +1,5 @@
1
1
  import { a as resolveServerForOrg$1 } from "./utils.js";
2
- import { a as ComputeServerUnconfiguredError } from "./schema-extraction.js";
2
+ import { u as ComputeServerUnconfiguredError } from "./schema-extraction.js";
3
3
  // ../server/src/compute/resolve-server.ts
4
4
  /**
5
5
  * Pick the right Rhino.Compute server for an (org, definition) pair.
@@ -1,4 +1,4 @@
1
- import { a as normalizeUISchemaCasing, o as readSchemaResults$1 } from "./grasshopper.js";
1
+ import { a as fetchParsedDefinitionIO, o as normalizeUISchemaCasing, s as readSchemaResults$1 } from "./grasshopper.js";
2
2
  import { t as UI_SCHEMA_VERSION } from "./schema.js";
3
3
  // ../server/src/compute/errors.ts
4
4
  /**
@@ -21,6 +21,44 @@ var ComputeServerUnconfiguredError = class extends Error {
21
21
  this.name = "ComputeServerUnconfiguredError";
22
22
  }
23
23
  };
24
+ // ../server/src/definitions/saved-values.ts
25
+ function savedValuesFrom(inputs) {
26
+ const values = /* @__PURE__ */ new Map();
27
+ for (const input of inputs) {
28
+ if (input.id === void 0 || input.default === void 0) continue;
29
+ values.set(input.id, input.paramType === "Color" ? colorToHex(input.default) : input.default);
30
+ }
31
+ return values;
32
+ }
33
+ /** `schema` with each input's `default` replaced by its saved value, where it has one. */
34
+ function applySavedValues(schema, values) {
35
+ return {
36
+ ...schema,
37
+ inputs: schema.inputs.map((input) => values.has(input.id) ? {
38
+ ...input,
39
+ default: values.get(input.id)
40
+ } : input)
41
+ };
42
+ }
43
+ function colorToHex(value) {
44
+ const parts = String(value).split(",").map((s) => parseInt(s.trim(), 10));
45
+ const hex = (n) => n.toString(16).padStart(2, "0");
46
+ if (parts.length === 3) return `#${hex(parts[0])}${hex(parts[1])}${hex(parts[2])}`;
47
+ if (parts.length === 4) return `#${hex(parts[1])}${hex(parts[2])}${hex(parts[3])}`;
48
+ return value;
49
+ }
50
+ // ../server/src/definitions/with-timeout.ts
51
+ /**
52
+ * Settles with `work`, or rejects with `onTimeout()` after `ms`. `work` is not cancelled: it runs
53
+ * on, and its later rejection stays handled.
54
+ */
55
+ function withTimeout(work, ms, onTimeout) {
56
+ let timer;
57
+ const timeout = new Promise((_, reject) => {
58
+ timer = setTimeout(() => reject(onTimeout()), ms);
59
+ });
60
+ return Promise.race([work, timeout]).finally(() => clearTimeout(timer));
61
+ }
24
62
  // ../server/src/definitions/schema-extraction.ts
25
63
  /** Thin re-export of @selvajs/compute's unwrap, typed to `UISchema`. */
26
64
  function readSchemaResults(raw) {
@@ -78,18 +116,25 @@ function parseSemver(version) {
78
116
  ] : null;
79
117
  }
80
118
  /**
119
+ * Orders a schema format version against the app's `UI_SCHEMA_VERSION`: -1 older, 0 current,
120
+ * 1 newer, null unparseable. A missing version is older: plugins before 2.12.0 emitted none.
121
+ */
122
+ function compareSchemaVersion(version) {
123
+ if (!version) return -1;
124
+ const extracted = parseSemver(version);
125
+ const supported = parseSemver(UI_SCHEMA_VERSION);
126
+ if (!extracted || !supported) return null;
127
+ for (let i = 0; i < 3; i++) if (extracted[i] !== supported[i]) return extracted[i] < supported[i] ? -1 : 1;
128
+ return 0;
129
+ }
130
+ /**
81
131
  * Rejects a schema from a NEWER plugin than this app was built against — its
82
132
  * shape may contain constructs the renderer doesn't know. Older (or missing)
83
133
  * versions pass: the compute-side C# migrator always emits its own current
84
134
  * version, and an older shape only lacks optional additions.
85
135
  */
86
136
  function assertSupportedSchemaVersion(schema) {
87
- const version = schema.schemaVersion;
88
- if (!version) return;
89
- const extracted = parseSemver(version);
90
- const supported = parseSemver(UI_SCHEMA_VERSION);
91
- if (!extracted || !supported) return;
92
- if (extracted[0] > supported[0] || extracted[0] === supported[0] && (extracted[1] > supported[1] || extracted[1] === supported[1] && extracted[2] > supported[2])) throw new SchemaExtractionError("unsupported", `This definition was authored with a newer Selva plugin (schema format ${version}); this server supports schema format ≤ ${UI_SCHEMA_VERSION}. Update the server, or re-save the definition with a matching plugin version.`);
137
+ if (compareSchemaVersion(schema.schemaVersion) === 1) throw new SchemaExtractionError("unsupported", `This definition was authored with a newer Selva plugin (schema format ${schema.schemaVersion}); this server supports schema format ≤ ${UI_SCHEMA_VERSION}. Update the server, or re-save the definition with a matching plugin version.`);
93
138
  }
94
139
  /**
95
140
  * POSTs a multipart form to Rhino Compute's `/grasshopper/schema` endpoint (no
@@ -136,6 +181,28 @@ async function fetchSchemaFromCompute(definitionBytes, server) {
136
181
  assertCamelCaseSchema(schemas[0]);
137
182
  return schemas[0];
138
183
  }
139
- export { ComputeServerUnconfiguredError as a, postSchemaFormData as i, assertCamelCaseSchema as n, fetchSchemaFromCompute as r, SchemaExtractionError as t };
184
+ /**
185
+ * How long an upload waits for the saved values once the schema is in. Missing them costs only
186
+ * the first render its defaults: the render path reads them behind that render.
187
+ */
188
+ var SAVED_VALUES_GRACE_MS = 5e3;
189
+ var SAVED_VALUES_TIMEOUT_MS = 12e4;
190
+ /**
191
+ * `fetchSchemaFromCompute` with the values saved in the file as input defaults, so the stored
192
+ * schema renders without asking Compute again. The values are read beside the schema,
193
+ * best-effort: only the schema gates the upload.
194
+ */
195
+ async function extractSchemaForUpload(definitionBytes, server) {
196
+ const values = fetchParsedDefinitionIO(definitionBytes, {
197
+ serverUrl: server.serverUrl,
198
+ ...server.apiKey && { apiKey: server.apiKey },
199
+ timeoutMs: SAVED_VALUES_TIMEOUT_MS
200
+ }).then((io) => savedValuesFrom(io.inputs));
201
+ values.catch(() => {});
202
+ const schema = await fetchSchemaFromCompute(definitionBytes, server);
203
+ const saved = await withTimeout(values, SAVED_VALUES_GRACE_MS, () => /* @__PURE__ */ new Error("saved values not read in time")).catch(() => null);
204
+ return saved ? applySavedValues(schema, saved) : schema;
205
+ }
206
+ export { fetchSchemaFromCompute as a, applySavedValues as c, extractSchemaForUpload as i, savedValuesFrom as l, assertCamelCaseSchema as n, postSchemaFormData as o, compareSchemaVersion as r, withTimeout as s, SchemaExtractionError as t, ComputeServerUnconfiguredError as u };
140
207
 
141
208
  //# sourceMappingURL=schema-extraction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema-extraction.js","names":["readWrapper"],"sources":["../../../../server/src/compute/errors.ts","../../../../server/src/definitions/schema-extraction.ts"],"sourcesContent":["/**\n * Compute error types, kept in a leaf module with no imports.\n *\n * Separate from the function that throws them on purpose: an error mapper needs\n * nothing but the class to `instanceof` against, and importing it from beside\n * the throw site drags that module's dependencies into every mapper. Anything\n * an error mapper imports belongs here.\n */\n\n/**\n * Thrown when no compute server is configured or visible for the org — a\n * misconfiguration an operator must fix in `/admin/compute`, not a bug. Routes\n * map this to 503 instead of letting the pure helper's plain `Error` surface as\n * a generic 500.\n */\nexport class ComputeServerUnconfiguredError extends Error {\n\tconstructor(\n\t\tmessage = 'No compute server configured. Ask an admin to add one in /admin/compute.'\n\t) {\n\t\tsuper(message);\n\t\tthis.name = 'ComputeServerUnconfiguredError';\n\t}\n}\n","// Extraction IS validation: a `.gh` with no valid \"Schema\" output, or an\n// unreachable compute server, throws here — which is what makes this the upload\n// gate as well as the render path's fallback for un-cached or stale versions.\n\nimport {\n\tnormalizeUISchemaCasing,\n\treadSchemaResults as readWrapper,\n\ttype SchemaEndpointResult\n} from '@selvajs/compute/grasshopper';\nimport { UI_SCHEMA_VERSION, type UISchema } from '@selvajs/schemas';\nimport type { ComputeServerConfig } from '@selvajs/platform';\n\n/** One entry of the compute schema endpoint's response, typed to our `UISchema`. */\nexport type SchemaExtractionResult = SchemaEndpointResult<UISchema>;\n\n/** Thin re-export of @selvajs/compute's unwrap, typed to `UISchema`. */\nexport function readSchemaResults(raw: unknown): SchemaExtractionResult[] {\n\treturn readWrapper<UISchema>(raw);\n}\n\n/** Thrown when compute is reachable but the definition yields no usable schema. */\nexport class SchemaExtractionError extends Error {\n\tconstructor(\n\t\tpublic readonly kind: 'unreachable' | 'invalid' | 'unsupported' | 'malformed',\n\t\tmessage: string\n\t) {\n\t\tsuper(message);\n\t\tthis.name = 'SchemaExtractionError';\n\t}\n}\n\n/**\n * Rejects a schema whose keys are not camelCase by the time it reaches a consumer.\n *\n * Compute serializes the plugin's `UISchema` POCO, whose camelCase names live in\n * `[JsonProperty]` attributes. `Selva.gha` ILRepack-merges Newtonsoft, so those\n * attributes have type `Selva!Newtonsoft.Json.JsonPropertyAttribute`; a compute\n * server serializing with its OWN Newtonsoft does not recognize them, reads no\n * attributes, and falls back to raw CLR member names — `Inputs`, `Layout`.\n * Nothing throws on the wire: every consumer just reads `schema.inputs` as\n * undefined and renders a definition with no inputs.\n *\n * `postSchemaFormData` repairs that casing via `normalizeUISchemaCasing`, so a\n * schema fresh off the wire never trips this. It stays because schemas are also\n * PERSISTED: a row cached before the normalizer existed still holds PascalCase,\n * and it reaches consumers without passing through `postSchemaFormData` again.\n * A schema with no `inputs` in any casing lands here too. It is a backstop, not\n * the primary defense — which is why it names the missing key rather than telling\n * the operator to go update their compute server.\n *\n * Checked structurally rather than by plugin version, because the casing depends\n * on which assembly serialized the schema, not on any version number.\n */\nexport function assertCamelCaseSchema(schema: UISchema): void {\n\tconst raw = schema as unknown as Record<string, unknown>;\n\tif (Array.isArray(raw.inputs)) return;\n\n\tconst pascalKeys = ['Inputs', 'Outputs', 'Layout', 'SchemaVersion'].filter((k) => k in raw);\n\tif (pascalKeys.length > 0) {\n\t\tthrow new SchemaExtractionError(\n\t\t\t'malformed',\n\t\t\t`Schema keys are PascalCase (found ${pascalKeys.join(', ')}), so every property name ` +\n\t\t\t\t`is wrong and the definition would render with no inputs. Compute serialized it with ` +\n\t\t\t\t`its own Newtonsoft instead of the one merged into Selva.gha. Fresh responses are ` +\n\t\t\t\t`normalized, so this is most likely a schema cached before that fix — re-save the ` +\n\t\t\t\t`definition version to re-extract it.`\n\t\t);\n\t}\n\n\tthrow new SchemaExtractionError(\n\t\t'malformed',\n\t\t`Compute returned a schema with no 'inputs' array (got keys: ${Object.keys(raw)\n\t\t\t.slice(0, 12)\n\t\t\t.join(', ')}).`\n\t);\n}\n\nfunction parseSemver(version: string): [number, number, number] | null {\n\tconst m = /^(\\d+)\\.(\\d+)\\.(\\d+)$/.exec(version);\n\treturn m ? [Number(m[1]), Number(m[2]), Number(m[3])] : null;\n}\n\n/**\n * Rejects a schema from a NEWER plugin than this app was built against — its\n * shape may contain constructs the renderer doesn't know. Older (or missing)\n * versions pass: the compute-side C# migrator always emits its own current\n * version, and an older shape only lacks optional additions.\n */\nexport function assertSupportedSchemaVersion(schema: UISchema): void {\n\tconst version = schema.schemaVersion;\n\tif (!version) return; // pre-2.12.0 plugin — older than the app, fine\n\tconst extracted = parseSemver(version);\n\tconst supported = parseSemver(UI_SCHEMA_VERSION);\n\tif (!extracted || !supported) return;\n\tconst newer =\n\t\textracted[0] > supported[0] ||\n\t\t(extracted[0] === supported[0] &&\n\t\t\t(extracted[1] > supported[1] ||\n\t\t\t\t(extracted[1] === supported[1] && extracted[2] > supported[2])));\n\tif (newer) {\n\t\tthrow new SchemaExtractionError(\n\t\t\t'unsupported',\n\t\t\t`This definition was authored with a newer Selva plugin (schema format ${version}); ` +\n\t\t\t\t`this server supports schema format ≤ ${UI_SCHEMA_VERSION}. Update the server, or ` +\n\t\t\t\t`re-save the definition with a matching plugin version.`\n\t\t);\n\t}\n}\n\n/**\n * POSTs a multipart form to Rhino Compute's `/grasshopper/schema` endpoint (no\n * solve required). Throws 'unreachable' on a network failure or non-2xx. The\n * per-file `error` Compute reports on its 200-with-no-schemas case is left to\n * the caller — single-file and multi-file callers want different messages.\n */\nexport async function postSchemaFormData(\n\tformData: FormData,\n\tserver: ComputeServerConfig\n): Promise<SchemaExtractionResult[]> {\n\tconst schemaUrl = new URL('/grasshopper/schema', server.serverUrl).toString();\n\n\tconst headers: Record<string, string> = {};\n\tif (server.apiKey) {\n\t\theaders['RhinoComputeKey'] = server.apiKey;\n\t}\n\n\tlet response: Response;\n\ttry {\n\t\tresponse = await fetch(schemaUrl, { method: 'POST', headers, body: formData });\n\t} catch (err) {\n\t\tthrow new SchemaExtractionError(\n\t\t\t'unreachable',\n\t\t\t`Compute server is unreachable: ${err instanceof Error ? err.message : String(err)}`\n\t\t);\n\t}\n\n\tif (!response.ok) {\n\t\tthrow new SchemaExtractionError(\n\t\t\t'unreachable',\n\t\t\t`Schema endpoint returned ${response.status}: ${response.statusText}`\n\t\t);\n\t}\n\n\t// Normalize here rather than in each caller: the upload/validation route reads\n\t// `postSchemaFormData` directly, so a fix applied only inside\n\t// `fetchSchemaFromCompute` would leave that path serving PascalCase schemas.\n\tconst results = readSchemaResults(await response.json());\n\treturn results.map((result) => ({\n\t\t...result,\n\t\tschemas: result.schemas?.map((schema) => normalizeUISchemaCasing(schema))\n\t}));\n}\n\n/**\n * Throws `SchemaExtractionError` so callers can map to the right HTTP status:\n * 503 unreachable / 422 invalid or unsupported.\n */\nexport async function fetchSchemaFromCompute(\n\tdefinitionBytes: Uint8Array,\n\tserver: ComputeServerConfig\n): Promise<UISchema> {\n\tconst formData = new FormData();\n\tconst blob = new Blob([new Uint8Array(definitionBytes)], { type: 'application/octet-stream' });\n\tformData.append('file', blob, 'definition.gh');\n\n\tconst results = await postSchemaFormData(formData, server);\n\tconst schemas = results.flatMap((r) => r.schemas ?? []);\n\n\tif (schemas.length === 0) {\n\t\t// Compute answers 200 while reporting a per-file `error`, so the\n\t\t// !response.ok guard never fires for it. Surface that message verbatim: it\n\t\t// names the actual cause (bad Schema source, no embedded schema, ...),\n\t\t// which the generic fallback below cannot.\n\t\tconst diagnosis = results.map((r) => r.error).filter(Boolean);\n\t\tif (diagnosis.length > 0) {\n\t\t\tthrow new SchemaExtractionError('invalid', diagnosis.join('\\n'));\n\t\t}\n\n\t\tthrow new SchemaExtractionError(\n\t\t\t'invalid',\n\t\t\t'No schemas found in definition.\\n\\n' +\n\t\t\t\t'In Grasshopper, verify a Context Bake component with the output name \"Schema\" is present and wired to the solver.'\n\t\t);\n\t}\n\n\tassertSupportedSchemaVersion(schemas[0]);\n\tassertCamelCaseSchema(schemas[0]);\n\treturn schemas[0];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAeA,IAAa,iCAAb,cAAoD,MAAM;CACzD,YACC,UAAU,4EACT;EACD,MAAM,OAAO;EACb,KAAK,OAAO;CACb;AACD;;;ACNA,SAAgB,kBAAkB,KAAwC;CACzE,OAAOA,oBAAsB,GAAG;AACjC;;AAGA,IAAa,wBAAb,cAA2C,MAAM;CAE/B;CADjB,YACC,MACA,SACC;EACD,MAAM,OAAO;EAHG,KAAA,OAAA;EAIhB,KAAK,OAAO;CACb;AACD;;;;;;;;;;;;;;;;;;;;;;;AAwBA,SAAgB,sBAAsB,QAAwB;CAC7D,MAAM,MAAM;CACZ,IAAI,MAAM,QAAQ,IAAI,MAAM,GAAG;CAE/B,MAAM,aAAa;EAAC;EAAU;EAAW;EAAU;CAAe,CAAC,CAAC,QAAQ,MAAM,KAAK,GAAG;CAC1F,IAAI,WAAW,SAAS,GACvB,MAAM,IAAI,sBACT,aACA,qCAAqC,WAAW,KAAK,IAAI,EAAE,qTAK5D;CAGD,MAAM,IAAI,sBACT,aACA,+DAA+D,OAAO,KAAK,GAAG,CAAC,CAC7E,MAAM,GAAG,EAAE,CAAC,CACZ,KAAK,IAAI,EAAE,GACd;AACD;AAEA,SAAS,YAAY,SAAkD;CACtE,MAAM,IAAI,wBAAwB,K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K,CAAC,IAAI,WAAW,eAAe,CAAC,GAAG,EAAE,MAAM,2BAA2B,CAAC;CAC7F,SAAS,OAAO,QAAQ,MAAM,eAAe;CAE7C,MAAM,UAAU,MAAM,mBAAmB,UAAU,MAAM;CACzD,MAAM,UAAU,QAAQ,SAAS,MAAM,EAAE,WAAW,CAAC,CAAC;CAEtD,IAAI,QAAQ,WAAW,GAAG;EAKzB,MAAM,YAAY,QAAQ,KAAK,MAAM,EAAE,KAAK,CAAC,CAAC,OAAO,OAAO;EAC5D,IAAI,UAAU,SAAS,GACtB,MAAM,IAAI,sBAAsB,WAAW,UAAU,KAAK,IAAI,CAAC;EAGhE,MAAM,IAAI,sBACT,WACA,wJAED;CACD;CAEA,6BAA6B,QAAQ,EAAE;CACvC,sBAAsB,QAAQ,EAAE;CAChC,OAAO,QAAQ;AAChB"}
1
+ {"version":3,"file":"schema-extraction.js","names":["readWrapper"],"sources":["../../../../server/src/compute/errors.ts","../../../../server/src/definitions/saved-values.ts","../../../../server/src/definitions/with-timeout.ts","../../../../server/src/definitions/schema-extraction.ts"],"sourcesContent":["/**\n * Compute error types, kept in a leaf module with no imports.\n *\n * Separate from the function that throws them on purpose: an error mapper needs\n * nothing but the class to `instanceof` against, and importing it from beside\n * the throw site drags that module's dependencies into every mapper. Anything\n * an error mapper imports belongs here.\n */\n\n/**\n * Thrown when no compute server is configured or visible for the org — a\n * misconfiguration an operator must fix in `/admin/compute`, not a bug. Routes\n * map this to 503 instead of letting the pure helper's plain `Error` surface as\n * a generic 500.\n */\nexport class ComputeServerUnconfiguredError extends Error {\n\tconstructor(\n\t\tmessage = 'No compute server configured. Ask an admin to add one in /admin/compute.'\n\t) {\n\t\tsuper(message);\n\t\tthis.name = 'ComputeServerUnconfiguredError';\n\t}\n}\n","// The embedded schema carries input values from the author's last schema sync. Compute's `/io`\n// reads the values saved in the file, which can be newer, and those are what a form must start\n// from. A version's bytes never change, so neither do its saved values.\n\nimport type { UISchema } from '@selvajs/schemas';\n\n/** Each input's saved value, keyed by param id. */\nexport type SavedValues = ReadonlyMap<string, unknown>;\n\nexport function savedValuesFrom(\n\tinputs: ReadonlyArray<{ id?: string; paramType?: string; default?: unknown }>\n): SavedValues {\n\tconst values = new Map<string, unknown>();\n\tfor (const input of inputs) {\n\t\tif (input.id === undefined || input.default === undefined) continue;\n\t\tvalues.set(input.id, input.paramType === 'Color' ? colorToHex(input.default) : input.default);\n\t}\n\treturn values;\n}\n\n/** `schema` with each input's `default` replaced by its saved value, where it has one. */\nexport function applySavedValues(schema: UISchema, values: SavedValues): UISchema {\n\treturn {\n\t\t...schema,\n\t\tinputs: schema.inputs.map((input) =>\n\t\t\tvalues.has(input.id) ? { ...input, default: values.get(input.id) } : input\n\t\t)\n\t};\n}\n\n// Compute sends colors as \"r,g,b\" or \"a,r,g,b\"; the color picker takes hex.\nfunction colorToHex(value: unknown): unknown {\n\tconst parts = String(value)\n\t\t.split(',')\n\t\t.map((s) => parseInt(s.trim(), 10));\n\tconst hex = (n: number) => n.toString(16).padStart(2, '0');\n\tif (parts.length === 3) return `#${hex(parts[0])}${hex(parts[1])}${hex(parts[2])}`;\n\tif (parts.length === 4) return `#${hex(parts[1])}${hex(parts[2])}${hex(parts[3])}`;\n\treturn value;\n}\n","/**\n * Settles with `work`, or rejects with `onTimeout()` after `ms`. `work` is not cancelled: it runs\n * on, and its later rejection stays handled.\n */\nexport function withTimeout<T>(work: Promise<T>, ms: number, onTimeout: () => Error): Promise<T> {\n\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\tconst timeout = new Promise<never>((_, reject) => {\n\t\ttimer = setTimeout(() => reject(onTimeout()), ms);\n\t});\n\treturn Promise.race([work, timeout]).finally(() => clearTimeout(timer));\n}\n","// Extraction IS validation: a `.gh` with no valid \"Schema\" output, or an\n// unreachable compute server, throws here — which is what makes this the upload\n// gate as well as the render path's fallback for un-cached or stale versions.\n\nimport {\n\tfetchParsedDefinitionIO,\n\tnormalizeUISchemaCasing,\n\treadSchemaResults as readWrapper,\n\ttype SchemaEndpointResult\n} from '@selvajs/compute/grasshopper';\nimport { UI_SCHEMA_VERSION, type UISchema } from '@selvajs/schemas';\nimport type { ComputeServerConfig } from '@selvajs/platform';\nimport { applySavedValues, savedValuesFrom } from './saved-values.js';\nimport { withTimeout } from './with-timeout.js';\n\n/** One entry of the compute schema endpoint's response, typed to our `UISchema`. */\nexport type SchemaExtractionResult = SchemaEndpointResult<UISchema>;\n\n/** Thin re-export of @selvajs/compute's unwrap, typed to `UISchema`. */\nexport function readSchemaResults(raw: unknown): SchemaExtractionResult[] {\n\treturn readWrapper<UISchema>(raw);\n}\n\n/** Thrown when compute is reachable but the definition yields no usable schema. */\nexport class SchemaExtractionError extends Error {\n\tconstructor(\n\t\tpublic readonly kind: 'unreachable' | 'invalid' | 'unsupported' | 'malformed',\n\t\tmessage: string\n\t) {\n\t\tsuper(message);\n\t\tthis.name = 'SchemaExtractionError';\n\t}\n}\n\n/**\n * Rejects a schema whose keys are not camelCase by the time it reaches a consumer.\n *\n * Compute serializes the plugin's `UISchema` POCO, whose camelCase names live in\n * `[JsonProperty]` attributes. `Selva.gha` ILRepack-merges Newtonsoft, so those\n * attributes have type `Selva!Newtonsoft.Json.JsonPropertyAttribute`; a compute\n * server serializing with its OWN Newtonsoft does not recognize them, reads no\n * attributes, and falls back to raw CLR member names — `Inputs`, `Layout`.\n * Nothing throws on the wire: every consumer just reads `schema.inputs` as\n * undefined and renders a definition with no inputs.\n *\n * `postSchemaFormData` repairs that casing via `normalizeUISchemaCasing`, so a\n * schema fresh off the wire never trips this. It stays because schemas are also\n * PERSISTED: a row cached before the normalizer existed still holds PascalCase,\n * and it reaches consumers without passing through `postSchemaFormData` again.\n * A schema with no `inputs` in any casing lands here too. It is a backstop, not\n * the primary defense — which is why it names the missing key rather than telling\n * the operator to go update their compute server.\n *\n * Checked structurally rather than by plugin version, because the casing depends\n * on which assembly serialized the schema, not on any version number.\n */\nexport function assertCamelCaseSchema(schema: UISchema): void {\n\tconst raw = schema as unknown as Record<string, unknown>;\n\tif (Array.isArray(raw.inputs)) return;\n\n\tconst pascalKeys = ['Inputs', 'Outputs', 'Layout', 'SchemaVersion'].filter((k) => k in raw);\n\tif (pascalKeys.length > 0) {\n\t\tthrow new SchemaExtractionError(\n\t\t\t'malformed',\n\t\t\t`Schema keys are PascalCase (found ${pascalKeys.join(', ')}), so every property name ` +\n\t\t\t\t`is wrong and the definition would render with no inputs. Compute serialized it with ` +\n\t\t\t\t`its own Newtonsoft instead of the one merged into Selva.gha. Fresh responses are ` +\n\t\t\t\t`normalized, so this is most likely a schema cached before that fix — re-save the ` +\n\t\t\t\t`definition version to re-extract it.`\n\t\t);\n\t}\n\n\tthrow new SchemaExtractionError(\n\t\t'malformed',\n\t\t`Compute returned a schema with no 'inputs' array (got keys: ${Object.keys(raw)\n\t\t\t.slice(0, 12)\n\t\t\t.join(', ')}).`\n\t);\n}\n\nfunction parseSemver(version: string): [number, number, number] | null {\n\tconst m = /^(\\d+)\\.(\\d+)\\.(\\d+)$/.exec(version);\n\treturn m ? [Number(m[1]), Number(m[2]), Number(m[3])] : null;\n}\n\n/**\n * Orders a schema format version against the app's `UI_SCHEMA_VERSION`: -1 older, 0 current,\n * 1 newer, null unparseable. A missing version is older: plugins before 2.12.0 emitted none.\n */\nexport function compareSchemaVersion(version: string | undefined): -1 | 0 | 1 | null {\n\tif (!version) return -1;\n\tconst extracted = parseSemver(version);\n\tconst supported = parseSemver(UI_SCHEMA_VERSION);\n\tif (!extracted || !supported) return null;\n\tfor (let i = 0; i < 3; i++) {\n\t\tif (extracted[i] !== supported[i]) return extracted[i] < supported[i] ? -1 : 1;\n\t}\n\treturn 0;\n}\n\n/**\n * Rejects a schema from a NEWER plugin than this app was built against — its\n * shape may contain constructs the renderer doesn't know. Older (or missing)\n * versions pass: the compute-side C# migrator always emits its own current\n * version, and an older shape only lacks optional additions.\n */\nexport function assertSupportedSchemaVersion(schema: UISchema): void {\n\tif (compareSchemaVersion(schema.schemaVersion) === 1) {\n\t\tthrow new SchemaExtractionError(\n\t\t\t'unsupported',\n\t\t\t`This definition was authored with a newer Selva plugin (schema format ${schema.schemaVersion}); ` +\n\t\t\t\t`this server supports schema format ≤ ${UI_SCHEMA_VERSION}. Update the server, or ` +\n\t\t\t\t`re-save the definition with a matching plugin version.`\n\t\t);\n\t}\n}\n\n/**\n * POSTs a multipart form to Rhino Compute's `/grasshopper/schema` endpoint (no\n * solve required). Throws 'unreachable' on a network failure or non-2xx. The\n * per-file `error` Compute reports on its 200-with-no-schemas case is left to\n * the caller — single-file and multi-file callers want different messages.\n */\nexport async function postSchemaFormData(\n\tformData: FormData,\n\tserver: ComputeServerConfig\n): Promise<SchemaExtractionResult[]> {\n\tconst schemaUrl = new URL('/grasshopper/schema', server.serverUrl).toString();\n\n\tconst headers: Record<string, string> = {};\n\tif (server.apiKey) {\n\t\theaders['RhinoComputeKey'] = server.apiKey;\n\t}\n\n\tlet response: Response;\n\ttry {\n\t\tresponse = await fetch(schemaUrl, { method: 'POST', headers, body: formData });\n\t} catch (err) {\n\t\tthrow new SchemaExtractionError(\n\t\t\t'unreachable',\n\t\t\t`Compute server is unreachable: ${err instanceof Error ? err.message : String(err)}`\n\t\t);\n\t}\n\n\tif (!response.ok) {\n\t\tthrow new SchemaExtractionError(\n\t\t\t'unreachable',\n\t\t\t`Schema endpoint returned ${response.status}: ${response.statusText}`\n\t\t);\n\t}\n\n\t// Normalize here rather than in each caller: the upload/validation route reads\n\t// `postSchemaFormData` directly, so a fix applied only inside\n\t// `fetchSchemaFromCompute` would leave that path serving PascalCase schemas.\n\tconst results = readSchemaResults(await response.json());\n\treturn results.map((result) => ({\n\t\t...result,\n\t\tschemas: result.schemas?.map((schema) => normalizeUISchemaCasing(schema))\n\t}));\n}\n\n/**\n * Throws `SchemaExtractionError` so callers can map to the right HTTP status:\n * 503 unreachable / 422 invalid or unsupported.\n */\nexport async function fetchSchemaFromCompute(\n\tdefinitionBytes: Uint8Array,\n\tserver: ComputeServerConfig\n): Promise<UISchema> {\n\tconst formData = new FormData();\n\tconst blob = new Blob([new Uint8Array(definitionBytes)], { type: 'application/octet-stream' });\n\tformData.append('file', blob, 'definition.gh');\n\n\tconst results = await postSchemaFormData(formData, server);\n\tconst schemas = results.flatMap((r) => r.schemas ?? []);\n\n\tif (schemas.length === 0) {\n\t\t// Compute answers 200 while reporting a per-file `error`, so the\n\t\t// !response.ok guard never fires for it. Surface that message verbatim: it\n\t\t// names the actual cause (bad Schema source, no embedded schema, ...),\n\t\t// which the generic fallback below cannot.\n\t\tconst diagnosis = results.map((r) => r.error).filter(Boolean);\n\t\tif (diagnosis.length > 0) {\n\t\t\tthrow new SchemaExtractionError('invalid', diagnosis.join('\\n'));\n\t\t}\n\n\t\tthrow new SchemaExtractionError(\n\t\t\t'invalid',\n\t\t\t'No schemas found in definition.\\n\\n' +\n\t\t\t\t'In Grasshopper, verify a Context Bake component with the output name \"Schema\" is present and wired to the solver.'\n\t\t);\n\t}\n\n\tassertSupportedSchemaVersion(schemas[0]);\n\tassertCamelCaseSchema(schemas[0]);\n\treturn schemas[0];\n}\n\n/**\n * How long an upload waits for the saved values once the schema is in. Missing them costs only\n * the first render its defaults: the render path reads them behind that render.\n */\nconst SAVED_VALUES_GRACE_MS = 5_000;\n\n// Bounds the `/io` request itself, which outlives an upload that stopped waiting for it.\nconst SAVED_VALUES_TIMEOUT_MS = 120_000;\n\n/**\n * `fetchSchemaFromCompute` with the values saved in the file as input defaults, so the stored\n * schema renders without asking Compute again. The values are read beside the schema,\n * best-effort: only the schema gates the upload.\n */\nexport async function extractSchemaForUpload(\n\tdefinitionBytes: Uint8Array,\n\tserver: ComputeServerConfig\n): Promise<UISchema> {\n\tconst values = fetchParsedDefinitionIO(definitionBytes, {\n\t\tserverUrl: server.serverUrl,\n\t\t...(server.apiKey && { apiKey: server.apiKey }),\n\t\ttimeoutMs: SAVED_VALUES_TIMEOUT_MS\n\t}).then((io) => savedValuesFrom(io.inputs));\n\tvalues.catch(() => {});\n\n\tconst schema = await fetchSchemaFromCompute(definitionBytes, server);\n\tconst saved = await withTimeout(\n\t\tvalues,\n\t\tSAVED_VALUES_GRACE_MS,\n\t\t() => new Error('saved values not read in time')\n\t).catch(() => null);\n\treturn saved ? applySavedValues(schema, saved) : schema;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAeA,IAAa,iCAAb,cAAoD,MAAM;CACzD,YACC,UAAU,4EACT;EACD,MAAM,OAAO;EACb,KAAK,OAAO;CACb;AACD;;ACbA,SAAgB,gBACf,QACc;CACd,MAAM,yBAAS,IAAI,IAAqB;CACxC,KAAK,MAAM,SAAS,QAAQ;EAC3B,IAAI,MAAM,OAAO,KAAA,KAAa,MAAM,YAAY,KAAA,GAAW;EAC3D,OAAO,IAAI,MAAM,IAAI,MAAM,cAAc,UAAU,WAAW,MAAM,OAAO,IAAI,MAAM,OAAO;CAC7F;CACA,OAAO;AACR;;AAGA,SAAgB,iBAAiB,QAAkB,QAA+B;CACjF,OAAO;EACN,GAAG;EACH,QAAQ,OAAO,OAAO,KAAK,UAC1B,OAAO,IAAI,MAAM,EAAE,IAAI;GAAE,GAAG;GAAO,SAAS,OAAO,IAAI,MAAM,EAAE;EAAE,IAAI,KACtE;CACD;AACD;AAGA,SAAS,WAAW,OAAyB;CAC5C,MAAM,QAAQ,OAAO,KAAK,CAAC,CACzB,MAAM,GAAG,CAAC,CACV,KAAK,MAAM,SAAS,EAAE,KAAK,GAAG,EAAE,CAAC;CACnC,MAAM,OAAO,MAAc,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG;CACzD,IAAI,MAAM,WAAW,GAAG,OAAO,IAAI,IAAI,MAAM,EAAE,IAAI,IAAI,MAAM,EAAE,IAAI,IAAI,MAAM,EAAE;CAC/E,IAAI,MAAM,WAAW,GAAG,OAAO,IAAI,IAAI,MAAM,EAAE,IAAI,IAAI,MAAM,EAAE,IAAI,IAAI,MAAM,EAAE;CAC/E,OAAO;AACR;;;;;;ACnCA,SAAgB,YAA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,QAAQ,KAAK,MAAM,EAAE,KAAK,CAAC,CAAC,OAAO,OAAO;EAC5D,IAAI,UAAU,SAAS,GACtB,MAAM,IAAI,sBAAsB,WAAW,UAAU,KAAK,IAAI,CAAC;EAGhE,MAAM,IAAI,sBACT,WACA,wJAED;CACD;CAEA,6BAA6B,QAAQ,EAAE;CACvC,sBAAsB,QAAQ,EAAE;CAChC,OAAO,QAAQ;AAChB;;;;;AAMA,IAAM,wBAAwB;AAG9B,IAAM,0BAA0B;;;;;;AAOhC,eAAsB,uBACrB,iBACA,QACoB;CACpB,MAAM,SAAS,wBAAwB,iBAAiB;EACvD,WAAW,OAAO;EAClB,GAAI,OAAO,UAAU,EAAE,QAAQ,OAAO,OAAO;EAC7C,WAAW;CACZ,CAAC,CAAC,CAAC,MAAM,OAAO,gBAAgB,GAAG,MAAM,CAAC;CAC1C,OAAO,YAAY,CAAC,CAAC;CAErB,MAAM,SAAS,MAAM,uBAAuB,iBAAiB,MAAM;CACnE,MAAM,QAAQ,MAAM,YACnB,QACA,6CACM,IAAI,MAAM,+BAA+B,CAChD,CAAC,CAAC,YAAY,IAAI;CAClB,OAAO,QAAQ,iBAAiB,QAAQ,KAAK,IAAI;AAClD"}
@@ -1,6 +1,6 @@
1
1
  // ../schemas/src/generated/schema.ts
2
2
  /** Current UISchema format version (from ui-schema.json's schemaVersion default). */
3
- var UI_SCHEMA_VERSION = "2.19.0";
3
+ var UI_SCHEMA_VERSION = "2.20.0";
4
4
  function isNumberWidget(item) {
5
5
  return item.type === "input" && item.widgetType === "number";
6
6
  }
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","names":[],"sources":["../../../../schemas/src/generated/schema.ts"],"sourcesContent":["/* eslint-disable */\n/**\n * This file was automatically generated from packages/schemas/ui-schema.json.\n * DO NOT MODIFY IT BY HAND. Instead, modify the source JSON Schema file\n * and run `pnpm generate` at the repo root to regenerate it.\n */\n\nexport type ParamType =\n\t| 'number'\n\t| 'integer'\n\t| 'boolean'\n\t| 'text'\n\t| 'valueList'\n\t| 'dynamicValueList'\n\t| 'file'\n\t| 'color'\n\t| 'generic'\n\t| 'geometry'\n\t| 'point'\n\t| 'line'\n\t| 'plane';\nexport type InputNumberLayoutItem = LayoutItemBase & {\n\ttype: 'input';\n\twidgetType: 'number';\n\tconfig?: NumberWidgetConfig;\n\t[k: string]: unknown | undefined;\n};\nexport type InputTextLayoutItem = LayoutItemBase & {\n\ttype: 'input';\n\twidgetType: 'text';\n\tconfig?: TextWidgetConfig;\n\t[k: string]: unknown | undefined;\n};\nexport type InputDropdownLayoutItem = LayoutItemBase & {\n\ttype: 'input';\n\twidgetType: 'dropdown';\n\tconfig: DropdownWidgetConfig;\n\t[k: string]: unknown | undefined;\n};\nexport type InputDynamicValueListLayoutItem = LayoutItemBase & {\n\ttype: 'input';\n\twidgetType: 'dynamicValueList';\n\tconfig?: DynamicValueListWidgetConfig;\n\t[k: string]: unknown | undefined;\n};\nexport type InputCheckboxLayoutItem = LayoutItemBase & {\n\ttype: 'input';\n\twidgetType: 'checkbox';\n\tconfig?: CheckboxWidgetConfig;\n\t[k: string]: unknown | undefined;\n};\nexport type InputFileLayoutItem = LayoutItemBase & {\n\ttype: 'input';\n\twidgetType: 'file';\n\tconfig?: FileInputWidgetConfig;\n\t[k: string]: unknown | undefined;\n};\nexport type InputColorLayoutItem = LayoutItemBase & {\n\ttype: 'input';\n\twidgetType: 'color';\n\tconfig?: ColorWidgetConfig;\n\t[k: string]: unknown | undefined;\n};\nexport type OutputTextLayoutItem = LayoutItemBase & {\n\ttype: 'output';\n\twidgetType: 'text';\n\t[k: string]: unknown | undefined;\n};\nexport type OutputNumberLayoutItem = LayoutItemBase & {\n\ttype: 'output';\n\twidgetType: 'number';\n\t[k: string]: unknown | undefined;\n};\nexport type OutputFileLayoutItem = LayoutItemBase & {\n\ttype: 'output';\n\twidgetType: 'file';\n\tconfig?: FileWidgetConfig;\n\t[k: string]: unknown | undefined;\n};\nexport type OutputChartLayoutItem = LayoutItemBase & {\n\ttype: 'output';\n\twidgetType: 'chart';\n\tconfig?: ChartWidgetConfig;\n\t[k: string]: unknown | undefined;\n};\nexport type OutputImageLayoutItem = LayoutItemBase & {\n\ttype: 'output';\n\twidgetType: 'image';\n\tconfig?: ImageWidgetConfig;\n\t[k: string]: unknown | undefined;\n};\nexport type OutputDynamicValueListLayoutItem = LayoutItemBase & {\n\ttype: 'output';\n\twidgetType: 'dynamicValueList';\n\tconfig: DynamicValueListOutputConfig;\n\t[k: string]: unknown | undefined;\n};\nexport type LayoutItem =\n\t| InputNumberLayoutItem\n\t| InputTextLayoutItem\n\t| InputDropdownLayoutItem\n\t| InputDynamicValueListLayoutItem\n\t| InputCheckboxLayoutItem\n\t| InputFileLayoutItem\n\t| InputColorLayoutItem\n\t| OutputTextLayoutItem\n\t| OutputNumberLayoutItem\n\t| OutputFileLayoutItem\n\t| OutputChartLayoutItem\n\t| OutputImageLayoutItem\n\t| OutputDynamicValueListLayoutItem\n\t| LineBreakLayoutItem;\nexport type LayoutConfig = TabbedLayoutConfig | FlatLayoutConfig;\nexport type InputStructure = 'item' | 'list' | 'tree';\n\n/**\n * Schema definitions for Selva UI configuration\n */\nexport interface SelvaUISchema {\n\t[k: string]: unknown | undefined;\n}\nexport interface VisibilityRule {\n\t/**\n\t * Parameter ID to watch for changes\n\t */\n\tparamId: string;\n\t/**\n\t * Comparison operator. 'contains', 'containsAny', 'isEmpty', 'isNotEmpty' apply to array-valued params (e.g., checklist value lists).\n\t */\n\toperator:\n\t\t| 'equals'\n\t\t| 'notEquals'\n\t\t| 'greaterThan'\n\t\t| 'lessThan'\n\t\t| 'greaterThanOrEqual'\n\t\t| 'lessThanOrEqual'\n\t\t| 'in'\n\t\t| 'notIn'\n\t\t| 'between'\n\t\t| 'matches'\n\t\t| 'contains'\n\t\t| 'containsAny'\n\t\t| 'isEmpty'\n\t\t| 'isNotEmpty';\n\t/**\n\t * Value to compare against (used for equals, notEquals, greaterThan, lessThan, greaterThanOrEqual, lessThanOrEqual)\n\t */\n\tvalue?: {\n\t\t[k: string]: unknown | undefined;\n\t};\n\t/**\n\t * Array of values (used for 'in', 'notIn' operators, or [min, max] for 'between')\n\t */\n\tvalues?: unknown[];\n}\nexport interface VisibilityCondition {\n\t/**\n\t * Evaluation mode: 'all' = AND (all rules must pass), 'any' = OR (at least one rule must pass)\n\t */\n\tmode?: 'all' | 'any';\n\t/**\n\t * List of rules to evaluate\n\t *\n\t * @minItems 1\n\t */\n\trules: [VisibilityRule, ...VisibilityRule[]];\n\t/**\n\t * Action to apply when condition is met: 'show' makes visible and enabled, 'hide' removes from view, 'disable' makes visible but greyed out and non-interactive\n\t */\n\taction?: 'show' | 'hide' | 'disable';\n\t/**\n\t * Default value to set for the parameter when condition is met. The value should be compatible with the parameter type (number, string, boolean, etc.)\n\t */\n\tdefaultValue?: {\n\t\t[k: string]: unknown | undefined;\n\t};\n}\nexport interface GroupVisibilityCondition {\n\t/**\n\t * Evaluation mode: 'all' = AND (all rules must pass), 'any' = OR (at least one rule must pass)\n\t */\n\tmode?: 'all' | 'any';\n\t/**\n\t * List of rules to evaluate\n\t *\n\t * @minItems 1\n\t */\n\trules: [VisibilityRule, ...VisibilityRule[]];\n\t/**\n\t * Action to apply when condition is met: 'show' makes group visible, 'hide' removes group from view\n\t */\n\taction?: 'show' | 'hide';\n}\nexport interface NumberWidgetConfig {\n\tminimum?: number;\n\tmaximum?: number;\n\tstepSize?: number;\n\tplaceholder?: string;\n\trenderAsSlider?: boolean;\n\t/**\n\t * Never show the min/max hint. Without it, a number box shows the hint beside its label while focused; sliders never show it.\n\t */\n\thideRange?: boolean;\n}\nexport interface TextWidgetConfig {\n\tplaceholder?: string;\n\trequired?: boolean;\n\t/**\n\t * Maximum character length for text input\n\t */\n\tmaxLength?: number;\n\t/**\n\t * Regex pattern for validation (e.g., email, phone)\n\t */\n\tpattern?: string;\n\t/**\n\t * Custom error message shown when pattern validation fails\n\t */\n\tcustomErrorMessage?: string;\n}\nexport interface OptionMedia {\n\t/**\n\t * Asset holding the option's icon (an OptionAsset with d).\n\t */\n\ticon?: string;\n\t/**\n\t * Asset holding the option's thumbnail (an OptionAsset with img).\n\t */\n\timage?: string;\n\t/**\n\t * Iconify name the icon was picked as (e.g. 'lucide:house'), so the builder can reopen the picker on it. Never rendered.\n\t */\n\ticonName?: string;\n}\nexport interface OptionAsset {\n\t/**\n\t * SVG path data on a 24x24 grid, drawn as a stroke (width 2, round caps and joins, no fill). Rendered as a path's d attribute, never as markup.\n\t */\n\td?: string;\n\t/**\n\t * Thumbnail as a base64 data URI. Only WebP, JPEG and PNG are accepted.\n\t */\n\timg?: string;\n\t/**\n\t * Thumbnail width in pixels\n\t */\n\tw?: number;\n\t/**\n\t * Thumbnail height in pixels\n\t */\n\th?: number;\n}\nexport interface DropdownWidgetConfig {\n\t/**\n\t * Key-value pairs for dropdown options\n\t */\n\toptions: {\n\t\t[k: string]: string | undefined;\n\t};\n\trequired?: boolean;\n\t/**\n\t * How to render the value list. 'dropdown' = single-select dropdown (value: string). 'checklist' = multi-select checkboxes (value: string[]); requires list access on the connected parameter. 'segmented' = single-select button row, shown as a dropdown when there are too many options to fit. 'tiles' = single-select grid of thumbnails.\n\t */\n\tdisplayAs?: 'dropdown' | 'checklist' | 'segmented' | 'tiles';\n\t/**\n\t * Icon and thumbnail per option, keyed by option name. Grasshopper owns options; this map is the author's and survives a re-sync.\n\t */\n\toptionMedia?: {\n\t\t[k: string]: OptionMedia | undefined;\n\t};\n}\nexport interface DynamicValueListWidgetConfig {\n\t/**\n\t * Author-provided seed list (name -> value). Shown until computed options replace it. Empty/absent means the input is empty until the first solve produces options.\n\t */\n\tdefaultOptions?: {\n\t\t[k: string]: string | undefined;\n\t};\n\t/**\n\t * What to render when there are no options yet (no defaultOptions and no computed options): 'hide' removes the field from view, 'show-empty' shows a disabled 'no options yet' control.\n\t */\n\temptyBehavior?: 'hide' | 'show-empty';\n\t/**\n\t * How to render the value list. 'dropdown' = single-select (value: string). 'checklist' = multi-select (value: string[]). 'segmented' = single-select button row, shown as a dropdown when there are too many options to fit. 'tiles' = single-select grid of thumbnails.\n\t */\n\tdisplayAs?: 'dropdown' | 'checklist' | 'segmented' | 'tiles';\n\t/**\n\t * Icon and thumbnail per option, keyed by option name. Names without an entry show text only.\n\t */\n\toptionMedia?: {\n\t\t[k: string]: OptionMedia | undefined;\n\t};\n}\nexport interface DynamicValueListOutputConfig {\n\t/**\n\t * The backend parameter's GUID (paramId) of the DynamicValueList input that this output's computed options populate.\n\t */\n\ttargetInputId: string;\n}\nexport interface CheckboxWidgetConfig {\n\t/**\n\t * 'checkbox' = a toggle whose value is sent with every solve. 'button' = a trigger: a press solves once with true, then the input goes back to false. A button holds no value in the form, so presets and value updates skip it.\n\t */\n\tdisplayAs?: 'checkbox' | 'button';\n}\nexport interface FileWidgetConfig {\n\tbuttonLabel?: string;\n\t/**\n\t * File format hint (e.g., '3dm') for setting download extension\n\t */\n\tfileFormat?: string;\n}\nexport interface FileInputWidgetConfig {\n\t/**\n\t * List of accepted file extensions (e.g., ['.3dm', '.step'])\n\t */\n\tacceptedFormats?: string[];\n\t/**\n\t * Which mode is active by default when both are allowed\n\t */\n\tdefaultInputMode?: 'upload' | 'url';\n\t/**\n\t * Which input modes the end user can choose from. If omitted, both are allowed.\n\t */\n\tallowedInputModes?: ('upload' | 'url')[];\n}\nexport interface ColorWidgetConfig {}\nexport interface LayoutItemBase {\n\t/**\n\t * Unique identifier for this layout item in the UI tree (not the parameter ID)\n\t */\n\tid: string;\n\t/**\n\t * References the backend parameter's GUID (Data Source)\n\t */\n\tparamId: string;\n\tdisplayName?: string;\n\tdescription?: string;\n\torder?: number;\n\tspan?: number;\n\t/**\n\t * Base visibility (static). If false, item is always hidden regardless of conditions.\n\t */\n\tvisible?: boolean;\n\tvisibilityCondition?: VisibilityCondition;\n\tsource?: InputSource;\n\t[k: string]: unknown | undefined;\n}\nexport interface InputSource {\n\t/**\n\t * Which data provider supplies the value. 'user' = the person types it into the form. 'client' = a browser app (e.g. a measurement/producer tool) fills it in before the form runs, not the person. 'server' = reserved for a server-side lookup that no host performs yet: the input solves with its default, a solve that posts a value for it is refused, and it is never shown in the form.\n\t */\n\tkind: 'user' | 'client' | 'server';\n\t/**\n\t * The address the host resolves to fill this input — opaque to Selva, interpreted by the host per 'kind'. For 'client' it names WHICH producer app supplies the value (e.g. 'line-app', 'file-upload') so the host pre-routes to it; for 'server' it names WHAT a resolver would fetch (e.g. 'capture.geometry'). Keys need not be unique: the same producer/fetch may fill several inputs. Ignored for kind='user'.\n\t */\n\tkey?: string;\n\t/**\n\t * How a client-sourced input appears in the form (only meaningful when kind='client'). Omitted = 'hidden': the value is prefilled silently and the input does not appear. 'slot' = Selva reserves the input's grid cell and lets the host render its own element there; Selva draws nothing itself and never interprets that element.\n\t */\n\tclient?: {\n\t\t/**\n\t\t * 'hidden' = no UI; the producer app prefills the value and the input does not appear. 'slot' = the host renders a custom element (e.g. an 'Edit JSON' button) in this input's place, referencing the producer named by 'key'.\n\t\t */\n\t\tpresentation?: 'hidden' | 'slot';\n\t};\n}\nexport interface ChartWidgetConfig {}\nexport interface ImageWidgetConfig {\n\t/**\n\t * Show a download button on the image viewer\n\t */\n\tallowDownload?: boolean;\n\t/**\n\t * Show a fullscreen toggle button on the image viewer\n\t */\n\tallowFullscreen?: boolean;\n\t/**\n\t * Optional background color shown behind the image (hex string, e.g. '#ffffff')\n\t */\n\tbackgroundColor?: string;\n}\nexport interface LineBreakLayoutItem {\n\t/**\n\t * Unique identifier for this layout item in the UI tree\n\t */\n\tid: string;\n\ttype: 'linebreak';\n}\nexport interface GroupConfig {\n\tid: string;\n\tlabel: string;\n\tdescription?: string;\n\torder?: number;\n\tcollapsed?: boolean;\n\tcolumns?: number;\n\titems: LayoutItem[];\n\tvisibilityCondition?: GroupVisibilityCondition;\n}\nexport interface TabConfig {\n\tid: string;\n\tlabel: string;\n\ticon?: string;\n\torder?: number;\n\tgroups: GroupConfig[];\n\t/**\n\t * Horizontal region where this tab should be positioned in multi-column layouts\n\t */\n\tposition?: 'left' | 'center' | 'right';\n\t/**\n\t * Base visibility (static). If false, the tab is always hidden. A tab whose groups are all hidden is hidden too.\n\t */\n\tvisible?: boolean;\n}\nexport interface TabbedLayoutConfig {\n\ttype: 'tabbed';\n\tgap?: number;\n\ttabs: TabConfig[];\n}\nexport interface FlatLayoutConfig {\n\ttype: 'flat';\n\tgap?: number;\n\tgroups: GroupConfig[];\n}\nexport interface SchemaInput {\n\t/**\n\t * Backend-specific parameter identifier (e.g. a Grasshopper InstanceGuid)\n\t */\n\tid: string;\n\tnickname: string;\n\tparamType: ParamType;\n\tdescription?: string;\n\tdefault?: unknown;\n\t/**\n\t * Data access mode: 'item' = single value, 'list' = flat list, 'tree' = branching data tree. Defaults to 'item'.\n\t */\n\tinputStructure?: 'item' | 'list' | 'tree';\n}\nexport interface SchemaOutput {\n\t/**\n\t * Backend-specific parameter identifier (e.g. a Grasshopper InstanceGuid)\n\t */\n\tid: string;\n\tnickname: string;\n\tdescription?: string;\n\t/**\n\t * Output display type\n\t */\n\ttype: 'text' | 'number' | 'file' | 'chart' | 'dynamicValueList';\n\t/**\n\t * For 'dynamicValueList' outputs: the instance GUID (paramId) of the DynamicValueList input that this output's computed options populate.\n\t */\n\ttargetInputId?: string;\n}\nexport interface ViewerOptions {\n\t/**\n\t * If true, the plugin streams display meshes to its local web preview, which then shows the 3D viewer. Selva ignores it.\n\t */\n\tenableLocal?: boolean;\n\t/**\n\t * If true, Selva draws the display meshes in the Rhino.Compute response and shows the 3D viewer. The plugin's local preview ignores it.\n\t */\n\tenableRemote?: boolean;\n\t/**\n\t * Background color for the 3D viewer as hex string (e.g., '#ffffff')\n\t */\n\tbackgroundColor?: string;\n\t/**\n\t * The viewer look a definition opens in. A viewer can still switch look from its display menu.\n\t */\n\tlook?:\n\t\t'technical' | 'studio' | 'showcase' | 'arctic' | 'xray' | 'lineart' | 'wireframe' | 'night';\n}\nexport interface LocalOptions {\n\t/**\n\t * If true, geometry picked in the Rhino viewport follows the Rhino objects it came from: editing or moving one re-solves with its new shape, deleting one drops it. If false, a pick is a snapshot.\n\t */\n\ttrackPickedObjects?: boolean;\n}\nexport interface UISchema {\n\tid: string;\n\tname: string;\n\tdescription?: string;\n\t/**\n\t * Grasshopper document file name (e.g., 'myfile.gh')\n\t */\n\tprojectFileName?: string;\n\t/**\n\t * Grasshopper document unique identifier (GUID)\n\t */\n\tdocumentId?: string;\n\t/**\n\t * Version of Selva plugin that created/last modified this schema\n\t */\n\tpluginVersion?: string;\n\t/**\n\t * Tags for the Selva library (e.g., ['architecture', 'facade']). Selva copies them into the definition when it is uploaded; after that the definition's own tags win. At most MAX_TAGS, none containing a comma.\n\t */\n\ttags?: string[];\n\t/**\n\t * Category for the Selva library (e.g., 'architecture', 'structural'). Selva copies it into the definition when it is uploaded; after that the definition's own category wins. At most MAX_CATEGORY_LENGTH characters.\n\t */\n\tcategory?: string;\n\t/**\n\t * User or organization who created the schema\n\t */\n\tauthor?: string;\n\t/**\n\t * Organization/company name\n\t */\n\torganization?: string;\n\t/**\n\t * Semantic version of the schema format (MAJOR.MINOR.PATCH)\n\t */\n\tschemaVersion: string;\n\t/**\n\t * Minimum plugin version required to load this schema\n\t */\n\tminPluginVersion?: string;\n\tcreated?: string;\n\t/**\n\t * Last modification timestamp\n\t */\n\tlastModified?: string;\n\tviewerOptions?: ViewerOptions1;\n\tlocalOptions?: LocalOptions;\n\t/**\n\t * If true, changes trigger immediate solving. If false, user must press Calculate button.\n\t */\n\tinstanceSolve?: boolean;\n\tinputs: SchemaInput[];\n\t/**\n\t * All output components (print, bake, file download)\n\t */\n\toutputs: SchemaOutput[];\n\tlayout: LayoutConfig;\n\t/**\n\t * Icons and thumbnails referenced by optionMedia, keyed by a hash of their content so a shared one is stored once.\n\t */\n\tassets?: {\n\t\t[k: string]: OptionAsset | undefined;\n\t};\n}\n/**\n * Configuration for the 3D viewer\n */\nexport interface ViewerOptions1 {\n\t/**\n\t * If true, the plugin streams display meshes to its local web preview, which then shows the 3D viewer. Selva ignores it.\n\t */\n\tenableLocal?: boolean;\n\t/**\n\t * If true, Selva draws the display meshes in the Rhino.Compute response and shows the 3D viewer. The plugin's local preview ignores it.\n\t */\n\tenableRemote?: boolean;\n\t/**\n\t * Background color for the 3D viewer as hex string (e.g., '#ffffff')\n\t */\n\tbackgroundColor?: string;\n\t/**\n\t * The viewer look a definition opens in. A viewer can still switch look from its display menu.\n\t */\n\tlook?:\n\t\t'technical' | 'studio' | 'showcase' | 'arctic' | 'xray' | 'lineart' | 'wireframe' | 'night';\n}\n\n// ============================================================================\n// CONSTANTS (from schema)\n// ============================================================================\n\nexport const ACCEPTED_FILE_FORMATS = [\n\t'.3dm',\n\t'.stp',\n\t'.step',\n\t'.fbx',\n\t'.obj',\n\t'.dxf',\n\t'.stl'\n] as const;\nexport const MAX_TAGS = 5 as const;\nexport const MAX_CATEGORY_LENGTH = 40 as const;\n\n/** Current UISchema format version (from ui-schema.json's schemaVersion default). */\nexport const UI_SCHEMA_VERSION = '2.19.0';\n\n// ============================================================================\n// TYPE ALIASES AND GUARDS (derived from the LayoutItem union)\n// ============================================================================\n\nexport type InputLayoutItem =\n\t| InputNumberLayoutItem\n\t| InputTextLayoutItem\n\t| InputDropdownLayoutItem\n\t| InputDynamicValueListLayoutItem\n\t| InputCheckboxLayoutItem\n\t| InputFileLayoutItem\n\t| InputColorLayoutItem;\nexport type OutputLayoutItem =\n\t| OutputTextLayoutItem\n\t| OutputNumberLayoutItem\n\t| OutputFileLayoutItem\n\t| OutputChartLayoutItem\n\t| OutputImageLayoutItem\n\t| OutputDynamicValueListLayoutItem;\nexport type SupportedTypes = string | number | boolean | string[];\n\nexport function isInputLayoutItem(item: LayoutItem): item is InputLayoutItem {\n\treturn item.type === 'input';\n}\n\nexport function isOutputLayoutItem(item: LayoutItem): item is OutputLayoutItem {\n\treturn item.type === 'output';\n}\n\nexport function isLineBreakLayoutItem(item: LayoutItem): item is LineBreakLayoutItem {\n\treturn item.type === 'linebreak';\n}\n\nexport function isNumberWidget(item: LayoutItem): item is InputNumberLayoutItem {\n\treturn item.type === 'input' && item.widgetType === 'number';\n}\n\nexport function isTextWidget(item: LayoutItem): item is InputTextLayoutItem {\n\treturn item.type === 'input' && item.widgetType === 'text';\n}\n\nexport function isDropdownWidget(item: LayoutItem): item is InputDropdownLayoutItem {\n\treturn item.type === 'input' && item.widgetType === 'dropdown';\n}\n\nexport function isDynamicValueListWidget(\n\titem: LayoutItem\n): item is InputDynamicValueListLayoutItem {\n\treturn item.type === 'input' && item.widgetType === 'dynamicValueList';\n}\n\nexport function isCheckboxWidget(item: LayoutItem): item is InputCheckboxLayoutItem {\n\treturn item.type === 'input' && item.widgetType === 'checkbox';\n}\n\nexport function isFileWidget(item: LayoutItem): item is InputFileLayoutItem {\n\treturn item.type === 'input' && item.widgetType === 'file';\n}\n\nexport function isColorWidget(item: LayoutItem): item is InputColorLayoutItem {\n\treturn item.type === 'input' && item.widgetType === 'color';\n}\n\nexport function isTextOutputWidget(item: LayoutItem): item is OutputTextLayoutItem {\n\treturn item.type === 'output' && item.widgetType === 'text';\n}\n\nexport function isNumberOutputWidget(item: LayoutItem): item is OutputNumberLayoutItem {\n\treturn item.type === 'output' && item.widgetType === 'number';\n}\n\nexport function isFileOutputWidget(item: LayoutItem): item is OutputFileLayoutItem {\n\treturn item.type === 'output' && item.widgetType === 'file';\n}\n\nexport function isChartOutputWidget(item: LayoutItem): item is OutputChartLayoutItem {\n\treturn item.type === 'output' && item.widgetType === 'chart';\n}\n\nexport function isImageOutputWidget(item: LayoutItem): item is OutputImageLayoutItem {\n\treturn item.type === 'output' && item.widgetType === 'image';\n}\n\nexport function isDynamicValueListOutputWidget(\n\titem: LayoutItem\n): item is OutputDynamicValueListLayoutItem {\n\treturn item.type === 'output' && item.widgetType === 'dynamicValueList';\n}\n"],"mappings":";;AAukBA,IAAa,oBAAoB;AAmCjC,SAAgB,eAAe,MAAiD;CAC/E,OAAO,KAAK,SAAS,WAAW,KAAK,eAAe;AACrD;AAEA,SAAgB,aAAa,MAA+C;CAC3E,OAAO,KAAK,SAAS,WAAW,KAAK,eAAe;AACrD;AAEA,SAAgB,iBAAiB,MAAmD;CACnF,OAAO,KAAK,SAAS,WAAW,KAAK,eAAe;AACrD;AAEA,SAAgB,yBACf,MAC0C;CAC1C,OAAO,KAAK,SAAS,WAAW,KAAK,eAAe;AACrD;AAEA,SAAgB,iBAAiB,MAAmD;CACnF,OAAO,KAAK,SAAS,WAAW,KAAK,eAAe;AACrD;AAEA,SAAgB,aAAa,MAA+C;CAC3E,OAAO,KAAK,SAAS,WAAW,KAAK,eAAe;AACrD;AAEA,SAAgB,cAAc,MAAgD;CAC7E,OAAO,KAAK,SAAS,WAAW,KAAK,eAAe;AACrD"}
1
+ {"version":3,"file":"schema.js","names":[],"sources":["../../../../schemas/src/generated/schema.ts"],"sourcesContent":["/* eslint-disable */\n/**\n * This file was automatically generated from packages/schemas/ui-schema.json.\n * DO NOT MODIFY IT BY HAND. Instead, modify the source JSON Schema file\n * and run `pnpm generate` at the repo root to regenerate it.\n */\n\nexport type ParamType =\n\t| 'number'\n\t| 'integer'\n\t| 'boolean'\n\t| 'text'\n\t| 'valueList'\n\t| 'dynamicValueList'\n\t| 'file'\n\t| 'color'\n\t| 'generic'\n\t| 'geometry'\n\t| 'point'\n\t| 'line'\n\t| 'plane';\nexport type InputNumberLayoutItem = LayoutItemBase & {\n\ttype: 'input';\n\twidgetType: 'number';\n\tconfig?: NumberWidgetConfig;\n\t[k: string]: unknown | undefined;\n};\nexport type InputTextLayoutItem = LayoutItemBase & {\n\ttype: 'input';\n\twidgetType: 'text';\n\tconfig?: TextWidgetConfig;\n\t[k: string]: unknown | undefined;\n};\nexport type InputDropdownLayoutItem = LayoutItemBase & {\n\ttype: 'input';\n\twidgetType: 'dropdown';\n\tconfig: DropdownWidgetConfig;\n\t[k: string]: unknown | undefined;\n};\nexport type InputDynamicValueListLayoutItem = LayoutItemBase & {\n\ttype: 'input';\n\twidgetType: 'dynamicValueList';\n\tconfig?: DynamicValueListWidgetConfig;\n\t[k: string]: unknown | undefined;\n};\nexport type InputCheckboxLayoutItem = LayoutItemBase & {\n\ttype: 'input';\n\twidgetType: 'checkbox';\n\tconfig?: CheckboxWidgetConfig;\n\t[k: string]: unknown | undefined;\n};\nexport type InputFileLayoutItem = LayoutItemBase & {\n\ttype: 'input';\n\twidgetType: 'file';\n\tconfig?: FileInputWidgetConfig;\n\t[k: string]: unknown | undefined;\n};\nexport type InputColorLayoutItem = LayoutItemBase & {\n\ttype: 'input';\n\twidgetType: 'color';\n\tconfig?: ColorWidgetConfig;\n\t[k: string]: unknown | undefined;\n};\nexport type OutputTextLayoutItem = LayoutItemBase & {\n\ttype: 'output';\n\twidgetType: 'text';\n\t[k: string]: unknown | undefined;\n};\nexport type OutputNumberLayoutItem = LayoutItemBase & {\n\ttype: 'output';\n\twidgetType: 'number';\n\t[k: string]: unknown | undefined;\n};\nexport type OutputFileLayoutItem = LayoutItemBase & {\n\ttype: 'output';\n\twidgetType: 'file';\n\tconfig?: FileWidgetConfig;\n\t[k: string]: unknown | undefined;\n};\nexport type OutputChartLayoutItem = LayoutItemBase & {\n\ttype: 'output';\n\twidgetType: 'chart';\n\tconfig?: ChartWidgetConfig;\n\t[k: string]: unknown | undefined;\n};\nexport type OutputImageLayoutItem = LayoutItemBase & {\n\ttype: 'output';\n\twidgetType: 'image';\n\tconfig?: ImageWidgetConfig;\n\t[k: string]: unknown | undefined;\n};\nexport type OutputDynamicValueListLayoutItem = LayoutItemBase & {\n\ttype: 'output';\n\twidgetType: 'dynamicValueList';\n\tconfig: DynamicValueListOutputConfig;\n\t[k: string]: unknown | undefined;\n};\nexport type LayoutItem =\n\t| InputNumberLayoutItem\n\t| InputTextLayoutItem\n\t| InputDropdownLayoutItem\n\t| InputDynamicValueListLayoutItem\n\t| InputCheckboxLayoutItem\n\t| InputFileLayoutItem\n\t| InputColorLayoutItem\n\t| OutputTextLayoutItem\n\t| OutputNumberLayoutItem\n\t| OutputFileLayoutItem\n\t| OutputChartLayoutItem\n\t| OutputImageLayoutItem\n\t| OutputDynamicValueListLayoutItem\n\t| LineBreakLayoutItem;\nexport type LayoutConfig = TabbedLayoutConfig | FlatLayoutConfig;\nexport type InputStructure = 'item' | 'list' | 'tree';\n\n/**\n * Schema definitions for Selva UI configuration\n */\nexport interface SelvaUISchema {\n\t[k: string]: unknown | undefined;\n}\nexport interface VisibilityRule {\n\t/**\n\t * Parameter ID to watch for changes\n\t */\n\tparamId: string;\n\t/**\n\t * Comparison operator. 'contains', 'containsAny', 'isEmpty', 'isNotEmpty' apply to array-valued params (e.g., checklist value lists).\n\t */\n\toperator:\n\t\t| 'equals'\n\t\t| 'notEquals'\n\t\t| 'greaterThan'\n\t\t| 'lessThan'\n\t\t| 'greaterThanOrEqual'\n\t\t| 'lessThanOrEqual'\n\t\t| 'in'\n\t\t| 'notIn'\n\t\t| 'between'\n\t\t| 'matches'\n\t\t| 'contains'\n\t\t| 'containsAny'\n\t\t| 'isEmpty'\n\t\t| 'isNotEmpty';\n\t/**\n\t * Value to compare against (used for equals, notEquals, greaterThan, lessThan, greaterThanOrEqual, lessThanOrEqual)\n\t */\n\tvalue?: {\n\t\t[k: string]: unknown | undefined;\n\t};\n\t/**\n\t * Array of values (used for 'in', 'notIn' operators, or [min, max] for 'between')\n\t */\n\tvalues?: unknown[];\n}\nexport interface VisibilityCondition {\n\t/**\n\t * Evaluation mode: 'all' = AND (all rules must pass), 'any' = OR (at least one rule must pass)\n\t */\n\tmode?: 'all' | 'any';\n\t/**\n\t * List of rules to evaluate\n\t *\n\t * @minItems 1\n\t */\n\trules: [VisibilityRule, ...VisibilityRule[]];\n\t/**\n\t * Action to apply when condition is met: 'show' makes visible and enabled, 'hide' removes from view, 'disable' makes visible but greyed out and non-interactive\n\t */\n\taction?: 'show' | 'hide' | 'disable';\n\t/**\n\t * Default value to set for the parameter when condition is met. The value should be compatible with the parameter type (number, string, boolean, etc.)\n\t */\n\tdefaultValue?: {\n\t\t[k: string]: unknown | undefined;\n\t};\n}\nexport interface GroupVisibilityCondition {\n\t/**\n\t * Evaluation mode: 'all' = AND (all rules must pass), 'any' = OR (at least one rule must pass)\n\t */\n\tmode?: 'all' | 'any';\n\t/**\n\t * List of rules to evaluate\n\t *\n\t * @minItems 1\n\t */\n\trules: [VisibilityRule, ...VisibilityRule[]];\n\t/**\n\t * Action to apply when condition is met: 'show' makes group visible, 'hide' removes group from view\n\t */\n\taction?: 'show' | 'hide';\n}\nexport interface NumberWidgetConfig {\n\tminimum?: number;\n\tmaximum?: number;\n\tstepSize?: number;\n\tplaceholder?: string;\n\trenderAsSlider?: boolean;\n\t/**\n\t * Never show the min/max hint. Without it, a number box shows the hint beside its label while focused; sliders never show it.\n\t */\n\thideRange?: boolean;\n}\nexport interface TextWidgetConfig {\n\tplaceholder?: string;\n\trequired?: boolean;\n\t/**\n\t * Maximum character length for text input\n\t */\n\tmaxLength?: number;\n\t/**\n\t * Regex pattern for validation (e.g., email, phone)\n\t */\n\tpattern?: string;\n\t/**\n\t * Custom error message shown when pattern validation fails\n\t */\n\tcustomErrorMessage?: string;\n}\nexport interface OptionMedia {\n\t/**\n\t * Asset holding the option's icon (an OptionAsset with d).\n\t */\n\ticon?: string;\n\t/**\n\t * Asset holding the option's thumbnail (an OptionAsset with img).\n\t */\n\timage?: string;\n\t/**\n\t * Iconify name the icon was picked as (e.g. 'lucide:house'), so the builder can reopen the picker on it. Never rendered.\n\t */\n\ticonName?: string;\n}\nexport interface OptionAsset {\n\t/**\n\t * SVG path data on a 24x24 grid, drawn as a stroke (width 2, round caps and joins, no fill). Rendered as a path's d attribute, never as markup.\n\t */\n\td?: string;\n\t/**\n\t * Thumbnail as a base64 data URI. Only WebP, JPEG and PNG are accepted.\n\t */\n\timg?: string;\n\t/**\n\t * Thumbnail width in pixels\n\t */\n\tw?: number;\n\t/**\n\t * Thumbnail height in pixels\n\t */\n\th?: number;\n}\nexport interface DropdownWidgetConfig {\n\t/**\n\t * Key-value pairs for dropdown options\n\t */\n\toptions: {\n\t\t[k: string]: string | undefined;\n\t};\n\trequired?: boolean;\n\t/**\n\t * How to render the value list. 'dropdown' = single-select dropdown (value: string). 'checklist' = multi-select checkboxes (value: string[]); requires list access on the connected parameter. 'segmented' = single-select button row, shown as a dropdown when there are too many options to fit. 'tiles' = single-select grid of thumbnails.\n\t */\n\tdisplayAs?: 'dropdown' | 'checklist' | 'segmented' | 'tiles';\n\t/**\n\t * Icon and thumbnail per option, keyed by option name. Grasshopper owns options; this map is the author's and survives a re-sync.\n\t */\n\toptionMedia?: {\n\t\t[k: string]: OptionMedia | undefined;\n\t};\n}\nexport interface DynamicValueListWidgetConfig {\n\t/**\n\t * Author-provided seed list (name -> value). Shown until computed options replace it. Empty/absent means the input is empty until the first solve produces options.\n\t */\n\tdefaultOptions?: {\n\t\t[k: string]: string | undefined;\n\t};\n\t/**\n\t * What to render when there are no options yet (no defaultOptions and no computed options): 'hide' removes the field from view, 'show-empty' shows a disabled 'no options yet' control.\n\t */\n\temptyBehavior?: 'hide' | 'show-empty';\n\t/**\n\t * How to render the value list. 'dropdown' = single-select (value: string). 'checklist' = multi-select (value: string[]). 'segmented' = single-select button row, shown as a dropdown when there are too many options to fit. 'tiles' = single-select grid of thumbnails.\n\t */\n\tdisplayAs?: 'dropdown' | 'checklist' | 'segmented' | 'tiles';\n\t/**\n\t * Icon and thumbnail per option, keyed by option name. Names without an entry show text only.\n\t */\n\toptionMedia?: {\n\t\t[k: string]: OptionMedia | undefined;\n\t};\n}\nexport interface DynamicValueListOutputConfig {\n\t/**\n\t * The backend parameter's GUID (paramId) of the DynamicValueList input that this output's computed options populate.\n\t */\n\ttargetInputId: string;\n}\nexport interface CheckboxWidgetConfig {\n\t/**\n\t * 'checkbox' = a toggle whose value is sent with every solve. 'button' = a trigger: a press solves once with true, then the input goes back to false. A button holds no value in the form, so presets and value updates skip it.\n\t */\n\tdisplayAs?: 'checkbox' | 'button';\n}\nexport interface FileWidgetConfig {\n\tbuttonLabel?: string;\n\t/**\n\t * File format hint (e.g., '3dm') for setting download extension\n\t */\n\tfileFormat?: string;\n}\nexport interface FileInputWidgetConfig {\n\t/**\n\t * List of accepted file extensions (e.g., ['.3dm', '.step'])\n\t */\n\tacceptedFormats?: string[];\n\t/**\n\t * Which mode is active by default when both are allowed\n\t */\n\tdefaultInputMode?: 'upload' | 'url';\n\t/**\n\t * Which input modes the end user can choose from. If omitted, both are allowed.\n\t */\n\tallowedInputModes?: ('upload' | 'url')[];\n}\nexport interface ColorWidgetConfig {}\nexport interface LayoutItemBase {\n\t/**\n\t * Unique identifier for this layout item in the UI tree (not the parameter ID)\n\t */\n\tid: string;\n\t/**\n\t * References the backend parameter's GUID (Data Source)\n\t */\n\tparamId: string;\n\tdisplayName?: string;\n\tdescription?: string;\n\torder?: number;\n\tspan?: number;\n\t/**\n\t * Base visibility (static). If false, item is always hidden regardless of conditions.\n\t */\n\tvisible?: boolean;\n\tvisibilityCondition?: VisibilityCondition;\n\tsource?: InputSource;\n\t[k: string]: unknown | undefined;\n}\nexport interface InputSource {\n\t/**\n\t * Which data provider supplies the value. 'user' = the person types it into the form. 'client' = a browser app (e.g. a measurement/producer tool) fills it in before the form runs, not the person. 'server' = reserved for a server-side lookup that no host performs yet: the input solves with its default, a solve that posts a value for it is refused, and it is never shown in the form.\n\t */\n\tkind: 'user' | 'client' | 'server';\n\t/**\n\t * The address the host resolves to fill this input — opaque to Selva, interpreted by the host per 'kind'. For 'client' it names WHICH producer app supplies the value (e.g. 'line-app', 'file-upload') so the host pre-routes to it; for 'server' it names WHAT a resolver would fetch (e.g. 'capture.geometry'). Keys need not be unique: the same producer/fetch may fill several inputs. Ignored for kind='user'.\n\t */\n\tkey?: string;\n\t/**\n\t * How a client-sourced input appears in the form (only meaningful when kind='client'). Omitted = 'hidden': the value is prefilled silently and the input does not appear. 'slot' = Selva reserves the input's grid cell and lets the host render its own element there; Selva draws nothing itself and never interprets that element.\n\t */\n\tclient?: {\n\t\t/**\n\t\t * 'hidden' = no UI; the producer app prefills the value and the input does not appear. 'slot' = the host renders a custom element (e.g. an 'Edit JSON' button) in this input's place, referencing the producer named by 'key'.\n\t\t */\n\t\tpresentation?: 'hidden' | 'slot';\n\t};\n}\nexport interface ChartWidgetConfig {}\nexport interface ImageWidgetConfig {\n\t/**\n\t * Show a download button on the image viewer\n\t */\n\tallowDownload?: boolean;\n\t/**\n\t * Show a fullscreen toggle button on the image viewer\n\t */\n\tallowFullscreen?: boolean;\n\t/**\n\t * Optional background color shown behind the image (hex string, e.g. '#ffffff')\n\t */\n\tbackgroundColor?: string;\n}\nexport interface LineBreakLayoutItem {\n\t/**\n\t * Unique identifier for this layout item in the UI tree\n\t */\n\tid: string;\n\ttype: 'linebreak';\n}\nexport interface GroupConfig {\n\tid: string;\n\tlabel: string;\n\tdescription?: string;\n\torder?: number;\n\tcollapsed?: boolean;\n\tcolumns?: number;\n\titems: LayoutItem[];\n\tvisibilityCondition?: GroupVisibilityCondition;\n}\nexport interface TabConfig {\n\tid: string;\n\tlabel: string;\n\ticon?: string;\n\torder?: number;\n\tgroups: GroupConfig[];\n\t/**\n\t * Horizontal region where this tab should be positioned in multi-column layouts\n\t */\n\tposition?: 'left' | 'center' | 'right';\n\t/**\n\t * Base visibility (static). If false, the tab is always hidden. A tab whose groups are all hidden is hidden too.\n\t */\n\tvisible?: boolean;\n}\nexport interface TabbedLayoutConfig {\n\ttype: 'tabbed';\n\tgap?: number;\n\ttabs: TabConfig[];\n}\nexport interface FlatLayoutConfig {\n\ttype: 'flat';\n\tgap?: number;\n\tgroups: GroupConfig[];\n}\nexport interface SchemaInput {\n\t/**\n\t * Backend-specific parameter identifier (e.g. a Grasshopper InstanceGuid)\n\t */\n\tid: string;\n\tnickname: string;\n\tparamType: ParamType;\n\tdescription?: string;\n\tdefault?: unknown;\n\t/**\n\t * Data access mode: 'item' = single value, 'list' = flat list, 'tree' = branching data tree. Defaults to 'item'.\n\t */\n\tinputStructure?: 'item' | 'list' | 'tree';\n}\nexport interface SchemaOutput {\n\t/**\n\t * Backend-specific parameter identifier (e.g. a Grasshopper InstanceGuid)\n\t */\n\tid: string;\n\tnickname: string;\n\tdescription?: string;\n\t/**\n\t * Output display type\n\t */\n\ttype: 'text' | 'number' | 'file' | 'chart' | 'dynamicValueList';\n\t/**\n\t * For 'dynamicValueList' outputs: the instance GUID (paramId) of the DynamicValueList input that this output's computed options populate.\n\t */\n\ttargetInputId?: string;\n}\nexport interface ViewerOptions {\n\t/**\n\t * If true, the plugin streams display meshes to its local web preview, which then shows the 3D viewer. Selva ignores it.\n\t */\n\tenableLocal?: boolean;\n\t/**\n\t * If true, Selva draws the display meshes in the Rhino.Compute response and shows the 3D viewer. The plugin's local preview ignores it.\n\t */\n\tenableRemote?: boolean;\n\t/**\n\t * Background color for the 3D viewer as hex string (e.g., '#ffffff')\n\t */\n\tbackgroundColor?: string;\n\t/**\n\t * The viewer look a definition opens in. A viewer can still switch look from its display menu.\n\t */\n\tlook?:\n\t\t'technical' | 'studio' | 'showcase' | 'arctic' | 'xray' | 'lineart' | 'wireframe' | 'night';\n}\nexport interface LocalOptions {\n\t/**\n\t * If true, geometry picked in the Rhino viewport follows the Rhino objects it came from: editing or moving one re-solves with its new shape, deleting one drops it. If false, a pick is a snapshot.\n\t */\n\ttrackPickedObjects?: boolean;\n}\nexport interface UISchema {\n\tid: string;\n\tname: string;\n\tdescription?: string;\n\t/**\n\t * Grasshopper document file name (e.g., 'myfile.gh')\n\t */\n\tprojectFileName?: string;\n\t/**\n\t * Grasshopper document unique identifier (GUID)\n\t */\n\tdocumentId?: string;\n\t/**\n\t * Version of Selva plugin that created/last modified this schema\n\t */\n\tpluginVersion?: string;\n\t/**\n\t * Tags for the Selva library (e.g., ['architecture', 'facade']). Selva copies them into the definition when it is uploaded; after that the definition's own tags win. At most MAX_TAGS, none containing a comma.\n\t */\n\ttags?: string[];\n\t/**\n\t * Category for the Selva library (e.g., 'architecture', 'structural'). Selva copies it into the definition when it is uploaded; after that the definition's own category wins. At most MAX_CATEGORY_LENGTH characters.\n\t */\n\tcategory?: string;\n\t/**\n\t * User or organization who created the schema\n\t */\n\tauthor?: string;\n\t/**\n\t * Organization/company name\n\t */\n\torganization?: string;\n\t/**\n\t * Semantic version of the schema format (MAJOR.MINOR.PATCH)\n\t */\n\tschemaVersion: string;\n\t/**\n\t * Minimum plugin version required to load this schema\n\t */\n\tminPluginVersion?: string;\n\tcreated?: string;\n\t/**\n\t * Last modification timestamp\n\t */\n\tlastModified?: string;\n\tviewerOptions?: ViewerOptions1;\n\tlocalOptions?: LocalOptions;\n\t/**\n\t * If true, changes trigger immediate solving. If false, user must press Calculate button.\n\t */\n\tinstanceSolve?: boolean;\n\t/**\n\t * If true, edits solve as previews: file components that only feed a Download output are skipped, and a click on Download runs one full solve. If false or absent, every solve makes every file.\n\t */\n\tpreviewSolves?: boolean;\n\tinputs: SchemaInput[];\n\t/**\n\t * All output components (print, bake, file download)\n\t */\n\toutputs: SchemaOutput[];\n\tlayout: LayoutConfig;\n\t/**\n\t * Icons and thumbnails referenced by optionMedia, keyed by a hash of their content so a shared one is stored once.\n\t */\n\tassets?: {\n\t\t[k: string]: OptionAsset | undefined;\n\t};\n}\n/**\n * Configuration for the 3D viewer\n */\nexport interface ViewerOptions1 {\n\t/**\n\t * If true, the plugin streams display meshes to its local web preview, which then shows the 3D viewer. Selva ignores it.\n\t */\n\tenableLocal?: boolean;\n\t/**\n\t * If true, Selva draws the display meshes in the Rhino.Compute response and shows the 3D viewer. The plugin's local preview ignores it.\n\t */\n\tenableRemote?: boolean;\n\t/**\n\t * Background color for the 3D viewer as hex string (e.g., '#ffffff')\n\t */\n\tbackgroundColor?: string;\n\t/**\n\t * The viewer look a definition opens in. A viewer can still switch look from its display menu.\n\t */\n\tlook?:\n\t\t'technical' | 'studio' | 'showcase' | 'arctic' | 'xray' | 'lineart' | 'wireframe' | 'night';\n}\n\n// ============================================================================\n// CONSTANTS (from schema)\n// ============================================================================\n\nexport const ACCEPTED_FILE_FORMATS = [\n\t'.3dm',\n\t'.stp',\n\t'.step',\n\t'.fbx',\n\t'.obj',\n\t'.dxf',\n\t'.stl'\n] as const;\nexport const MAX_TAGS = 5 as const;\nexport const MAX_CATEGORY_LENGTH = 40 as const;\n\n/** Current UISchema format version (from ui-schema.json's schemaVersion default). */\nexport const UI_SCHEMA_VERSION = '2.20.0';\n\n// ============================================================================\n// TYPE ALIASES AND GUARDS (derived from the LayoutItem union)\n// ============================================================================\n\nexport type InputLayoutItem =\n\t| InputNumberLayoutItem\n\t| InputTextLayoutItem\n\t| InputDropdownLayoutItem\n\t| InputDynamicValueListLayoutItem\n\t| InputCheckboxLayoutItem\n\t| InputFileLayoutItem\n\t| InputColorLayoutItem;\nexport type OutputLayoutItem =\n\t| OutputTextLayoutItem\n\t| OutputNumberLayoutItem\n\t| OutputFileLayoutItem\n\t| OutputChartLayoutItem\n\t| OutputImageLayoutItem\n\t| OutputDynamicValueListLayoutItem;\nexport type SupportedTypes = string | number | boolean | string[];\n\nexport function isInputLayoutItem(item: LayoutItem): item is InputLayoutItem {\n\treturn item.type === 'input';\n}\n\nexport function isOutputLayoutItem(item: LayoutItem): item is OutputLayoutItem {\n\treturn item.type === 'output';\n}\n\nexport function isLineBreakLayoutItem(item: LayoutItem): item is LineBreakLayoutItem {\n\treturn item.type === 'linebreak';\n}\n\nexport function isNumberWidget(item: LayoutItem): item is InputNumberLayoutItem {\n\treturn item.type === 'input' && item.widgetType === 'number';\n}\n\nexport function isTextWidget(item: LayoutItem): item is InputTextLayoutItem {\n\treturn item.type === 'input' && item.widgetType === 'text';\n}\n\nexport function isDropdownWidget(item: LayoutItem): item is InputDropdownLayoutItem {\n\treturn item.type === 'input' && item.widgetType === 'dropdown';\n}\n\nexport function isDynamicValueListWidget(\n\titem: LayoutItem\n): item is InputDynamicValueListLayoutItem {\n\treturn item.type === 'input' && item.widgetType === 'dynamicValueList';\n}\n\nexport function isCheckboxWidget(item: LayoutItem): item is InputCheckboxLayoutItem {\n\treturn item.type === 'input' && item.widgetType === 'checkbox';\n}\n\nexport function isFileWidget(item: LayoutItem): item is InputFileLayoutItem {\n\treturn item.type === 'input' && item.widgetType === 'file';\n}\n\nexport function isColorWidget(item: LayoutItem): item is InputColorLayoutItem {\n\treturn item.type === 'input' && item.widgetType === 'color';\n}\n\nexport function isTextOutputWidget(item: LayoutItem): item is OutputTextLayoutItem {\n\treturn item.type === 'output' && item.widgetType === 'text';\n}\n\nexport function isNumberOutputWidget(item: LayoutItem): item is OutputNumberLayoutItem {\n\treturn item.type === 'output' && item.widgetType === 'number';\n}\n\nexport function isFileOutputWidget(item: LayoutItem): item is OutputFileLayoutItem {\n\treturn item.type === 'output' && item.widgetType === 'file';\n}\n\nexport function isChartOutputWidget(item: LayoutItem): item is OutputChartLayoutItem {\n\treturn item.type === 'output' && item.widgetType === 'chart';\n}\n\nexport function isImageOutputWidget(item: LayoutItem): item is OutputImageLayoutItem {\n\treturn item.type === 'output' && item.widgetType === 'image';\n}\n\nexport function isDynamicValueListOutputWidget(\n\titem: LayoutItem\n): item is OutputDynamicValueListLayoutItem {\n\treturn item.type === 'output' && item.widgetType === 'dynamicValueList';\n}\n"],"mappings":";;AA2kBA,IAAa,oBAAoB;AAmCjC,SAAgB,eAAe,MAAiD;CAC/E,OAAO,KAAK,SAAS,WAAW,KAAK,eAAe;AACrD;AAEA,SAAgB,aAAa,MAA+C;CAC3E,OAAO,KAAK,SAAS,WAAW,KAAK,eAAe;AACrD;AAEA,SAAgB,iBAAiB,MAAmD;CACnF,OAAO,KAAK,SAAS,WAAW,KAAK,eAAe;AACrD;AAEA,SAAgB,yBACf,MAC0C;CAC1C,OAAO,KAAK,SAAS,WAAW,KAAK,eAAe;AACrD;AAEA,SAAgB,iBAAiB,MAAmD;CACnF,OAAO,KAAK,SAAS,WAAW,KAAK,eAAe;AACrD;AAEA,SAAgB,aAAa,MAA+C;CAC3E,OAAO,KAAK,SAAS,WAAW,KAAK,eAAe;AACrD;AAEA,SAAgB,cAAc,MAAgD;CAC7E,OAAO,KAAK,SAAS,WAAW,KAAK,eAAe;AACrD"}
@@ -1,4 +1,4 @@
1
- import { R as isEncryptedSecret } from "./providers.server.js";
1
+ import { V as isEncryptedSecret } from "./providers.server.js";
2
2
  import { A as apiError, it as trimTrailing, k as ApiErrorCode } from "./access.js";
3
3
  import { r as GuidSchema } from "./schemas.js";
4
4
  import { n as isLinkLocalUrl } from "./safe-url.js";
@@ -91,14 +91,14 @@ function validateIncomingServers(servers) {
91
91
  }
92
92
  }
93
93
  /**
94
- * A key that failed to decrypt reads as `hasApiKey` with no `apiKey`. Saving with
95
- * the field omitted would write `undefined` over the ciphertext, destroying the
96
- * key the logs tell the operator to recover by restoring `SELVA_AT_REST_KEY`.
97
- * Replacing or clearing it is a decision, so those pass.
94
+ * A key the store could not open reads as `hasApiKey` with no `apiKey`. Saving with
95
+ * the field omitted would write `undefined` over it, destroying the key the logs
96
+ * tell the operator how to recover. Replacing or clearing it is a decision, so
97
+ * those pass.
98
98
  */
99
99
  function assertStoredKeysReadable(incoming, stored) {
100
100
  const unreadable = new Set(stored.filter((s) => s.hasApiKey && !s.apiKey).map((s) => s.id));
101
- for (const s of incoming) if (unreadable.has(s.id) && (s.apiKey === void 0 || s.apiKey === "")) apiError(409, ApiErrorCode.CONFLICT, `The stored key for server ${s.id} cannot be decrypted. Restore the original SELVA_AT_REST_KEY, or re-enter the key.`);
101
+ for (const s of incoming) if (unreadable.has(s.id) && (s.apiKey === void 0 || s.apiKey === "")) apiError(409, ApiErrorCode.CONFLICT, `The stored key for server ${s.id} cannot be read. Re-enter the key, or see the server log for how to recover it.`);
102
102
  }
103
103
  /**
104
104
  * An omitted key is kept, so without this check anyone who may save the config
@@ -1 +1 @@
1
- {"version":3,"file":"server-config-write.js","names":[],"sources":["../../../../server/src/compute/evict-changed-servers.ts","../../../../server/src/compute/server-config-write.ts"],"sourcesContent":["/**\n * A warm compute client caches on server `id`, so a rotated `serverUrl`/`apiKey`\n * keeps the same cache key with stale connection details — it never ages out on\n * its own. The config-write path has to evict explicitly.\n *\n * The eviction sink is a parameter rather than an import: which cache holds the\n * warm clients is the host's decision, and importing one would drag a whole\n * solve engine into every consumer that only wants the diff.\n */\n\n/** The connection-identifying fields — a change in either makes the warm client stale. */\nexport interface ServerConnection {\n\tid: string;\n\tserverUrl: string;\n\tapiKey?: string;\n}\n\n/**\n * Drop the warm client for every server that was removed or whose connection\n * details changed. `prev` and `next` are the scoped server sets before and\n * after the write; unchanged servers are left alone.\n */\nexport function evictChangedServers(\n\tprev: readonly ServerConnection[],\n\tnext: readonly ServerConnection[],\n\tevict: (id: string) => void\n): void {\n\tconst nextById = new Map(next.map((s) => [s.id, s]));\n\n\t// Removed: no longer in `next`.\n\tfor (const before of prev) {\n\t\tif (!nextById.has(before.id)) evict(before.id);\n\t}\n\n\t// Rotated: same id, different URL or key.\n\tconst prevById = new Map(prev.map((s) => [s.id, s]));\n\tfor (const after of next) {\n\t\tconst before = prevById.get(after.id);\n\t\tif (before && (before.serverUrl !== after.serverUrl || before.apiKey !== after.apiKey)) {\n\t\t\tevict(after.id);\n\t\t}\n\t}\n}\n","/**\n * Shared write-path rules for compute server config.\n *\n * Two routes accept a server set: `/api/admin/compute` (platform scope,\n * `manage_compute`) and `/api/v1/orgs/{orgId}/compute` (org scope,\n * `manage_org_compute`). They differ in who may call them, what extra fields\n * they carry (`sharedWith` vs `ownerOrgId`), and how they validate the default\n * selection — but the field validation and the apiKey merge below must behave\n * identically in both, so they live here rather than in either handler.\n *\n * The apiKey merge is why this file exists: if the two copies disagree, a\n * stored credential silently gets cleared or leaked, and nothing fails at\n * build time.\n */\n\nimport { GuidSchema, trimTrailing } from '@selvajs/platform';\nimport { isEncryptedSecret } from '@selvajs/platform/computeServer';\nimport { isLinkLocalUrl } from './safe-url.js';\nimport { apiError, ApiErrorCode } from '../api/errors.js';\n\n/**\n * A stored `serverUrl` is fetched server-side on every status probe, every\n * purge/shutdown action, and every solve, so an unfiltered one is an SSRF\n * primitive handed to whoever holds `manage_compute`. Two rules:\n *\n * - Scheme allowlist: `http`/`https`. `file:`, `gopher:` and friends are never\n * a Rhino.Compute endpoint.\n * - Link-local (`169.254.0.0/16`) is refused. That range carries the cloud\n * metadata service at `169.254.169.254`, which hands out the host's own IAM\n * credentials to anything running on the box.\n *\n * **Loopback and RFC1918 are deliberately allowed.** Running compute on\n * `localhost:6500` or a LAN box is the ordinary self-hosted layout, not an\n * attack — most deployments reach their compute server over exactly those\n * addresses. Blocking them by default would break those instances on upgrade\n * and push every operator toward an opt-out flag, and a guard that everyone\n * disables protects nobody. So the check is narrowed to the range where no\n * legitimate compute server ever lives.\n *\n * What this does not stop: a privileged admin pointing the app at an internal\n * host to probe it. That is a real but much weaker concern than credential\n * theft, it needs `manage_compute` already, and it is inseparable from the\n * legitimate case. Revisit if `manage_org_compute` is ever delegated widely on\n * a multi-tenant instance.\n *\n * `isLinkLocalUrl` is reused rather than hand-rolled because a string compare\n * against `169.254.169.254` misses the encodings that reach the same address:\n * `http://2852039166/`, `http://0xa9fea9fe/`, `http://0251.0376.0251.0376/`.\n */\nfunction assertUsableServerUrl(serverUrl: string): void {\n\tlet parsed: URL;\n\ttry {\n\t\tparsed = new URL(serverUrl);\n\t} catch {\n\t\tapiError(400, ApiErrorCode.VALIDATION_FAILED, `Invalid serverUrl: ${serverUrl}`);\n\t}\n\tif (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {\n\t\tapiError(400, ApiErrorCode.VALIDATION_FAILED, `serverUrl must use http or https: ${serverUrl}`);\n\t}\n\tif (isLinkLocalUrl(serverUrl)) {\n\t\tapiError(\n\t\t\t400,\n\t\t\tApiErrorCode.VALIDATION_FAILED,\n\t\t\t`serverUrl points at the link-local range, which carries the cloud metadata service: ${serverUrl}`\n\t\t);\n\t}\n}\n\n/** The fields every incoming server carries, whatever its scope. */\nexport interface IncomingServerBase {\n\tid: string;\n\tlabel: string;\n\tserverUrl: string;\n\t/**\n\t * `undefined` → preserve the stored key; `null` → clear it;\n\t * non-empty string → replace it. See {@link resolveApiKey}.\n\t */\n\tapiKey?: string | null;\n}\n\n/**\n * Validates the scope-independent fields of every submitted server. Throws the\n * first failure as a 400; scope-specific fields (`sharedWith`, `ownerOrgId`)\n * are the caller's business.\n */\nexport function validateIncomingServers(servers: readonly IncomingServerBase[]): void {\n\tconst seen = new Set<string>();\n\tfor (const s of servers) {\n\t\tif (!s.id || typeof s.id !== 'string')\n\t\t\tapiError(400, ApiErrorCode.VALIDATION_FAILED, 'Each server needs an id');\n\t\tif (!GuidSchema.safeParse(s.id).success)\n\t\t\tapiError(400, ApiErrorCode.VALIDATION_FAILED, `Server id must be a UUID: ${s.id}`);\n\t\tif (seen.has(s.id))\n\t\t\tapiError(400, ApiErrorCode.VALIDATION_FAILED, `Server id appears more than once: ${s.id}`);\n\t\tseen.add(s.id);\n\t\tif (!s.label || typeof s.label !== 'string')\n\t\t\tapiError(400, ApiErrorCode.VALIDATION_FAILED, 'Each server needs a label');\n\t\tif (!s.serverUrl || typeof s.serverUrl !== 'string')\n\t\t\tapiError(400, ApiErrorCode.VALIDATION_FAILED, 'Each server needs a serverUrl');\n\t\tassertUsableServerUrl(s.serverUrl);\n\t\tif (s.apiKey !== undefined && s.apiKey !== null && typeof s.apiKey !== 'string')\n\t\t\tapiError(400, ApiErrorCode.VALIDATION_FAILED, 'apiKey must be a string, null, or omitted');\n\t\t// Clients never receive stored keys, so an envelope here is someone else's\n\t\t// ciphertext being replayed against a URL they control.\n\t\tif (s.apiKey && isEncryptedSecret(s.apiKey))\n\t\t\tapiError(400, ApiErrorCode.VALIDATION_FAILED, 'apiKey must be a plaintext key');\n\t}\n}\n\n/**\n * A key that failed to decrypt reads as `hasApiKey` with no `apiKey`. Saving with\n * the field omitted would write `undefined` over the ciphertext, destroying the\n * key the logs tell the operator to recover by restoring `SELVA_AT_REST_KEY`.\n * Replacing or clearing it is a decision, so those pass.\n */\nexport function assertStoredKeysReadable(\n\tincoming: readonly Pick<IncomingServerBase, 'id' | 'apiKey'>[],\n\tstored: readonly { id: string; apiKey?: string; hasApiKey?: boolean }[]\n): void {\n\tconst unreadable = new Set(stored.filter((s) => s.hasApiKey && !s.apiKey).map((s) => s.id));\n\tfor (const s of incoming) {\n\t\tif (unreadable.has(s.id) && (s.apiKey === undefined || s.apiKey === '')) {\n\t\t\tapiError(\n\t\t\t\t409,\n\t\t\t\tApiErrorCode.CONFLICT,\n\t\t\t\t`The stored key for server ${s.id} cannot be decrypted. Restore the original SELVA_AT_REST_KEY, or re-enter the key.`\n\t\t\t);\n\t\t}\n\t}\n}\n\n/**\n * An omitted key is kept, so without this check anyone who may save the config\n * could point a server at their own host and have the next solve send them the\n * stored key, which they never saw. Moving a server needs the key re-entered or\n * cleared.\n */\nexport function assertKeyNotRetargeted(\n\tincoming: readonly Pick<IncomingServerBase, 'id' | 'serverUrl' | 'apiKey'>[],\n\tstored: readonly { id: string; serverUrl: string; apiKey?: string; hasApiKey?: boolean }[]\n): void {\n\tconst byId = new Map(stored.map((s) => [s.id, s]));\n\tfor (const s of incoming) {\n\t\tconst prev = byId.get(s.id);\n\t\tif (!prev || !(prev.hasApiKey || prev.apiKey)) continue;\n\t\tif (s.apiKey === null || (typeof s.apiKey === 'string' && s.apiKey !== '')) continue;\n\t\tif (sameServerUrl(prev.serverUrl, s.serverUrl)) continue;\n\t\tapiError(\n\t\t\t409,\n\t\t\tApiErrorCode.CONFLICT,\n\t\t\t`Server ${s.id} has a new URL. Re-enter its API key, or clear it, to save.`\n\t\t);\n\t}\n}\n\nfunction sameServerUrl(a: string, b: string): boolean {\n\tconst normalize = (u: string) => {\n\t\ttry {\n\t\t\treturn trimTrailing(new URL(u.trim()).href, '/');\n\t\t} catch {\n\t\t\treturn trimTrailing(u.trim(), '/');\n\t\t}\n\t};\n\treturn normalize(a) === normalize(b);\n}\n\n/**\n * The UI never receives stored keys — it sends back `hasApiKey` and omits the\n * field for servers the operator didn't touch. So \"omitted\" cannot mean \"clear\":\n * it has to preserve, or every save through the settings form would wipe the\n * keys of every server the operator left alone. Clearing is explicit (`null`);\n * an empty string is treated as \"not provided\" since that's what an untouched\n * password input submits.\n */\nexport function resolveApiKey(\n\tsubmitted: string | null | undefined,\n\tstoredKey: string | undefined\n): string | undefined {\n\tif (submitted === null) return undefined;\n\treturn submitted ? submitted : storedKey;\n}\n\n/**\n * Builds the id → stored-key lookup the merge reads. The caller passes only the\n * servers in its own scope, so one scope's write can never resolve a key from\n * another's rows.\n */\nexport function storedKeysById(\n\tscopedServers: readonly { id: string; apiKey?: string }[]\n): Map<string, string | undefined> {\n\treturn new Map(scopedServers.map((s) => [s.id, s.apiKey]));\n}\n\n/**\n * The whole apiKey merge for one scope's write: refuses an unreadable or\n * retargeted key with 409, then returns the key to store for each submitted id.\n * `scopedStored` must be read with `includeApiKeys` and hold only the caller's\n * scope.\n */\nexport function mergeApiKeys(\n\tincoming: readonly Pick<IncomingServerBase, 'id' | 'serverUrl' | 'apiKey'>[],\n\tscopedStored: readonly { id: string; serverUrl: string; apiKey?: string; hasApiKey?: boolean }[]\n): Map<string, string | undefined> {\n\tassertStoredKeysReadable(incoming, scopedStored);\n\tassertKeyNotRetargeted(incoming, scopedStored);\n\tconst stored = storedKeysById(scopedStored);\n\treturn new Map(incoming.map((s) => [s.id, resolveApiKey(s.apiKey, stored.get(s.id))]));\n}\n"],"mappings":";;;;;;;;;;AAsBA,SAAgB,oBACf,MACA,MACA,OACO;CACP,MAAM,WAAW,IAAI,IAAI,KAAK,KAAK,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;CAGnD,KAAK,MAAM,UAAU,MACpB,IAAI,CAAC,SAAS,IAAI,OAAO,EAAE,GAAG,MAAM,OAAO,EAAE;CAI9C,MAAM,WAAW,IAAI,IAAI,KAAK,KAAK,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;CACnD,KAAK,MAAM,SAAS,MAAM;EACzB,MAAM,SAAS,SAAS,IAAI,MAAM,EAAE;EACpC,IAAI,WAA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,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAC1D;;;;;;;AAQA,SAAgB,aACf,UACA,cACkC;CAClC,yBAAyB,UAAU,YAAY;CAC/C,uBAAuB,UAAU,YAAY;CAC7C,MAAM,SAAS,eAAe,YAAY;CAC1C,OAAO,IAAI,IAAI,SAAS,KAAK,MAAM,CAAC,EAAE,IAAI,cAAc,EAAE,QAAQ,OAAO,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;AACtF"}
1
+ {"version":3,"file":"server-config-write.js","names":[],"sources":["../../../../server/src/compute/evict-changed-servers.ts","../../../../server/src/compute/server-config-write.ts"],"sourcesContent":["/**\n * A warm compute client caches on server `id`, so a rotated `serverUrl`/`apiKey`\n * keeps the same cache key with stale connection details — it never ages out on\n * its own. The config-write path has to evict explicitly.\n *\n * The eviction sink is a parameter rather than an import: which cache holds the\n * warm clients is the host's decision, and importing one would drag a whole\n * solve engine into every consumer that only wants the diff.\n */\n\n/** The connection-identifying fields — a change in either makes the warm client stale. */\nexport interface ServerConnection {\n\tid: string;\n\tserverUrl: string;\n\tapiKey?: string;\n}\n\n/**\n * Drop the warm client for every server that was removed or whose connection\n * details changed. `prev` and `next` are the scoped server sets before and\n * after the write; unchanged servers are left alone.\n */\nexport function evictChangedServers(\n\tprev: readonly ServerConnection[],\n\tnext: readonly ServerConnection[],\n\tevict: (id: string) => void\n): void {\n\tconst nextById = new Map(next.map((s) => [s.id, s]));\n\n\t// Removed: no longer in `next`.\n\tfor (const before of prev) {\n\t\tif (!nextById.has(before.id)) evict(before.id);\n\t}\n\n\t// Rotated: same id, different URL or key.\n\tconst prevById = new Map(prev.map((s) => [s.id, s]));\n\tfor (const after of next) {\n\t\tconst before = prevById.get(after.id);\n\t\tif (before && (before.serverUrl !== after.serverUrl || before.apiKey !== after.apiKey)) {\n\t\t\tevict(after.id);\n\t\t}\n\t}\n}\n","/**\n * Shared write-path rules for compute server config.\n *\n * Two routes accept a server set: `/api/admin/compute` (platform scope,\n * `manage_compute`) and `/api/v1/orgs/{orgId}/compute` (org scope,\n * `manage_org_compute`). They differ in who may call them, what extra fields\n * they carry (`sharedWith` vs `ownerOrgId`), and how they validate the default\n * selection — but the field validation and the apiKey merge below must behave\n * identically in both, so they live here rather than in either handler.\n *\n * The apiKey merge is why this file exists: if the two copies disagree, a\n * stored credential silently gets cleared or leaked, and nothing fails at\n * build time.\n */\n\nimport { GuidSchema, trimTrailing } from '@selvajs/platform';\nimport { isEncryptedSecret } from '@selvajs/platform/computeServer';\nimport { isLinkLocalUrl } from './safe-url.js';\nimport { apiError, ApiErrorCode } from '../api/errors.js';\n\n/**\n * A stored `serverUrl` is fetched server-side on every status probe, every\n * purge/shutdown action, and every solve, so an unfiltered one is an SSRF\n * primitive handed to whoever holds `manage_compute`. Two rules:\n *\n * - Scheme allowlist: `http`/`https`. `file:`, `gopher:` and friends are never\n * a Rhino.Compute endpoint.\n * - Link-local (`169.254.0.0/16`) is refused. That range carries the cloud\n * metadata service at `169.254.169.254`, which hands out the host's own IAM\n * credentials to anything running on the box.\n *\n * **Loopback and RFC1918 are deliberately allowed.** Running compute on\n * `localhost:6500` or a LAN box is the ordinary self-hosted layout, not an\n * attack — most deployments reach their compute server over exactly those\n * addresses. Blocking them by default would break those instances on upgrade\n * and push every operator toward an opt-out flag, and a guard that everyone\n * disables protects nobody. So the check is narrowed to the range where no\n * legitimate compute server ever lives.\n *\n * What this does not stop: a privileged admin pointing the app at an internal\n * host to probe it. That is a real but much weaker concern than credential\n * theft, it needs `manage_compute` already, and it is inseparable from the\n * legitimate case. Revisit if `manage_org_compute` is ever delegated widely on\n * a multi-tenant instance.\n *\n * `isLinkLocalUrl` is reused rather than hand-rolled because a string compare\n * against `169.254.169.254` misses the encodings that reach the same address:\n * `http://2852039166/`, `http://0xa9fea9fe/`, `http://0251.0376.0251.0376/`.\n */\nfunction assertUsableServerUrl(serverUrl: string): void {\n\tlet parsed: URL;\n\ttry {\n\t\tparsed = new URL(serverUrl);\n\t} catch {\n\t\tapiError(400, ApiErrorCode.VALIDATION_FAILED, `Invalid serverUrl: ${serverUrl}`);\n\t}\n\tif (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {\n\t\tapiError(400, ApiErrorCode.VALIDATION_FAILED, `serverUrl must use http or https: ${serverUrl}`);\n\t}\n\tif (isLinkLocalUrl(serverUrl)) {\n\t\tapiError(\n\t\t\t400,\n\t\t\tApiErrorCode.VALIDATION_FAILED,\n\t\t\t`serverUrl points at the link-local range, which carries the cloud metadata service: ${serverUrl}`\n\t\t);\n\t}\n}\n\n/** The fields every incoming server carries, whatever its scope. */\nexport interface IncomingServerBase {\n\tid: string;\n\tlabel: string;\n\tserverUrl: string;\n\t/**\n\t * `undefined` → preserve the stored key; `null` → clear it;\n\t * non-empty string → replace it. See {@link resolveApiKey}.\n\t */\n\tapiKey?: string | null;\n}\n\n/**\n * Validates the scope-independent fields of every submitted server. Throws the\n * first failure as a 400; scope-specific fields (`sharedWith`, `ownerOrgId`)\n * are the caller's business.\n */\nexport function validateIncomingServers(servers: readonly IncomingServerBase[]): void {\n\tconst seen = new Set<string>();\n\tfor (const s of servers) {\n\t\tif (!s.id || typeof s.id !== 'string')\n\t\t\tapiError(400, ApiErrorCode.VALIDATION_FAILED, 'Each server needs an id');\n\t\tif (!GuidSchema.safeParse(s.id).success)\n\t\t\tapiError(400, ApiErrorCode.VALIDATION_FAILED, `Server id must be a UUID: ${s.id}`);\n\t\tif (seen.has(s.id))\n\t\t\tapiError(400, ApiErrorCode.VALIDATION_FAILED, `Server id appears more than once: ${s.id}`);\n\t\tseen.add(s.id);\n\t\tif (!s.label || typeof s.label !== 'string')\n\t\t\tapiError(400, ApiErrorCode.VALIDATION_FAILED, 'Each server needs a label');\n\t\tif (!s.serverUrl || typeof s.serverUrl !== 'string')\n\t\t\tapiError(400, ApiErrorCode.VALIDATION_FAILED, 'Each server needs a serverUrl');\n\t\tassertUsableServerUrl(s.serverUrl);\n\t\tif (s.apiKey !== undefined && s.apiKey !== null && typeof s.apiKey !== 'string')\n\t\t\tapiError(400, ApiErrorCode.VALIDATION_FAILED, 'apiKey must be a string, null, or omitted');\n\t\t// Clients never receive stored keys, so an envelope here is someone else's\n\t\t// ciphertext being replayed against a URL they control.\n\t\tif (s.apiKey && isEncryptedSecret(s.apiKey))\n\t\t\tapiError(400, ApiErrorCode.VALIDATION_FAILED, 'apiKey must be a plaintext key');\n\t}\n}\n\n/**\n * A key the store could not open reads as `hasApiKey` with no `apiKey`. Saving with\n * the field omitted would write `undefined` over it, destroying the key the logs\n * tell the operator how to recover. Replacing or clearing it is a decision, so\n * those pass.\n */\nexport function assertStoredKeysReadable(\n\tincoming: readonly Pick<IncomingServerBase, 'id' | 'apiKey'>[],\n\tstored: readonly { id: string; apiKey?: string; hasApiKey?: boolean }[]\n): void {\n\tconst unreadable = new Set(stored.filter((s) => s.hasApiKey && !s.apiKey).map((s) => s.id));\n\tfor (const s of incoming) {\n\t\tif (unreadable.has(s.id) && (s.apiKey === undefined || s.apiKey === '')) {\n\t\t\tapiError(\n\t\t\t\t409,\n\t\t\t\tApiErrorCode.CONFLICT,\n\t\t\t\t`The stored key for server ${s.id} cannot be read. Re-enter the key, or see the server log for how to recover it.`\n\t\t\t);\n\t\t}\n\t}\n}\n\n/**\n * An omitted key is kept, so without this check anyone who may save the config\n * could point a server at their own host and have the next solve send them the\n * stored key, which they never saw. Moving a server needs the key re-entered or\n * cleared.\n */\nexport function assertKeyNotRetargeted(\n\tincoming: readonly Pick<IncomingServerBase, 'id' | 'serverUrl' | 'apiKey'>[],\n\tstored: readonly { id: string; serverUrl: string; apiKey?: string; hasApiKey?: boolean }[]\n): void {\n\tconst byId = new Map(stored.map((s) => [s.id, s]));\n\tfor (const s of incoming) {\n\t\tconst prev = byId.get(s.id);\n\t\tif (!prev || !(prev.hasApiKey || prev.apiKey)) continue;\n\t\tif (s.apiKey === null || (typeof s.apiKey === 'string' && s.apiKey !== '')) continue;\n\t\tif (sameServerUrl(prev.serverUrl, s.serverUrl)) continue;\n\t\tapiError(\n\t\t\t409,\n\t\t\tApiErrorCode.CONFLICT,\n\t\t\t`Server ${s.id} has a new URL. Re-enter its API key, or clear it, to save.`\n\t\t);\n\t}\n}\n\nfunction sameServerUrl(a: string, b: string): boolean {\n\tconst normalize = (u: string) => {\n\t\ttry {\n\t\t\treturn trimTrailing(new URL(u.trim()).href, '/');\n\t\t} catch {\n\t\t\treturn trimTrailing(u.trim(), '/');\n\t\t}\n\t};\n\treturn normalize(a) === normalize(b);\n}\n\n/**\n * The UI never receives stored keys — it sends back `hasApiKey` and omits the\n * field for servers the operator didn't touch. So \"omitted\" cannot mean \"clear\":\n * it has to preserve, or every save through the settings form would wipe the\n * keys of every server the operator left alone. Clearing is explicit (`null`);\n * an empty string is treated as \"not provided\" since that's what an untouched\n * password input submits.\n */\nexport function resolveApiKey(\n\tsubmitted: string | null | undefined,\n\tstoredKey: string | undefined\n): string | undefined {\n\tif (submitted === null) return undefined;\n\treturn submitted ? submitted : storedKey;\n}\n\n/**\n * Builds the id → stored-key lookup the merge reads. The caller passes only the\n * servers in its own scope, so one scope's write can never resolve a key from\n * another's rows.\n */\nexport function storedKeysById(\n\tscopedServers: readonly { id: string; apiKey?: string }[]\n): Map<string, string | undefined> {\n\treturn new Map(scopedServers.map((s) => [s.id, s.apiKey]));\n}\n\n/**\n * The whole apiKey merge for one scope's write: refuses an unreadable or\n * retargeted key with 409, then returns the key to store for each submitted id.\n * `scopedStored` must be read with `includeApiKeys` and hold only the caller's\n * scope.\n */\nexport function mergeApiKeys(\n\tincoming: readonly Pick<IncomingServerBase, 'id' | 'serverUrl' | 'apiKey'>[],\n\tscopedStored: readonly { id: string; serverUrl: string; apiKey?: string; hasApiKey?: boolean }[]\n): Map<string, string | undefined> {\n\tassertStoredKeysReadable(incoming, scopedStored);\n\tassertKeyNotRetargeted(incoming, scopedStored);\n\tconst stored = storedKeysById(scopedStored);\n\treturn new Map(incoming.map((s) => [s.id, resolveApiKey(s.apiKey, stored.get(s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GAAW,GAAoB;CACrD,MAAM,aAAa,MAAc;EAChC,IAAI;GACH,OAAO,aAAa,IAAI,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,MAAM,GAAG;EAChD,QAAQ;GACP,OAAO,aAAa,EAAE,KAAK,GAAG,GAAG;EAClC;CACD;CACA,OAAO,UAAU,CAAC,MAAM,UAAU,CAAC;AACpC;;;;;;;;;AAUA,SAAgB,cACf,WACA,WACqB;CACrB,IAAI,cAAc,MAAM,OAAO,KAAA;CAC/B,OAAO,YAAY,YAAY;AAChC;;;;;;AAOA,SAAgB,eACf,eACkC;CAClC,OAAO,IAAI,IAAI,cAAc,KAAK,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAC1D;;;;;;;AAQA,SAAgB,aACf,UACA,cACkC;CAClC,yBAAyB,UAAU,YAAY;CAC/C,uBAAuB,UAAU,YAAY;CAC7C,MAAM,SAAS,eAAe,YAAY;CAC1C,OAAO,IAAI,IAAI,SAAS,KAAK,MAAM,CAAC,EAAE,IAAI,cAAc,EAAE,QAAQ,OAAO,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;AACtF"}
@@ -1,9 +1,9 @@
1
- import { s as createOAuthServer, t as CODE_TTL_MS } from "./oauth.js";
2
1
  import { t as hmacKeys } from "./keys.server.js";
3
2
  import { t as createComputeRateLimiter } from "./rate-limit.js";
4
3
  import { t as assertSafeRemoteDefinitionUrl } from "./safe-url.js";
5
4
  import { n as readBodyWithCap } from "./remote-definition.js";
6
5
  import "./compute.js";
6
+ import { a as createOAuthServer, t as CODE_TTL_MS } from "./oauth.js";
7
7
  import "./tokens.js";
8
8
  import { json } from "@sveltejs/kit";
9
9
  // src/lib/server/oauth/server.ts
@@ -101,6 +101,6 @@ var DISCOVERY_HEADERS = {
101
101
  "Access-Control-Allow-Origin": "*",
102
102
  "Cache-Control": "public, max-age=3600"
103
103
  };
104
- export { oauthServer as a, oauthRateLimited as i, expectRedemption as n, oauthUnavailable as o, oauthConfigured as r, DISCOVERY_HEADERS as t };
104
+ export { oauthUnavailable as a, oauthServer as i, expectRedemption as n, oauthRateLimited as r, DISCOVERY_HEADERS as t };
105
105
 
106
106
  //# sourceMappingURL=server2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"server2.js","names":[],"sources":["../../../src/lib/server/oauth/server.ts"],"sourcesContent":["/**\n * This instance's OAuth authorization server for MCP clients. The protocol lives\n * in `@selvajs/server/oauth`; this file supplies the secret, the SSRF-guarded\n * metadata fetch and the per-IP limit the endpoints share.\n */\n\nimport { json, type RequestEvent } from '@sveltejs/kit';\nimport { hmacKeys } from '#lib/server/keys.server.js';\nimport {\n\tassertSafeRemoteDefinitionUrl,\n\tcreateComputeRateLimiter,\n\treadBodyWithCap\n} from '@selvajs/server/compute';\nimport { CODE_TTL_MS, createOAuthServer, type OAuthServer } from '@selvajs/server/oauth';\nimport { MIN_TOKEN_SECRET_LENGTH } from '@selvajs/server/tokens';\n\nconst METADATA_TIMEOUT_MS = 5_000;\nconst METADATA_MAX_BYTES = 64 * 1024;\n\n// One slot, as for `/mcp`: the origin comes from the request, so a map would grow\n// with whatever hosts a caller sends. Re-keyed on the secret, like the token codecs.\nlet cached: { origin: string; secret: string; server: OAuthServer } | null = null;\n// Outlives `cached`, so rebuilding the server for another origin can't forget a redeemed code.\nconst redeemedCodes = new Map<string, number>();\n\n// The key is minted at consent, before its code is redeemed. A client that never\n// exchanges the code would leave a live key nobody holds, so it is revoked once\n// the code can no longer be redeemed. Lost on restart: best effort.\nconst ABANDON_AFTER_MS = CODE_TTL_MS + 60_000;\nconst unredeemed = new Map<string, ReturnType<typeof setTimeout>>();\n\n/** Revoke `tokenId` with `revoke` unless its code is redeemed in time. */\nexport function expectRedemption(tokenId: string, revoke: () => Promise<void>): void {\n\tconst timer = setTimeout(() => {\n\t\tunredeemed.delete(tokenId);\n\t\trevoke().catch(() => {});\n\t}, ABANDON_AFTER_MS);\n\ttimer.unref?.();\n\tunredeemed.set(tokenId, timer);\n}\n\nfunction onRedeemed(tokenId: string): void {\n\tclearTimeout(unredeemed.get(tokenId));\n\tunredeemed.delete(tokenId);\n}\n\n/** Whether `oauthServer` would build one, without building it. */\nexport function oauthConfigured(): boolean {\n\tconst secret = hmacKeys().current;\n\treturn Boolean(secret && secret.length >= MIN_TOKEN_SECRET_LENGTH);\n}\n\n/** Undefined without a usable SELVA_HMAC_KEY: the endpoints then answer 503. */\nexport function oauthServer(origin: string): OAuthServer | undefined {\n\tif (!oauthConfigured()) return undefined;\n\tconst { current, previous } = hmacKeys();\n\tconst secret = current!;\n\tconst cacheKey = `${secret}\\n${previous ?? ''}`;\n\tif (cached?.origin !== origin || cached.secret !== cacheKey) {\n\t\tcached = {\n\t\t\torigin,\n\t\t\tsecret: cacheKey,\n\t\t\tserver: createOAuthServer({\n\t\t\t\torigin,\n\t\t\t\tsecret,\n\t\t\t\t...(previous ? { previousSecret: previous } : {}),\n\t\t\t\tfetchClientMetadata,\n\t\t\t\tredeemedCodes,\n\t\t\t\tonRedeemed\n\t\t\t})\n\t\t};\n\t}\n\treturn cached.server;\n}\n\n/** The URL is an unknown client's, so it goes through the same guard as remote definitions. */\nasync function fetchClientMetadata(url: string): Promise<unknown> {\n\tawait assertSafeRemoteDefinitionUrl(url);\n\tconst controller = new AbortController();\n\tconst timer = setTimeout(() => controller.abort(), METADATA_TIMEOUT_MS);\n\ttry {\n\t\tconst res = await fetch(url, {\n\t\t\theaders: { Accept: 'application/json' },\n\t\t\tredirect: 'error',\n\t\t\tsignal: controller.signal\n\t\t});\n\t\tif (!res.ok) throw new Error(`HTTP ${res.status}`);\n\t\t// Counted while streaming: a body with no or a lying Content-Length must not buffer whole.\n\t\tconst bytes = await readBodyWithCap(res, METADATA_MAX_BYTES, controller);\n\t\treturn JSON.parse(new TextDecoder().decode(bytes));\n\t} finally {\n\t\tclearTimeout(timer);\n\t}\n}\n\n// Registration and token exchange take no credential, so the IP is the only key.\nconst limiter = createComputeRateLimiter({ windowMs: 60_000, maxPerWindow: 30 });\n\n/** A 429 response when the caller's IP is over the limit, else undefined. */\nexport function oauthRateLimited(event: RequestEvent): Response | undefined {\n\tconst verdict = limiter.check(`oauth:${event.getClientAddress()}`);\n\tif (verdict.allowed) return undefined;\n\treturn json(\n\t\t{ error: 'slow_down', error_description: 'Too many requests. Try again shortly.' },\n\t\t{ status: 429, headers: { 'Retry-After': String(verdict.retryAfter ?? 60) } }\n\t);\n}\n\nexport function oauthUnavailable(): Response {\n\treturn json(\n\t\t{ error: 'temporarily_unavailable', error_description: 'OAuth is not configured here.' },\n\t\t{ status: 503 }\n\t);\n}\n\n/** Discovery documents are read by browser-based clients too. */\nexport const DISCOVERY_HEADERS = {\n\t'Access-Control-Allow-Origin': '*',\n\t'Cache-Control': 'public, max-age=3600'\n};\n"],"mappings":";;;;;;;;;;;;;;AAgBA,IAAM,sBAAsB;AAC5B,IAAM,qBAAqB;AAI3B,IAAI,SAAyE;AAE7E,IAAM,gCAAgB,IAAI,IAAoB;AAK9C,IAAM,mBAAmB,cAAc;AACvC,IAAM,6BAAa,IAAI,IAA2C;;AAGlE,SAAgB,iBAAiB,SAAiB,QAAmC;CACpF,MAAM,QAAQ,iBAAiB;EAC9B,WAAW,OAAO,OAAO;EACzB,OAAO,CAAC,CAAC,YAAY,CAAC,CAAC;CACxB,GAAG,gBAAgB;CACnB,MAAM,QAAQ;CACd,WAAW,IAAI,SAAS,KAAK;AAC9B;AAEA,SAAS,WAAW,SAAuB;CAC1C,aAAa,WAAW,IAAI,OAAO,CAAC;CACpC,WAAW,OAAO,OAAO;AAC1B;;AAGA,SAAgB,kBAA2B;CAC1C,MAAM,SAAS,SAAS,CAAC,CAAC;CAC1B,OAAO,QAAQ,UAAU,OAAO,UAAA,EAAiC;AAClE;;AAGA,SAAgB,YAAY,QAAyC;CACpE,IAAI,CAAC,gBAAgB,GAAG,OAAO,KAAA;CAC/B,MAAM,EAAE,SAAS,aAAa,SAAS;CACvC,MAAM,SAAS;CACf,MAAM,WAAW,G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
+ {"version":3,"file":"server2.js","names":[],"sources":["../../../src/lib/server/oauth/server.ts"],"sourcesContent":["/**\n * This instance's OAuth authorization server for MCP clients. The protocol lives\n * in `@selvajs/server/oauth`; this file supplies the secret, the SSRF-guarded\n * metadata fetch and the per-IP limit the endpoints share.\n */\n\nimport { json, type RequestEvent } from '@sveltejs/kit';\nimport { hmacKeys } from '#lib/server/keys.server.js';\nimport {\n\tassertSafeRemoteDefinitionUrl,\n\tcreateComputeRateLimiter,\n\treadBodyWithCap\n} from '@selvajs/server/compute';\nimport { CODE_TTL_MS, createOAuthServer, type OAuthServer } from '@selvajs/server/oauth';\nimport { MIN_TOKEN_SECRET_LENGTH } from '@selvajs/server/tokens';\n\nconst METADATA_TIMEOUT_MS = 5_000;\nconst METADATA_MAX_BYTES = 64 * 1024;\n\n// One slot, as for `/mcp`: the origin comes from the request, so a map would grow\n// with whatever hosts a caller sends. Re-keyed on the secret, like the token codecs.\nlet cached: { origin: string; secret: string; server: OAuthServer } | null = null;\n// Outlives `cached`, so rebuilding the server for another origin can't forget a redeemed code.\nconst redeemedCodes = new Map<string, number>();\n\n// The key is minted at consent, before its code is redeemed. A client that never\n// exchanges the code would leave a live key nobody holds, so it is revoked once\n// the code can no longer be redeemed. Lost on restart: best effort.\nconst ABANDON_AFTER_MS = CODE_TTL_MS + 60_000;\nconst unredeemed = new Map<string, ReturnType<typeof setTimeout>>();\n\n/** Revoke `tokenId` with `revoke` unless its code is redeemed in time. */\nexport function expectRedemption(tokenId: string, revoke: () => Promise<void>): void {\n\tconst timer = setTimeout(() => {\n\t\tunredeemed.delete(tokenId);\n\t\trevoke().catch(() => {});\n\t}, ABANDON_AFTER_MS);\n\ttimer.unref?.();\n\tunredeemed.set(tokenId, timer);\n}\n\nfunction onRedeemed(tokenId: string): void {\n\tclearTimeout(unredeemed.get(tokenId));\n\tunredeemed.delete(tokenId);\n}\n\n/** Whether `oauthServer` would build one, without building it. */\nfunction oauthConfigured(): boolean {\n\tconst secret = hmacKeys().current;\n\treturn Boolean(secret && secret.length >= MIN_TOKEN_SECRET_LENGTH);\n}\n\n/** Undefined without a usable SELVA_HMAC_KEY: the endpoints then answer 503. */\nexport function oauthServer(origin: string): OAuthServer | undefined {\n\tif (!oauthConfigured()) return undefined;\n\tconst { current, previous } = hmacKeys();\n\tconst secret = current!;\n\tconst cacheKey = `${secret}\\n${previous ?? ''}`;\n\tif (cached?.origin !== origin || cached.secret !== cacheKey) {\n\t\tcached = {\n\t\t\torigin,\n\t\t\tsecret: cacheKey,\n\t\t\tserver: createOAuthServer({\n\t\t\t\torigin,\n\t\t\t\tsecret,\n\t\t\t\t...(previous ? { previousSecret: previous } : {}),\n\t\t\t\tfetchClientMetadata,\n\t\t\t\tredeemedCodes,\n\t\t\t\tonRedeemed\n\t\t\t})\n\t\t};\n\t}\n\treturn cached.server;\n}\n\n/** The URL is an unknown client's, so it goes through the same guard as remote definitions. */\nasync function fetchClientMetadata(url: string): Promise<unknown> {\n\tawait assertSafeRemoteDefinitionUrl(url);\n\tconst controller = new AbortController();\n\tconst timer = setTimeout(() => controller.abort(), METADATA_TIMEOUT_MS);\n\ttry {\n\t\tconst res = await fetch(url, {\n\t\t\theaders: { Accept: 'application/json' },\n\t\t\tredirect: 'error',\n\t\t\tsignal: controller.signal\n\t\t});\n\t\tif (!res.ok) throw new Error(`HTTP ${res.status}`);\n\t\t// Counted while streaming: a body with no or a lying Content-Length must not buffer whole.\n\t\tconst bytes = await readBodyWithCap(res, METADATA_MAX_BYTES, controller);\n\t\treturn JSON.parse(new TextDecoder().decode(bytes));\n\t} finally {\n\t\tclearTimeout(timer);\n\t}\n}\n\n// Registration and token exchange take no credential, so the IP is the only key.\nconst limiter = createComputeRateLimiter({ windowMs: 60_000, maxPerWindow: 30 });\n\n/** A 429 response when the caller's IP is over the limit, else undefined. */\nexport function oauthRateLimited(event: RequestEvent): Response | undefined {\n\tconst verdict = limiter.check(`oauth:${event.getClientAddress()}`);\n\tif (verdict.allowed) return undefined;\n\treturn json(\n\t\t{ error: 'slow_down', error_description: 'Too many requests. Try again shortly.' },\n\t\t{ status: 429, headers: { 'Retry-After': String(verdict.retryAfter ?? 60) } }\n\t);\n}\n\nexport function oauthUnavailable(): Response {\n\treturn json(\n\t\t{ error: 'temporarily_unavailable', error_description: 'OAuth is not configured here.' },\n\t\t{ status: 503 }\n\t);\n}\n\n/** Discovery documents are read by browser-based clients too. */\nexport const DISCOVERY_HEADERS = {\n\t'Access-Control-Allow-Origin': '*',\n\t'Cache-Control': 'public, max-age=3600'\n};\n"],"mappings":";;;;;;;;;;;;;;AAgBA,IAAM,sBAAsB;AAC5B,IAAM,qBAAqB;AAI3B,IAAI,SAAyE;AAE7E,IAAM,gCAAgB,IAAI,IAAoB;AAK9C,IAAM,mBAAmB,cAAc;AACvC,IAAM,6BAAa,IAAI,IAA2C;;AAGlE,SAAgB,iBAAiB,SAAiB,QAAmC;CACpF,MAAM,QAAQ,iBAAiB;EAC9B,WAAW,OAAO,OAAO;EACzB,OAAO,CAAC,CAAC,YAAY,CAAC,CAAC;CACxB,GAAG,gBAAgB;CACnB,MAAM,QAAQ;CACd,WAAW,IAAI,SAAS,KAAK;AAC9B;AAEA,SAAS,WAAW,SAAuB;CAC1C,aAAa,WAAW,IAAI,OAAO,CAAC;CACpC,WAAW,OAAO,OAAO;AAC1B;;AAGA,SAAS,kBAA2B;CACnC,MAAM,SAAS,SAAS,CAAC,CAAC;CAC1B,OAAO,QAAQ,UAAU,OAAO,UAAA,EAAiC;AAClE;;AAGA,SAAgB,YAAY,QAAyC;CACpE,IAAI,CAAC,gBAAgB,GAAG,OAAO,KAAA;CAC/B,MAAM,EAAE,SAAS,aAAa,SAAS;CACvC,MAAM,SAAS;CACf,MAAM,WAAW,GAAG,OAAO,IAAI,YAAY;CAC3C,IAAI,QAAQ,WAAW,UAAU,OAAO,WAAW,UAClD,SAAS;EACR;EACA,QAAQ;EACR,QAAQ,kBAAkB;GACzB;GACA;GACA,GAAI,WAAW,EAAE,gBAAgB,SAAS,IAAI,CAAC;GAC/C;GACA;GACA;EACD,CAAC;CACF;CAED,OAAO,OAAO;AACf;;AAGA,eAAe,oBAAoB,KAA+B;CACjE,MAAM,8BAA8B,GAAG;CACvC,MAAM,aAAa,IAAI,gBAAgB;CACvC,MAAM,QAAQ,iBAAiB,WAAW,MAAM,GAAG,mBAAmB;CACtE,IAAI;EACH,MAAM,MAAM,MAAM,MAAM,KAAK;GAC5B,SAAS,EAAE,QAAQ,mBAAmB;GACtC,UAAU;GACV,QAAQ,WAAW;EACpB,CAAC;EACD,IAAI,CAAC,IAAI,IAAI,MAAM,IAAI,MAAM,QAAQ,IAAI,QAAQ;EAEjD,MAAM,QAAQ,MAAM,gBAAgB,KAAK,oBAAoB,UAAU;EACvE,OAAO,KAAK,MAAM,IAAI,YAAY,CAAC,CAAC,OAAO,KAAK,CAAC;CAClD,UAAU;EACT,aAAa,KAAK;CACnB;AACD;AAGA,IAAM,UAAU,yBAAyB;CAAE,UAAU;CAAQ,cAAc;AAAG,CAAC;;AAG/E,SAAgB,iBAAiB,OAA2C;CAC3E,MAAM,UAAU,QAAQ,MAAM,SAAS,MAAM,iBAAiB,GAAG;CACjE,IAAI,QAAQ,SAAS,OAAO,KAAA;CAC5B,OAAO,KACN;EAAE,OAAO;EAAa,mBAAmB;CAAwC,GACjF;EAAE,QAAQ;EAAK,SAAS,EAAE,eAAe,OAAO,QAAQ,cAAc,EAAE,EAAE;CAAE,CAC7E;AACD;AAEA,SAAgB,mBAA6B;CAC5C,OAAO,KACN;EAAE,OAAO;EAA2B,mBAAmB;CAAgC,GACvF,EAAE,QAAQ,IAAI,CACf;AACD;;AAGA,IAAa,oBAAoB;CAChC,+BAA+B;CAC/B,iBAAiB;AAClB"}
@@ -1,4 +1,4 @@
1
- import { c as ComputeError, l as ErrorCodes, t as ComputeServerStats } from "./grasshopper.js";
1
+ import { d as ErrorCodes, t as ComputeServerStats, u as ComputeError } from "./grasshopper.js";
2
2
  // src/lib/server/compute/serverStats.server.ts
3
3
  /**
4
4
  * `ComputeServerStats` for a stored server. An unusable stored URL or key is the operator's to fix,
@@ -1,6 +1,6 @@
1
1
  import { r as getAuthProvider } from "./providers.server.js";
2
2
  import { n as env } from "./previous-key.js";
3
- import { o as resolveSignInMaxAgeMs, s as signInIsStale } from "./http.js";
3
+ import { c as signInIsStale, s as resolveSignInMaxAgeMs } from "./http.js";
4
4
  import { a as destroySession, s as getSessionToken } from "./admin-auth.server.js";
5
5
  import { redirect } from "@sveltejs/kit";
6
6
  // src/lib/server/signInMaxAge.server.ts
@@ -1,19 +1,43 @@
1
- import { F as postedServerSourcedIds, I as solveInputsFromSchema, M as MAX_SOLVE_DEADLINE_MS, T as providers, b as getSolveMetricSink, w as lazyLogger, x as getStorageProvider } from "./providers.server.js";
1
+ import { I as postedServerSourcedIds, N as MAX_SOLVE_DEADLINE_MS, R as solveInputsFromSchema, T as providers, b as getSolveMetricSink, w as lazyLogger, x as getStorageProvider } from "./providers.server.js";
2
2
  import { E as scoped, M as isApiError, N as toErrorBody, O as ApiError, d as requireCanEditDefinition, h as requireCanSolve, k as ApiErrorCode } from "./access.js";
3
- import { E as chargeApiRateLimit, M as assertScope, j as withRateLimitHeaders, k as rateLimitedResponse } from "./api.js";
3
+ import { t as hmacKeys } from "./keys.server.js";
4
+ import { A as rateLimitedResponse, D as chargeApiRateLimit, M as withRateLimitHeaders, N as assertScope } from "./api.js";
4
5
  import { t as createRemoteDefinitionFetcher } from "./remote-definition.js";
5
- import { a as ComputeServerUnconfiguredError, r as fetchSchemaFromCompute } from "./schema-extraction.js";
6
+ import { a as fetchSchemaFromCompute, u as ComputeServerUnconfiguredError } from "./schema-extraction.js";
6
7
  import "./compute.js";
7
8
  import { n as renderThrown } from "./definitions.js";
8
- import { c as ComputeError, l as ErrorCodes } from "./grasshopper.js";
9
+ import { d as ErrorCodes, u as ComputeError } from "./grasshopper.js";
9
10
  import { t as apiError } from "./api-errors.js";
10
11
  import "./access2.server.js";
11
- import { d as REMOTE_DEFINITION_MAX_BYTES, l as REMOTE_DEFINITION_CACHE_TTL_MS, u as REMOTE_DEFINITION_FETCH_TIMEOUT_MS } from "./computeLimits.js";
12
- import { n as COMPUTE_DEBUG_VERBOSE, o as engine, t as COMPUTE_DEBUG } from "./engine.server.js";
12
+ import { S as REMOTE_DEFINITION_MAX_BYTES, b as REMOTE_DEFINITION_CACHE_TTL_MS, n as COMPUTE_DEBUG_VERBOSE, s as engine, t as COMPUTE_DEBUG, x as REMOTE_DEFINITION_FETCH_TIMEOUT_MS } from "./engine.server.js";
13
13
  import { t as serverResolver } from "./serverResolver.server.js";
14
14
  import { n as checkComputeRateLimit, t as apiRateLimiter } from "./computeRateLimit.server.js";
15
15
  import { n as liveOwnerKey, r as solveEndedKind, t as bindLiveSolve } from "./liveSolve.server.js";
16
16
  import { isHttpError } from "@sveltejs/kit";
17
+ import { createHmac } from "node:crypto";
18
+ // src/lib/server/compute/sessionId.server.ts
19
+ /**
20
+ * Share links have no caller identity, and a remote URL (no `guid`) is caller-chosen, so varying
21
+ * its query string would mint ids: neither gets one, and both route as if compute had no sessions.
22
+ */
23
+ function solveSessionId(access, guid) {
24
+ if (access.kind !== "user" || !access.ctx.userId || !guid) return void 0;
25
+ return computeSessionId(access.ctx.userId, guid);
26
+ }
27
+ /**
28
+ * The `X-Session-Id` for one user's solves of one definition: the compute fork routes them back
29
+ * to the child holding that user's warm document. Derived rather than stored, so every Selva
30
+ * instance computes the same id with no shared state, and the browser can't mint ids to fill
31
+ * compute's claim cap. Keyed, so a compute operator can't recover the user id from it.
32
+ *
33
+ * Undefined without `SELVA_HMAC_KEY`: a routing hint never fails a solve. Rotating the key moves
34
+ * every session to a new id, so each solves cold once.
35
+ */
36
+ function computeSessionId(userId, definitionKey) {
37
+ const key = hmacKeys().current;
38
+ if (!key) return void 0;
39
+ return createHmac("sha256", key).update(`compute-session\0${userId}\0${definitionKey}`).digest("hex").slice(0, 32);
40
+ }
17
41
  // src/lib/server/compute/errorLogFields.ts
18
42
  /**
19
43
  * Log fields for a failed solve. Compute's raw error body can quote what was solved, and erasure
@@ -81,7 +105,7 @@ function admittedSolveInputs(schema, inputs, values) {
81
105
  * that mapping through `mapSolveError`.
82
106
  */
83
107
  async function runSolve(params) {
84
- const { access, definitionUrl, inputs, values, channel, versionId: explicitVersionId, request, locals, loadStart, prepMarks, concealAccessFailure = false, streamId = null, tokenCharged = false } = params;
108
+ const { access, definitionUrl, inputs, values, channel, versionId: explicitVersionId, request, locals, loadStart, prepMarks, concealAccessFailure = false, streamId = null, solveMode = "full", tokenCharged = false } = params;
85
109
  const storage = getStorageProvider();
86
110
  const sharedAccess = access.kind === "share" ? access : null;
87
111
  const solveCtx = access.ctx;
@@ -256,7 +280,9 @@ async function runSolve(params) {
256
280
  loadStartMs: loadStart,
257
281
  defLoadMs,
258
282
  prepMarks,
259
- selvaEvents: live.selvaEvents
283
+ selvaEvents: live.selvaEvents,
284
+ sessionId: solveSessionId(access, guid),
285
+ solveMode
260
286
  });
261
287
  } finally {
262
288
  live.end(outcome ? solveEndedKind(outcome) : "error");