typekro 0.1.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (436) hide show
  1. package/LICENSE +201 -185
  2. package/README.md +581 -563
  3. package/dist/.tsbuildinfo +1 -1
  4. package/dist/alchemy/deployers.d.ts +1 -1
  5. package/dist/alchemy/deployers.d.ts.map +1 -1
  6. package/dist/alchemy/deployers.js +25 -20
  7. package/dist/alchemy/deployers.js.map +1 -1
  8. package/dist/alchemy/deployment.d.ts +3 -3
  9. package/dist/alchemy/deployment.d.ts.map +1 -1
  10. package/dist/alchemy/deployment.js +2 -2
  11. package/dist/alchemy/deployment.js.map +1 -1
  12. package/dist/alchemy/index.d.ts +4 -4
  13. package/dist/alchemy/index.d.ts.map +1 -1
  14. package/dist/alchemy/index.js +6 -6
  15. package/dist/alchemy/index.js.map +1 -1
  16. package/dist/alchemy/resolver.d.ts +3 -3
  17. package/dist/alchemy/resolver.d.ts.map +1 -1
  18. package/dist/alchemy/resolver.js +70 -17
  19. package/dist/alchemy/resolver.js.map +1 -1
  20. package/dist/alchemy/resource-registration.d.ts.map +1 -1
  21. package/dist/alchemy/resource-registration.js +3 -3
  22. package/dist/alchemy/resource-registration.js.map +1 -1
  23. package/dist/alchemy/type-inference.d.ts.map +1 -1
  24. package/dist/alchemy/type-inference.js.map +1 -1
  25. package/dist/alchemy/types.d.ts +2 -2
  26. package/dist/alchemy/types.d.ts.map +1 -1
  27. package/dist/alchemy/utilities.d.ts.map +1 -1
  28. package/dist/alchemy/utilities.js.map +1 -1
  29. package/dist/alchemy/wrapper.d.ts.map +1 -1
  30. package/dist/alchemy/wrapper.js +2 -2
  31. package/dist/alchemy/wrapper.js.map +1 -1
  32. package/dist/core/composition/composition.d.ts +1 -85
  33. package/dist/core/composition/composition.d.ts.map +1 -1
  34. package/dist/core/composition/composition.js +3 -214
  35. package/dist/core/composition/composition.js.map +1 -1
  36. package/dist/core/composition/imperative.d.ts +39 -0
  37. package/dist/core/composition/imperative.d.ts.map +1 -0
  38. package/dist/core/composition/imperative.js +219 -0
  39. package/dist/core/composition/imperative.js.map +1 -0
  40. package/dist/core/composition/index.d.ts +5 -3
  41. package/dist/core/composition/index.d.ts.map +1 -1
  42. package/dist/core/composition/index.js +4 -2
  43. package/dist/core/composition/index.js.map +1 -1
  44. package/dist/core/composition/typekro-runtime/index.d.ts +1 -1
  45. package/dist/core/composition/typekro-runtime/index.d.ts.map +1 -1
  46. package/dist/core/composition/typekro-runtime/typekro-runtime.d.ts.map +1 -1
  47. package/dist/core/composition/typekro-runtime/typekro-runtime.js +3 -3
  48. package/dist/core/composition/typekro-runtime/typekro-runtime.js.map +1 -1
  49. package/dist/core/composition/types.d.ts +0 -237
  50. package/dist/core/composition/types.d.ts.map +1 -1
  51. package/dist/core/composition/types.js +6 -0
  52. package/dist/core/composition/types.js.map +1 -1
  53. package/dist/core/constants/brands.d.ts.map +1 -1
  54. package/dist/core/constants/brands.js +3 -9
  55. package/dist/core/constants/brands.js.map +1 -1
  56. package/dist/core/dependencies/resolver.d.ts.map +1 -1
  57. package/dist/core/dependencies/resolver.js +3 -3
  58. package/dist/core/dependencies/resolver.js.map +1 -1
  59. package/dist/core/dependencies/type-guards.d.ts +3 -3
  60. package/dist/core/dependencies/type-guards.d.ts.map +1 -1
  61. package/dist/core/dependencies/type-guards.js +3 -3
  62. package/dist/core/dependencies/type-guards.js.map +1 -1
  63. package/dist/core/deployment/debug-logger.d.ts +119 -0
  64. package/dist/core/deployment/debug-logger.d.ts.map +1 -0
  65. package/dist/core/deployment/debug-logger.js +372 -0
  66. package/dist/core/deployment/debug-logger.js.map +1 -0
  67. package/dist/core/deployment/deployment-strategies.d.ts +1 -1
  68. package/dist/core/deployment/deployment-strategies.d.ts.map +1 -1
  69. package/dist/core/deployment/deployment-strategies.js +1 -1
  70. package/dist/core/deployment/deployment-strategies.js.map +1 -1
  71. package/dist/core/deployment/direct-factory.d.ts +11 -5
  72. package/dist/core/deployment/direct-factory.d.ts.map +1 -1
  73. package/dist/core/deployment/direct-factory.js +22 -12
  74. package/dist/core/deployment/direct-factory.js.map +1 -1
  75. package/dist/core/deployment/engine.d.ts +9 -6
  76. package/dist/core/deployment/engine.d.ts.map +1 -1
  77. package/dist/core/deployment/engine.js +184 -95
  78. package/dist/core/deployment/engine.js.map +1 -1
  79. package/dist/core/deployment/event-filter.d.ts +142 -0
  80. package/dist/core/deployment/event-filter.d.ts.map +1 -0
  81. package/dist/core/deployment/event-filter.js +420 -0
  82. package/dist/core/deployment/event-filter.js.map +1 -0
  83. package/dist/core/deployment/event-monitor.d.ts +197 -0
  84. package/dist/core/deployment/event-monitor.d.ts.map +1 -0
  85. package/dist/core/deployment/event-monitor.js +738 -0
  86. package/dist/core/deployment/event-monitor.js.map +1 -0
  87. package/dist/core/deployment/event-streamer.d.ts +112 -0
  88. package/dist/core/deployment/event-streamer.d.ts.map +1 -0
  89. package/dist/core/deployment/event-streamer.js +348 -0
  90. package/dist/core/deployment/event-streamer.js.map +1 -0
  91. package/dist/core/deployment/index.d.ts +5 -5
  92. package/dist/core/deployment/index.d.ts.map +1 -1
  93. package/dist/core/deployment/index.js +5 -5
  94. package/dist/core/deployment/index.js.map +1 -1
  95. package/dist/core/deployment/kro-factory.d.ts +2 -8
  96. package/dist/core/deployment/kro-factory.d.ts.map +1 -1
  97. package/dist/core/deployment/kro-factory.js +63 -109
  98. package/dist/core/deployment/kro-factory.js.map +1 -1
  99. package/dist/core/deployment/readiness.d.ts +6 -0
  100. package/dist/core/deployment/readiness.d.ts.map +1 -1
  101. package/dist/core/deployment/readiness.js +45 -1
  102. package/dist/core/deployment/readiness.js.map +1 -1
  103. package/dist/core/deployment/rollback-manager.d.ts.map +1 -1
  104. package/dist/core/deployment/rollback-manager.js +3 -3
  105. package/dist/core/deployment/rollback-manager.js.map +1 -1
  106. package/dist/core/deployment/shared-utilities.d.ts +1 -1
  107. package/dist/core/deployment/shared-utilities.d.ts.map +1 -1
  108. package/dist/core/deployment/shared-utilities.js +2 -0
  109. package/dist/core/deployment/shared-utilities.js.map +1 -1
  110. package/dist/core/deployment/status-hydrator.d.ts.map +1 -1
  111. package/dist/core/deployment/status-hydrator.js +31 -12
  112. package/dist/core/deployment/status-hydrator.js.map +1 -1
  113. package/dist/core/deployment/strategies/alchemy-strategy.d.ts +4 -4
  114. package/dist/core/deployment/strategies/alchemy-strategy.d.ts.map +1 -1
  115. package/dist/core/deployment/strategies/alchemy-strategy.js +9 -9
  116. package/dist/core/deployment/strategies/alchemy-strategy.js.map +1 -1
  117. package/dist/core/deployment/strategies/base-strategy.d.ts +7 -4
  118. package/dist/core/deployment/strategies/base-strategy.d.ts.map +1 -1
  119. package/dist/core/deployment/strategies/base-strategy.js +257 -11
  120. package/dist/core/deployment/strategies/base-strategy.js.map +1 -1
  121. package/dist/core/deployment/strategies/direct-strategy.d.ts +4 -3
  122. package/dist/core/deployment/strategies/direct-strategy.d.ts.map +1 -1
  123. package/dist/core/deployment/strategies/direct-strategy.js +4 -4
  124. package/dist/core/deployment/strategies/direct-strategy.js.map +1 -1
  125. package/dist/core/deployment/strategies/index.d.ts +1 -1
  126. package/dist/core/deployment/strategies/index.d.ts.map +1 -1
  127. package/dist/core/deployment/strategies/index.js +1 -1
  128. package/dist/core/deployment/strategies/index.js.map +1 -1
  129. package/dist/core/deployment/strategies/kro-strategy.d.ts +1 -1
  130. package/dist/core/deployment/strategies/kro-strategy.d.ts.map +1 -1
  131. package/dist/core/deployment/strategies/kro-strategy.js +14 -14
  132. package/dist/core/deployment/strategies/kro-strategy.js.map +1 -1
  133. package/dist/core/errors.d.ts +136 -0
  134. package/dist/core/errors.d.ts.map +1 -1
  135. package/dist/core/errors.js +362 -0
  136. package/dist/core/errors.js.map +1 -1
  137. package/dist/core/evaluation/cel-optimizer.d.ts.map +1 -1
  138. package/dist/core/evaluation/cel-optimizer.js +33 -11
  139. package/dist/core/evaluation/cel-optimizer.js.map +1 -1
  140. package/dist/core/factory.d.ts.map +1 -1
  141. package/dist/core/factory.js.map +1 -1
  142. package/dist/core/kubernetes/api.d.ts +13 -2
  143. package/dist/core/kubernetes/api.d.ts.map +1 -1
  144. package/dist/core/kubernetes/api.js +21 -8
  145. package/dist/core/kubernetes/api.js.map +1 -1
  146. package/dist/core/kubernetes/client-provider.d.ts +192 -0
  147. package/dist/core/kubernetes/client-provider.d.ts.map +1 -1
  148. package/dist/core/kubernetes/client-provider.js +423 -22
  149. package/dist/core/kubernetes/client-provider.js.map +1 -1
  150. package/dist/core/logging/config.d.ts.map +1 -1
  151. package/dist/core/logging/config.js.map +1 -1
  152. package/dist/core/logging/index.d.ts +1 -1
  153. package/dist/core/logging/index.d.ts.map +1 -1
  154. package/dist/core/logging/index.js +1 -1
  155. package/dist/core/logging/index.js.map +1 -1
  156. package/dist/core/logging/logger.d.ts +1 -1
  157. package/dist/core/logging/logger.d.ts.map +1 -1
  158. package/dist/core/logging/logger.js.map +1 -1
  159. package/dist/core/readiness/cluster-state.d.ts.map +1 -1
  160. package/dist/core/readiness/cluster-state.js +12 -6
  161. package/dist/core/readiness/cluster-state.js.map +1 -1
  162. package/dist/core/references/cel-evaluator.js +1 -1
  163. package/dist/core/references/cel-evaluator.js.map +1 -1
  164. package/dist/core/references/cel.d.ts.map +1 -1
  165. package/dist/core/references/cel.js +1 -1
  166. package/dist/core/references/cel.js.map +1 -1
  167. package/dist/core/references/external-refs.d.ts +1 -1
  168. package/dist/core/references/external-refs.js +1 -1
  169. package/dist/core/references/index.d.ts +4 -4
  170. package/dist/core/references/index.d.ts.map +1 -1
  171. package/dist/core/references/index.js +6 -6
  172. package/dist/core/references/index.js.map +1 -1
  173. package/dist/core/references/resolver.d.ts +1 -1
  174. package/dist/core/references/resolver.d.ts.map +1 -1
  175. package/dist/core/references/resolver.js +69 -44
  176. package/dist/core/references/resolver.js.map +1 -1
  177. package/dist/core/references/schema-proxy.d.ts.map +1 -1
  178. package/dist/core/references/schema-proxy.js +2 -4
  179. package/dist/core/references/schema-proxy.js.map +1 -1
  180. package/dist/core/serialization/core.d.ts +1 -1
  181. package/dist/core/serialization/core.d.ts.map +1 -1
  182. package/dist/core/serialization/core.js +122 -16
  183. package/dist/core/serialization/core.js.map +1 -1
  184. package/dist/core/serialization/schema.js +1 -1
  185. package/dist/core/serialization/schema.js.map +1 -1
  186. package/dist/core/serialization/validation.js +1 -1
  187. package/dist/core/serialization/validation.js.map +1 -1
  188. package/dist/core/serialization/yaml.js +1 -1
  189. package/dist/core/serialization/yaml.js.map +1 -1
  190. package/dist/core/types/common.d.ts.map +1 -1
  191. package/dist/core/types/deployment.d.ts +116 -3
  192. package/dist/core/types/deployment.d.ts.map +1 -1
  193. package/dist/core/types/deployment.js.map +1 -1
  194. package/dist/core/types/index.d.ts +1 -1
  195. package/dist/core/types/index.d.ts.map +1 -1
  196. package/dist/core/types/index.js.map +1 -1
  197. package/dist/core/types/kubernetes.d.ts.map +1 -1
  198. package/dist/core/types/serialization.d.ts +14 -3
  199. package/dist/core/types/serialization.d.ts.map +1 -1
  200. package/dist/core/validation/cel-validator.d.ts.map +1 -1
  201. package/dist/core/validation/cel-validator.js +28 -10
  202. package/dist/core/validation/cel-validator.js.map +1 -1
  203. package/dist/core/yaml/index.d.ts +1 -1
  204. package/dist/core/yaml/index.d.ts.map +1 -1
  205. package/dist/core/yaml/index.js +1 -1
  206. package/dist/core/yaml/index.js.map +1 -1
  207. package/dist/core/yaml/path-resolver.d.ts.map +1 -1
  208. package/dist/core/yaml/path-resolver.js +6 -6
  209. package/dist/core/yaml/path-resolver.js.map +1 -1
  210. package/dist/core.d.ts +10 -10
  211. package/dist/core.d.ts.map +1 -1
  212. package/dist/core.js +14 -14
  213. package/dist/core.js.map +1 -1
  214. package/dist/factories/flux/git-repository.d.ts.map +1 -1
  215. package/dist/factories/flux/git-repository.js.map +1 -1
  216. package/dist/factories/flux/index.d.ts +1 -1
  217. package/dist/factories/flux/index.d.ts.map +1 -1
  218. package/dist/factories/flux/index.js.map +1 -1
  219. package/dist/factories/flux/kustomize/index.d.ts +1 -1
  220. package/dist/factories/flux/kustomize/index.d.ts.map +1 -1
  221. package/dist/factories/flux/kustomize/index.js.map +1 -1
  222. package/dist/factories/flux/kustomize/readiness-evaluators.d.ts.map +1 -1
  223. package/dist/factories/flux/kustomize/readiness-evaluators.js +9 -9
  224. package/dist/factories/flux/kustomize/readiness-evaluators.js.map +1 -1
  225. package/dist/factories/flux/kustomize/types.d.ts +1 -1
  226. package/dist/factories/flux/kustomize/types.d.ts.map +1 -1
  227. package/dist/factories/helm/helm-release.d.ts +7 -4
  228. package/dist/factories/helm/helm-release.d.ts.map +1 -1
  229. package/dist/factories/helm/helm-release.js +7 -4
  230. package/dist/factories/helm/helm-release.js.map +1 -1
  231. package/dist/factories/helm/helm-repository.d.ts.map +1 -1
  232. package/dist/factories/helm/helm-repository.js.map +1 -1
  233. package/dist/factories/helm/index.d.ts +1 -1
  234. package/dist/factories/helm/index.d.ts.map +1 -1
  235. package/dist/factories/helm/index.js +1 -1
  236. package/dist/factories/helm/index.js.map +1 -1
  237. package/dist/factories/helm/readiness-evaluators.d.ts.map +1 -1
  238. package/dist/factories/helm/readiness-evaluators.js +4 -2
  239. package/dist/factories/helm/readiness-evaluators.js.map +1 -1
  240. package/dist/factories/index.d.ts +6 -3
  241. package/dist/factories/index.d.ts.map +1 -1
  242. package/dist/factories/index.js +10 -6
  243. package/dist/factories/index.js.map +1 -1
  244. package/dist/factories/kro/index.d.ts +3 -3
  245. package/dist/factories/kro/index.d.ts.map +1 -1
  246. package/dist/factories/kro/index.js +2 -2
  247. package/dist/factories/kro/index.js.map +1 -1
  248. package/dist/factories/kro/kro-crd.d.ts.map +1 -1
  249. package/dist/factories/kro/kro-crd.js +5 -5
  250. package/dist/factories/kro/kro-crd.js.map +1 -1
  251. package/dist/factories/kro/kro-custom-resource.d.ts.map +1 -1
  252. package/dist/factories/kro/kro-custom-resource.js +21 -21
  253. package/dist/factories/kro/kro-custom-resource.js.map +1 -1
  254. package/dist/factories/kro/resource-graph-definition.d.ts.map +1 -1
  255. package/dist/factories/kro/resource-graph-definition.js +7 -7
  256. package/dist/factories/kro/resource-graph-definition.js.map +1 -1
  257. package/dist/factories/kubernetes/autoscaling/horizontal-pod-autoscaler-v1.d.ts.map +1 -1
  258. package/dist/factories/kubernetes/autoscaling/horizontal-pod-autoscaler-v1.js.map +1 -1
  259. package/dist/factories/kubernetes/autoscaling/horizontal-pod-autoscaler.js +2 -2
  260. package/dist/factories/kubernetes/certificates/certificate-signing-request.js +2 -2
  261. package/dist/factories/kubernetes/certificates/certificate-signing-request.js.map +1 -1
  262. package/dist/factories/kubernetes/config/config-map.js +1 -1
  263. package/dist/factories/kubernetes/config/config-map.js.map +1 -1
  264. package/dist/factories/kubernetes/config/secret.js +1 -1
  265. package/dist/factories/kubernetes/config/secret.js.map +1 -1
  266. package/dist/factories/kubernetes/core/component-status.js +1 -1
  267. package/dist/factories/kubernetes/core/component-status.js.map +1 -1
  268. package/dist/factories/kubernetes/core/node.js +1 -1
  269. package/dist/factories/kubernetes/core/node.js.map +1 -1
  270. package/dist/factories/kubernetes/core/pod.js +4 -4
  271. package/dist/factories/kubernetes/core/pod.js.map +1 -1
  272. package/dist/factories/kubernetes/extensions/custom-resource-definition.js +2 -2
  273. package/dist/factories/kubernetes/extensions/custom-resource-definition.js.map +1 -1
  274. package/dist/factories/kubernetes/index.d.ts +2 -2
  275. package/dist/factories/kubernetes/index.d.ts.map +1 -1
  276. package/dist/factories/kubernetes/index.js +8 -8
  277. package/dist/factories/kubernetes/index.js.map +1 -1
  278. package/dist/factories/kubernetes/networking/endpoints.d.ts.map +1 -1
  279. package/dist/factories/kubernetes/networking/endpoints.js +4 -4
  280. package/dist/factories/kubernetes/networking/endpoints.js.map +1 -1
  281. package/dist/factories/kubernetes/networking/ingress.js +2 -2
  282. package/dist/factories/kubernetes/networking/network-policy.js +2 -2
  283. package/dist/factories/kubernetes/networking/network-policy.js.map +1 -1
  284. package/dist/factories/kubernetes/networking/service.d.ts.map +1 -1
  285. package/dist/factories/kubernetes/networking/service.js +8 -7
  286. package/dist/factories/kubernetes/networking/service.js.map +1 -1
  287. package/dist/factories/kubernetes/policy/limit-range.js +2 -2
  288. package/dist/factories/kubernetes/policy/limit-range.js.map +1 -1
  289. package/dist/factories/kubernetes/policy/pod-disruption-budget.js +5 -5
  290. package/dist/factories/kubernetes/policy/resource-quota.js +4 -4
  291. package/dist/factories/kubernetes/rbac/cluster-role-binding.js +2 -2
  292. package/dist/factories/kubernetes/rbac/cluster-role-binding.js.map +1 -1
  293. package/dist/factories/kubernetes/rbac/cluster-role.js +2 -2
  294. package/dist/factories/kubernetes/rbac/cluster-role.js.map +1 -1
  295. package/dist/factories/kubernetes/rbac/role-binding.js +2 -2
  296. package/dist/factories/kubernetes/rbac/role-binding.js.map +1 -1
  297. package/dist/factories/kubernetes/rbac/role.js +2 -2
  298. package/dist/factories/kubernetes/rbac/role.js.map +1 -1
  299. package/dist/factories/kubernetes/rbac/service-account.js +2 -2
  300. package/dist/factories/kubernetes/rbac/service-account.js.map +1 -1
  301. package/dist/factories/kubernetes/storage/persistent-volume-claim.js +2 -2
  302. package/dist/factories/kubernetes/storage/persistent-volume.js +4 -4
  303. package/dist/factories/kubernetes/storage/storage-class.js +2 -2
  304. package/dist/factories/kubernetes/storage/storage-class.js.map +1 -1
  305. package/dist/factories/kubernetes/workloads/cron-job.js +5 -5
  306. package/dist/factories/kubernetes/workloads/daemon-set.js +2 -2
  307. package/dist/factories/kubernetes/workloads/deployment.d.ts.map +1 -1
  308. package/dist/factories/kubernetes/workloads/deployment.js +5 -6
  309. package/dist/factories/kubernetes/workloads/deployment.js.map +1 -1
  310. package/dist/factories/kubernetes/workloads/job.js +10 -10
  311. package/dist/factories/kubernetes/workloads/replica-set.js +2 -2
  312. package/dist/factories/kubernetes/workloads/replication-controller.js +5 -5
  313. package/dist/factories/kubernetes/workloads/stateful-set.d.ts.map +1 -1
  314. package/dist/factories/kubernetes/workloads/stateful-set.js +7 -7
  315. package/dist/factories/kubernetes/workloads/stateful-set.js.map +1 -1
  316. package/dist/factories/kubernetes/yaml/index.d.ts +1 -1
  317. package/dist/factories/kubernetes/yaml/index.d.ts.map +1 -1
  318. package/dist/factories/kubernetes/yaml/index.js +1 -1
  319. package/dist/factories/kubernetes/yaml/index.js.map +1 -1
  320. package/dist/factories/kubernetes/yaml/yaml-directory.d.ts +2 -2
  321. package/dist/factories/kubernetes/yaml/yaml-directory.d.ts.map +1 -1
  322. package/dist/factories/kubernetes/yaml/yaml-directory.js +106 -101
  323. package/dist/factories/kubernetes/yaml/yaml-directory.js.map +1 -1
  324. package/dist/factories/kubernetes/yaml/yaml-file.d.ts +7 -4
  325. package/dist/factories/kubernetes/yaml/yaml-file.d.ts.map +1 -1
  326. package/dist/factories/kubernetes/yaml/yaml-file.js +110 -99
  327. package/dist/factories/kubernetes/yaml/yaml-file.js.map +1 -1
  328. package/dist/factories/shared.d.ts +49 -0
  329. package/dist/factories/shared.d.ts.map +1 -1
  330. package/dist/factories/shared.js +75 -3
  331. package/dist/factories/shared.js.map +1 -1
  332. package/dist/factories/simple/autoscaling/horizontal-pod-autoscaler.d.ts +17 -0
  333. package/dist/factories/simple/autoscaling/horizontal-pod-autoscaler.d.ts.map +1 -0
  334. package/dist/factories/simple/autoscaling/horizontal-pod-autoscaler.js +46 -0
  335. package/dist/factories/simple/autoscaling/horizontal-pod-autoscaler.js.map +1 -0
  336. package/dist/factories/simple/autoscaling/index.d.ts +8 -0
  337. package/dist/factories/simple/autoscaling/index.d.ts.map +1 -0
  338. package/dist/factories/simple/autoscaling/index.js +8 -0
  339. package/dist/factories/simple/autoscaling/index.js.map +1 -0
  340. package/dist/factories/simple/config/config-map.d.ts +17 -0
  341. package/dist/factories/simple/config/config-map.d.ts.map +1 -0
  342. package/dist/factories/simple/config/config-map.js +25 -0
  343. package/dist/factories/simple/config/config-map.js.map +1 -0
  344. package/dist/factories/simple/config/index.d.ts +9 -0
  345. package/dist/factories/simple/config/index.d.ts.map +1 -0
  346. package/dist/factories/simple/config/index.js +9 -0
  347. package/dist/factories/simple/config/index.js.map +1 -0
  348. package/dist/factories/simple/config/secret.d.ts +17 -0
  349. package/dist/factories/simple/config/secret.d.ts.map +1 -0
  350. package/dist/factories/simple/config/secret.js +24 -0
  351. package/dist/factories/simple/config/secret.js.map +1 -0
  352. package/dist/factories/simple/helm/index.d.ts +16 -0
  353. package/dist/factories/simple/helm/index.d.ts.map +1 -0
  354. package/dist/factories/simple/helm/index.js +21 -0
  355. package/dist/factories/simple/helm/index.js.map +1 -0
  356. package/dist/factories/simple/index.d.ts +50 -0
  357. package/dist/factories/simple/index.d.ts.map +1 -0
  358. package/dist/factories/simple/index.js +58 -0
  359. package/dist/factories/simple/index.js.map +1 -0
  360. package/dist/factories/simple/networking/index.d.ts +10 -0
  361. package/dist/factories/simple/networking/index.d.ts.map +1 -0
  362. package/dist/factories/simple/networking/index.js +10 -0
  363. package/dist/factories/simple/networking/index.js.map +1 -0
  364. package/dist/factories/simple/networking/ingress.d.ts +17 -0
  365. package/dist/factories/simple/networking/ingress.d.ts.map +1 -0
  366. package/dist/factories/simple/networking/ingress.js +30 -0
  367. package/dist/factories/simple/networking/ingress.js.map +1 -0
  368. package/dist/factories/simple/networking/network-policy.d.ts +17 -0
  369. package/dist/factories/simple/networking/network-policy.d.ts.map +1 -0
  370. package/dist/factories/simple/networking/network-policy.js +30 -0
  371. package/dist/factories/simple/networking/network-policy.js.map +1 -0
  372. package/dist/factories/simple/networking/service.d.ts +17 -0
  373. package/dist/factories/simple/networking/service.d.ts.map +1 -0
  374. package/dist/factories/simple/networking/service.js +27 -0
  375. package/dist/factories/simple/networking/service.js.map +1 -0
  376. package/dist/factories/simple/storage/index.d.ts +9 -0
  377. package/dist/factories/simple/storage/index.d.ts.map +1 -0
  378. package/dist/factories/simple/storage/index.js +9 -0
  379. package/dist/factories/simple/storage/index.js.map +1 -0
  380. package/dist/factories/simple/storage/persistent-volume-claim.d.ts +17 -0
  381. package/dist/factories/simple/storage/persistent-volume-claim.d.ts.map +1 -0
  382. package/dist/factories/simple/storage/persistent-volume-claim.js +32 -0
  383. package/dist/factories/simple/storage/persistent-volume-claim.js.map +1 -0
  384. package/dist/factories/simple/storage/persistent-volume.d.ts +17 -0
  385. package/dist/factories/simple/storage/persistent-volume.d.ts.map +1 -0
  386. package/dist/factories/simple/storage/persistent-volume.js +44 -0
  387. package/dist/factories/simple/storage/persistent-volume.js.map +1 -0
  388. package/dist/factories/simple/types.d.ts +165 -0
  389. package/dist/factories/simple/types.d.ts.map +1 -0
  390. package/dist/factories/simple/types.js +9 -0
  391. package/dist/factories/simple/types.js.map +1 -0
  392. package/dist/factories/simple/workloads/cron-job.d.ts +17 -0
  393. package/dist/factories/simple/workloads/cron-job.d.ts.map +1 -0
  394. package/dist/factories/simple/workloads/cron-job.js +43 -0
  395. package/dist/factories/simple/workloads/cron-job.js.map +1 -0
  396. package/dist/factories/simple/workloads/daemon-set.d.ts +17 -0
  397. package/dist/factories/simple/workloads/daemon-set.d.ts.map +1 -0
  398. package/dist/factories/simple/workloads/daemon-set.js +46 -0
  399. package/dist/factories/simple/workloads/daemon-set.js.map +1 -0
  400. package/dist/factories/simple/workloads/deployment.d.ts +17 -0
  401. package/dist/factories/simple/workloads/deployment.d.ts.map +1 -0
  402. package/dist/factories/simple/workloads/deployment.js +47 -0
  403. package/dist/factories/simple/workloads/deployment.js.map +1 -0
  404. package/dist/factories/simple/workloads/index.d.ts +12 -0
  405. package/dist/factories/simple/workloads/index.d.ts.map +1 -0
  406. package/dist/factories/simple/workloads/index.js +12 -0
  407. package/dist/factories/simple/workloads/index.js.map +1 -0
  408. package/dist/factories/simple/workloads/job.d.ts +17 -0
  409. package/dist/factories/simple/workloads/job.d.ts.map +1 -0
  410. package/dist/factories/simple/workloads/job.js +40 -0
  411. package/dist/factories/simple/workloads/job.js.map +1 -0
  412. package/dist/factories/simple/workloads/stateful-set.d.ts +17 -0
  413. package/dist/factories/simple/workloads/stateful-set.d.ts.map +1 -0
  414. package/dist/factories/simple/workloads/stateful-set.js +47 -0
  415. package/dist/factories/simple/workloads/stateful-set.js.map +1 -0
  416. package/dist/factories/simple/yaml/index.d.ts +13 -0
  417. package/dist/factories/simple/yaml/index.d.ts.map +1 -0
  418. package/dist/factories/simple/yaml/index.js +23 -0
  419. package/dist/factories/simple/yaml/index.js.map +1 -0
  420. package/dist/index.d.ts +5 -3
  421. package/dist/index.d.ts.map +1 -1
  422. package/dist/index.js +25 -22
  423. package/dist/index.js.map +1 -1
  424. package/dist/utils/helpers.d.ts +1 -1
  425. package/dist/utils/helpers.d.ts.map +1 -1
  426. package/dist/utils/helpers.js +53 -7
  427. package/dist/utils/helpers.js.map +1 -1
  428. package/dist/utils/index.d.ts +2 -2
  429. package/dist/utils/index.d.ts.map +1 -1
  430. package/dist/utils/index.js +2 -2
  431. package/dist/utils/index.js.map +1 -1
  432. package/dist/utils/type-guards.d.ts +1 -1
  433. package/dist/utils/type-guards.d.ts.map +1 -1
  434. package/dist/utils/type-guards.js +3 -9
  435. package/dist/utils/type-guards.js.map +1 -1
  436. package/package.json +12 -6
package/README.md CHANGED
@@ -6,12 +6,16 @@
6
6
 
7
7
  [![NPM Version](https://img.shields.io/npm/v/typekro.svg)](https://www.npmjs.com/package/typekro)
8
8
  [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
9
+ [![GitHub stars](https://img.shields.io/github/stars/yehudacohen/typekro)](https://github.com/yehudacohen/typekro)
10
+ [![Build Status](https://img.shields.io/github/actions/workflow/status/yehudacohen/typekro/deploy.yml?branch=master)](https://github.com/yehudacohen/typekro/actions)
11
+ [![Coverage](https://codecov.io/gh/yehudacohen/typekro/branch/master/graph/badge.svg)](https://codecov.io/gh/yehudacohen/typekro)
9
12
 
10
- > **Kubernetes infrastructure with TypeScript instead of YAML**
13
+ 📚 **[Documentation](https://typekro.run)** 💬 **[Discord Community](https://discord.gg/kKNSDDjW)** 🚀 **[Getting Started](https://typekro.run/guide/getting-started)**
14
+ ## **TypeKro: Kubernetes with TypeScript**
11
15
 
12
- TypeKro combines the type safety of TypeScript, the GitOps-friendly output of declarative YAML, and the runtime intelligence of **Kubernetes Resource Orchestrator (KRO)** - an open-source project that enables advanced resource orchestration with runtime dependencies and CEL expressions. Write infrastructure in pure TypeScript with full IDE support, then deploy directly to clusters or generate deterministic YAML for GitOps workflows.
16
+ **A control plane aware framework for orchestrating kubernetes resources like a programmer**
13
17
 
14
- > **What is KRO?** [Kubernetes Resource Orchestrator](https://kro.run/) is an open-source project by AWS Labs that enables resources to reference each other's runtime state using CEL expressions. TypeKro works in Direct Mode (no KRO required) for simple deployments, or KRO Mode for advanced orchestration.
18
+ TypeKro combines the type safety of TypeScript, the GitOps-friendly output of declarative YAML, and the runtime intelligence of **Kubernetes Resource Orchestrator (KRO)** - an open-source project that enables advanced resource orchestration with runtime dependencies and CEL expressions. Write infrastructure in pure TypeScript with full IDE support, then deploy directly to clusters or generate deterministic YAML for GitOps workflows.
15
19
 
16
20
  ## Table of Contents
17
21
 
@@ -30,106 +34,127 @@ TypeKro combines the type safety of TypeScript, the GitOps-friendly output of de
30
34
 
31
35
  ## Quick Start
32
36
 
33
- Here's a complete web application with database in ~30 lines of TypeScript:
37
+ Write Kubernetes infrastructure in pure TypeScript with full IDE support and type safety:
34
38
 
35
39
  ```typescript
36
- import { type } from 'arktype';  // Runtime-safe TypeScript schemas with concise syntax
37
- import { toResourceGraph, simpleDeployment, simpleService, Cel } from 'typekro';
38
-
39
- // Define your app's interface
40
- const WebAppSpec = type(
41
-   name: 'string', 
42
-   image: 'string', 
43
-   replicas: 'number' 
44
- });
45
-
46
- const WebAppStatus = type({ 
47
-   ready: 'boolean', 
48
-   url: 'string' 
49
- });
50
-
51
- // Create your infrastructure
52
- const webapp = toResourceGraph(
53
-   {
54
-     name: 'my-webapp',
55
-     apiVersion: 'example.com/v1',
56
-     kind: 'WebApp',
57
-     spec: WebAppSpec,
58
-     status: WebAppStatus
59
-   },
60
-   (schema) => ({
61
-     // Database
62
-     database: simpleDeployment({
63
-       name: 'postgres', 
64
-       image: 'postgres:15',
65
-       env: { POSTGRES_DB: 'app', POSTGRES_USER: 'user', POSTGRES_PASSWORD: 'secret' }
66
-     }),
67
-     
68
-     // Service (defined first to show cross-references work in any order)
69
-     service: simpleService({
70
-       name: schema.spec.name,  // Type-safe schema reference
71
-       selector: { app: schema.spec.name },
72
-       ports: [{ port: 80, targetPort: 80 }]
73
-     }),
74
-     
75
-     // Web app that references schema fields
76
-     app: simpleDeployment({
77
-       name: schema.spec.name,    // Type-safe schema reference
78
-       image: schema.spec.image,  // Full IDE autocomplete
79
-       replicas: schema.spec.replicas,
80
-       env: { DATABASE_HOST: 'postgres' }
81
-     })
82
-   }),
83
-   (schema, resources) => ({
84
-     ready: Cel.expr(resources.app.status.readyReplicas, ' > 0'),  // Runtime logic
85
-     url: Cel.template('http://%s', schema.spec.name)  // String templating with schema reference
86
-   })
40
+ import { type } from 'arktype';
41
+ import { kubernetesComposition, simple, Cel } from 'typekro';
42
+
43
+ // Build your infrastructure with full type safety using imperative composition
44
+ const deploymentService = kubernetesComposition(
45
+ {
46
+ name: 'deployment-service',
47
+ apiVersion: 'example.com/v1alpha1',
48
+ kind: 'DeploymentService',
49
+ spec: type({ name: 'string', environment: '"dev" | "staging" | "prod"' }),
50
+ status: type({ ready: 'boolean', url: 'string' })
51
+ },
52
+ (spec) => {
53
+ // Resources auto-register when created - no explicit builders needed!
54
+ const deployment = simple.Deployment({
55
+ name: spec.name, // Full IDE autocomplete
56
+ image: 'nginx',
57
+ replicas: spec.environment === 'prod' ? 3 : 1, // ← Type-safe logic
58
+ labels: {
59
+ app: 'deployment',
60
+ env: spec.environment // ← Validated enum
61
+ },
62
+ ports: [{ containerPort: 80 }]
63
+ });
64
+
65
+ const service = simple.Service({
66
+ name: spec.name,
67
+ selector: { app: 'deployment' }, // ← Cross-resource reference
68
+ ports: [{ port: 80, targetPort: 80 }]
69
+ });
70
+
71
+ // Return status with CEL expressions and resource references
72
+ return {
73
+ ready: Cel.expr<boolean>(deployment.status.readyReplicas, ' > 0'),
74
+ url: Cel.template('http://%s.%s.svc', spec.name, spec.environment)
75
+ };
76
+ }
87
77
  );
88
78
 
89
- // Deploy it directly to your cluster
90
- const factory = await webapp.factory('direct', { namespace: 'default' });
91
- await factory.deploy({ name: 'my-app', image: 'nginx', replicas: 3 });
79
+ // Deploy instantly with full type checking
80
+ await deploymentService.factory('direct').deploy({
81
+ name: 'my-app', // IDE validates this exists
82
+ environment: 'staging' // ← Only accepts: "dev" | "staging" | "prod"
83
+ });
92
84
  ```
93
85
 
94
86
  **Key Features Demonstrated:**
95
- - **Schema References**: `schema.spec.name` becomes runtime CEL expressions
96
- - **Type Safety**: Full TypeScript validation and autocomplete  
97
- - **CEL Expressions**: `Cel.template()` for dynamic resource configuration
98
- - **Direct Deployment**: Resources are created immediately in your cluster
87
+ - **Full IDE autocomplete** - IntelliSense for all properties
88
+ - **Compile-time type checking** - Catch errors before deployment
89
+ - **Runtime validation** - ArkType validates deployment specs
90
+ - **Zero YAML required** - Pure TypeScript infrastructure
91
+ - **Instant deployment** - No kubectl, no YAML files
99
92
 
100
- *Note: You can also generate GitOps-ready YAML with `factory.toYaml()` instead of deploying directly.*
93
+ **Deploy anywhere:** Generate KRO YAML for GitOps with `factory.toYaml()` or integrate with multi-cloud using Alchemy.
101
94
 
102
- **Need advanced features?** Bootstrap a complete runtime environment with Flux CD and KRO:
103
- ```typescript
104
- import { typeKroRuntimeBootstrap } from 'typekro';
105
- const bootstrap = typeKroRuntimeBootstrap({ fluxVersion: 'v2.4.0', kroVersion: '0.3.0' });
106
- await bootstrap.factory('direct').deploy({ namespace: 'flux-system' });
107
- ```
95
+ ::: tip Imperative vs Declarative
96
+ This example uses TypeKro's **imperative composition pattern** (`kubernetesComposition`) - the recommended approach for most use cases. For teams preferring explicit resource/status builders, TypeKro also supports a **declarative pattern** (`toResourceGraph`). [Learn more about both patterns →](https://typekro.run/guide/imperative-composition)
97
+ :::
98
+
99
+ ---
100
+
101
+ ## Comparison Grid
102
+
103
+ | Feature | TypeKro | Pulumi | CDK8s | Helm | Kustomize | Crossplane |
104
+ |---------|---------|---------|--------|------|-----------|------------|
105
+ | **Type Safety** | ✅ Full TypeScript | ✅ Multi-language | ✅ TypeScript | ❌ Templates | ❌ YAML | ❌ YAML |
106
+ | **GitOps Ready** | ✅ Deterministic YAML | ❌ State backend | ✅ YAML output | ✅ Charts | ✅ YAML | ✅ YAML |
107
+ | **Runtime Dependencies** | ✅ KRO + CEL expressions | ❌ Deploy-time only | ❌ Static | ❌ Templates | ❌ Static | ✅ Compositions |
108
+ | **IDE Support** | ✅ Full autocomplete | ✅ Language support | ✅ TypeScript | ❌ Limited | ❌ Limited | ❌ Limited |
109
+ | **Learning Curve** | 🟢 Just TypeScript | 🔴 New concepts | 🟡 TypeScript + K8s | 🔴 Templates | 🔴 YAML hell | 🔴 Complex |
110
+ | **Kubernetes Native** | ✅ Pure K8s resources | ❌ Abstraction layer | ✅ Pure K8s | ✅ K8s resources | ✅ K8s resources | ✅ K8s + CRDs |
111
+ | **Cross-Resource Refs** | ✅ Runtime resolution | ❌ Deploy-time | ❌ Manual | ❌ Manual | ❌ Manual | ✅ Built-in |
112
+ | **Multi-Cloud** | 🟡 Via Alchemy | ✅ Native | ❌ K8s only | ❌ K8s only | ❌ K8s only | ✅ Native |
113
+ | **State Management** | ✅ Stateless | ❌ State backend | ✅ Stateless | ✅ Stateless | ✅ Stateless | ✅ Controller |
114
+ | **CRD Timing** | ✅ Automatic | ❌ Manual | ❌ Manual | ❌ Manual | ❌ Manual | ✅ Built-in |
108
115
 
109
116
  ---
110
117
 
111
118
  ## Deployment Flexibility
112
119
 
113
- ### Write Once, Deploy Everywhere
120
+ ### Deploy the Same Resource Graph using GitOps, Direct Kubernetes API Integration, or using KRO
121
+
122
+ TypeKro offers deployment flexibility.
123
+
124
+ > **What is KRO?** [Kubernetes Resource Orchestrator](https://kro.run/) is an open-source project by AWS Labs that enables resources to reference each other's runtime state using CEL expressions. TypeKro works in Direct Mode (no KRO required) for simple deployments, or KRO Mode for advanced orchestration.
114
125
 
115
- TypeKro's core strength is **deployment flexibility**. The same TypeScript code can be deployed in multiple ways without modification:
126
+ The same TypeScript code can be deployed in multiple ways without modification:
116
127
 
117
128
  ```typescript
118
- // Define your infrastructure once  
119
- const webappGraph = toResourceGraph(
120
-   {
121
-     name: 'my-webapp',
122
-     apiVersion: 'example.com/v1',
123
-     kind: 'WebApp', 
124
-     spec: WebAppSpec,
125
-     status: WebAppStatus
126
-   },
127
-   (schema) => ({
128
-     // ... your resources
129
-   }),
130
-   (schema, resources) => ({
131
-     // ... status builder
132
-   })
129
+ // Define your infrastructure once with imperative composition
130
+ const webappGraph = kubernetesComposition(
131
+ {
132
+ name: 'my-webapp',
133
+ apiVersion: 'example.com/v1',
134
+ kind: 'WebApp',
135
+ spec: WebAppSpec,
136
+ status: WebAppStatus
137
+ },
138
+ (spec) => {
139
+ // Resources auto-register when created - no explicit builders needed!
140
+ const deployment = simple.Deployment({
141
+ name: spec.name,
142
+ image: spec.image,
143
+ replicas: spec.replicas
144
+ });
145
+
146
+ const service = simple.Service({
147
+ name: `${spec.name}-service`,
148
+ selector: { app: spec.name },
149
+ ports: [{ port: 80, targetPort: 80 }]
150
+ });
151
+
152
+ // Return status with CEL expressions and resource references
153
+ return {
154
+ ready: Cel.expr<boolean>(deployment.status.readyReplicas, ' > 0'),
155
+ url: Cel.template('http://%s-service', spec.name)
156
+ };
157
+ }
133
158
  );
134
159
 
135
160
  const spec = { name: 'my-app', image: 'nginx:1.21', replicas: 3 };
@@ -137,21 +162,21 @@ const spec = { name: 'my-app', image: 'nginx:1.21', replicas: 3 };
137
162
  // Deploy the SAME code in different ways:
138
163
 
139
164
  // 1. Generate YAML for GitOps (no cluster interaction)
140
- const kroFactory = await webappGraph.factory('kro', { namespace: 'dev' });
165
+ const kroFactory = webappGraph.factory('kro', { namespace: 'dev' });
141
166
  const yaml = kroFactory.toYaml();
142
167
  writeFileSync('k8s/webapp.yaml', yaml);
143
168
 
144
169
  // 2. Deploy directly to cluster (immediate)
145
- const directFactory = await webappGraph.factory('direct', { namespace: 'dev' });
170
+ const directFactory = webappGraph.factory('direct', { namespace: 'dev' });
146
171
  const directInstance = await directFactory.deploy(spec);
147
172
 
148
173
  // 3. Integrate with Alchemy for multi-cloud coordination
149
174
  await alchemyScope.run(async () => {
150
- const factory = await webappGraph.factory('direct', {
175
+ const alchemyFactory = webappGraph.factory('direct', {
151
176
  namespace: 'dev',
152
177
  alchemyScope: alchemyScope
153
178
  });
154
- await factory.deploy(spec);
179
+ await alchemyFactory.deploy(spec);
155
180
  });
156
181
  ```
157
182
 
@@ -165,7 +190,7 @@ Generate deterministic Kubernetes YAML that integrates with any GitOps workflow:
165
190
 
166
191
  ```typescript
167
192
  // Generate ResourceGraphDefinition YAML
168
- const kroFactory = await webappGraph.factory('kro', { namespace: 'default' });
193
+ const kroFactory = webappGraph.factory('kro', { namespace: 'default' });
169
194
  const yaml = kroFactory.toYaml();
170
195
 
171
196
  // Save for GitOps deployment
@@ -193,7 +218,7 @@ Deploy directly to your cluster for rapid iteration:
193
218
 
194
219
  ```typescript
195
220
  // Create factory and deploy immediately
196
- const factory = await webappGraph.factory('direct', { namespace: 'development' });
221
+ const factory = webappGraph.factory('direct', { namespace: 'development' });
197
222
 
198
223
  // Deploy with specific configuration
199
224
  const instance = await factory.deploy({
@@ -224,7 +249,7 @@ Leverage Kubernetes Resource Orchestrator for advanced runtime capabilities:
224
249
 
225
250
  ```typescript
226
251
  // Deploy as ResourceGraphDefinition with runtime resolution
227
- const kroFactory = await webappGraph.factory('kro', { namespace: 'production' });
252
+ const kroFactory = webappGraph.factory('kro', { namespace: 'production' });
228
253
 
229
254
  // Apply the ResourceGraphDefinition to cluster
230
255
  await kroFactory.deploy({ 
@@ -260,7 +285,7 @@ Deploy the same graph to different environments with environment-specific config
260
285
 
261
286
  ```typescript
262
287
  // Development: Direct deployment for fast iteration
263
- const devFactory = await webappGraph.factory('direct', { namespace: 'dev' });
288
+ const factory = webappGraph.factory('direct', { namespace: 'dev' });
264
289
  await devFactory.deploy({
265
290
    name: 'webapp-dev',
266
291
    image: 'nginx:latest',
@@ -268,7 +293,7 @@ await devFactory.deploy({
268
293
  });
269
294
 
270
295
  // Staging: Kro deployment for testing runtime dependencies  
271
- const stagingFactory = await webappGraph.factory('kro', { namespace: 'staging' });
296
+ const factory = webappGraph.factory('kro', { namespace: 'staging' });
272
297
  await stagingFactory.deploy({
273
298
    name: 'webapp-staging',
274
299
    image: 'nginx:1.21-rc',
@@ -276,7 +301,7 @@ await stagingFactory.deploy({
276
301
  });
277
302
 
278
303
  // Production: GitOps deployment
279
- const prodFactory = await webappGraph.factory('kro', { namespace: 'production' });
304
+ const factory = webappGraph.factory('kro', { namespace: 'production' });
280
305
  const prodYaml = prodFactory.toYaml();
281
306
  writeFileSync('k8s/production/webapp.yaml', prodYaml);
282
307
  // Deployed via ArgoCD/Flux
@@ -298,175 +323,6 @@ writeFileSync('k8s/production/webapp.yaml', prodYaml);
298
323
 
299
324
  ---
300
325
 
301
- ## Core Architecture
302
-
303
- TypeKro's architecture enables compile-time type safety with runtime intelligence through three key systems:
304
-
305
- ```mermaid
306
- graph TD
307
- A[TypeScript Code] --> B[Magic Proxy System]
308
- B --> C[Schema References]
309
- B --> D[Static Values]
310
- C --> E[CEL Expressions]
311
- D --> F[Direct Values]
312
- E --> G[Runtime Resolution]
313
- F --> G
314
- G --> H{Deployment Strategy}
315
-
316
- H --> I[YAML Generation]
317
- H --> J[Direct Deployment]
318
- H --> K[KRO Deployment]
319
-
320
- I --> L[GitOps Tools<br/>ArgoCD, Flux, kubectl]
321
- J --> M[Kubernetes API<br/>Immediate Deployment]
322
- K --> N[KRO Controller<br/>Runtime Dependencies]
323
-
324
- L --> O[Kubernetes Cluster]
325
- M --> O
326
- N --> O
327
-
328
- subgraph "Compile Time"
329
- A
330
- B
331
- C
332
- D
333
- P[IDE Support<br/>Autocomplete<br/>Type Safety]
334
- end
335
-
336
- subgraph "Runtime"
337
- E
338
- G
339
- Q[CEL Evaluation<br/>Cross-Resource Refs<br/>Status Propagation]
340
- end
341
-
342
- A -.-> P
343
- N -.-> Q
344
-
345
- style A fill:#e1f5fe
346
- style B fill:#f3e5f5
347
- style O fill:#e8f5e8
348
- style P fill:#fff3e0
349
- style Q fill:#fff3e0
350
- ```
351
-
352
- ### Magic Proxy System
353
-
354
- TypeKro's "magic" comes from its **proxy system** that creates different behaviors for execution-time vs runtime values:
355
-
356
- #### Static Values (Known at Execution Time)
357
- ```typescript
358
- const deployment = simpleDeployment({
359
-   name: 'my-app',        // Static string
360
-   replicas: 3,           // Static number
361
- });
362
-
363
- // Accessing static values returns the actual value
364
- console.log(deployment.spec.replicas); // Returns: 3
365
- ```
366
-
367
- #### Dynamic References (Unknown at Execution Time)
368
- ```typescript
369
- const deployment = simpleDeployment({
370
-   name: schema.spec.name,  // Schema reference - unknown until runtime
371
- });
372
-
373
- // Accessing schema or status fields creates KubernetesRef objects
374
- const nameRef = schema.spec.name;        // Creates: KubernetesRef<string>
375
- const statusRef = deployment.status.readyReplicas; // Creates: KubernetesRef<number>
376
- ```
377
-
378
- #### The `$` Prefix for Explicit References
379
- ```typescript
380
- const configMap = simpleConfigMap({
381
-   name: 'config',
382
-   data: { key: 'value' }  // Static value
383
- });
384
-
385
- const deployment = simpleDeployment({
386
-   name: 'app',
387
-   env: {
388
-     // Static behavior: Uses the known value "value" at execution time
389
-     STATIC_VALUE: configMap.data.key,
390
-     
391
-     // Dynamic behavior: Creates reference resolved by Kro at runtime
392
-     DYNAMIC_VALUE: configMap.data.$key,
393
-   }
394
- });
395
- ```
396
-
397
- **Key Rule**: Schema references (`schema.spec.*`) and status references (`resource.status.*`) are automatically converted to CEL expressions. For explicit runtime references to other resource properties, use the `$` prefix.
398
-
399
- ### Enhanced Types (RefOrValue Pattern)
400
-
401
- Every factory function accepts `RefOrValue<T>`, which means any parameter can be:
402
-
403
- ```typescript
404
- // 1. Direct value
405
- name: "my-app"
406
-
407
- // 2. Schema reference (becomes CEL)
408
- name: schema.spec.name
409
-
410
- // 3. CEL expression 
411
- name: Cel.template("%s-service", schema.spec.name)
412
-
413
- // 4. Reference to another resource
414
- env: {
415
-   DB_HOST: database.service.spec.clusterIP  // Runtime resolution
416
- }
417
- ```
418
-
419
- This pattern provides **compile-time type safety** while enabling **runtime flexibility**.
420
-
421
- ### CRD Installation Intelligence
422
-
423
- TypeKro's direct deployer automatically handles Custom Resource Definition timing:
424
-
425
- ```typescript
426
- // TypeKro automatically detects CRD dependencies
427
- const kroResources = [
428
-   kroDefinition,           // CRD must be installed first
429
-   kroInstance             // Instance depends on CRD
430
- ];
431
-
432
- const factory = await graph.factory('direct', { namespace: 'default' });
433
- await factory.deploy(spec);  // ✅ Automatically waits for CRD readiness
434
- ```
435
-
436
- **Benefits:**
437
- - **No "CRD not found" errors** - Automatic timing coordination
438
- - **Zero manual ordering** - Intelligent dependency detection  
439
- - **Production reliability** - Handles CRD establishment properly
440
-
441
- ### Runtime vs Compile-time Behavior
442
-
443
- | **Aspect** | **Compile-time** | **Runtime** |
444
- |------------|------------------|-------------|
445
- | **Type checking** | Full TypeScript validation | N/A |
446
- | **IDE support** | Autocomplete, refactoring | N/A |
447
- | **Schema references** | Appear as typed properties | Resolve to CEL expressions |
448
- | **Resource references** | Type-safe property access | Runtime cluster state lookup |
449
- | **Validation** | TypeScript + arktype schemas | Kubernetes validation + CEL |
450
-
451
- ---
452
-
453
- ## Comparison Grid
454
-
455
- | Feature | TypeKro | Pulumi | CDK8s | Helm | Kustomize | Crossplane |
456
- |---------|---------|---------|--------|------|-----------|------------|
457
- | **Type Safety** | ✅ Full TypeScript | ✅ Multi-language | ✅ TypeScript | ❌ Templates | ❌ YAML | ❌ YAML |
458
- | **GitOps Ready** | ✅ Deterministic YAML | ❌ State backend | ✅ YAML output | ✅ Charts | ✅ YAML | ✅ YAML |
459
- | **Runtime Dependencies** | ✅ KRO + CEL expressions | ❌ Deploy-time only | ❌ Static | ❌ Templates | ❌ Static | ✅ Compositions |
460
- | **IDE Support** | ✅ Full autocomplete | ✅ Language support | ✅ TypeScript | ❌ Limited | ❌ Limited | ❌ Limited |
461
- | **Learning Curve** | 🟢 Just TypeScript | 🔴 New concepts | 🟡 TypeScript + K8s | 🔴 Templates | 🔴 YAML hell | 🔴 Complex |
462
- | **Kubernetes Native** | ✅ Pure K8s resources | ❌ Abstraction layer | ✅ Pure K8s | ✅ K8s resources | ✅ K8s resources | ✅ K8s + CRDs |
463
- | **Cross-Resource Refs** | ✅ Runtime resolution | ❌ Deploy-time | ❌ Manual | ❌ Manual | ❌ Manual | ✅ Built-in |
464
- | **Multi-Cloud** | 🟡 Via Alchemy | ✅ Native | ❌ K8s only | ❌ K8s only | ❌ K8s only | ✅ Native |
465
- | **State Management** | ✅ Stateless | ❌ State backend | ✅ Stateless | ✅ Stateless | ✅ Stateless | ✅ Controller |
466
- | **CRD Timing** | ✅ Automatic | ❌ Manual | ❌ Manual | ❌ Manual | ❌ Manual | ✅ Built-in |
467
-
468
- ---
469
-
470
326
  ## GitOps Workflows
471
327
 
472
328
  ### Deterministic YAML Generation
@@ -477,10 +333,10 @@ TypeKro generates stable, deterministic YAML output perfect for GitOps workflows
477
333
  // generate-manifests.ts
478
334
  import { writeFileSync } from 'fs';
479
335
 
480
- const graph = toResourceGraph(/* ... */);
336
+ const graph = kubernetesComposition(/* ... */);
481
337
 
482
338
  // Same input always generates identical YAML
483
- const factory = await graph.factory('kro', { namespace: 'default' });
339
+ const factory = graph.factory('kro', { namespace: 'default' });
484
340
  const yaml = factory.toYaml();
485
341
 
486
342
  // Write to file for GitOps
@@ -496,7 +352,7 @@ const environments = ['development', 'staging', 'production'];
496
352
 
497
353
  for (const env of environments) {
498
354
    // Generate ResourceGraphDefinition YAML for this environment
499
-   const factory = await webappGraph.factory('kro', { namespace: env });
355
+   const factory = webappGraph.factory('kro', { namespace: env });
500
356
    const rgdYaml = factory.toYaml();
501
357
    writeFileSync(`k8s/${env}/webapp-rgd.yaml`, rgdYaml);
502
358
    
@@ -532,7 +388,7 @@ const InfraSpec = type({
532
388
    environment: 'string'
533
389
  });
534
390
 
535
- const infraGraph = toResourceGraph(
391
+ const infraGraph = kubernetesComposition(
536
392
    {
537
393
      name: 'ingress-infrastructure',
538
394
      apiVersion: 'infrastructure.example.com/v1',
@@ -540,46 +396,40 @@ const infraGraph = toResourceGraph(
540
396
      spec: InfraSpec,
541
397
      status: type({ ready: 'boolean' })
542
398
    },
543
-   (schema) => ({
544
-     // Helm repository source
545
-     repository: helmRepository({
546
-       name: 'nginx-repo',
547
-       url: 'https://kubernetes.github.io/ingress-nginx'
548
-     }),
549
-     
550
-     // Type-safe Helm release with schema references
551
-     controller: helmRelease({
552
-       name: Cel.template('%s-ingress', schema.spec.name),
553
-       chart: {
554
-         spec: {
555
-           chart: 'ingress-nginx',
556
-           sourceRef: {
557
-             kind: 'HelmRepository',
558
-             name: 'nginx-repo'
559
-           },
560
-           version: '4.8.0'
561
-         }
562
-       },
563
-       values: {
564
-         controller: {
565
-           replicaCount: schema.spec.replicas,                    // Schema reference
566
-           service: {
567
-             loadBalancerIP: schema.spec.loadBalancerIP           // Schema reference
568
-           },
569
-           config: {
570
-             'custom-config': Cel.template('env-%s', schema.spec.environment)  // CEL expression
571
-           }
572
-         }
573
-       }
574
-     })
575
-   }),
399
+ (schema) => {
400
+ // Create Helm repository first
401
+ const repository = helmRepository({
402
+ name: 'nginx-repo',
403
+ url: 'https://kubernetes.github.io/ingress-nginx'
404
+ });
405
+
406
+ // Create Helm release using helmRelease factory
407
+ const controller = helmRelease({
408
+ name: Cel.template('%s-ingress', schema.spec.name),
409
+ repository: repository, // Reference repository
410
+ chart: 'ingress-nginx',
411
+ values: {
412
+ controller: {
413
+ replicaCount: schema.spec.replicas, // Schema reference
414
+ service: {
415
+ loadBalancerIP: schema.spec.loadBalancerIP // Schema reference
416
+ },
417
+ config: {
418
+ 'custom-config': Cel.template('env-%s', schema.spec.environment) // CEL expression
419
+ }
420
+ }
421
+ }
422
+ });
423
+
424
+ return { repository, controller };
425
+ },
576
426
    (schema, resources) => ({
577
427
      ready: Cel.expr(resources.controller.status.conditions, '[?@.type=="Ready"].status == "True"')
578
428
    })
579
429
  );
580
430
 
581
431
  // Deploy via Flux
582
- const factory = await infraGraph.factory('kro', { namespace: 'flux-system' });
432
+ const factory = infraGraph.factory('kro', { namespace: 'flux-system' });
583
433
  const yaml = factory.toYaml();
584
434
  writeFileSync('k8s/ingress-controller.yaml', yaml);
585
435
  ```
@@ -602,53 +452,55 @@ const AppSpec = type({
602
452
    image: 'string'
603
453
  });
604
454
 
605
- const hybridGraph = toResourceGraph(
606
-   {
607
-     name: 'hybrid-app',
608
-     apiVersion: 'apps.example.com/v1',
609
-     kind: 'HybridApp',
610
-     spec: AppSpec,
611
-     status: type({ ready: 'boolean' })
612
-   },
613
-   (schema) => ({
614
-     // Include external YAML files
615
-     monitoring: yamlFile({
616
-       path: './k8s/prometheus-operator.yaml',
617
-       namespace: schema.metadata.namespace  // Schema reference for namespace
618
-     }),
619
-     
620
-     // Include entire directories with Kustomization
621
-     monitoringStack: yamlDirectory({
622
-       path: './k8s/monitoring/',
623
-       recursive: true,
624
-       kustomization: {
625
-         namePrefix: Cel.template('%s-', schema.spec.name),     // Dynamic prefix
626
-         namespace: schema.metadata.namespace,
627
-         commonLabels: {
628
-           'app.kubernetes.io/instance': schema.spec.name        // Schema reference
629
-         }
630
-       }
631
-     }),
632
-     
633
-     // Include from Git repositories
634
-     kubePrometheus: yamlDirectory({
635
-       path: 'https://github.com/prometheus-operator/kube-prometheus.git//manifests',
636
-       ref: 'v0.12.0',
637
-       namespace: 'monitoring'
638
-     }),
639
-     
640
-     // TypeKro resources that reference external resources
641
-     app: simpleDeployment({
642
-       name: schema.spec.name,
643
-       image: schema.spec.image,
644
-       env: {
645
-         PROMETHEUS_URL: 'http://prometheus-operated.monitoring.svc.cluster.local:9090'
646
-       }
647
-     })
648
-   }),
649
-   (schema, resources) => ({
650
-     ready: Cel.expr(resources.app.status.readyReplicas, ' > 0')
651
-   })
455
+ const hybridGraph = kubernetesComposition(
456
+ {
457
+ name: 'hybrid-app',
458
+ apiVersion: 'apps.example.com/v1',
459
+ kind: 'HybridApp',
460
+ spec: AppSpec,
461
+ status: type({ ready: 'boolean' })
462
+ },
463
+ (spec) => {
464
+ // Include external YAML files
465
+ const monitoring = yamlFile({
466
+ path: './k8s/prometheus-operator.yaml',
467
+ namespace: 'default' // Can use static namespace or reference
468
+ });
469
+
470
+ // Include entire directories with Kustomization
471
+ const monitoringStack = yamlDirectory({
472
+ path: './k8s/monitoring/',
473
+ recursive: true,
474
+ kustomization: {
475
+ namePrefix: Cel.template('%s-', spec.name), // Dynamic prefix
476
+ namespace: 'default',
477
+ commonLabels: {
478
+ 'app.kubernetes.io/instance': spec.name // Schema reference
479
+ }
480
+ }
481
+ });
482
+
483
+ // Include from Git repositories
484
+ const kubePrometheus = yamlDirectory({
485
+ path: 'https://github.com/prometheus-operator/kube-prometheus.git//manifests',
486
+ ref: 'v0.12.0',
487
+ namespace: 'monitoring'
488
+ });
489
+
490
+ // TypeKro resources that reference external resources
491
+ const app = simple.Deployment({
492
+ name: spec.name,
493
+ image: spec.image,
494
+ env: {
495
+ PROMETHEUS_URL: 'http://prometheus-operated.monitoring.svc.cluster.local:9090'
496
+ }
497
+ });
498
+
499
+ // Return status
500
+ return {
501
+ ready: Cel.expr<boolean>(app.status.readyReplicas, ' > 0')
502
+ };
503
+ }
652
504
  );
653
505
  ```
654
506
 
@@ -664,7 +516,7 @@ const hybridGraph = toResourceGraph(
664
516
 
665
517
  TypeKro provides 50+ factory functions for all major Kubernetes resources:
666
518
 
667
- **Core Resources:** `simpleDeployment()`, `simpleService()`, `simpleConfigMap()`, `simpleSecret()`, `simplePvc()`
519
+ **Core Resources:** `simple.Deployment()`, `simple.Service()`, `simple.ConfigMap()`, `simple.Secret()`, `simple.Pvc()`
668
520
 
669
521
  **Advanced:** `helmRelease()`, `yamlFile()`, `customResource()`, `networkPolicy()`, `serviceAccount()`, plus comprehensive RBAC, storage, networking, and workload resources.
670
522
 
@@ -679,7 +531,7 @@ All resources support full type safety, cross-resource references, IDE autocompl
679
531
  ### 🆕 "I'm new to Kubernetes"
680
532
  **→ Use: Direct Deployment**
681
533
  ```typescript
682
- const factory = await graph.factory('direct', { namespace: 'default' });
534
+ const factory = graph.factory('direct', { namespace: 'default' });
683
535
  await factory.deploy(spec);
684
536
  ```
685
537
  - Immediate feedback loop
@@ -690,24 +542,25 @@ await factory.deploy(spec);
690
542
  ### 🔄 "I have existing YAML and want to migrate gradually"  
691
543
  **→ Use: yamlFile() + gradual adoption**
692
544
  ```typescript
693
- const hybridGraph = toResourceGraph(
694
-   {
695
-     name: 'legacy-app',
696
-     apiVersion: 'apps.example.com/v1',
697
-     kind: 'LegacyApp',
698
-     spec: type({ name: 'string' }),
699
-     status: type({ ready: 'boolean' })
700
-   },
701
-   (schema) => ({
702
-     existing: yamlFile({ path: './existing/app.yaml' }),        // Keep existing
703
-     newService: simpleService({                                 // Add TypeKro gradually
704
-       name: schema.spec.name,
705
-       selector: { app: schema.spec.name }
706
-     })
707
-   }),
708
-   (schema, resources) => ({
709
-     ready: Cel.expr(resources.newService.status.ready, ' == true')
710
-   })
545
+ const hybridGraph = kubernetesComposition(
546
+ {
547
+ name: 'legacy-app',
548
+ apiVersion: 'apps.example.com/v1',
549
+ kind: 'LegacyApp',
550
+ spec: type({ name: 'string' }),
551
+ status: type({ ready: 'boolean' })
552
+ },
553
+ (spec) => {
554
+ const existing = yamlFile({ path: './existing/app.yaml' }); // Keep existing
555
+ const newService = simple.Service({ // Add TypeKro gradually
556
+ name: spec.name,
557
+ selector: { app: spec.name }
558
+ });
559
+
560
+ return {
561
+ ready: Cel.expr<boolean>(newService.status.ready, ' == true')
562
+ };
563
+ }
711
564
  );
712
565
  ```
713
566
  - Preserve existing workflows
@@ -717,7 +570,7 @@ const hybridGraph = toResourceGraph(
717
570
  ### 🚀 "I want GitOps workflows"
718
571
  **→ Use: YAML Generation + Flux HelmRelease**
719
572
  ```typescript
720
- const factory = await graph.factory('kro', { namespace: 'production' });
573
+ const factory = graph.factory('kro', { namespace: 'production' });
721
574
  const yaml = factory.toYaml();
722
575
  writeFileSync('k8s/app.yaml', yaml);
723
576
  ```
@@ -729,7 +582,7 @@ writeFileSync('k8s/app.yaml', yaml);
729
582
  **→ Use: [Alchemy Integration](#multi-cloud-integration-with-alchemy)**
730
583
  ```typescript
731
584
  await alchemyScope.run(async () => {
732
- const factory = await graph.factory('direct', {
585
+ const factory = graph.factory('direct', {
733
586
  namespace: 'default',
734
587
  alchemyScope: alchemyScope
735
588
  });
@@ -744,14 +597,15 @@ await alchemyScope.run(async () => {
744
597
  **→ Use: helmRelease() patterns**
745
598
  ```typescript
746
599
  helmRelease({
747
-   name: 'nginx',
748
-   chart: { /* ... */ },
749
-   values: {
750
-     replicaCount: schema.spec.replicas,  // Type-safe values
751
-     service: {
752
-       loadBalancerIP: schema.spec.ip     // Schema references
753
-     }
754
-   }
600
+ name: 'nginx',
601
+ repository: repository,
602
+ chart: 'nginx',
603
+ values: {
604
+ replicaCount: spec.replicas, // Type-safe values
605
+ service: {
606
+ loadBalancerIP: spec.ip // Schema references
607
+ }
608
+ }
755
609
  })
756
610
  ```
757
611
  - Type-safe Helm values
@@ -761,7 +615,7 @@ helmRelease({
761
615
  ### 🔗 "I have complex runtime dependencies"
762
616
  **→ Use: Kro Deployment + CEL expressions**
763
617
  ```typescript
764
- simpleDeployment({
618
+ simple.Deployment({
765
619
    env: {
766
620
      DB_HOST: database.service.spec.clusterIP,           // Runtime resolution
767
621
      API_URL: Cel.template('http://%s:8080', 
@@ -789,129 +643,16 @@ Choose based on your team's needs, not just technical capabilities. You can alwa
789
643
 
790
644
  ---
791
645
 
792
- ## Enhanced Type System
646
+ ## Multi-Cloud Integration with Alchemy
793
647
 
794
- TypeKro provides **enhanced types** through its magic proxy system, eliminating the need for optional chaining (`?.`) when working with schema and resource references.
648
+ TypeKro integrates seamlessly with [Alchemy](https://alchemy.run) to enable unified cloud + Kubernetes infrastructure management. Alchemy is infrastructure-as-TypeScript that lets you deploy to Cloudflare, AWS, and more with pure TypeScript.
795
649
 
796
- ### Schema References - Always Present
650
+ ### Why Use TypeKro + Alchemy?
797
651
 
798
- When you access schema fields in the resource builder, TypeScript treats them as always present:
799
-
800
- ```typescript
801
- const graph = toResourceGraph(
802
-   {
803
-     name: 'my-app',
804
-     spec: type({
805
-       name: 'string',
806
-       image: 'string',
807
-       replicas: 'number',
808
-       environment: 'string',
809
-     }),
810
-     status: type({
811
-       ready: 'boolean',
812
-       url: 'string',
813
-     }),
814
-   },
815
-   (schema) => ({
816
-     deployment: simpleDeployment({
817
-       // ✅ No optional chaining needed - TypeScript knows these exist
818
-       name: schema.spec.name,           // Type: string (not string | undefined)
819
-       image: schema.spec.image,         // Type: string (not string | undefined)
820
-       replicas: schema.spec.replicas,   // Type: number (not number | undefined)
821
-       
822
-       env: {
823
-         NODE_ENV: schema.spec.environment,  // Type: string
824
-       },
825
-     }),
826
-   }),
827
-   (schema, resources) => ({
828
-     // ✅ Status fields are also enhanced - no optional chaining needed
829
-     ready: Cel.expr(resources.deployment.status.readyReplicas, ' > 0'),
830
-     url: Cel.template('https://%s.example.com', schema.spec.name),
831
-   })
832
- );
833
- ```
834
-
835
- ### Resource Status References - Enhanced Types
836
-
837
- Resource status fields are enhanced to be non-optional within the builders:
838
-
839
- ```typescript
840
- // Without TypeKro (regular Kubernetes types)
841
- const regularK8s = {
842
-   // These would require optional chaining
843
-   replicas: deployment.status?.readyReplicas,        // number | undefined
844
-   conditions: deployment.status?.conditions?.[0],   // Condition | undefined
845
- };
846
-
847
- // With TypeKro (enhanced types)
848
- const graph = toResourceGraph(
849
-   // ... schema definition
850
-   (schema, resources) => ({
851
-     // ✅ No optional chaining needed - enhanced types guarantee presence
852
-     replicas: resources.deployment.status.readyReplicas,     // Type: number
853
-     phase: resources.deployment.status.phase,                // Type: string
854
-     conditions: resources.deployment.status.conditions[0],   // Type: Condition
855
-     
856
-     // Complex expressions work naturally
857
-     healthy: Cel.expr(
858
-       resources.deployment.status.readyReplicas, ' == ',
859
-       resources.deployment.spec.replicas
860
-     ),
861
-   })
862
- );
863
- ```
864
-
865
- ### How Enhanced Types Work
866
-
867
- The magic proxy system provides type enhancement while respecting the static/dynamic value distinction:
868
-
869
- 1. **Enhanced Type Safety**: Schema and resource references appear as non-optional TypeScript types
870
- 2. **Dynamic Reference Creation**: Schema and status field access creates `KubernetesRef<T>` objects
871
- 3. **Static Value Preservation**: Known values at execution time remain as actual values
872
-
873
- ```typescript
874
- // Schema references (always dynamic - unknown until runtime)
875
- const nameRef = schema.spec.name;                    // Creates: KubernetesRef<string>
876
- const imageRef = schema.spec.image;                  // Creates: KubernetesRef<string>
877
-
878
- // Resource status references (always dynamic - runtime cluster state)
879
- const replicasRef = resources.deployment.status.readyReplicas;  // Creates: KubernetesRef<number>
880
-
881
- // Static values (known at execution time)
882
- const staticName = 'my-app';                         // Remains: string
883
- const staticReplicas = 3;                            // Remains: number
884
-
885
- // Mixed usage in factory functions
886
- const deployment = simpleDeployment({
887
-   name: schema.spec.name,        // Dynamic: KubernetesRef<string> → CEL expression
888
-   replicas: 3,                   // Static: number → direct value
889
-   image: 'nginx:latest'          // Static: string → direct value
890
- });
891
- ```
892
-
893
- ### Benefits of Enhanced Types
894
-
895
- - **No Optional Chaining**: Write cleaner code without `?.` operators
896
- - **Better IntelliSense**: Full autocomplete for all schema and status fields
897
- - **Execution-Time Safety**: Catch typos and missing fields when building resources
898
- - **Runtime Flexibility**: References are resolved dynamically by Kro
899
- - **Natural Syntax**: Write code that looks like direct property access
900
-
901
- This enhanced type system makes TypeKro feel natural to use while maintaining the powerful reference resolution capabilities needed for complex Kubernetes deployments.
902
-
903
- ---
904
-
905
- ## Multi-Cloud Integration with Alchemy
906
-
907
- TypeKro integrates seamlessly with [Alchemy](https://alchemy.run) to enable unified cloud + Kubernetes infrastructure management. Alchemy is infrastructure-as-TypeScript that lets you deploy to Cloudflare, AWS, and more with pure TypeScript.
908
-
909
- ### Why Use TypeKro + Alchemy?
910
-
911
- - **Unified TypeScript Experience**: Write both cloud resources and Kubernetes resources in the same language
912
- - **Cross-Platform References**: Cloud resources can reference Kubernetes resources and vice versa
913
- - **Type-Safe Integration**: Full TypeScript validation across your entire infrastructure stack
914
- - **Flexible Deployment**: Use any TypeKro deployment strategy (Direct, YAML, KRO) with Alchemy
652
+ - **Unified TypeScript Experience**: Write both cloud resources and Kubernetes resources in the same language
653
+ - **Cross-Platform References**: Cloud resources can reference Kubernetes resources and vice versa
654
+ - **Type-Safe Integration**: Full TypeScript validation across your entire infrastructure stack
655
+ - **Flexible Deployment**: Use any TypeKro deployment strategy (Direct, YAML, KRO) with Alchemy
915
656
 
916
657
  ### Individual Resource Registration Pattern
917
658
 
@@ -928,32 +669,33 @@ const app = await alchemy('webapp-infrastructure');
928
669
  const bucket = await Bucket('webapp-uploads');
929
670
 
930
671
  // 3. Create Kubernetes resources that reference cloud resources
931
- const webappGraph = toResourceGraph(
932
-   {
933
-     name: 'webapp-with-cloud',
934
-     apiVersion: 'example.com/v1',
935
-     kind: 'CloudWebApp',
936
-     spec: type({ name: 'string', image: 'string', replicas: 'number' }),
937
-     status: type({ ready: 'boolean' })
938
-   },
939
-   (schema) => ({
940
-     app: simpleDeployment({
941
-       name: schema.spec.name,
942
-       image: schema.spec.image,
943
-       env: {
944
-         BUCKET_NAME: bucket.name,  // Reference to Alchemy resource
945
-         API_URL: Cel.template('http://%s-service', schema.spec.name)
946
-       }
947
-     })
948
-   }),
949
-   (schema, resources) => ({
950
-     ready: Cel.expr(resources.app.status.readyReplicas, ' > 0')
951
-   })
672
+ const webappGraph = kubernetesComposition(
673
+ {
674
+ name: 'webapp-with-cloud',
675
+ apiVersion: 'example.com/v1',
676
+ kind: 'CloudWebApp',
677
+ spec: type({ name: 'string', image: 'string', replicas: 'number' }),
678
+ status: type({ ready: 'boolean' })
679
+ },
680
+ (spec) => {
681
+ const app = simple.Deployment({
682
+ name: spec.name,
683
+ image: spec.image,
684
+ env: {
685
+ BUCKET_NAME: bucket.name, // Reference to Alchemy resource
686
+ API_URL: Cel.template('http://%s-service', spec.name)
687
+ }
688
+ });
689
+
690
+ return {
691
+ ready: Cel.expr<boolean>(app.status.readyReplicas, ' > 0')
692
+ };
693
+ }
952
694
  );
953
695
 
954
696
  // Deploy TypeKro resources with Alchemy integration
955
697
  await app.run(async () => {
956
- const factory = await webappGraph.factory('direct', {
698
+ const factory = webappGraph.factory('direct', {
957
699
  namespace: 'default',
958
700
  alchemyScope: app
959
701
  });
@@ -972,7 +714,7 @@ Here's a complete example showing TypeKro + Alchemy for a production cloud-nativ
972
714
  ```typescript
973
715
  import alchemy from 'alchemy';
974
716
  import { Bucket, Function as LambdaFunction } from 'alchemy/aws';
975
- import { toResourceGraph, simpleDeployment, type } from 'typekro';
717
+ import { kubernetesComposition, simple, type } from 'typekro';
976
718
 
977
719
  // 1. Create Alchemy scope
978
720
  const app = await alchemy('cloud-native-app');
@@ -994,40 +736,45 @@ const AppSpec = type({
994
736
    replicas: 'number'
995
737
  });
996
738
 
997
- const appGraph = toResourceGraph(
998
-   {
999
-     name: 'cloud-native-app',
1000
-     apiVersion: 'example.com/v1',
1001
-     kind: 'CloudNativeApp',
1002
-     spec: AppSpec,
1003
-     status: type({ ready: 'boolean' })
1004
-   },
1005
-   (schema) => ({
1006
-     app: simpleDeployment({
1007
-       name: schema.spec.name,
1008
-       image: schema.spec.image,
1009
-       env: {
1010
-         // Reference cloud resources
1011
-         API_URL: api.url,
1012
-         UPLOAD_BUCKET: bucket.name,
1013
-         // Reference other Kubernetes resources  
1014
-         REDIS_HOST: Cel.template('%s-redis', schema.spec.name)
1015
-       }
1016
-     }),
1017
-     
1018
-     redis: simpleDeployment({
1019
-       name: Cel.template('%s-redis', schema.spec.name),
1020
-       image: 'redis:7'
1021
-     })
1022
-   }),
1023
-   (schema, resources) => ({
1024
-     ready: Cel.expr(resources.app.status.readyReplicas, ' > 0')
1025
-   })
739
+ const appGraph = kubernetesComposition(
740
+ {
741
+ name: 'cloud-native-app',
742
+ apiVersion: 'example.com/v1',
743
+ kind: 'CloudNativeApp',
744
+ spec: AppSpec,
745
+ status: type({ ready: 'boolean' })
746
+ },
747
+ (spec) => {
748
+ // Create redis first
749
+ const redis = simple.Deployment({
750
+ name: Cel.template('%s-redis', spec.name),
751
+ image: 'redis:7',
752
+ labels: { app: Cel.template('%s-redis', spec.name), component: 'cache' }
753
+ });
754
+
755
+ // Create app that references redis
756
+ const app = simple.Deployment({
757
+ name: spec.name,
758
+ image: spec.image,
759
+ labels: { app: spec.name, component: 'web' },
760
+ env: {
761
+ // Reference cloud resources
762
+ API_URL: api.url,
763
+ UPLOAD_BUCKET: bucket.name,
764
+ // Reference other Kubernetes resources by field
765
+ REDIS_HOST: redis.metadata.name
766
+ }
767
+ });
768
+
769
+ return {
770
+ ready: Cel.expr<boolean>(app.status.readyReplicas, ' > 0')
771
+ };
772
+ }
1026
773
  );
1027
774
 
1028
775
  // 4. Deploy as unified infrastructure
1029
776
  await app.run(async () => {
1030
- const factory = await appGraph.factory('direct', {
777
+ const factory = appGraph.factory('direct', {
1031
778
  namespace: 'production',
1032
779
  alchemyScope: app
1033
780
  });
@@ -1051,9 +798,9 @@ const database = await RDS('main-db');
1051
798
  const cache = await ElastiCache('redis-cluster');
1052
799
 
1053
800
  // Add Kubernetes workloads that use cloud resources
1054
- const k8sWorkloads = await webappGraph.factory('kro', { namespace: 'apps' });
801
+ const k8sWorkloads = webappGraph.factory('kro', { namespace: 'apps' });
1055
802
  await app.run(async () => {
1056
- const factory = await k8sWorkloads.factory('kro', {
803
+ const factory = k8sWorkloads.factory('kro', {
1057
804
  namespace: 'apps',
1058
805
  alchemyScope: app
1059
806
  });
@@ -1066,20 +813,24 @@ await app.run(async () => {
1066
813
 
1067
814
  #### Pattern 2: Kubernetes-First with Cloud Services
1068
815
  ```typescript
1069
- // Start with Kubernetes infrastructure
1070
- const webappFactory = await webappGraph.factory('direct', { namespace: 'default' });
1071
-
1072
- // Add cloud resources that support the Kubernetes workloads
816
+ // Start with cloud infrastructure first
1073
817
  const app = await alchemy('support-services');
1074
818
  const monitoring = await CloudWatch('webapp-metrics');
1075
819
  const storage = await S3('webapp-data');
1076
820
 
821
+ // Deploy Kubernetes resources with access to cloud resources
1077
822
  await app.run(async () => {
1078
- const factory = await webappGraph.factory('direct', {
823
+ const factory = webappGraph.factory('direct', {
1079
824
  namespace: 'default',
1080
825
  alchemyScope: app
1081
826
  });
1082
- await factory.deploy({ /* config */ });
827
+ await factory.deploy({
828
+ name: 'webapp',
829
+ image: 'myapp:latest',
830
+ // Kubernetes resources can reference cloud resources
831
+ monitoring: monitoring.endpoint,
832
+ storage: storage.bucketName
833
+ });
1083
834
  });
1084
835
  ```
1085
836
 
@@ -1094,6 +845,273 @@ await app.run(async () => {
1094
845
 
1095
846
  ---
1096
847
 
848
+
849
+ ## Core Architecture
850
+
851
+ TypeKro's architecture enables compile-time type safety with runtime intelligence through three key systems:
852
+
853
+ ```mermaid
854
+ graph TD
855
+ A[TypeScript Code] --> B[Magic Proxy System]
856
+ B --> C[Schema References]
857
+ B --> D[Static Values]
858
+ C --> E[CEL Expressions]
859
+ D --> F[Direct Values]
860
+ E --> G[Runtime Resolution]
861
+ F --> G
862
+ G --> H{Deployment Strategy}
863
+
864
+ H --> I[YAML Generation]
865
+ H --> J[Direct Deployment]
866
+ H --> K[KRO Deployment]
867
+
868
+ I --> L[GitOps Tools<br/>ArgoCD, Flux, kubectl]
869
+ J --> M[Kubernetes API<br/>Immediate Deployment]
870
+ K --> N[KRO Controller<br/>Runtime Dependencies]
871
+
872
+ L --> O[Kubernetes Cluster]
873
+ M --> O
874
+ N --> O
875
+
876
+ subgraph "Compile Time"
877
+ A
878
+ B
879
+ C
880
+ D
881
+ P[IDE Support<br/>Autocomplete<br/>Type Safety]
882
+ end
883
+
884
+ subgraph "Runtime"
885
+ E
886
+ G
887
+ Q[CEL Evaluation<br/>Cross-Resource Refs<br/>Status Propagation]
888
+ end
889
+
890
+ A -.-> P
891
+ N -.-> Q
892
+
893
+ style A fill:#e1f5fe
894
+ style B fill:#f3e5f5
895
+ style O fill:#e8f5e8
896
+ style P fill:#fff3e0
897
+ style Q fill:#fff3e0
898
+ ```
899
+
900
+ ### Magic Proxy System
901
+
902
+ TypeKro's "magic" comes from its **proxy system** that creates different behaviors for execution-time vs runtime values:
903
+
904
+ #### Static Values (Known at Execution Time)
905
+ ```typescript
906
+ const deployment = simple.Deployment({
907
+   name: 'my-app',        // Static string
908
+   replicas: 3,           // Static number
909
+ });
910
+
911
+ // Accessing static values returns the actual value
912
+ console.log(deployment.spec.replicas); // Returns: 3
913
+ ```
914
+
915
+ #### Dynamic References (Unknown at Execution Time)
916
+ ```typescript
917
+ const deployment = simple.Deployment({
918
+   name: schema.spec.name,  // Schema reference - unknown until runtime
919
+ });
920
+
921
+ // Accessing schema or status fields creates KubernetesRef objects
922
+ const nameRef = schema.spec.name;        // Creates: KubernetesRef<string>
923
+ const statusRef = deployment.status.readyReplicas; // Creates: KubernetesRef<number>
924
+ ```
925
+
926
+ #### The `$` Prefix for Explicit References
927
+ ```typescript
928
+ const configMap = simple.ConfigMap({
929
+   name: 'config',
930
+   data: { key: 'value' }  // Static value
931
+ });
932
+
933
+ const deployment = simple.Deployment({
934
+   name: 'app',
935
+   env: {
936
+     // Static behavior: Uses the known value "value" at execution time
937
+     STATIC_VALUE: configMap.data.key,
938
+     
939
+     // Dynamic behavior: Creates reference resolved by Kro at runtime
940
+     DYNAMIC_VALUE: configMap.data.$key,
941
+   }
942
+ });
943
+ ```
944
+
945
+ **Key Rule**: Schema references (`schema.spec.*`) and status references (`resource.status.*`) are automatically converted to CEL expressions. For explicit runtime references to other resource properties, use the `$` prefix.
946
+
947
+ ### Enhanced Types (RefOrValue Pattern)
948
+
949
+ Every factory function accepts `RefOrValue<T>`, which means any parameter can be:
950
+
951
+ ```typescript
952
+ // 1. Direct value
953
+ name: "my-app"
954
+
955
+ // 2. Schema reference (becomes CEL)
956
+ name: schema.spec.name
957
+
958
+ // 3. CEL expression 
959
+ name: Cel.template("%s-service", schema.spec.name)
960
+
961
+ // 4. Reference to another resource
962
+ env: {
963
+   DB_HOST: database.service.spec.clusterIP  // Runtime resolution
964
+ }
965
+ ```
966
+
967
+ This pattern provides **compile-time type safety** while enabling **runtime flexibility**.
968
+
969
+ ### CRD Installation Intelligence
970
+
971
+ TypeKro's direct deployer automatically handles Custom Resource Definition timing:
972
+
973
+ ```typescript
974
+ // TypeKro automatically detects CRD dependencies
975
+ const kroResources = [
976
+   kroDefinition,           // CRD must be installed first
977
+   kroInstance             // Instance depends on CRD
978
+ ];
979
+
980
+ const factory = graph.factory('direct', { namespace: 'default' });
981
+ await factory.deploy(spec);  // ✅ Automatically waits for CRD readiness
982
+ ```
983
+
984
+ **Benefits:**
985
+ - **No "CRD not found" errors** - Automatic timing coordination
986
+ - **Zero manual ordering** - Intelligent dependency detection  
987
+ - **Production reliability** - Handles CRD establishment properly
988
+
989
+ ### Runtime vs Compile-time Behavior
990
+
991
+ | **Aspect** | **Compile-time** | **Runtime** |
992
+ |------------|------------------|-------------|
993
+ | **Type checking** | Full TypeScript validation | N/A |
994
+ | **IDE support** | Autocomplete, refactoring | N/A |
995
+ | **Schema references** | Appear as typed properties | Resolve to CEL expressions |
996
+ | **Resource references** | Type-safe property access | Runtime cluster state lookup |
997
+ | **Validation** | TypeScript + arktype schemas | Kubernetes validation + CEL |
998
+
999
+ ---
1000
+
1001
+
1002
+ ## Enhanced Type System
1003
+
1004
+ TypeKro provides **enhanced types** through its magic proxy system, eliminating the need for optional chaining (`?.`) when working with schema and resource references.
1005
+
1006
+ ### Schema References - Always Present
1007
+
1008
+ When you access schema fields in the resource builder, TypeScript treats them as always present:
1009
+
1010
+ ```typescript
1011
+ const graph = toResourceGraph(
1012
+   {
1013
+     name: 'my-app',
1014
+     spec: type({
1015
+       name: 'string',
1016
+       image: 'string',
1017
+       replicas: 'number',
1018
+       environment: 'string',
1019
+     }),
1020
+     status: type({
1021
+       ready: 'boolean',
1022
+       url: 'string',
1023
+     }),
1024
+   },
1025
+   (schema) => ({
1026
+     deployment: simple.Deployment({
1027
+       // ✅ No optional chaining needed - TypeScript knows these exist
1028
+       name: schema.spec.name,           // Type: string (not string | undefined)
1029
+       image: schema.spec.image,         // Type: string (not string | undefined)
1030
+       replicas: schema.spec.replicas,   // Type: number (not number | undefined)
1031
+       
1032
+       env: {
1033
+         NODE_ENV: schema.spec.environment,  // Type: string
1034
+       },
1035
+     }),
1036
+   }),
1037
+   (schema, resources) => ({
1038
+     // ✅ Status fields are also enhanced - no optional chaining needed
1039
+     ready: Cel.expr(resources.deployment.status.readyReplicas, ' > 0'),
1040
+     url: Cel.template('https://%s.example.com', schema.spec.name),
1041
+   })
1042
+ );
1043
+ ```
1044
+
1045
+ ### Resource Status References - Enhanced Types
1046
+
1047
+ Resource status fields are enhanced to be non-optional within the builders:
1048
+
1049
+ ```typescript
1050
+ // Without TypeKro (regular Kubernetes types)
1051
+ const regularK8s = {
1052
+   // These would require optional chaining
1053
+   replicas: deployment.status?.readyReplicas,        // number | undefined
1054
+   conditions: deployment.status?.conditions?.[0],   // Condition | undefined
1055
+ };
1056
+
1057
+ // With TypeKro (enhanced types)
1058
+ const graph = toResourceGraph(
1059
+   // ... schema definition
1060
+   (schema, resources) => ({
1061
+     // ✅ No optional chaining needed - enhanced types guarantee presence
1062
+     replicas: resources.deployment.status.readyReplicas,     // Type: number
1063
+     phase: resources.deployment.status.phase,                // Type: string
1064
+     conditions: resources.deployment.status.conditions[0],   // Type: Condition
1065
+     
1066
+     // Complex expressions work naturally
1067
+     healthy: Cel.expr(
1068
+       resources.deployment.status.readyReplicas, ' == ',
1069
+       resources.deployment.spec.replicas
1070
+     ),
1071
+   })
1072
+ );
1073
+ ```
1074
+
1075
+ ### How Enhanced Types Work
1076
+
1077
+ The magic proxy system provides type enhancement while respecting the static/dynamic value distinction:
1078
+
1079
+ 1. **Enhanced Type Safety**: Schema and resource references appear as non-optional TypeScript types
1080
+ 2. **Dynamic Reference Creation**: Schema and status field access creates `KubernetesRef<T>` objects
1081
+ 3. **Static Value Preservation**: Known values at execution time remain as actual values
1082
+
1083
+ ```typescript
1084
+ // Schema references (always dynamic - unknown until runtime)
1085
+ const nameRef = schema.spec.name;                    // Creates: KubernetesRef<string>
1086
+ const imageRef = schema.spec.image;                  // Creates: KubernetesRef<string>
1087
+
1088
+ // Resource status references (always dynamic - runtime cluster state)
1089
+ const replicasRef = resources.deployment.status.readyReplicas;  // Creates: KubernetesRef<number>
1090
+
1091
+ // Static values (known at execution time)
1092
+ const staticName = 'my-app';                         // Remains: string
1093
+ const staticReplicas = 3;                            // Remains: number
1094
+
1095
+ // Mixed usage in factory functions
1096
+ const deployment = simple.Deployment({
1097
+   name: schema.spec.name,        // Dynamic: KubernetesRef<string> → CEL expression
1098
+   replicas: 3,                   // Static: number → direct value
1099
+   image: 'nginx:latest'          // Static: string → direct value
1100
+ });
1101
+ ```
1102
+
1103
+ ### Benefits of Enhanced Types
1104
+
1105
+ - **No Optional Chaining**: Write cleaner code without `?.` operators
1106
+ - **Better IntelliSense**: Full autocomplete for all schema and status fields
1107
+ - **Execution-Time Safety**: Catch typos and missing fields when building resources
1108
+ - **Runtime Flexibility**: References are resolved dynamically by Kro
1109
+ - **Natural Syntax**: Write code that looks like direct property access
1110
+
1111
+ This enhanced type system makes TypeKro feel natural to use while maintaining the powerful reference resolution capabilities needed for complex Kubernetes deployments.
1112
+
1113
+ ---
1114
+
1097
1115
  ## Contributing
1098
1116
 
1099
1117
  We welcome contributions to TypeKro! Whether you're fixing bugs, adding features, or improving documentation, your help makes TypeKro better for everyone.
@@ -1134,4 +1152,4 @@ The contributing guide includes:
1134
1152
 
1135
1153
  ## License
1136
1154
 
1137
- Apache 2.0 - see [LICENSE](LICENSE) for details.
1155
+ Apache 2.0 - see [LICENSE](LICENSE) for details.