@xemahq/xema 0.13.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (564) hide show
  1. package/README.md +90 -21
  2. package/dist/assets/appliance-base/distribution.lock.json +5144 -0
  3. package/dist/assets/appliance-base/images.lock.json +1706 -0
  4. package/dist/assets/appliance-lean/distribution.lock.json +2888 -0
  5. package/dist/assets/appliance-lean/images.lock.json +1229 -0
  6. package/dist/assets/boot-graph.json +380 -28
  7. package/dist/assets/cloud/distribution.lock.json +5278 -0
  8. package/dist/assets/cloud/images.lock.json +1713 -0
  9. package/dist/assets/core/distribution.lock.json +2401 -354
  10. package/dist/assets/core/images.lock.json +1208 -268
  11. package/dist/assets/distribution-assets.manifest.json +147 -0
  12. package/dist/assets/keycloak/realm-xema.json +412 -0
  13. package/dist/assets/minimal/distribution.lock.json +2710 -0
  14. package/dist/assets/minimal/images.lock.json +1149 -0
  15. package/dist/assets/oss/distribution.lock.json +3742 -494
  16. package/dist/assets/oss/images.lock.json +1591 -472
  17. package/dist/assets/starter/distribution.lock.json +3422 -0
  18. package/dist/assets/starter/images.lock.json +1404 -0
  19. package/dist/cli.d.ts.map +1 -1
  20. package/dist/cli.js +40 -1
  21. package/dist/cli.js.map +1 -1
  22. package/dist/commands/apply.d.ts.map +1 -1
  23. package/dist/commands/apply.js +2 -2
  24. package/dist/commands/apply.js.map +1 -1
  25. package/dist/commands/biome-dev.d.ts +3 -0
  26. package/dist/commands/biome-dev.d.ts.map +1 -0
  27. package/dist/commands/biome-dev.js +176 -0
  28. package/dist/commands/biome-dev.js.map +1 -0
  29. package/dist/commands/biome-validate.d.ts +10 -0
  30. package/dist/commands/biome-validate.d.ts.map +1 -0
  31. package/dist/commands/biome-validate.js +49 -0
  32. package/dist/commands/biome-validate.js.map +1 -0
  33. package/dist/commands/biome.d.ts.map +1 -1
  34. package/dist/commands/biome.js +437 -26
  35. package/dist/commands/biome.js.map +1 -1
  36. package/dist/commands/canopy.d.ts +3 -0
  37. package/dist/commands/canopy.d.ts.map +1 -0
  38. package/dist/commands/canopy.js +214 -0
  39. package/dist/commands/canopy.js.map +1 -0
  40. package/dist/commands/config.d.ts +3 -0
  41. package/dist/commands/config.d.ts.map +1 -0
  42. package/dist/commands/config.js +78 -0
  43. package/dist/commands/config.js.map +1 -0
  44. package/dist/commands/dev.d.ts.map +1 -1
  45. package/dist/commands/dev.js +92 -20
  46. package/dist/commands/dev.js.map +1 -1
  47. package/dist/commands/dist.d.ts +13 -0
  48. package/dist/commands/dist.d.ts.map +1 -1
  49. package/dist/commands/dist.js +51 -11
  50. package/dist/commands/dist.js.map +1 -1
  51. package/dist/commands/doctor.d.ts +25 -0
  52. package/dist/commands/doctor.d.ts.map +1 -1
  53. package/dist/commands/doctor.js +422 -18
  54. package/dist/commands/doctor.js.map +1 -1
  55. package/dist/commands/down.d.ts +10 -0
  56. package/dist/commands/down.d.ts.map +1 -1
  57. package/dist/commands/down.js +107 -33
  58. package/dist/commands/down.js.map +1 -1
  59. package/dist/commands/export.js +1 -1
  60. package/dist/commands/export.js.map +1 -1
  61. package/dist/commands/import.d.ts.map +1 -1
  62. package/dist/commands/import.js +2 -2
  63. package/dist/commands/import.js.map +1 -1
  64. package/dist/commands/init.d.ts.map +1 -1
  65. package/dist/commands/init.js +56 -3
  66. package/dist/commands/init.js.map +1 -1
  67. package/dist/commands/installation.d.ts +3 -0
  68. package/dist/commands/installation.d.ts.map +1 -0
  69. package/dist/commands/installation.js +258 -0
  70. package/dist/commands/installation.js.map +1 -0
  71. package/dist/commands/license.d.ts +3 -0
  72. package/dist/commands/license.d.ts.map +1 -0
  73. package/dist/commands/license.js +97 -0
  74. package/dist/commands/license.js.map +1 -0
  75. package/dist/commands/login.d.ts +4 -0
  76. package/dist/commands/login.d.ts.map +1 -0
  77. package/dist/commands/login.js +127 -0
  78. package/dist/commands/login.js.map +1 -0
  79. package/dist/commands/logs.d.ts +21 -0
  80. package/dist/commands/logs.d.ts.map +1 -1
  81. package/dist/commands/logs.js +133 -32
  82. package/dist/commands/logs.js.map +1 -1
  83. package/dist/commands/objects.d.ts.map +1 -1
  84. package/dist/commands/objects.js +85 -6
  85. package/dist/commands/objects.js.map +1 -1
  86. package/dist/commands/plan.d.ts.map +1 -1
  87. package/dist/commands/plan.js +2 -2
  88. package/dist/commands/plan.js.map +1 -1
  89. package/dist/commands/run.d.ts.map +1 -1
  90. package/dist/commands/run.js +61 -9
  91. package/dist/commands/run.js.map +1 -1
  92. package/dist/commands/serve.d.ts.map +1 -1
  93. package/dist/commands/serve.js +67 -14
  94. package/dist/commands/serve.js.map +1 -1
  95. package/dist/commands/shell.d.ts.map +1 -1
  96. package/dist/commands/shell.js +190 -6
  97. package/dist/commands/shell.js.map +1 -1
  98. package/dist/commands/source.d.ts +3 -0
  99. package/dist/commands/source.d.ts.map +1 -0
  100. package/dist/commands/source.js +120 -0
  101. package/dist/commands/source.js.map +1 -0
  102. package/dist/commands/status.d.ts.map +1 -1
  103. package/dist/commands/status.js +29 -3
  104. package/dist/commands/status.js.map +1 -1
  105. package/dist/commands/up.d.ts.map +1 -1
  106. package/dist/commands/up.js +70 -5
  107. package/dist/commands/up.js.map +1 -1
  108. package/dist/dev/env-defaults.d.ts +1 -0
  109. package/dist/dev/env-defaults.d.ts.map +1 -1
  110. package/dist/dev/env-defaults.js +24 -12
  111. package/dist/dev/env-defaults.js.map +1 -1
  112. package/dist/dev/forked-worker-bootstrap-protocol.d.ts +17 -0
  113. package/dist/dev/forked-worker-bootstrap-protocol.d.ts.map +1 -0
  114. package/dist/dev/forked-worker-bootstrap-protocol.js +35 -0
  115. package/dist/dev/forked-worker-bootstrap-protocol.js.map +1 -0
  116. package/dist/dev/forked-worker-bootstrap.d.ts +18 -0
  117. package/dist/dev/forked-worker-bootstrap.d.ts.map +1 -0
  118. package/dist/dev/forked-worker-bootstrap.js +84 -0
  119. package/dist/dev/forked-worker-bootstrap.js.map +1 -0
  120. package/dist/dev/forked-worker.d.ts +29 -0
  121. package/dist/dev/forked-worker.d.ts.map +1 -1
  122. package/dist/dev/forked-worker.js +267 -42
  123. package/dist/dev/forked-worker.js.map +1 -1
  124. package/dist/dev/opa-policies.d.ts +3 -0
  125. package/dist/dev/opa-policies.d.ts.map +1 -0
  126. package/dist/dev/opa-policies.js +64 -0
  127. package/dist/dev/opa-policies.js.map +1 -0
  128. package/dist/lib/cli-errors.d.ts +7 -0
  129. package/dist/lib/cli-errors.d.ts.map +1 -0
  130. package/dist/lib/cli-errors.js +30 -0
  131. package/dist/lib/cli-errors.js.map +1 -0
  132. package/dist/lib/control-plane.d.ts +5 -1
  133. package/dist/lib/control-plane.d.ts.map +1 -1
  134. package/dist/lib/control-plane.js +61 -8
  135. package/dist/lib/control-plane.js.map +1 -1
  136. package/dist/lib/exit-codes.d.ts +3 -4
  137. package/dist/lib/exit-codes.d.ts.map +1 -1
  138. package/dist/lib/exit-codes.js +3 -4
  139. package/dist/lib/exit-codes.js.map +1 -1
  140. package/dist/lib/http-error.d.ts +2 -0
  141. package/dist/lib/http-error.d.ts.map +1 -0
  142. package/dist/lib/http-error.js +51 -0
  143. package/dist/lib/http-error.js.map +1 -0
  144. package/dist/lib/roster-profile.d.ts +10 -0
  145. package/dist/lib/roster-profile.d.ts.map +1 -0
  146. package/dist/lib/roster-profile.js +44 -0
  147. package/dist/lib/roster-profile.js.map +1 -0
  148. package/dist/runtime/asset-provenance.d.ts +17 -0
  149. package/dist/runtime/asset-provenance.d.ts.map +1 -0
  150. package/dist/runtime/asset-provenance.js +29 -0
  151. package/dist/runtime/asset-provenance.js.map +1 -0
  152. package/dist/runtime/auth/client-bootstrap.d.ts +11 -0
  153. package/dist/runtime/auth/client-bootstrap.d.ts.map +1 -0
  154. package/dist/runtime/auth/client-bootstrap.js +60 -0
  155. package/dist/runtime/auth/client-bootstrap.js.map +1 -0
  156. package/dist/runtime/auth/device-flow.d.ts +43 -0
  157. package/dist/runtime/auth/device-flow.d.ts.map +1 -0
  158. package/dist/runtime/auth/device-flow.js +201 -0
  159. package/dist/runtime/auth/device-flow.js.map +1 -0
  160. package/dist/runtime/auth/session-auth.d.ts +8 -0
  161. package/dist/runtime/auth/session-auth.d.ts.map +1 -0
  162. package/dist/runtime/auth/session-auth.js +43 -0
  163. package/dist/runtime/auth/session-auth.js.map +1 -0
  164. package/dist/runtime/auth/session-store.d.ts +19 -0
  165. package/dist/runtime/auth/session-store.d.ts.map +1 -0
  166. package/dist/runtime/auth/session-store.js +83 -0
  167. package/dist/runtime/auth/session-store.js.map +1 -0
  168. package/dist/runtime/auth/token-claims.d.ts +2 -0
  169. package/dist/runtime/auth/token-claims.d.ts.map +1 -0
  170. package/dist/runtime/auth/token-claims.js +45 -0
  171. package/dist/runtime/auth/token-claims.js.map +1 -0
  172. package/dist/runtime/biome-dev.d.ts +28 -0
  173. package/dist/runtime/biome-dev.d.ts.map +1 -0
  174. package/dist/runtime/biome-dev.js +131 -0
  175. package/dist/runtime/biome-dev.js.map +1 -0
  176. package/dist/runtime/biome-local-install.d.ts +29 -0
  177. package/dist/runtime/biome-local-install.d.ts.map +1 -0
  178. package/dist/runtime/biome-local-install.js +243 -0
  179. package/dist/runtime/biome-local-install.js.map +1 -0
  180. package/dist/runtime/biome-provenance.d.ts +26 -0
  181. package/dist/runtime/biome-provenance.d.ts.map +1 -0
  182. package/dist/runtime/biome-provenance.js +70 -0
  183. package/dist/runtime/biome-provenance.js.map +1 -0
  184. package/dist/runtime/biome-publish.d.ts +48 -0
  185. package/dist/runtime/biome-publish.d.ts.map +1 -0
  186. package/dist/runtime/biome-publish.js +278 -0
  187. package/dist/runtime/biome-publish.js.map +1 -0
  188. package/dist/runtime/biome-scaffold.d.ts +35 -0
  189. package/dist/runtime/biome-scaffold.d.ts.map +1 -0
  190. package/dist/runtime/biome-scaffold.js +151 -0
  191. package/dist/runtime/biome-scaffold.js.map +1 -0
  192. package/dist/runtime/biome-validate.d.ts +28 -0
  193. package/dist/runtime/biome-validate.d.ts.map +1 -0
  194. package/dist/runtime/biome-validate.js +452 -0
  195. package/dist/runtime/biome-validate.js.map +1 -0
  196. package/dist/runtime/boot-graph-loader.d.ts +1 -0
  197. package/dist/runtime/boot-graph-loader.d.ts.map +1 -1
  198. package/dist/runtime/boot-graph-loader.js +99 -7
  199. package/dist/runtime/boot-graph-loader.js.map +1 -1
  200. package/dist/runtime/canopy-refs.d.ts +8 -0
  201. package/dist/runtime/canopy-refs.d.ts.map +1 -0
  202. package/dist/runtime/canopy-refs.js +51 -0
  203. package/dist/runtime/canopy-refs.js.map +1 -0
  204. package/dist/runtime/canopy-replies.d.ts +14 -0
  205. package/dist/runtime/canopy-replies.d.ts.map +1 -0
  206. package/dist/runtime/canopy-replies.js +39 -0
  207. package/dist/runtime/canopy-replies.js.map +1 -0
  208. package/dist/runtime/capability-invoke.d.ts +35 -0
  209. package/dist/runtime/capability-invoke.d.ts.map +1 -0
  210. package/dist/runtime/capability-invoke.js +119 -0
  211. package/dist/runtime/capability-invoke.js.map +1 -0
  212. package/dist/runtime/cleanup.d.ts +10 -0
  213. package/dist/runtime/cleanup.d.ts.map +1 -0
  214. package/dist/runtime/cleanup.js +35 -0
  215. package/dist/runtime/cleanup.js.map +1 -0
  216. package/dist/runtime/config/dev-mode.d.ts +8 -0
  217. package/dist/runtime/config/dev-mode.d.ts.map +1 -0
  218. package/dist/runtime/config/dev-mode.js +84 -0
  219. package/dist/runtime/config/dev-mode.js.map +1 -0
  220. package/dist/runtime/config/init-presets.d.ts +1 -1
  221. package/dist/runtime/config/init-presets.d.ts.map +1 -1
  222. package/dist/runtime/config/init-presets.js +68 -13
  223. package/dist/runtime/config/init-presets.js.map +1 -1
  224. package/dist/runtime/config/loader.d.ts +1 -0
  225. package/dist/runtime/config/loader.d.ts.map +1 -1
  226. package/dist/runtime/config/loader.js +41 -5
  227. package/dist/runtime/config/loader.js.map +1 -1
  228. package/dist/runtime/config/schema.d.ts +27 -12
  229. package/dist/runtime/config/schema.d.ts.map +1 -1
  230. package/dist/runtime/config/schema.js +113 -8
  231. package/dist/runtime/config/schema.js.map +1 -1
  232. package/dist/runtime/config/sources-config.d.ts +14 -0
  233. package/dist/runtime/config/sources-config.d.ts.map +1 -0
  234. package/dist/runtime/config/sources-config.js +79 -0
  235. package/dist/runtime/config/sources-config.js.map +1 -0
  236. package/dist/runtime/distribution/available-biome.d.ts.map +1 -1
  237. package/dist/runtime/distribution/available-biome.js +2 -0
  238. package/dist/runtime/distribution/available-biome.js.map +1 -1
  239. package/dist/runtime/distribution/compose.d.ts +2 -1
  240. package/dist/runtime/distribution/compose.d.ts.map +1 -1
  241. package/dist/runtime/distribution/compose.js +4 -1
  242. package/dist/runtime/distribution/compose.js.map +1 -1
  243. package/dist/runtime/env-seeder.d.ts +5 -0
  244. package/dist/runtime/env-seeder.d.ts.map +1 -1
  245. package/dist/runtime/env-seeder.js +152 -19
  246. package/dist/runtime/env-seeder.js.map +1 -1
  247. package/dist/runtime/foreground.d.ts +9 -0
  248. package/dist/runtime/foreground.d.ts.map +1 -1
  249. package/dist/runtime/foreground.js +37 -3
  250. package/dist/runtime/foreground.js.map +1 -1
  251. package/dist/runtime/infra/infra-catalog.d.ts +34 -1
  252. package/dist/runtime/infra/infra-catalog.d.ts.map +1 -1
  253. package/dist/runtime/infra/infra-catalog.js +202 -10
  254. package/dist/runtime/infra/infra-catalog.js.map +1 -1
  255. package/dist/runtime/infra/infra-environment.d.ts +10 -0
  256. package/dist/runtime/infra/infra-environment.d.ts.map +1 -0
  257. package/dist/runtime/infra/infra-environment.js +76 -0
  258. package/dist/runtime/infra/infra-environment.js.map +1 -0
  259. package/dist/runtime/infra/infra-plan.d.ts +2 -1
  260. package/dist/runtime/infra/infra-plan.d.ts.map +1 -1
  261. package/dist/runtime/infra/infra-plan.js +10 -0
  262. package/dist/runtime/infra/infra-plan.js.map +1 -1
  263. package/dist/runtime/infra/infra-runner.d.ts +16 -1
  264. package/dist/runtime/infra/infra-runner.d.ts.map +1 -1
  265. package/dist/runtime/infra/infra-runner.js +245 -55
  266. package/dist/runtime/infra/infra-runner.js.map +1 -1
  267. package/dist/runtime/infra/keycloak-realm.d.ts +25 -0
  268. package/dist/runtime/infra/keycloak-realm.d.ts.map +1 -0
  269. package/dist/runtime/infra/keycloak-realm.js +116 -0
  270. package/dist/runtime/infra/keycloak-realm.js.map +1 -0
  271. package/dist/runtime/infra/postgres-endpoint.d.ts +8 -0
  272. package/dist/runtime/infra/postgres-endpoint.d.ts.map +1 -0
  273. package/dist/runtime/infra/postgres-endpoint.js +21 -0
  274. package/dist/runtime/infra/postgres-endpoint.js.map +1 -0
  275. package/dist/runtime/installation/compiler.d.ts +114 -0
  276. package/dist/runtime/installation/compiler.d.ts.map +1 -0
  277. package/dist/runtime/installation/compiler.js +456 -0
  278. package/dist/runtime/installation/compiler.js.map +1 -0
  279. package/dist/runtime/installation/contract.d.ts +296 -0
  280. package/dist/runtime/installation/contract.d.ts.map +1 -0
  281. package/dist/runtime/installation/contract.js +504 -0
  282. package/dist/runtime/installation/contract.js.map +1 -0
  283. package/dist/runtime/installation/current-launcher-renderer.d.ts +12 -0
  284. package/dist/runtime/installation/current-launcher-renderer.d.ts.map +1 -0
  285. package/dist/runtime/installation/current-launcher-renderer.js +123 -0
  286. package/dist/runtime/installation/current-launcher-renderer.js.map +1 -0
  287. package/dist/runtime/installation/diagnostics.d.ts +16 -0
  288. package/dist/runtime/installation/diagnostics.d.ts.map +1 -0
  289. package/dist/runtime/installation/diagnostics.js +21 -0
  290. package/dist/runtime/installation/diagnostics.js.map +1 -0
  291. package/dist/runtime/installation/diff.d.ts +32 -0
  292. package/dist/runtime/installation/diff.d.ts.map +1 -0
  293. package/dist/runtime/installation/diff.js +136 -0
  294. package/dist/runtime/installation/diff.js.map +1 -0
  295. package/dist/runtime/installation/format.d.ts +3 -0
  296. package/dist/runtime/installation/format.d.ts.map +1 -0
  297. package/dist/runtime/installation/format.js +22 -0
  298. package/dist/runtime/installation/format.js.map +1 -0
  299. package/dist/runtime/installation/from-current-config.d.ts +9 -0
  300. package/dist/runtime/installation/from-current-config.d.ts.map +1 -0
  301. package/dist/runtime/installation/from-current-config.js +245 -0
  302. package/dist/runtime/installation/from-current-config.js.map +1 -0
  303. package/dist/runtime/installation/helm-release-readiness.d.ts +9 -0
  304. package/dist/runtime/installation/helm-release-readiness.d.ts.map +1 -0
  305. package/dist/runtime/installation/helm-release-readiness.js +97 -0
  306. package/dist/runtime/installation/helm-release-readiness.js.map +1 -0
  307. package/dist/runtime/installation/helm-release.d.ts +24 -0
  308. package/dist/runtime/installation/helm-release.d.ts.map +1 -0
  309. package/dist/runtime/installation/helm-release.js +96 -0
  310. package/dist/runtime/installation/helm-release.js.map +1 -0
  311. package/dist/runtime/installation/index.d.ts +22 -0
  312. package/dist/runtime/installation/index.d.ts.map +1 -0
  313. package/dist/runtime/installation/index.js +38 -0
  314. package/dist/runtime/installation/index.js.map +1 -0
  315. package/dist/runtime/installation/json-schema.d.ts +4 -0
  316. package/dist/runtime/installation/json-schema.d.ts.map +1 -0
  317. package/dist/runtime/installation/json-schema.js +16 -0
  318. package/dist/runtime/installation/json-schema.js.map +1 -0
  319. package/dist/runtime/installation/kubernetes-readiness.d.ts +60 -0
  320. package/dist/runtime/installation/kubernetes-readiness.d.ts.map +1 -0
  321. package/dist/runtime/installation/kubernetes-readiness.js +384 -0
  322. package/dist/runtime/installation/kubernetes-readiness.js.map +1 -0
  323. package/dist/runtime/installation/lifecycle.d.ts +25 -0
  324. package/dist/runtime/installation/lifecycle.d.ts.map +1 -0
  325. package/dist/runtime/installation/lifecycle.js +157 -0
  326. package/dist/runtime/installation/lifecycle.js.map +1 -0
  327. package/dist/runtime/installation/readiness-proof.d.ts +72 -0
  328. package/dist/runtime/installation/readiness-proof.d.ts.map +1 -0
  329. package/dist/runtime/installation/readiness-proof.js +142 -0
  330. package/dist/runtime/installation/readiness-proof.js.map +1 -0
  331. package/dist/runtime/installation/readiness.d.ts +21 -0
  332. package/dist/runtime/installation/readiness.d.ts.map +1 -0
  333. package/dist/runtime/installation/readiness.js +418 -0
  334. package/dist/runtime/installation/readiness.js.map +1 -0
  335. package/dist/runtime/installation/serialization.d.ts +3 -0
  336. package/dist/runtime/installation/serialization.d.ts.map +1 -0
  337. package/dist/runtime/installation/serialization.js +39 -0
  338. package/dist/runtime/installation/serialization.js.map +1 -0
  339. package/dist/runtime/installation/setup-profile.d.ts +8 -0
  340. package/dist/runtime/installation/setup-profile.d.ts.map +1 -0
  341. package/dist/runtime/installation/setup-profile.js +41 -0
  342. package/dist/runtime/installation/setup-profile.js.map +1 -0
  343. package/dist/runtime/installation/setup-renderer.d.ts +31 -0
  344. package/dist/runtime/installation/setup-renderer.d.ts.map +1 -0
  345. package/dist/runtime/installation/setup-renderer.js +238 -0
  346. package/dist/runtime/installation/setup-renderer.js.map +1 -0
  347. package/dist/runtime/installation/state-store.d.ts +28 -0
  348. package/dist/runtime/installation/state-store.d.ts.map +1 -0
  349. package/dist/runtime/installation/state-store.js +377 -0
  350. package/dist/runtime/installation/state-store.js.map +1 -0
  351. package/dist/runtime/installation/status.d.ts +24 -0
  352. package/dist/runtime/installation/status.d.ts.map +1 -0
  353. package/dist/runtime/installation/status.js +52 -0
  354. package/dist/runtime/installation/status.js.map +1 -0
  355. package/dist/runtime/installation/support-bundle.d.ts +30 -0
  356. package/dist/runtime/installation/support-bundle.d.ts.map +1 -0
  357. package/dist/runtime/installation/support-bundle.js +145 -0
  358. package/dist/runtime/installation/support-bundle.js.map +1 -0
  359. package/dist/runtime/installation/to-current-config.d.ts +4 -0
  360. package/dist/runtime/installation/to-current-config.d.ts.map +1 -0
  361. package/dist/runtime/installation/to-current-config.js +171 -0
  362. package/dist/runtime/installation/to-current-config.js.map +1 -0
  363. package/dist/runtime/installation/validation.d.ts +8 -0
  364. package/dist/runtime/installation/validation.d.ts.map +1 -0
  365. package/dist/runtime/installation/validation.js +117 -0
  366. package/dist/runtime/installation/validation.js.map +1 -0
  367. package/dist/runtime/installation/validators/common.d.ts +4 -0
  368. package/dist/runtime/installation/validators/common.d.ts.map +1 -0
  369. package/dist/runtime/installation/validators/common.js +32 -0
  370. package/dist/runtime/installation/validators/common.js.map +1 -0
  371. package/dist/runtime/installation/validators/infrastructure.d.ts +4 -0
  372. package/dist/runtime/installation/validators/infrastructure.d.ts.map +1 -0
  373. package/dist/runtime/installation/validators/infrastructure.js +96 -0
  374. package/dist/runtime/installation/validators/infrastructure.js.map +1 -0
  375. package/dist/runtime/installation/validators/operational.d.ts +4 -0
  376. package/dist/runtime/installation/validators/operational.d.ts.map +1 -0
  377. package/dist/runtime/installation/validators/operational.js +68 -0
  378. package/dist/runtime/installation/validators/operational.js.map +1 -0
  379. package/dist/runtime/installation/validators/profile.d.ts +4 -0
  380. package/dist/runtime/installation/validators/profile.d.ts.map +1 -0
  381. package/dist/runtime/installation/validators/profile.js +80 -0
  382. package/dist/runtime/installation/validators/profile.js.map +1 -0
  383. package/dist/runtime/installation/validators/secrets.d.ts +4 -0
  384. package/dist/runtime/installation/validators/secrets.d.ts.map +1 -0
  385. package/dist/runtime/installation/validators/secrets.js +85 -0
  386. package/dist/runtime/installation/validators/secrets.js.map +1 -0
  387. package/dist/runtime/launch-plan-format.d.ts +3 -0
  388. package/dist/runtime/launch-plan-format.d.ts.map +1 -0
  389. package/dist/runtime/launch-plan-format.js +57 -0
  390. package/dist/runtime/launch-plan-format.js.map +1 -0
  391. package/dist/runtime/launch.d.ts +35 -3
  392. package/dist/runtime/launch.d.ts.map +1 -1
  393. package/dist/runtime/launch.js +382 -37
  394. package/dist/runtime/launch.js.map +1 -1
  395. package/dist/runtime/license/license-clock.d.ts +12 -0
  396. package/dist/runtime/license/license-clock.d.ts.map +1 -0
  397. package/dist/runtime/license/license-clock.js +57 -0
  398. package/dist/runtime/license/license-clock.js.map +1 -0
  399. package/dist/runtime/license/license-report.d.ts +19 -0
  400. package/dist/runtime/license/license-report.d.ts.map +1 -0
  401. package/dist/runtime/license/license-report.js +105 -0
  402. package/dist/runtime/license/license-report.js.map +1 -0
  403. package/dist/runtime/license/license-store.d.ts +5 -0
  404. package/dist/runtime/license/license-store.d.ts.map +1 -0
  405. package/dist/runtime/license/license-store.js +11 -0
  406. package/dist/runtime/license/license-store.js.map +1 -0
  407. package/dist/runtime/license/registry-credential.d.ts +26 -0
  408. package/dist/runtime/license/registry-credential.d.ts.map +1 -0
  409. package/dist/runtime/license/registry-credential.js +94 -0
  410. package/dist/runtime/license/registry-credential.js.map +1 -0
  411. package/dist/runtime/license/resolve-license.d.ts +30 -0
  412. package/dist/runtime/license/resolve-license.d.ts.map +1 -0
  413. package/dist/runtime/license/resolve-license.js +73 -0
  414. package/dist/runtime/license/resolve-license.js.map +1 -0
  415. package/dist/runtime/license/store-license.d.ts +18 -0
  416. package/dist/runtime/license/store-license.d.ts.map +1 -0
  417. package/dist/runtime/license/store-license.js +26 -0
  418. package/dist/runtime/license/store-license.js.map +1 -0
  419. package/dist/runtime/lock-loader.d.ts +3 -6
  420. package/dist/runtime/lock-loader.d.ts.map +1 -1
  421. package/dist/runtime/lock-loader.js +26 -20
  422. package/dist/runtime/lock-loader.js.map +1 -1
  423. package/dist/runtime/native-process-group.d.ts +46 -0
  424. package/dist/runtime/native-process-group.d.ts.map +1 -0
  425. package/dist/runtime/native-process-group.js +390 -0
  426. package/dist/runtime/native-process-group.js.map +1 -0
  427. package/dist/runtime/object-registry-client.d.ts +31 -0
  428. package/dist/runtime/object-registry-client.d.ts.map +1 -0
  429. package/dist/runtime/object-registry-client.js +54 -0
  430. package/dist/runtime/object-registry-client.js.map +1 -0
  431. package/dist/runtime/paths.d.ts +2 -0
  432. package/dist/runtime/paths.d.ts.map +1 -1
  433. package/dist/runtime/paths.js +3 -0
  434. package/dist/runtime/paths.js.map +1 -1
  435. package/dist/runtime/roster.d.ts +12 -5
  436. package/dist/runtime/roster.d.ts.map +1 -1
  437. package/dist/runtime/roster.js +89 -11
  438. package/dist/runtime/roster.js.map +1 -1
  439. package/dist/runtime/run-manifest.d.ts +52 -0
  440. package/dist/runtime/run-manifest.d.ts.map +1 -0
  441. package/dist/runtime/run-manifest.js +587 -0
  442. package/dist/runtime/run-manifest.js.map +1 -0
  443. package/dist/runtime/runner/container-preflight.d.ts +77 -0
  444. package/dist/runtime/runner/container-preflight.d.ts.map +1 -0
  445. package/dist/runtime/runner/container-preflight.js +360 -0
  446. package/dist/runtime/runner/container-preflight.js.map +1 -0
  447. package/dist/runtime/runner/container-runner.d.ts +14 -0
  448. package/dist/runtime/runner/container-runner.d.ts.map +1 -1
  449. package/dist/runtime/runner/container-runner.js +110 -14
  450. package/dist/runtime/runner/container-runner.js.map +1 -1
  451. package/dist/runtime/runner/docker-cli.d.ts +35 -2
  452. package/dist/runtime/runner/docker-cli.d.ts.map +1 -1
  453. package/dist/runtime/runner/docker-cli.js +314 -9
  454. package/dist/runtime/runner/docker-cli.js.map +1 -1
  455. package/dist/runtime/runner/health-probe.d.ts +1 -0
  456. package/dist/runtime/runner/health-probe.d.ts.map +1 -1
  457. package/dist/runtime/runner/health-probe.js +3 -2
  458. package/dist/runtime/runner/health-probe.js.map +1 -1
  459. package/dist/runtime/runner/helm-cli.d.ts +19 -1
  460. package/dist/runtime/runner/helm-cli.d.ts.map +1 -1
  461. package/dist/runtime/runner/helm-cli.js +76 -8
  462. package/dist/runtime/runner/helm-cli.js.map +1 -1
  463. package/dist/runtime/runner/helm-runner.d.ts +3 -0
  464. package/dist/runtime/runner/helm-runner.d.ts.map +1 -1
  465. package/dist/runtime/runner/helm-runner.js +23 -7
  466. package/dist/runtime/runner/helm-runner.js.map +1 -1
  467. package/dist/runtime/runner/host-platform.d.ts +39 -0
  468. package/dist/runtime/runner/host-platform.d.ts.map +1 -0
  469. package/dist/runtime/runner/host-platform.js +136 -0
  470. package/dist/runtime/runner/host-platform.js.map +1 -0
  471. package/dist/runtime/runner/kube-cli.d.ts +23 -0
  472. package/dist/runtime/runner/kube-cli.d.ts.map +1 -0
  473. package/dist/runtime/runner/kube-cli.js +112 -0
  474. package/dist/runtime/runner/kube-cli.js.map +1 -0
  475. package/dist/runtime/runner/native-runner.d.ts.map +1 -1
  476. package/dist/runtime/runner/native-runner.js +46 -15
  477. package/dist/runtime/runner/native-runner.js.map +1 -1
  478. package/dist/runtime/runner/service-runner.d.ts +5 -0
  479. package/dist/runtime/runner/service-runner.d.ts.map +1 -1
  480. package/dist/runtime/runner/service-runner.js.map +1 -1
  481. package/dist/runtime/runner/stream-outcome.d.ts +7 -0
  482. package/dist/runtime/runner/stream-outcome.d.ts.map +1 -0
  483. package/dist/runtime/runner/stream-outcome.js +13 -0
  484. package/dist/runtime/runner/stream-outcome.js.map +1 -0
  485. package/dist/runtime/secrets/managed-local-cipher.d.ts +18 -0
  486. package/dist/runtime/secrets/managed-local-cipher.d.ts.map +1 -0
  487. package/dist/runtime/secrets/managed-local-cipher.js +110 -0
  488. package/dist/runtime/secrets/managed-local-cipher.js.map +1 -0
  489. package/dist/runtime/secrets/managed-local-files.d.ts +4 -0
  490. package/dist/runtime/secrets/managed-local-files.d.ts.map +1 -0
  491. package/dist/runtime/secrets/managed-local-files.js +132 -0
  492. package/dist/runtime/secrets/managed-local-files.js.map +1 -0
  493. package/dist/runtime/secrets/managed-local-key-provider.d.ts +27 -0
  494. package/dist/runtime/secrets/managed-local-key-provider.d.ts.map +1 -0
  495. package/dist/runtime/secrets/managed-local-key-provider.js +144 -0
  496. package/dist/runtime/secrets/managed-local-key-provider.js.map +1 -0
  497. package/dist/runtime/secrets/managed-local-secret-store.d.ts +18 -0
  498. package/dist/runtime/secrets/managed-local-secret-store.d.ts.map +1 -0
  499. package/dist/runtime/secrets/managed-local-secret-store.js +82 -0
  500. package/dist/runtime/secrets/managed-local-secret-store.js.map +1 -0
  501. package/dist/runtime/secrets/managed-local-store.d.ts +33 -0
  502. package/dist/runtime/secrets/managed-local-store.d.ts.map +1 -0
  503. package/dist/runtime/secrets/managed-local-store.js +121 -0
  504. package/dist/runtime/secrets/managed-local-store.js.map +1 -0
  505. package/dist/runtime/secrets/resolver.d.ts +23 -0
  506. package/dist/runtime/secrets/resolver.d.ts.map +1 -0
  507. package/dist/runtime/secrets/resolver.js +265 -0
  508. package/dist/runtime/secrets/resolver.js.map +1 -0
  509. package/dist/runtime/secrets/url-security.d.ts +3 -0
  510. package/dist/runtime/secrets/url-security.d.ts.map +1 -0
  511. package/dist/runtime/secrets/url-security.js +13 -0
  512. package/dist/runtime/secrets/url-security.js.map +1 -0
  513. package/dist/runtime/sources/credentials.d.ts +2 -0
  514. package/dist/runtime/sources/credentials.d.ts.map +1 -1
  515. package/dist/runtime/sources/credentials.js +51 -1
  516. package/dist/runtime/sources/credentials.js.map +1 -1
  517. package/dist/runtime/sources/kinds/distribution.js +3 -3
  518. package/dist/runtime/sources/kinds/distribution.js.map +1 -1
  519. package/dist/runtime/sources/kinds/git.d.ts +6 -3
  520. package/dist/runtime/sources/kinds/git.d.ts.map +1 -1
  521. package/dist/runtime/sources/kinds/git.js +99 -22
  522. package/dist/runtime/sources/kinds/git.js.map +1 -1
  523. package/dist/runtime/sources/manifest-walk.d.ts +1 -0
  524. package/dist/runtime/sources/manifest-walk.d.ts.map +1 -1
  525. package/dist/runtime/sources/manifest-walk.js +16 -11
  526. package/dist/runtime/sources/manifest-walk.js.map +1 -1
  527. package/dist/runtime/sources/resolve-context.d.ts +7 -0
  528. package/dist/runtime/sources/resolve-context.d.ts.map +1 -0
  529. package/dist/runtime/sources/resolve-context.js +3 -0
  530. package/dist/runtime/sources/resolve-context.js.map +1 -0
  531. package/dist/runtime/sources/resolver.d.ts +2 -2
  532. package/dist/runtime/sources/resolver.d.ts.map +1 -1
  533. package/dist/runtime/sources/resolver.js +11 -5
  534. package/dist/runtime/sources/resolver.js.map +1 -1
  535. package/dist/runtime/sources/schema.d.ts.map +1 -1
  536. package/dist/runtime/sources/schema.js +51 -3
  537. package/dist/runtime/sources/schema.js.map +1 -1
  538. package/dist/runtime/store-client.d.ts +59 -0
  539. package/dist/runtime/store-client.d.ts.map +1 -0
  540. package/dist/runtime/store-client.js +72 -0
  541. package/dist/runtime/store-client.js.map +1 -0
  542. package/dist/runtime/store-submit.d.ts +31 -0
  543. package/dist/runtime/store-submit.d.ts.map +1 -0
  544. package/dist/runtime/store-submit.js +77 -0
  545. package/dist/runtime/store-submit.js.map +1 -0
  546. package/dist/runtime/supervisor.d.ts +18 -0
  547. package/dist/runtime/supervisor.d.ts.map +1 -1
  548. package/dist/runtime/supervisor.js +162 -15
  549. package/dist/runtime/supervisor.js.map +1 -1
  550. package/dist/runtime/waves.d.ts +1 -1
  551. package/dist/runtime/waves.d.ts.map +1 -1
  552. package/dist/runtime/waves.js +86 -19
  553. package/dist/runtime/waves.js.map +1 -1
  554. package/examples/01-local-native.yaml +4 -1
  555. package/examples/03-byo-infra.yaml +17 -7
  556. package/examples/05-appliance-helm.yaml +1 -1
  557. package/examples/06-biome-sources.yaml +4 -1
  558. package/package.json +20 -28
  559. package/xema.config.example.yaml +22 -18
  560. package/LICENSE +0 -176
  561. package/dist/lib/command-registry.d.ts +0 -5
  562. package/dist/lib/command-registry.d.ts.map +0 -1
  563. package/dist/lib/command-registry.js +0 -17
  564. package/dist/lib/command-registry.js.map +0 -1
@@ -0,0 +1,238 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.renderInstallationSetup = renderInstallationSetup;
4
+ const contract_1 = require("./contract");
5
+ const diff_1 = require("./diff");
6
+ const serialization_1 = require("./serialization");
7
+ const RENDERER_ID = 'xema-cli-installation-setup/v1';
8
+ const MATERIAL_OBLIGATIONS = [
9
+ diff_1.InstallationRenderObligation.RuntimeReconfigure,
10
+ diff_1.InstallationRenderObligation.WorkloadRollout,
11
+ diff_1.InstallationRenderObligation.InfrastructureReconcile,
12
+ diff_1.InstallationRenderObligation.DataAndRecoveryReconcile,
13
+ ];
14
+ function renderInstallationSetup(installation, opts = {}) {
15
+ assertSupportedProfile(installation.spec.profile);
16
+ assertProfilePlacement(installation);
17
+ const providers = assertProvidersReady(installation, opts.providers ?? []);
18
+ const artifacts = artifactModels(installation, providers)
19
+ .map((candidate) => renderArtifact(installation, candidate))
20
+ .sort((left, right) => left.path.localeCompare(right.path));
21
+ const renderedArtifacts = MATERIAL_OBLIGATIONS.map((obligation) => {
22
+ const obligationArtifacts = artifacts.filter((artifact) => artifact.obligation === obligation);
23
+ if (obligationArtifacts.length === 0) {
24
+ throw new Error(`Installation setup renderer left obligation ${obligation} unresolved.`);
25
+ }
26
+ return {
27
+ obligation,
28
+ rendererId: RENDERER_ID,
29
+ effectivePlanHash: installation.effectivePlanHash,
30
+ artifactDigest: `sha256:${(0, serialization_1.hashInstallation)(obligationArtifacts.map(({ path, digest }) => ({ path, digest })))}`,
31
+ };
32
+ });
33
+ return {
34
+ rendererId: RENDERER_ID,
35
+ profile: installation.spec.profile,
36
+ effectivePlanHash: installation.effectivePlanHash,
37
+ artifacts,
38
+ renderedArtifacts,
39
+ };
40
+ }
41
+ function artifactModels(installation, providers) {
42
+ switch (installation.spec.profile) {
43
+ case contract_1.InstallationProfile.Developer:
44
+ case contract_1.InstallationProfile.Starter:
45
+ return localArtifactModels(installation, providers);
46
+ case contract_1.InstallationProfile.SingleNodeProduction:
47
+ return singleNodeArtifactModels(installation, providers);
48
+ case contract_1.InstallationProfile.BusinessHa:
49
+ case contract_1.InstallationProfile.EnterpriseRegulated:
50
+ case contract_1.InstallationProfile.HostedCell:
51
+ return unsupported(installation.spec.profile);
52
+ }
53
+ }
54
+ function localArtifactModels(installation, providers) {
55
+ const spec = installation.spec;
56
+ return [
57
+ {
58
+ path: 'runtime/config.json',
59
+ obligation: diff_1.InstallationRenderObligation.RuntimeReconfigure,
60
+ kind: 'LocalRuntimeConfiguration',
61
+ spec: {
62
+ lifecycle: spec.lifecycle,
63
+ security: spec.security,
64
+ observability: spec.observability,
65
+ capacity: spec.capacity,
66
+ },
67
+ },
68
+ {
69
+ path: 'launcher/workloads.json',
70
+ obligation: diff_1.InstallationRenderObligation.WorkloadRollout,
71
+ kind: 'LocalWorkloadPlan',
72
+ spec: {
73
+ distribution: spec.distribution,
74
+ features: spec.features,
75
+ sources: spec.sources,
76
+ domains: spec.domains,
77
+ upgrade: spec.upgrade,
78
+ },
79
+ },
80
+ {
81
+ path: 'bootstrap/local.json',
82
+ obligation: diff_1.InstallationRenderObligation.InfrastructureReconcile,
83
+ kind: 'LocalBootstrapPlan',
84
+ spec: {
85
+ profile: spec.profile,
86
+ target: spec.target,
87
+ operator: spec.operator,
88
+ infrastructure: spec.infrastructure,
89
+ secrets: renderedSecretBindings(spec.secrets, providers),
90
+ },
91
+ },
92
+ {
93
+ path: 'storage/policy.json',
94
+ obligation: diff_1.InstallationRenderObligation.DataAndRecoveryReconcile,
95
+ kind: 'LocalDataPolicy',
96
+ spec: {
97
+ tenancy: spec.tenancy,
98
+ storage: spec.storage,
99
+ recovery: spec.recovery,
100
+ },
101
+ },
102
+ ];
103
+ }
104
+ function singleNodeArtifactModels(installation, providers) {
105
+ const spec = installation.spec;
106
+ return [
107
+ {
108
+ path: 'observability/config.json',
109
+ obligation: diff_1.InstallationRenderObligation.RuntimeReconfigure,
110
+ kind: 'SingleNodeObservabilityConfiguration',
111
+ spec: {
112
+ lifecycle: spec.lifecycle,
113
+ security: spec.security,
114
+ observability: spec.observability,
115
+ },
116
+ },
117
+ {
118
+ path: 'helm/xema.values.json',
119
+ obligation: diff_1.InstallationRenderObligation.WorkloadRollout,
120
+ kind: 'SingleNodeHelmValues',
121
+ spec: {
122
+ distribution: spec.distribution,
123
+ features: spec.features,
124
+ capacity: spec.capacity,
125
+ domains: spec.domains,
126
+ sources: spec.sources,
127
+ },
128
+ },
129
+ {
130
+ path: 'upgrade/policy.json',
131
+ obligation: diff_1.InstallationRenderObligation.WorkloadRollout,
132
+ kind: 'SingleNodeUpgradePolicy',
133
+ spec: { upgrade: spec.upgrade },
134
+ },
135
+ {
136
+ path: 'bootstrap/cluster.json',
137
+ obligation: diff_1.InstallationRenderObligation.InfrastructureReconcile,
138
+ kind: 'SingleNodeBootstrapPlan',
139
+ spec: {
140
+ profile: spec.profile,
141
+ target: spec.target,
142
+ operator: spec.operator,
143
+ infrastructure: spec.infrastructure,
144
+ storage: spec.storage,
145
+ secrets: renderedSecretBindings(spec.secrets, providers),
146
+ },
147
+ },
148
+ {
149
+ path: 'backup/policy.json',
150
+ obligation: diff_1.InstallationRenderObligation.DataAndRecoveryReconcile,
151
+ kind: 'SingleNodeBackupPolicy',
152
+ spec: {
153
+ tenancy: spec.tenancy,
154
+ recovery: spec.recovery,
155
+ },
156
+ },
157
+ ];
158
+ }
159
+ function renderedSecretBindings(bindings, providers) {
160
+ return bindings.map((binding) => ({
161
+ ...binding,
162
+ ...(binding.provider === contract_1.SecretReferenceProvider.ManagedLocal
163
+ ? { keyRef: providers.get(binding.provider)?.keyRef }
164
+ : {}),
165
+ }));
166
+ }
167
+ function renderArtifact(installation, model) {
168
+ const content = `${(0, serialization_1.serializeInstallation)({
169
+ apiVersion: 'setup.xema.dev/v1',
170
+ kind: model.kind,
171
+ effectivePlanHash: installation.effectivePlanHash,
172
+ spec: model.spec,
173
+ })}\n`;
174
+ return {
175
+ path: model.path,
176
+ mediaType: 'application/json',
177
+ obligation: model.obligation,
178
+ effectivePlanHash: installation.effectivePlanHash,
179
+ digest: `sha256:${(0, serialization_1.hashInstallation)({
180
+ path: model.path,
181
+ effectivePlanHash: installation.effectivePlanHash,
182
+ content,
183
+ })}`,
184
+ content,
185
+ };
186
+ }
187
+ function assertProvidersReady(installation, readiness) {
188
+ const providers = new Map();
189
+ for (const item of readiness) {
190
+ if (providers.has(item.provider)) {
191
+ throw new Error(`Secret provider readiness was declared more than once for ${item.provider}.`);
192
+ }
193
+ providers.set(item.provider, item);
194
+ }
195
+ for (const binding of installation.spec.secrets) {
196
+ const provider = providers.get(binding.provider);
197
+ if (provider?.available !== true) {
198
+ throw new Error(`Secret provider ${binding.provider} is unavailable for binding "${binding.name}"; no fallback provider was attempted.`);
199
+ }
200
+ if (binding.provider === contract_1.SecretReferenceProvider.ManagedLocal &&
201
+ (provider.keyRef === undefined || provider.keyRef.length === 0)) {
202
+ throw new Error(`Managed-local binding "${binding.name}" has no custody key reference.`);
203
+ }
204
+ if (binding.provider === contract_1.SecretReferenceProvider.ManagedLocal &&
205
+ !provider.resolvedEntries?.includes(binding.entry)) {
206
+ throw new Error(`Managed-local binding "${binding.name}" has no authenticated immutable entry "${binding.entry}".`);
207
+ }
208
+ }
209
+ return providers;
210
+ }
211
+ function assertSupportedProfile(profile) {
212
+ if (profile === contract_1.InstallationProfile.BusinessHa ||
213
+ profile === contract_1.InstallationProfile.EnterpriseRegulated ||
214
+ profile === contract_1.InstallationProfile.HostedCell) {
215
+ unsupported(profile);
216
+ }
217
+ }
218
+ function assertProfilePlacement(installation) {
219
+ const spec = installation.spec;
220
+ if ((spec.profile === contract_1.InstallationProfile.Developer ||
221
+ spec.profile === contract_1.InstallationProfile.Starter) &&
222
+ (spec.lifecycle.environment !== contract_1.LifecycleEnvironment.Development ||
223
+ spec.target.kind !== contract_1.InstallationTargetKind.LocalMachine)) {
224
+ throw new Error(`Installation setup renderer requires ${spec.profile} to use a development lifecycle on a local-machine target.`);
225
+ }
226
+ if (spec.profile === contract_1.InstallationProfile.SingleNodeProduction &&
227
+ (spec.lifecycle.environment !== contract_1.LifecycleEnvironment.Production ||
228
+ spec.target.kind !== contract_1.InstallationTargetKind.SingleNodeKubernetes ||
229
+ spec.capacity.minReplicas !== 1 ||
230
+ spec.capacity.maxReplicas !== 1 ||
231
+ spec.capacity.zones !== 1)) {
232
+ throw new Error('Installation setup renderer requires single-node-production to use one production Kubernetes node in one zone.');
233
+ }
234
+ }
235
+ function unsupported(profile) {
236
+ throw new Error(`Installation setup renderer does not support profile ${profile}; no artifacts were produced.`);
237
+ }
238
+ //# sourceMappingURL=setup-renderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup-renderer.js","sourceRoot":"","sources":["../../../src/runtime/installation/setup-renderer.ts"],"names":[],"mappings":";;AAyDA,0DA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M,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC;IAC/B,IACE,CAAC,IAAI,CAAC,OAAO,KAAK,8BAAmB,CAAC,SAAS;QAC7C,IAAI,CAAC,OAAO,KAAK,8BAAmB,CAAC,OAAO,CAAC;QAC/C,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,KAAK,+BAAoB,CAAC,WAAW;YAC9D,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,iCAAsB,CAAC,YAAY,CAAC,EAC3D,CAAC;QACD,MAAM,IAAI,KAAK,CACb,wCAAwC,IAAI,CAAC,OAAO,4DAA4D,CACjH,CAAC;IACJ,CAAC;IACD,IACE,IAAI,CAAC,OAAO,KAAK,8BAAmB,CAAC,oBAAoB;QACzD,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,KAAK,+BAAoB,CAAC,UAAU;YAC7D,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,iCAAsB,CAAC,oBAAoB;YAChE,IAAI,CAAC,QAAQ,CAAC,WAAW,KAAK,CAAC;YAC/B,IAAI,CAAC,QAAQ,CAAC,WAAW,KAAK,CAAC;YAC/B,IAAI,CAAC,QAAQ,CAAC,KAAK,KAAK,CAAC,CAAC,EAC5B,CAAC;QACD,MAAM,IAAI,KAAK,CACb,gHAAgH,CACjH,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAS,WAAW,CAAC,OAA4B;IAC/C,MAAM,IAAI,KAAK,CACb,wDAAwD,OAAO,+BAA+B,CAC/F,CAAC;AACJ,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { type CompiledXemaInstallation } from './compiler';
2
+ import { type InstallationRenderAcknowledgement } from './diff';
3
+ export interface AppliedInstallationState {
4
+ readonly schemaVersion: 2;
5
+ readonly appliedAt: string;
6
+ readonly effectivePlanHash: string;
7
+ readonly renderedArtifacts: readonly InstallationRenderAcknowledgement[];
8
+ readonly plan: CompiledXemaInstallation;
9
+ }
10
+ export interface InstallationStateStoreOptions {
11
+ readonly root?: string;
12
+ }
13
+ export declare class InstallationStateStore {
14
+ private readonly root;
15
+ constructor(opts?: InstallationStateStoreOptions);
16
+ read(installationId: string): AppliedInstallationState | undefined;
17
+ write(plan: CompiledXemaInstallation, renderedArtifacts: readonly InstallationRenderAcknowledgement[], appliedAt?: string): AppliedInstallationState;
18
+ acquireApplyLock(installationId: string): () => void;
19
+ acquireLocalRuntimeLock(): () => void;
20
+ claimLocalRuntimeOwner(installationId: string): void;
21
+ assertLocalRuntimeOwner(installationId: string): void;
22
+ releaseLocalRuntimeOwner(installationId: string): void;
23
+ private acquireLock;
24
+ private appliedPath;
25
+ private localRuntimeOwnerPath;
26
+ private installationDirectory;
27
+ }
28
+ //# sourceMappingURL=state-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state-store.d.ts","sourceRoot":"","sources":["../../../src/runtime/installation/state-store.ts"],"names":[],"mappings":"AAkBA,OAAO,EAGL,KAAK,wBAAwB,EAC9B,MAAM,YAAY,CAAC;AACpB,OAAO,EAEL,KAAK,iCAAiC,EACvC,MAAM,QAAQ,CAAC;AAGhB,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,iBAAiB,EAAE,SAAS,iCAAiC,EAAE,CAAC;IACzE,QAAQ,CAAC,IAAI,EAAE,wBAAwB,CAAC;CACzC;AAED,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAgBD,qBAAa,sBAAsB;IACjC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;gBAEX,IAAI,GAAE,6BAAkC;IAIpD,IAAI,CAAC,cAAc,EAAE,MAAM,GAAG,wBAAwB,GAAG,SAAS;IAclE,KAAK,CACV,IAAI,EAAE,wBAAwB,EAC9B,iBAAiB,EAAE,SAAS,iCAAiC,EAAE,EAC/D,SAAS,SAA2B,GACnC,wBAAwB;IAiBpB,gBAAgB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,IAAI;IAapD,uBAAuB,IAAI,MAAM,IAAI;IAKrC,sBAAsB,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI;IAqBpD,uBAAuB,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI;IAkBrD,wBAAwB,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI;IAiB7D,OAAO,CAAC,WAAW;IA6DnB,OAAO,CAAC,WAAW;IAOnB,OAAO,CAAC,qBAAqB;IAI7B,OAAO,CAAC,qBAAqB;CAQ9B"}
@@ -0,0 +1,377 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InstallationStateStore = void 0;
4
+ const node_crypto_1 = require("node:crypto");
5
+ const node_fs_1 = require("node:fs");
6
+ const node_os_1 = require("node:os");
7
+ const node_path_1 = require("node:path");
8
+ const compiler_1 = require("./compiler");
9
+ const diff_1 = require("./diff");
10
+ const serialization_1 = require("./serialization");
11
+ const PRIVATE_DIRECTORY_MODE = 0o700;
12
+ const PRIVATE_FILE_MODE = 0o600;
13
+ class InstallationStateStore {
14
+ root;
15
+ constructor(opts = {}) {
16
+ this.root = opts.root ?? (0, node_path_1.join)((0, node_os_1.homedir)(), '.xema', 'installations');
17
+ }
18
+ read(installationId) {
19
+ const path = this.appliedPath(installationId);
20
+ const directory = (0, node_path_1.dirname)(path);
21
+ if (!(0, node_fs_1.existsSync)(directory)) {
22
+ return undefined;
23
+ }
24
+ assertPrivateDirectory(directory);
25
+ if (!(0, node_fs_1.existsSync)(path)) {
26
+ return undefined;
27
+ }
28
+ const parsed = JSON.parse(readPrivateFile(path));
29
+ return parseAppliedState(parsed, path);
30
+ }
31
+ write(plan, renderedArtifacts, appliedAt = new Date().toISOString()) {
32
+ validateRenderedArtifacts(renderedArtifacts, plan.effectivePlanHash, `new state for ${plan.metadata.name}`);
33
+ const state = {
34
+ schemaVersion: 2,
35
+ appliedAt,
36
+ effectivePlanHash: plan.effectivePlanHash,
37
+ renderedArtifacts,
38
+ plan,
39
+ };
40
+ writeJsonAtomically(this.appliedPath(plan.metadata.name), state);
41
+ return state;
42
+ }
43
+ acquireApplyLock(installationId) {
44
+ const path = (0, node_path_1.join)(this.installationDirectory(installationId), 'apply.lock');
45
+ return this.acquireLock(path, `Installation "${installationId}"`);
46
+ }
47
+ acquireLocalRuntimeLock() {
48
+ const path = (0, node_path_1.join)(this.root, '.local-runtime', 'apply.lock');
49
+ return this.acquireLock(path, 'Local runtime');
50
+ }
51
+ claimLocalRuntimeOwner(installationId) {
52
+ const path = this.localRuntimeOwnerPath();
53
+ ensurePrivateDirectory((0, node_path_1.dirname)(path));
54
+ if ((0, node_fs_1.existsSync)(path)) {
55
+ const owner = parseLocalRuntimeOwner(JSON.parse(readPrivateFile(path)), path);
56
+ if (owner.installationId !== installationId) {
57
+ throw new Error(`Local managed runtime data is owned by installation "${owner.installationId}", not "${installationId}". Purge the owning installation before reusing fixed local volumes and ports.`);
58
+ }
59
+ return;
60
+ }
61
+ writeJsonAtomically(path, {
62
+ installationId,
63
+ claimedAt: new Date().toISOString(),
64
+ });
65
+ }
66
+ assertLocalRuntimeOwner(installationId) {
67
+ const path = this.localRuntimeOwnerPath();
68
+ if (!(0, node_fs_1.existsSync)(path)) {
69
+ throw new Error(`Local managed runtime has no durable owner record; refusing destructive cleanup for installation "${installationId}".`);
70
+ }
71
+ const owner = parseLocalRuntimeOwner(JSON.parse(readPrivateFile(path)), path);
72
+ if (owner.installationId !== installationId) {
73
+ throw new Error(`Local managed runtime data is owned by installation "${owner.installationId}", not "${installationId}".`);
74
+ }
75
+ }
76
+ releaseLocalRuntimeOwner(installationId) {
77
+ const path = this.localRuntimeOwnerPath();
78
+ if (!(0, node_fs_1.existsSync)(path)) {
79
+ return;
80
+ }
81
+ const owner = parseLocalRuntimeOwner(JSON.parse(readPrivateFile(path)), path);
82
+ if (owner.installationId !== installationId) {
83
+ throw new Error(`Refusing to release local runtime data owned by installation "${owner.installationId}".`);
84
+ }
85
+ (0, node_fs_1.rmSync)(path);
86
+ }
87
+ acquireLock(path, subject) {
88
+ const recoveryPath = `${path}.recovery`;
89
+ ensurePrivateDirectory((0, node_path_1.dirname)(path));
90
+ for (let attempt = 0; attempt < 2; attempt += 1) {
91
+ const owner = {
92
+ pid: process.pid,
93
+ token: (0, node_crypto_1.randomUUID)(),
94
+ acquiredAt: new Date().toISOString(),
95
+ };
96
+ try {
97
+ writeExclusiveFile(path, owner);
98
+ let released = false;
99
+ return () => {
100
+ if (!released) {
101
+ assertLockOwnership(path, owner.token);
102
+ released = true;
103
+ (0, node_fs_1.rmSync)(path, { force: true });
104
+ }
105
+ };
106
+ }
107
+ catch (error) {
108
+ const code = error.code;
109
+ if (code !== 'EEXIST') {
110
+ throw error;
111
+ }
112
+ const existing = readLockOwner(path);
113
+ if (existing === undefined) {
114
+ throw new Error(`${subject} has an unreadable apply lock at ${path}; remove it only after confirming no apply process is running.`);
115
+ }
116
+ if (processIsAlive(existing.pid)) {
117
+ throw new Error(`${subject} is already being applied by process ${String(existing.pid)}.`);
118
+ }
119
+ const releaseRecovery = acquireRecoveryLock(recoveryPath, subject);
120
+ try {
121
+ const rechecked = readLockOwner(path);
122
+ if (rechecked === undefined ||
123
+ rechecked.token !== existing.token ||
124
+ processIsAlive(rechecked.pid)) {
125
+ throw new Error(`${subject} apply-lock ownership changed during stale-lock recovery; retry after the active apply completes.`);
126
+ }
127
+ (0, node_fs_1.rmSync)(path);
128
+ }
129
+ finally {
130
+ releaseRecovery();
131
+ }
132
+ }
133
+ }
134
+ throw new Error(`Could not acquire the apply lock for ${subject}.`);
135
+ }
136
+ appliedPath(installationId) {
137
+ return (0, node_path_1.join)(this.installationDirectory(installationId), 'last-applied.json');
138
+ }
139
+ localRuntimeOwnerPath() {
140
+ return (0, node_path_1.join)(this.root, '.local-runtime', 'owner.json');
141
+ }
142
+ installationDirectory(installationId) {
143
+ if (!/^[A-Za-z0-9._-]+$/.test(installationId)) {
144
+ throw new Error(`Installation id "${installationId}" is unsafe for local state storage.`);
145
+ }
146
+ return (0, node_path_1.join)(this.root, installationId);
147
+ }
148
+ }
149
+ exports.InstallationStateStore = InstallationStateStore;
150
+ function parseAppliedState(value, path) {
151
+ if (value === null || typeof value !== 'object') {
152
+ throw new Error(`Applied installation state is invalid: ${path}`);
153
+ }
154
+ const schemaVersion = value.schemaVersion;
155
+ if (schemaVersion === 1) {
156
+ throw new Error(`Applied installation state schema v1 is incompatible with effective-plan renderer evidence; re-apply the installation to create schema v2 state: ${path}`);
157
+ }
158
+ if (schemaVersion !== 2) {
159
+ throw new Error(`Applied installation state schema is unsupported: ${path}`);
160
+ }
161
+ const state = value;
162
+ if (typeof state.appliedAt !== 'string' ||
163
+ !Number.isFinite(Date.parse(state.appliedAt)) ||
164
+ typeof state.effectivePlanHash !== 'string' ||
165
+ !/^[a-f0-9]{64}$/.test(state.effectivePlanHash) ||
166
+ !Array.isArray(state.renderedArtifacts) ||
167
+ state.plan === undefined ||
168
+ state.plan.effectivePlanHash !== state.effectivePlanHash) {
169
+ throw new Error(`Applied installation state is corrupt: ${path}`);
170
+ }
171
+ validateRenderedArtifacts(state.renderedArtifacts, state.effectivePlanHash, path);
172
+ const { effectivePlanHash: _effectivePlanHash, ...planPayload } = state.plan;
173
+ if ((0, serialization_1.hashInstallation)((0, compiler_1.effectivePayload)(planPayload)) !== state.effectivePlanHash) {
174
+ throw new Error(`Applied installation state hash is invalid: ${path}`);
175
+ }
176
+ let plan;
177
+ try {
178
+ plan = (0, compiler_1.compileXemaInstallation)(planPayload);
179
+ }
180
+ catch {
181
+ throw new Error(`Applied installation state plan is invalid: ${path}`);
182
+ }
183
+ if (plan.effectivePlanHash !== state.effectivePlanHash) {
184
+ throw new Error(`Applied installation state plan is non-canonical: ${path}`);
185
+ }
186
+ return {
187
+ schemaVersion: 2,
188
+ appliedAt: state.appliedAt,
189
+ effectivePlanHash: state.effectivePlanHash,
190
+ renderedArtifacts: state.renderedArtifacts,
191
+ plan,
192
+ };
193
+ }
194
+ function parseLocalRuntimeOwner(value, path) {
195
+ if (typeof value !== 'object' || value === null) {
196
+ throw new Error(`Local runtime owner record is invalid at ${path}.`);
197
+ }
198
+ const record = value;
199
+ if (typeof record.installationId !== 'string' ||
200
+ record.installationId.length === 0 ||
201
+ typeof record.claimedAt !== 'string' ||
202
+ record.claimedAt.length === 0) {
203
+ throw new Error(`Local runtime owner record is invalid at ${path}.`);
204
+ }
205
+ return {
206
+ installationId: record.installationId,
207
+ claimedAt: record.claimedAt,
208
+ };
209
+ }
210
+ const RENDER_OBLIGATIONS = new Set(Object.values(diff_1.InstallationRenderObligation));
211
+ function validateRenderedArtifacts(value, effectivePlanHash, path) {
212
+ const seen = new Set();
213
+ for (const entry of value) {
214
+ if (entry === null || typeof entry !== 'object') {
215
+ throw new Error(`Applied installation renderer evidence is corrupt: ${path}`);
216
+ }
217
+ const evidence = entry;
218
+ if (evidence.obligation === undefined ||
219
+ !RENDER_OBLIGATIONS.has(evidence.obligation) ||
220
+ seen.has(evidence.obligation) ||
221
+ typeof evidence.rendererId !== 'string' ||
222
+ evidence.rendererId.length === 0 ||
223
+ evidence.effectivePlanHash !== effectivePlanHash ||
224
+ typeof evidence.artifactDigest !== 'string' ||
225
+ !/^sha256:[a-f0-9]{64}$/.test(evidence.artifactDigest)) {
226
+ throw new Error(`Applied installation renderer evidence is corrupt: ${path}`);
227
+ }
228
+ seen.add(evidence.obligation);
229
+ }
230
+ for (const required of [
231
+ diff_1.InstallationRenderObligation.RuntimeReconfigure,
232
+ diff_1.InstallationRenderObligation.WorkloadRollout,
233
+ diff_1.InstallationRenderObligation.InfrastructureReconcile,
234
+ diff_1.InstallationRenderObligation.DataAndRecoveryReconcile,
235
+ ]) {
236
+ if (!seen.has(required)) {
237
+ throw new Error(`Applied installation renderer evidence is incomplete (${required}): ${path}`);
238
+ }
239
+ }
240
+ }
241
+ function readLockOwner(path) {
242
+ try {
243
+ const value = JSON.parse(readPrivateFile(path));
244
+ return typeof value.pid === 'number' &&
245
+ Number.isInteger(value.pid) &&
246
+ typeof value.token === 'string' &&
247
+ value.token.length > 0 &&
248
+ typeof value.acquiredAt === 'string'
249
+ ? value
250
+ : undefined;
251
+ }
252
+ catch {
253
+ return undefined;
254
+ }
255
+ }
256
+ function processIsAlive(pid) {
257
+ try {
258
+ process.kill(pid, 0);
259
+ return true;
260
+ }
261
+ catch (error) {
262
+ return error.code === 'EPERM';
263
+ }
264
+ }
265
+ function writeJsonAtomically(path, value) {
266
+ const directory = (0, node_path_1.dirname)(path);
267
+ ensurePrivateDirectory(directory);
268
+ const temporary = (0, node_path_1.join)(directory, `.last-applied.${String(process.pid)}.${Date.now().toString(36)}.tmp`);
269
+ const fd = (0, node_fs_1.openSync)(temporary, 'wx', PRIVATE_FILE_MODE);
270
+ try {
271
+ (0, node_fs_1.writeFileSync)(fd, `${(0, serialization_1.serializeInstallation)(value)}\n`, 'utf8');
272
+ (0, node_fs_1.fsyncSync)(fd);
273
+ }
274
+ finally {
275
+ (0, node_fs_1.closeSync)(fd);
276
+ }
277
+ try {
278
+ (0, node_fs_1.renameSync)(temporary, path);
279
+ const directoryFd = (0, node_fs_1.openSync)(directory, 'r');
280
+ try {
281
+ (0, node_fs_1.fsyncSync)(directoryFd);
282
+ }
283
+ finally {
284
+ (0, node_fs_1.closeSync)(directoryFd);
285
+ }
286
+ }
287
+ catch (error) {
288
+ (0, node_fs_1.rmSync)(temporary, { force: true });
289
+ throw error;
290
+ }
291
+ }
292
+ function ensurePrivateDirectory(directory) {
293
+ (0, node_fs_1.mkdirSync)(directory, { recursive: true, mode: PRIVATE_DIRECTORY_MODE });
294
+ assertPrivateDirectory(directory);
295
+ }
296
+ function assertPrivateDirectory(directory) {
297
+ const stat = (0, node_fs_1.lstatSync)(directory);
298
+ if (!stat.isDirectory() ||
299
+ !ownedByCurrentUser(stat.uid) ||
300
+ (process.platform !== 'win32' && (stat.mode & 0o077) !== 0)) {
301
+ throw new Error(`Installation state directory is unsafe at ${directory}; expected an installer-owned directory with mode 0700.`);
302
+ }
303
+ }
304
+ function readPrivateFile(path) {
305
+ let fd;
306
+ try {
307
+ fd = (0, node_fs_1.openSync)(path, node_fs_1.constants.O_RDONLY | (node_fs_1.constants.O_NOFOLLOW ?? 0));
308
+ const stat = (0, node_fs_1.fstatSync)(fd);
309
+ if (!stat.isFile() ||
310
+ !ownedByCurrentUser(stat.uid) ||
311
+ (process.platform !== 'win32' && (stat.mode & 0o077) !== 0)) {
312
+ throw new Error(`Installation state file is unsafe at ${path}; expected an installer-owned regular file with mode 0600.`);
313
+ }
314
+ return (0, node_fs_1.readFileSync)(fd, 'utf8');
315
+ }
316
+ finally {
317
+ if (fd !== undefined) {
318
+ (0, node_fs_1.closeSync)(fd);
319
+ }
320
+ }
321
+ }
322
+ function writeExclusiveFile(path, value) {
323
+ const fd = (0, node_fs_1.openSync)(path, 'wx', PRIVATE_FILE_MODE);
324
+ try {
325
+ (0, node_fs_1.writeFileSync)(fd, `${(0, serialization_1.serializeInstallation)(value)}\n`, 'utf8');
326
+ (0, node_fs_1.fsyncSync)(fd);
327
+ }
328
+ finally {
329
+ (0, node_fs_1.closeSync)(fd);
330
+ }
331
+ }
332
+ function acquireRecoveryLock(path, subject) {
333
+ for (let attempt = 0; attempt < 2; attempt += 1) {
334
+ const owner = {
335
+ pid: process.pid,
336
+ token: (0, node_crypto_1.randomUUID)(),
337
+ acquiredAt: new Date().toISOString(),
338
+ };
339
+ try {
340
+ writeExclusiveFile(path, owner);
341
+ return () => {
342
+ assertLockOwnership(path, owner.token);
343
+ (0, node_fs_1.rmSync)(path);
344
+ };
345
+ }
346
+ catch (error) {
347
+ if (error.code !== 'EEXIST') {
348
+ throw error;
349
+ }
350
+ const existing = readLockOwner(path);
351
+ if (existing === undefined) {
352
+ throw new Error(`${subject} has an unreadable stale-lock recovery lease at ${path}; remove it only after confirming no apply process is running.`);
353
+ }
354
+ if (processIsAlive(existing.pid)) {
355
+ throw new Error(`${subject} stale-lock recovery is already in progress by process ${String(existing.pid)}. Retry after it completes.`);
356
+ }
357
+ const rechecked = readLockOwner(path);
358
+ if (rechecked === undefined ||
359
+ rechecked.token !== existing.token ||
360
+ processIsAlive(rechecked.pid)) {
361
+ throw new Error(`${subject} stale-lock recovery ownership changed; retry after the active recovery completes.`);
362
+ }
363
+ (0, node_fs_1.rmSync)(path);
364
+ }
365
+ }
366
+ throw new Error(`Could not acquire stale-lock recovery for ${subject}.`);
367
+ }
368
+ function assertLockOwnership(path, token) {
369
+ const owner = readLockOwner(path);
370
+ if (owner?.token !== token) {
371
+ throw new Error(`Installation apply lock ownership changed unexpectedly at ${path}; refusing to remove another process's lock.`);
372
+ }
373
+ }
374
+ function ownedByCurrentUser(uid) {
375
+ return typeof process.getuid !== 'function' || process.getuid() === uid;
376
+ }
377
+ //# sourceMappingURL=state-store.js.map