@geekmidas/cli 10.0.0-alpha.11 → 10.0.0-alpha.110

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 (501) hide show
  1. package/README.md +315 -414
  2. package/bin/adjacent-tsconfig.mjs +46 -8
  3. package/bin/gkm.mjs +11 -3
  4. package/bin/owning-tsconfig-jsx-register.mjs +18 -0
  5. package/bin/owning-tsconfig-jsx.mjs +108 -0
  6. package/dist/EndpointGenerator-BwbYTMtB.cjs +1090 -0
  7. package/dist/EndpointGenerator-BwbYTMtB.cjs.map +1 -0
  8. package/dist/EndpointGenerator-CvLX8bpx.mjs +1031 -0
  9. package/dist/EndpointGenerator-CvLX8bpx.mjs.map +1 -0
  10. package/dist/GoDaddyProvider-CjeOduia.mjs +388 -0
  11. package/dist/GoDaddyProvider-CjeOduia.mjs.map +1 -0
  12. package/dist/GoDaddyProvider-qNUzTXI7.cjs +388 -0
  13. package/dist/GoDaddyProvider-qNUzTXI7.cjs.map +1 -0
  14. package/dist/{HostingerProvider-BcyFRbqV.mjs → HostingerProvider-BNpS9aRJ.mjs} +29 -25
  15. package/dist/HostingerProvider-BNpS9aRJ.mjs.map +1 -0
  16. package/dist/{HostingerProvider-BOvsgATO.cjs → HostingerProvider-DR1iws1P.cjs} +29 -25
  17. package/dist/HostingerProvider-DR1iws1P.cjs.map +1 -0
  18. package/dist/LegacyStateStore-MxiSu7KJ.cjs +124 -0
  19. package/dist/LegacyStateStore-MxiSu7KJ.cjs.map +1 -0
  20. package/dist/LegacyStateStore-pgscYsiG.mjs +124 -0
  21. package/dist/LegacyStateStore-pgscYsiG.mjs.map +1 -0
  22. package/dist/LocalStateStore-BcvyKbAw.mjs +167 -0
  23. package/dist/LocalStateStore-BcvyKbAw.mjs.map +1 -0
  24. package/dist/LocalStateStore-Bm8Vmwjb.cjs +178 -0
  25. package/dist/LocalStateStore-Bm8Vmwjb.cjs.map +1 -0
  26. package/dist/OpenApiTsGenerator-BD6ZOQ51.cjs +541 -0
  27. package/dist/OpenApiTsGenerator-BD6ZOQ51.cjs.map +1 -0
  28. package/dist/OpenApiTsGenerator-DXXFXSbO.mjs +536 -0
  29. package/dist/OpenApiTsGenerator-DXXFXSbO.mjs.map +1 -0
  30. package/dist/{Route53Provider-CH9XH7bz.cjs → Route53Provider-Bllus2NR.cjs} +21 -22
  31. package/dist/Route53Provider-Bllus2NR.cjs.map +1 -0
  32. package/dist/{Route53Provider-C0xmer8U.mjs → Route53Provider-QXxjkZO1.mjs} +13 -13
  33. package/dist/Route53Provider-QXxjkZO1.mjs.map +1 -0
  34. package/dist/S3StateStore-DXHSBVsV.cjs +222 -0
  35. package/dist/S3StateStore-DXHSBVsV.cjs.map +1 -0
  36. package/dist/S3StateStore-H2XsAzpJ.mjs +223 -0
  37. package/dist/S3StateStore-H2XsAzpJ.mjs.map +1 -0
  38. package/dist/SSMStateStore-BLPSNl-U.cjs +204 -0
  39. package/dist/SSMStateStore-BLPSNl-U.cjs.map +1 -0
  40. package/dist/SSMStateStore-CENciQEM.mjs +205 -0
  41. package/dist/SSMStateStore-CENciQEM.mjs.map +1 -0
  42. package/dist/SubscriberGenerator-CeH7wbYt.cjs +571 -0
  43. package/dist/SubscriberGenerator-CeH7wbYt.cjs.map +1 -0
  44. package/dist/SubscriberGenerator-DHnIYwUU.mjs +518 -0
  45. package/dist/SubscriberGenerator-DHnIYwUU.mjs.map +1 -0
  46. package/dist/add-Cdg1kEqN.cjs +719 -0
  47. package/dist/add-Cdg1kEqN.cjs.map +1 -0
  48. package/dist/add-snhdVmR-.mjs +717 -0
  49. package/dist/add-snhdVmR-.mjs.map +1 -0
  50. package/dist/appPorts-BoXMwolc.mjs +249 -0
  51. package/dist/appPorts-BoXMwolc.mjs.map +1 -0
  52. package/dist/appPorts-IW-OZmRi.cjs +296 -0
  53. package/dist/appPorts-IW-OZmRi.cjs.map +1 -0
  54. package/dist/aws-8QQ8n-t6.mjs +89 -0
  55. package/dist/aws-8QQ8n-t6.mjs.map +1 -0
  56. package/dist/aws-DY9NqQIT.cjs +100 -0
  57. package/dist/aws-DY9NqQIT.cjs.map +1 -0
  58. package/dist/awsStore-Bx5nCFnS.mjs +121 -0
  59. package/dist/awsStore-Bx5nCFnS.mjs.map +1 -0
  60. package/dist/awsStore-u3ehhMoY.cjs +138 -0
  61. package/dist/awsStore-u3ehhMoY.cjs.map +1 -0
  62. package/dist/{backup-provisioner-DXXg6FIL.mjs → backup-provisioner-C8DnCmxK.mjs} +11 -8
  63. package/dist/backup-provisioner-C8DnCmxK.mjs.map +1 -0
  64. package/dist/{backup-provisioner-cE2PuCTb.cjs → backup-provisioner-oDEsPj02.cjs} +22 -20
  65. package/dist/backup-provisioner-oDEsPj02.cjs.map +1 -0
  66. package/dist/backups/runner.cjs +519 -0
  67. package/dist/backups/runner.cjs.map +1 -0
  68. package/dist/backups/runner.d.cts +102 -0
  69. package/dist/backups/runner.d.cts.map +1 -0
  70. package/dist/backups/runner.d.mts +102 -0
  71. package/dist/backups/runner.d.mts.map +1 -0
  72. package/dist/backups/runner.mjs +506 -0
  73. package/dist/backups/runner.mjs.map +1 -0
  74. package/dist/{bundler-CaTGtiaO.cjs → bundler-B4GDxImV.cjs} +38 -35
  75. package/dist/bundler-B4GDxImV.cjs.map +1 -0
  76. package/dist/{bundler-S3ek7ea-.mjs → bundler-Wd9H4QLJ.mjs} +36 -32
  77. package/dist/bundler-Wd9H4QLJ.mjs.map +1 -0
  78. package/dist/cli-BZYz55tO.cjs +71 -0
  79. package/dist/cli-BZYz55tO.cjs.map +1 -0
  80. package/dist/cli-BzrDSNSg.mjs +71 -0
  81. package/dist/cli-BzrDSNSg.mjs.map +1 -0
  82. package/dist/compose-DN9zySvQ.cjs +3330 -0
  83. package/dist/compose-DN9zySvQ.cjs.map +1 -0
  84. package/dist/compose-Gsd1Nq7R.mjs +3187 -0
  85. package/dist/compose-Gsd1Nq7R.mjs.map +1 -0
  86. package/dist/config-D48erO2j.d.mts +269 -0
  87. package/dist/config-D48erO2j.d.mts.map +1 -0
  88. package/dist/config-DHDtsQrB.d.cts +269 -0
  89. package/dist/config-DHDtsQrB.d.cts.map +1 -0
  90. package/dist/config.cjs +421 -11
  91. package/dist/config.cjs.map +1 -0
  92. package/dist/config.d.cts +4 -120
  93. package/dist/config.d.mts +4 -120
  94. package/dist/config.mjs +405 -4
  95. package/dist/config.mjs.map +1 -0
  96. package/dist/credentialSchemas-Cf5Pf8VE.mjs +237 -0
  97. package/dist/credentialSchemas-Cf5Pf8VE.mjs.map +1 -0
  98. package/dist/credentialSchemas-D_VUCDUh.cjs +272 -0
  99. package/dist/credentialSchemas-D_VUCDUh.cjs.map +1 -0
  100. package/dist/credentials-B5N5yKk6.mjs +267 -0
  101. package/dist/credentials-B5N5yKk6.mjs.map +1 -0
  102. package/dist/credentials-Zqr3QQYB.cjs +350 -0
  103. package/dist/credentials-Zqr3QQYB.cjs.map +1 -0
  104. package/dist/databases-BeGP5eDh.mjs +495 -0
  105. package/dist/databases-BeGP5eDh.mjs.map +1 -0
  106. package/dist/databases-DGALFDG3.cjs +598 -0
  107. package/dist/databases-DGALFDG3.cjs.map +1 -0
  108. package/dist/define-6poNqm5O.mjs +106 -0
  109. package/dist/define-6poNqm5O.mjs.map +1 -0
  110. package/dist/define-crmMcXFS.cjs +153 -0
  111. package/dist/define-crmMcXFS.cjs.map +1 -0
  112. package/dist/deploy/public.cjs +212 -0
  113. package/dist/deploy/public.cjs.map +1 -0
  114. package/dist/deploy/public.d.cts +653 -0
  115. package/dist/deploy/public.d.cts.map +1 -0
  116. package/dist/deploy/public.d.mts +653 -0
  117. package/dist/deploy/public.d.mts.map +1 -0
  118. package/dist/deploy/public.mjs +145 -0
  119. package/dist/deploy/public.mjs.map +1 -0
  120. package/dist/deploy/sniffer-envkit-patch.cjs +18 -10
  121. package/dist/deploy/sniffer-envkit-patch.cjs.map +1 -1
  122. package/dist/deploy/sniffer-envkit-patch.d.cts +0 -2
  123. package/dist/deploy/sniffer-envkit-patch.d.cts.map +1 -1
  124. package/dist/deploy/sniffer-envkit-patch.d.mts +0 -2
  125. package/dist/deploy/sniffer-envkit-patch.d.mts.map +1 -1
  126. package/dist/deploy/sniffer-envkit-patch.mjs +10 -2
  127. package/dist/deploy/sniffer-envkit-patch.mjs.map +1 -1
  128. package/dist/deploy/sniffer-envparser-worker.cjs +54 -0
  129. package/dist/deploy/sniffer-envparser-worker.cjs.map +1 -0
  130. package/dist/deploy/sniffer-envparser-worker.d.cts +1 -0
  131. package/dist/deploy/sniffer-envparser-worker.d.mts +1 -0
  132. package/dist/deploy/sniffer-envparser-worker.mjs +55 -0
  133. package/dist/deploy/sniffer-envparser-worker.mjs.map +1 -0
  134. package/dist/deploy/sniffer-hooks.cjs +13 -7
  135. package/dist/deploy/sniffer-hooks.cjs.map +1 -1
  136. package/dist/deploy/sniffer-hooks.d.cts +1 -2
  137. package/dist/deploy/sniffer-hooks.d.cts.map +1 -1
  138. package/dist/deploy/sniffer-hooks.d.mts +1 -2
  139. package/dist/deploy/sniffer-hooks.d.mts.map +1 -1
  140. package/dist/deploy/sniffer-hooks.mjs +10 -3
  141. package/dist/deploy/sniffer-hooks.mjs.map +1 -1
  142. package/dist/deploy/sniffer-loader.cjs +16 -7
  143. package/dist/deploy/sniffer-loader.cjs.map +1 -1
  144. package/dist/deploy/sniffer-loader.d.cts +1 -1
  145. package/dist/deploy/sniffer-loader.d.mts +1 -1
  146. package/dist/deploy/sniffer-loader.mjs +14 -3
  147. package/dist/deploy/sniffer-loader.mjs.map +1 -1
  148. package/dist/deploy/sniffer-routes-worker.cjs +11 -11
  149. package/dist/deploy/sniffer-routes-worker.cjs.map +1 -1
  150. package/dist/deploy/sniffer-routes-worker.d.cts +1 -1
  151. package/dist/deploy/sniffer-routes-worker.d.mts +1 -1
  152. package/dist/deploy/sniffer-routes-worker.mjs +4 -4
  153. package/dist/deploy/sniffer-routes-worker.mjs.map +1 -1
  154. package/dist/deploy/sniffer-worker.cjs +15 -6
  155. package/dist/deploy/sniffer-worker.cjs.map +1 -1
  156. package/dist/deploy/sniffer-worker.d.cts +1 -3
  157. package/dist/deploy/sniffer-worker.d.cts.map +1 -1
  158. package/dist/deploy/sniffer-worker.d.mts +1 -3
  159. package/dist/deploy/sniffer-worker.d.mts.map +1 -1
  160. package/dist/deploy/sniffer-worker.mjs +15 -4
  161. package/dist/deploy/sniffer-worker.mjs.map +1 -1
  162. package/dist/deploy-CFvq8daZ.cjs +2390 -0
  163. package/dist/deploy-CFvq8daZ.cjs.map +1 -0
  164. package/dist/deploy-H2S8_mTx.mjs +2317 -0
  165. package/dist/deploy-H2S8_mTx.mjs.map +1 -0
  166. package/dist/derive-B4vDpzgP.mjs +150 -0
  167. package/dist/derive-B4vDpzgP.mjs.map +1 -0
  168. package/dist/derive-DAbo49sm.cjs +161 -0
  169. package/dist/derive-DAbo49sm.cjs.map +1 -0
  170. package/dist/discover-Bsr7HjqJ.cjs +616 -0
  171. package/dist/discover-Bsr7HjqJ.cjs.map +1 -0
  172. package/dist/discover-Ca8U75dl.mjs +537 -0
  173. package/dist/discover-Ca8U75dl.mjs.map +1 -0
  174. package/dist/discover-CvTtV5ZD.d.cts +108 -0
  175. package/dist/discover-CvTtV5ZD.d.cts.map +1 -0
  176. package/dist/discover-W2kab9Lc.d.mts +108 -0
  177. package/dist/discover-W2kab9Lc.d.mts.map +1 -0
  178. package/dist/dns-BdETzP10.cjs +1057 -0
  179. package/dist/dns-BdETzP10.cjs.map +1 -0
  180. package/dist/dns-pFMShDqW.mjs +926 -0
  181. package/dist/dns-pFMShDqW.mjs.map +1 -0
  182. package/dist/dokploy-HioAjP7K.cjs +38 -0
  183. package/dist/dokploy-HioAjP7K.cjs.map +1 -0
  184. package/dist/dokploy-oDJbnvCb.mjs +38 -0
  185. package/dist/dokploy-oDJbnvCb.mjs.map +1 -0
  186. package/dist/drivers-D11JHxrD.mjs +177 -0
  187. package/dist/drivers-D11JHxrD.mjs.map +1 -0
  188. package/dist/drivers-GKaA6ITM.cjs +200 -0
  189. package/dist/drivers-GKaA6ITM.cjs.map +1 -0
  190. package/dist/{emit-CIlvnDvV.mjs → emit-C1e8qD08.mjs} +13 -26
  191. package/dist/emit-C1e8qD08.mjs.map +1 -0
  192. package/dist/{emit-CUD1BWls.cjs → emit-Dmc1nvdS.cjs} +31 -57
  193. package/dist/emit-Dmc1nvdS.cjs.map +1 -0
  194. package/dist/encryption-D5pDJyp2.mjs +89 -0
  195. package/dist/encryption-D5pDJyp2.mjs.map +1 -0
  196. package/dist/encryption-DVCxD-gV.cjs +90 -0
  197. package/dist/encryption-DVCxD-gV.cjs.map +1 -0
  198. package/dist/engine-BaJGPzte.cjs +3196 -0
  199. package/dist/engine-BaJGPzte.cjs.map +1 -0
  200. package/dist/engine-CfAKgr2_.mjs +3083 -0
  201. package/dist/engine-CfAKgr2_.mjs.map +1 -0
  202. package/dist/errors-D8Gwp5kU.mjs +23 -0
  203. package/dist/errors-D8Gwp5kU.mjs.map +1 -0
  204. package/dist/errors-DMC4Umsb.cjs +34 -0
  205. package/dist/errors-DMC4Umsb.cjs.map +1 -0
  206. package/dist/github-D902Vwr9.cjs +829 -0
  207. package/dist/github-D902Vwr9.cjs.map +1 -0
  208. package/dist/github-E-ZxqFPq.mjs +829 -0
  209. package/dist/github-E-ZxqFPq.mjs.map +1 -0
  210. package/dist/identity-CBXr4wNi.mjs +129 -0
  211. package/dist/identity-CBXr4wNi.mjs.map +1 -0
  212. package/dist/identity-CbLfgQNT.cjs +182 -0
  213. package/dist/identity-CbLfgQNT.cjs.map +1 -0
  214. package/dist/{index-Ayxg_DQY.d.mts → index-8OfpOtSI.d.cts} +39 -24
  215. package/dist/index-8OfpOtSI.d.cts.map +1 -0
  216. package/dist/{index-CR5urhWX.d.cts → index-Dpji6Bxq.d.mts} +39 -24
  217. package/dist/index-Dpji6Bxq.d.mts.map +1 -0
  218. package/dist/index.cjs +13764 -12651
  219. package/dist/index.cjs.map +1 -1
  220. package/dist/index.d.cts +1 -1
  221. package/dist/index.d.mts +1 -1
  222. package/dist/index.mjs +13654 -12553
  223. package/dist/index.mjs.map +1 -1
  224. package/dist/local-BwC2v2Y8.mjs +224 -0
  225. package/dist/local-BwC2v2Y8.mjs.map +1 -0
  226. package/dist/local-DNhnkugT.cjs +241 -0
  227. package/dist/local-DNhnkugT.cjs.map +1 -0
  228. package/dist/migrate-BZ0GnSZQ.mjs +181 -0
  229. package/dist/migrate-BZ0GnSZQ.mjs.map +1 -0
  230. package/dist/migrate-CTqhWtev.cjs +271 -0
  231. package/dist/migrate-CTqhWtev.cjs.map +1 -0
  232. package/dist/migrate-DCXwHcWX.mjs +266 -0
  233. package/dist/migrate-DCXwHcWX.mjs.map +1 -0
  234. package/dist/migrate-Df81ew0k.cjs +181 -0
  235. package/dist/migrate-Df81ew0k.cjs.map +1 -0
  236. package/dist/openapi.cjs +214 -10
  237. package/dist/openapi.cjs.map +1 -0
  238. package/dist/openapi.d.cts +38 -17
  239. package/dist/openapi.d.cts.map +1 -1
  240. package/dist/openapi.d.mts +38 -17
  241. package/dist/openapi.d.mts.map +1 -1
  242. package/dist/openapi.mjs +208 -5
  243. package/dist/openapi.mjs.map +1 -0
  244. package/dist/projectBucket-BBbQ1lHF.cjs +263 -0
  245. package/dist/projectBucket-BBbQ1lHF.cjs.map +1 -0
  246. package/dist/projectBucket-C_DN4WzF.mjs +222 -0
  247. package/dist/projectBucket-C_DN4WzF.mjs.map +1 -0
  248. package/dist/provider-BqpjG9QM.cjs +57 -0
  249. package/dist/provider-BqpjG9QM.cjs.map +1 -0
  250. package/dist/provider-CEOKk8NS.mjs +46 -0
  251. package/dist/provider-CEOKk8NS.mjs.map +1 -0
  252. package/dist/ready-BMFjxBYA.cjs +404 -0
  253. package/dist/ready-BMFjxBYA.cjs.map +1 -0
  254. package/dist/ready-CIt5SOtg.mjs +375 -0
  255. package/dist/ready-CIt5SOtg.mjs.map +1 -0
  256. package/dist/reconcile/public.cjs +3 -5
  257. package/dist/reconcile/public.d.cts +11 -87
  258. package/dist/reconcile/public.d.cts.map +1 -1
  259. package/dist/reconcile/public.d.mts +11 -87
  260. package/dist/reconcile/public.d.mts.map +1 -1
  261. package/dist/reconcile/public.mjs +3 -4
  262. package/dist/{reconcile-C13ERt1U.mjs → reconcile--I7V4Klj.mjs} +4 -7
  263. package/dist/reconcile--I7V4Klj.mjs.map +1 -0
  264. package/dist/{reconcile-CYMhFSYy.cjs → reconcile-CuCQBa5-.cjs} +5 -8
  265. package/dist/reconcile-CuCQBa5-.cjs.map +1 -0
  266. package/dist/resolve-BMpPd8x3.mjs +263 -0
  267. package/dist/resolve-BMpPd8x3.mjs.map +1 -0
  268. package/dist/resolve-D043YmW9.cjs +316 -0
  269. package/dist/resolve-D043YmW9.cjs.map +1 -0
  270. package/dist/rollback-CBiYsQ3T.cjs +165 -0
  271. package/dist/rollback-CBiYsQ3T.cjs.map +1 -0
  272. package/dist/rollback-CDs_XNb0.mjs +136 -0
  273. package/dist/rollback-CDs_XNb0.mjs.map +1 -0
  274. package/dist/rolldown-runtime-BhDjJH2R.mjs +15 -0
  275. package/dist/{chunk-CUT6urMc.cjs → rolldown-runtime-C0BPl7ul.cjs} +23 -10
  276. package/dist/run-BJLIerMM.mjs +133 -0
  277. package/dist/run-BJLIerMM.mjs.map +1 -0
  278. package/dist/run-fVZ-rLnc.cjs +174 -0
  279. package/dist/run-fVZ-rLnc.cjs.map +1 -0
  280. package/dist/runtime-ACdfK59n.d.cts +82 -0
  281. package/dist/runtime-ACdfK59n.d.cts.map +1 -0
  282. package/dist/runtime-YyQuekxi.d.mts +82 -0
  283. package/dist/runtime-YyQuekxi.d.mts.map +1 -0
  284. package/dist/s3-CrPoA89T.cjs +215 -0
  285. package/dist/s3-CrPoA89T.cjs.map +1 -0
  286. package/dist/s3-DQXZdmCM.mjs +215 -0
  287. package/dist/s3-DQXZdmCM.mjs.map +1 -0
  288. package/dist/sandbox/config-worker.cjs +43 -0
  289. package/dist/sandbox/config-worker.cjs.map +1 -0
  290. package/dist/sandbox/config-worker.d.cts +1 -0
  291. package/dist/sandbox/config-worker.d.mts +1 -0
  292. package/dist/sandbox/config-worker.mjs +44 -0
  293. package/dist/sandbox/config-worker.mjs.map +1 -0
  294. package/dist/sandbox/credentials-worker.cjs +54 -0
  295. package/dist/sandbox/credentials-worker.cjs.map +1 -0
  296. package/dist/sandbox/credentials-worker.d.cts +1 -0
  297. package/dist/sandbox/credentials-worker.d.mts +1 -0
  298. package/dist/sandbox/credentials-worker.mjs +55 -0
  299. package/dist/sandbox/credentials-worker.mjs.map +1 -0
  300. package/dist/sandbox/discover-worker.cjs +47 -0
  301. package/dist/sandbox/discover-worker.cjs.map +1 -0
  302. package/dist/sandbox/discover-worker.d.cts +1 -0
  303. package/dist/sandbox/discover-worker.d.mts +1 -0
  304. package/dist/sandbox/discover-worker.mjs +48 -0
  305. package/dist/sandbox/discover-worker.mjs.map +1 -0
  306. package/dist/sandbox/migrate-worker.cjs +75 -0
  307. package/dist/sandbox/migrate-worker.cjs.map +1 -0
  308. package/dist/sandbox/migrate-worker.d.cts +1 -0
  309. package/dist/sandbox/migrate-worker.d.mts +1 -0
  310. package/dist/sandbox/migrate-worker.mjs +76 -0
  311. package/dist/sandbox/migrate-worker.mjs.map +1 -0
  312. package/dist/sandbox-C4g1eG31.d.mts +104 -0
  313. package/dist/sandbox-C4g1eG31.d.mts.map +1 -0
  314. package/dist/sandbox-CHv3OYXg.cjs +165 -0
  315. package/dist/sandbox-CHv3OYXg.cjs.map +1 -0
  316. package/dist/sandbox-CbVB7uOD.mjs +118 -0
  317. package/dist/sandbox-CbVB7uOD.mjs.map +1 -0
  318. package/dist/sandbox-CdKgQ3XU.d.cts +104 -0
  319. package/dist/sandbox-CdKgQ3XU.d.cts.map +1 -0
  320. package/dist/{workspace-C-a3G_U0.cjs → schemas-BCwKKA42.mjs} +958 -1868
  321. package/dist/schemas-BCwKKA42.mjs.map +1 -0
  322. package/dist/{workspace-DaEX7FEg.mjs → schemas-BQ_v0lEX.cjs} +1048 -1678
  323. package/dist/schemas-BQ_v0lEX.cjs.map +1 -0
  324. package/dist/secretsManager-CQORubp9.mjs +97 -0
  325. package/dist/secretsManager-CQORubp9.mjs.map +1 -0
  326. package/dist/secretsManager-RAGcEDX1.cjs +108 -0
  327. package/dist/secretsManager-RAGcEDX1.cjs.map +1 -0
  328. package/dist/seeds-BjcO4DDa.mjs +8194 -0
  329. package/dist/seeds-BjcO4DDa.mjs.map +1 -0
  330. package/dist/seeds-DNqRA1aQ.cjs +9173 -0
  331. package/dist/seeds-DNqRA1aQ.cjs.map +1 -0
  332. package/dist/sniffer-DipSS8r8.cjs +1998 -0
  333. package/dist/sniffer-DipSS8r8.cjs.map +1 -0
  334. package/dist/sniffer-b0XPmSyT.mjs +1825 -0
  335. package/dist/sniffer-b0XPmSyT.mjs.map +1 -0
  336. package/dist/sst-B-Uz4cvm.cjs +464 -0
  337. package/dist/sst-B-Uz4cvm.cjs.map +1 -0
  338. package/dist/sst-C1pxbFEd.mjs +441 -0
  339. package/dist/sst-C1pxbFEd.mjs.map +1 -0
  340. package/dist/stage-C_y2UovO.cjs +266 -0
  341. package/dist/stage-C_y2UovO.cjs.map +1 -0
  342. package/dist/stage-DrDmZusd.mjs +266 -0
  343. package/dist/stage-DrDmZusd.mjs.map +1 -0
  344. package/dist/stages-DJrOYLZ-.mjs +176 -0
  345. package/dist/stages-DJrOYLZ-.mjs.map +1 -0
  346. package/dist/stages-_3RVNG83.cjs +176 -0
  347. package/dist/stages-_3RVNG83.cjs.map +1 -0
  348. package/dist/target/public.cjs +15 -0
  349. package/dist/target/public.d.cts +28 -0
  350. package/dist/target/public.d.cts.map +1 -0
  351. package/dist/target/public.d.mts +28 -0
  352. package/dist/target/public.d.mts.map +1 -0
  353. package/dist/target/public.mjs +4 -0
  354. package/dist/terminal-CvRLxz6g.mjs +85 -0
  355. package/dist/terminal-CvRLxz6g.mjs.map +1 -0
  356. package/dist/terminal-D_NRPW4W.cjs +85 -0
  357. package/dist/terminal-D_NRPW4W.cjs.map +1 -0
  358. package/dist/types-B6UXlEkf.d.cts +7650 -0
  359. package/dist/types-B6UXlEkf.d.cts.map +1 -0
  360. package/dist/types-HqVPddRK.d.mts +7649 -0
  361. package/dist/types-HqVPddRK.d.mts.map +1 -0
  362. package/dist/utils-D2Nk1Nv2.cjs +205 -0
  363. package/dist/utils-D2Nk1Nv2.cjs.map +1 -0
  364. package/dist/utils-D_fxUqvU.mjs +156 -0
  365. package/dist/utils-D_fxUqvU.mjs.map +1 -0
  366. package/dist/vitest.cjs +65 -0
  367. package/dist/vitest.cjs.map +1 -0
  368. package/dist/vitest.d.cts +29 -0
  369. package/dist/vitest.d.cts.map +1 -0
  370. package/dist/vitest.d.mts +29 -0
  371. package/dist/vitest.d.mts.map +1 -0
  372. package/dist/vitest.mjs +65 -0
  373. package/dist/vitest.mjs.map +1 -0
  374. package/dist/workerRuntime-BXfhbe13.cjs +108 -0
  375. package/dist/workerRuntime-BXfhbe13.cjs.map +1 -0
  376. package/dist/workerRuntime-CsOyBRx2.mjs +79 -0
  377. package/dist/workerRuntime-CsOyBRx2.mjs.map +1 -0
  378. package/dist/workspace/index.cjs +8 -4
  379. package/dist/workspace/index.d.cts +3 -3
  380. package/dist/workspace/index.d.mts +3 -3
  381. package/dist/workspace/index.mjs +2 -3
  382. package/dist/workspace-BwqQnool.cjs +2806 -0
  383. package/dist/workspace-BwqQnool.cjs.map +1 -0
  384. package/dist/workspace-D1QbNd55.mjs +2394 -0
  385. package/dist/workspace-D1QbNd55.mjs.map +1 -0
  386. package/package.json +54 -22
  387. package/dist/CachedStateProvider-BEBl2wQT.cjs +0 -60
  388. package/dist/CachedStateProvider-BEBl2wQT.cjs.map +0 -1
  389. package/dist/CachedStateProvider-C-8wtlto.mjs +0 -3
  390. package/dist/CachedStateProvider-Co4n5Wvs.mjs +0 -54
  391. package/dist/CachedStateProvider-Co4n5Wvs.mjs.map +0 -1
  392. package/dist/CachedStateProvider-DqhGpzsm.cjs +0 -3
  393. package/dist/HostingerProvider-BOvsgATO.cjs.map +0 -1
  394. package/dist/HostingerProvider-BcyFRbqV.mjs.map +0 -1
  395. package/dist/LocalStateProvider-Bq-0C0sg.mjs +0 -42
  396. package/dist/LocalStateProvider-Bq-0C0sg.mjs.map +0 -1
  397. package/dist/LocalStateProvider-yjXZXZDM.cjs +0 -43
  398. package/dist/LocalStateProvider-yjXZXZDM.cjs.map +0 -1
  399. package/dist/Route53Provider-C0xmer8U.mjs.map +0 -1
  400. package/dist/Route53Provider-CH9XH7bz.cjs.map +0 -1
  401. package/dist/SSMStateProvider-CXtNgPfy.cjs +0 -66
  402. package/dist/SSMStateProvider-CXtNgPfy.cjs.map +0 -1
  403. package/dist/SSMStateProvider-DOZifZfE.mjs +0 -66
  404. package/dist/SSMStateProvider-DOZifZfE.mjs.map +0 -1
  405. package/dist/backup-provisioner-DXXg6FIL.mjs.map +0 -1
  406. package/dist/backup-provisioner-cE2PuCTb.cjs.map +0 -1
  407. package/dist/bundler-CaTGtiaO.cjs.map +0 -1
  408. package/dist/bundler-S3ek7ea-.mjs.map +0 -1
  409. package/dist/chunk-Duj1WY3L.mjs +0 -7
  410. package/dist/config-B0L2tvvC.mjs +0 -402
  411. package/dist/config-B0L2tvvC.mjs.map +0 -1
  412. package/dist/config-HhDpJmLO.cjs +0 -462
  413. package/dist/config-HhDpJmLO.cjs.map +0 -1
  414. package/dist/config.d.cts.map +0 -1
  415. package/dist/config.d.mts.map +0 -1
  416. package/dist/credentials-B2Pyh3bJ.cjs +0 -2681
  417. package/dist/credentials-B2Pyh3bJ.cjs.map +0 -1
  418. package/dist/credentials-B5zRHdAl.mjs +0 -141
  419. package/dist/credentials-B5zRHdAl.mjs.map +0 -1
  420. package/dist/credentials-BapzjyV5.cjs +0 -195
  421. package/dist/credentials-BapzjyV5.cjs.map +0 -1
  422. package/dist/credentials-CZrys9C5.mjs +0 -2549
  423. package/dist/credentials-CZrys9C5.mjs.map +0 -1
  424. package/dist/discover-CAlFgYec.mjs +0 -229
  425. package/dist/discover-CAlFgYec.mjs.map +0 -1
  426. package/dist/discover-DTmFeloL.cjs +0 -271
  427. package/dist/discover-DTmFeloL.cjs.map +0 -1
  428. package/dist/dokploy-api-5cK2InBm.cjs +0 -3
  429. package/dist/dokploy-api-D2Ny4Jrc.mjs +0 -3
  430. package/dist/dokploy-api-pdaBryoY.mjs +0 -706
  431. package/dist/dokploy-api-pdaBryoY.mjs.map +0 -1
  432. package/dist/dokploy-api-zqKe9lHH.cjs +0 -718
  433. package/dist/dokploy-api-zqKe9lHH.cjs.map +0 -1
  434. package/dist/emit-CIlvnDvV.mjs.map +0 -1
  435. package/dist/emit-CUD1BWls.cjs.map +0 -1
  436. package/dist/encryption-D2pL3tHH.cjs +0 -54
  437. package/dist/encryption-D2pL3tHH.cjs.map +0 -1
  438. package/dist/encryption-YDsXXi6w.mjs +0 -3
  439. package/dist/encryption-_4zwjOAR.mjs +0 -42
  440. package/dist/encryption-_4zwjOAR.mjs.map +0 -1
  441. package/dist/encryption-sQ2Oxx0d.cjs +0 -4
  442. package/dist/fullstack-secrets-D6MyHhQP.cjs +0 -111
  443. package/dist/fullstack-secrets-D6MyHhQP.cjs.map +0 -1
  444. package/dist/fullstack-secrets-METaRLS1.mjs +0 -87
  445. package/dist/fullstack-secrets-METaRLS1.mjs.map +0 -1
  446. package/dist/generator-CNzBw7g5.cjs +0 -289
  447. package/dist/generator-CNzBw7g5.cjs.map +0 -1
  448. package/dist/generator-VE2JrFlY.mjs +0 -253
  449. package/dist/generator-VE2JrFlY.mjs.map +0 -1
  450. package/dist/github-BrvaPkFf.cjs +0 -197
  451. package/dist/github-BrvaPkFf.cjs.map +0 -1
  452. package/dist/github-CrpsXSfV.mjs +0 -196
  453. package/dist/github-CrpsXSfV.mjs.map +0 -1
  454. package/dist/index-Ayxg_DQY.d.mts.map +0 -1
  455. package/dist/index-CR5urhWX.d.cts.map +0 -1
  456. package/dist/keystore-C9rint2E.cjs +0 -101
  457. package/dist/keystore-C9rint2E.cjs.map +0 -1
  458. package/dist/keystore-TxeYM7an.mjs +0 -83
  459. package/dist/keystore-TxeYM7an.mjs.map +0 -1
  460. package/dist/openapi-DaKlTKxz.cjs +0 -2075
  461. package/dist/openapi-DaKlTKxz.cjs.map +0 -1
  462. package/dist/openapi-react-query-BKH334Ug.cjs +0 -173
  463. package/dist/openapi-react-query-BKH334Ug.cjs.map +0 -1
  464. package/dist/openapi-react-query-DoR5CmzQ.mjs +0 -167
  465. package/dist/openapi-react-query-DoR5CmzQ.mjs.map +0 -1
  466. package/dist/openapi-react-query.cjs +0 -4
  467. package/dist/openapi-react-query.d.cts +0 -11
  468. package/dist/openapi-react-query.d.cts.map +0 -1
  469. package/dist/openapi-react-query.d.mts +0 -11
  470. package/dist/openapi-react-query.d.mts.map +0 -1
  471. package/dist/openapi-react-query.mjs +0 -4
  472. package/dist/openapi-y1d7Kalt.mjs +0 -2021
  473. package/dist/openapi-y1d7Kalt.mjs.map +0 -1
  474. package/dist/reconcile-C13ERt1U.mjs.map +0 -1
  475. package/dist/reconcile-CYMhFSYy.cjs.map +0 -1
  476. package/dist/setup-BWgMs4gg.mjs +0 -12
  477. package/dist/setup-DOv92pIu.cjs +0 -473
  478. package/dist/setup-DOv92pIu.cjs.map +0 -1
  479. package/dist/setup-DQo_h_yK.mjs +0 -443
  480. package/dist/setup-DQo_h_yK.mjs.map +0 -1
  481. package/dist/setup-lCx_DcUo.cjs +0 -12
  482. package/dist/storage-B020InPW.mjs +0 -222
  483. package/dist/storage-B020InPW.mjs.map +0 -1
  484. package/dist/storage-CSNplaJn.cjs +0 -282
  485. package/dist/storage-CSNplaJn.cjs.map +0 -1
  486. package/dist/storage-DGBzMLZa.mjs +0 -4
  487. package/dist/storage-DlVol_oj.cjs +0 -8
  488. package/dist/sync-0ILCb-1S.cjs +0 -93
  489. package/dist/sync-0ILCb-1S.cjs.map +0 -1
  490. package/dist/sync-CzHXiR9c.mjs +0 -76
  491. package/dist/sync-CzHXiR9c.mjs.map +0 -1
  492. package/dist/sync-DYENfOt4.cjs +0 -4
  493. package/dist/sync-HAau6h_R.mjs +0 -3
  494. package/dist/types-CL7jPFM2.d.mts +0 -2220
  495. package/dist/types-CL7jPFM2.d.mts.map +0 -1
  496. package/dist/types-Y3fKQSAK.d.cts +0 -2220
  497. package/dist/types-Y3fKQSAK.d.cts.map +0 -1
  498. package/dist/workspace-C-a3G_U0.cjs.map +0 -1
  499. package/dist/workspace-DQxxs7Jk.cjs +0 -10
  500. package/dist/workspace-DaEX7FEg.mjs.map +0 -1
  501. package/dist/workspace-DbI580qS.mjs +0 -9
@@ -0,0 +1,237 @@
1
+ import { t as GkmError } from "./errors-D8Gwp5kU.mjs";
2
+ import { a as discriminatedUnion, c as literal, d as object, f as record, g as unknown, n as array, p as string, r as boolean, t as _enum, v as toJSONSchema } from "./schemas-BCwKKA42.mjs";
3
+ import { i as discover, l as runWorker, t as ConstructDiscoveryFailed } from "./discover-Ca8U75dl.mjs";
4
+ import { i as activeSandbox } from "./sandbox-CbVB7uOD.mjs";
5
+ import { provideKey } from "@geekmidas/manifest";
6
+ import { decodeCredentials } from "@geekmidas/constructs/credential";
7
+ //#region src/secrets/credentialSchemas.ts
8
+ /**
9
+ * A third party's credentials, checked against the schema of the construct
10
+ * that reads them — before they are stored, and before a deploy builds
11
+ * anything with them.
12
+ *
13
+ * The schema lives on the construct (`ExternalApi.credentialsSchema`,
14
+ * `Credential.credentialsSchema`), which is the project's code. So the
15
+ * constructs are loaded where a deploy loads them: in the run's sandbox when
16
+ * there is one, here otherwise. What comes back is data only — each schema as
17
+ * JSON Schema where it can say so, and `{ ok, issues }` for each value asked
18
+ * about — because a live schema cannot cross an isolating sandbox. A value
19
+ * asked about goes in as a secret file, never an argument, and no issue
20
+ * carries it back: an issue is a path and a message.
21
+ */
22
+ /** The credentials keys a manifest declares, by the construct that reads each. */
23
+ function credentialKeys(manifest) {
24
+ return Object.entries(manifest).flatMap(([id, declaration]) => declaration.kind === "external-api" || declaration.kind === "credential" ? [{
25
+ key: provideKey(id, "credentials"),
26
+ id,
27
+ kind: declaration.kind
28
+ }] : []);
29
+ }
30
+ /** The constructs that read a third party's credentials, with their schemas. */
31
+ function liveCredentials(manifest, sources) {
32
+ return credentialKeys(manifest).flatMap(({ key, id, kind }) => {
33
+ const schema = (sources[id]?.construct)?.credentialsSchema;
34
+ return isStandardSchema(schema) ? [{
35
+ key,
36
+ id,
37
+ kind,
38
+ schema
39
+ }] : [];
40
+ });
41
+ }
42
+ function isStandardSchema(value) {
43
+ return typeof value === "object" && value !== null && typeof value["~standard"]?.validate === "function";
44
+ }
45
+ /**
46
+ * A schema as JSON Schema: through the Standard JSON Schema extension where
47
+ * the schema has it, as zod 4's does, else zod's own converter — or nothing,
48
+ * for a schema neither can describe.
49
+ */
50
+ function jsonSchemaOf(schema) {
51
+ const standard = schema["~standard"];
52
+ try {
53
+ const described = standard.jsonSchema?.input?.({ target: "draft-2020-12" });
54
+ if (described) return described;
55
+ } catch {}
56
+ if (typeof schema === "object" && schema !== null && "_zod" in schema) try {
57
+ return toJSONSchema(schema, { io: "input" });
58
+ } catch {
59
+ return;
60
+ }
61
+ }
62
+ /** A stored value against its schema, read the way the construct reads it. */
63
+ async function checkCredential(schema, raw) {
64
+ const result = await schema["~standard"].validate(decodeCredentials(raw));
65
+ if (!result.issues) return {
66
+ ok: true,
67
+ issues: []
68
+ };
69
+ return {
70
+ ok: false,
71
+ issues: result.issues.map((issue) => ({
72
+ path: (issue.path ?? []).map((segment) => typeof segment === "object" ? String(segment.key) : String(segment)).join("."),
73
+ message: issue.message
74
+ }))
75
+ };
76
+ }
77
+ /** What a set of live credentials says about some values: data only. */
78
+ async function inspectLive(live, values) {
79
+ const checks = {};
80
+ for (const credential of live) {
81
+ const value = values[credential.key];
82
+ if (value === void 0) continue;
83
+ checks[credential.key] = await checkCredential(credential.schema, value);
84
+ }
85
+ return {
86
+ schemas: live.map(({ key, id, kind, schema }) => {
87
+ const jsonSchema = jsonSchemaOf(schema);
88
+ return {
89
+ key,
90
+ id,
91
+ kind,
92
+ ...jsonSchema ? { jsonSchema } : {}
93
+ };
94
+ }),
95
+ checks
96
+ };
97
+ }
98
+ const Issue = object({
99
+ path: string(),
100
+ message: string()
101
+ });
102
+ /** What the credentials worker answers. Checked: the worker ran project code. */
103
+ const CredentialsAnswer = discriminatedUnion("reason", [object({
104
+ reason: literal("inspected"),
105
+ schemas: array(object({
106
+ key: string(),
107
+ id: string(),
108
+ kind: _enum(["external-api", "credential"]),
109
+ jsonSchema: record(string(), unknown()).optional()
110
+ })),
111
+ checks: record(string(), object({
112
+ ok: boolean(),
113
+ issues: array(Issue)
114
+ }))
115
+ }), object({
116
+ reason: literal("failed"),
117
+ error: object({
118
+ name: string(),
119
+ message: string()
120
+ }).loose()
121
+ })]);
122
+ /** How long loading the constructs to check credentials may take. */
123
+ const INSPECT_TIMEOUT_MS = 6e4;
124
+ /**
125
+ * The workspace's credential schemas, and what each of `values` comes to —
126
+ * loaded in the run's sandbox when there is one, here otherwise.
127
+ */
128
+ async function inspectCredentials(options) {
129
+ const sandbox = activeSandbox();
130
+ if (!sandbox) return (await loadCredentialSchemasHere(options)).inspect(options.values ?? {});
131
+ const secrets = Object.fromEntries(Object.entries(options.values ?? {}).filter(([key]) => key.endsWith("_CREDENTIALS")));
132
+ const { value } = await runWorker(sandbox, "credentials check", {
133
+ name: "credentials-worker",
134
+ args: [JSON.stringify({
135
+ patterns: options.patterns,
136
+ cwd: options.root
137
+ })],
138
+ cwd: options.root,
139
+ timeoutMs: INSPECT_TIMEOUT_MS,
140
+ schema: CredentialsAnswer,
141
+ ...Object.keys(secrets).length > 0 ? { secrets } : {}
142
+ });
143
+ if (value.reason === "failed") throw new ConstructDiscoveryFailed(value.error.name, value.error.message);
144
+ const { schemas, checks } = value;
145
+ return {
146
+ schemas: schemas.map(({ jsonSchema, ...rest }) => ({
147
+ ...rest,
148
+ ...jsonSchema ? { jsonSchema } : {}
149
+ })),
150
+ checks
151
+ };
152
+ }
153
+ /** The constructs loaded once, here, and asked about as often as needed. */
154
+ async function loadCredentialSchemasHere(options) {
155
+ const sources = {};
156
+ const live = liveCredentials(await discover({
157
+ patterns: [...options.patterns],
158
+ cwd: options.root,
159
+ sources
160
+ }), sources);
161
+ return { inspect: (values) => inspectLive(live, values) };
162
+ }
163
+ /**
164
+ * The workspace's credential schemas, for a command that checks values one
165
+ * at a time as they are typed. In-process the constructs are loaded once;
166
+ * in a sandbox each check is a run of the worker.
167
+ */
168
+ async function loadCredentialSchemas(options) {
169
+ const here = activeSandbox() ? void 0 : await loadCredentialSchemasHere(options);
170
+ const inspect = (values) => here ? here.inspect(values) : inspectCredentials({
171
+ ...options,
172
+ values
173
+ });
174
+ const { schemas } = await inspect({});
175
+ return {
176
+ schemas,
177
+ async check(key, raw) {
178
+ if (!schemas.some((s) => s.key === key)) return {
179
+ ok: true,
180
+ issues: []
181
+ };
182
+ const { checks } = await inspect({ [key]: raw });
183
+ return checks[key] ?? {
184
+ ok: true,
185
+ issues: []
186
+ };
187
+ }
188
+ };
189
+ }
190
+ /** An issue as the line that names it: `SHIPPING_CREDENTIALS.apiKey: …`. */
191
+ function issueLine(key, issue) {
192
+ return `${key}${issue.path ? `.${issue.path}` : ""}: ${issue.message}`;
193
+ }
194
+ /**
195
+ * Credentials their construct's schema refuses — on their way into the
196
+ * stage's secrets, or already there when a deploy reads them. The values are
197
+ * never in the message: only where each is wrong, and why.
198
+ */
199
+ var CredentialsInvalid = class extends GkmError {
200
+ stage;
201
+ invalid;
202
+ during;
203
+ constructor(stage, invalid, during) {
204
+ const lines = invalid.flatMap(({ key, issues }) => issues.map((issue) => ` ${issueLine(key, issue)}`));
205
+ const keys = invalid.map((i) => i.key);
206
+ super(during === "set" ? `${keys.join(", ")} is not what its construct's schema describes, so nothing was saved:\n\n${lines.join("\n")}\n\nSet a value that matches, or let gkm ask for each field: gkm secrets:add --stage ${stage}` : `The stage '${stage}' holds ${keys.length === 1 ? "a credential" : "credentials"} ${keys.length === 1 ? "its construct's schema refuses" : "their constructs' schemas refuse"}, and every app reading ${keys.length === 1 ? "it" : "them"} would fail as it starts:\n\n${lines.join("\n")}\n\nSet ${keys.length === 1 ? "it" : "them"} again, field by field: gkm secrets:add --stage ${stage}`);
207
+ this.stage = stage;
208
+ this.invalid = invalid;
209
+ this.during = during;
210
+ this.name = "CredentialsInvalid";
211
+ }
212
+ };
213
+ /**
214
+ * Every credential the stage holds for a construct, against its schema —
215
+ * before a deploy builds anything with one the app would refuse as it
216
+ * starts. Loads nothing when the stage holds none.
217
+ *
218
+ * @throws {CredentialsInvalid} naming each key and every issue
219
+ */
220
+ async function assertStageCredentials(options) {
221
+ const values = Object.fromEntries(credentialKeys(options.manifest).map(({ key }) => [key, options.supplied[key]]).filter((entry) => entry[1] !== void 0));
222
+ if (Object.keys(values).length === 0) return;
223
+ const { checks } = await inspectCredentials({
224
+ root: options.root,
225
+ patterns: options.patterns,
226
+ values
227
+ });
228
+ const invalid = Object.entries(checks).filter(([, check]) => !check.ok).map(([key, check]) => ({
229
+ key,
230
+ issues: check.issues
231
+ })).sort((a, b) => a.key.localeCompare(b.key));
232
+ if (invalid.length > 0) throw new CredentialsInvalid(options.stage, invalid, "deploy");
233
+ }
234
+ //#endregion
235
+ export { liveCredentials as a, issueLine as i, assertStageCredentials as n, loadCredentialSchemas as o, inspectLive as r, CredentialsInvalid as t };
236
+
237
+ //# sourceMappingURL=credentialSchemas-Cf5Pf8VE.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentialSchemas-Cf5Pf8VE.mjs","names":["z.toJSONSchema","z.object","z.string","z.discriminatedUnion","z.literal","z.array","z.enum","z.record","z.unknown","z.boolean"],"sources":["../src/secrets/credentialSchemas.ts"],"sourcesContent":["/**\n * A third party's credentials, checked against the schema of the construct\n * that reads them — before they are stored, and before a deploy builds\n * anything with them.\n *\n * The schema lives on the construct (`ExternalApi.credentialsSchema`,\n * `Credential.credentialsSchema`), which is the project's code. So the\n * constructs are loaded where a deploy loads them: in the run's sandbox when\n * there is one, here otherwise. What comes back is data only — each schema as\n * JSON Schema where it can say so, and `{ ok, issues }` for each value asked\n * about — because a live schema cannot cross an isolating sandbox. A value\n * asked about goes in as a secret file, never an argument, and no issue\n * carries it back: an issue is a path and a message.\n */\n\nimport { decodeCredentials } from '@geekmidas/constructs/credential';\nimport { type ConstructManifest, provideKey } from '@geekmidas/manifest';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { z } from 'zod';\nimport { GkmError } from '../errors';\nimport {\n\tConstructDiscoveryFailed,\n\ttype ConstructSource,\n\tdiscover,\n} from '../reconcile/discover';\nimport { activeSandbox } from '../sandbox/sandbox';\nimport { runWorker } from '../sandbox/worker';\n\n/** One thing a schema refused: where in the value, and why. */\nexport interface CredentialIssue {\n\t/** Dotted, from the value's root — `apiKey`, `keys.0`; empty for the root. */\n\tpath: string;\n\tmessage: string;\n}\n\n/** What a candidate value came to. */\nexport interface CredentialCheck {\n\tok: boolean;\n\tissues: CredentialIssue[];\n}\n\n/** A construct's credentials key, and its schema as data. */\nexport interface CredentialSchemaInfo {\n\tkey: string;\n\tid: string;\n\tkind: 'external-api' | 'credential';\n\t/**\n\t * The schema as JSON Schema, where the schema can say — zod's, or any\n\t * Standard JSON Schema. Absent otherwise: the value is asked for as JSON.\n\t */\n\tjsonSchema?: Record<string, unknown>;\n}\n\n/** What loading the constructs answers. */\nexport interface CredentialInspection {\n\tschemas: CredentialSchemaInfo[];\n\t/** Each value asked about, by key. */\n\tchecks: Record<string, CredentialCheck>;\n}\n\n/** A construct whose credentials have a schema. */\ninterface LiveCredential {\n\tkey: string;\n\tid: string;\n\tkind: 'external-api' | 'credential';\n\tschema: StandardSchemaV1;\n}\n\n/** The credentials keys a manifest declares, by the construct that reads each. */\nexport function credentialKeys(\n\tmanifest: ConstructManifest,\n): { key: string; id: string; kind: 'external-api' | 'credential' }[] {\n\treturn Object.entries(manifest).flatMap(([id, declaration]) =>\n\t\tdeclaration.kind === 'external-api' || declaration.kind === 'credential'\n\t\t\t? [{ key: provideKey(id, 'credentials'), id, kind: declaration.kind }]\n\t\t\t: [],\n\t);\n}\n\n/** The constructs that read a third party's credentials, with their schemas. */\nexport function liveCredentials(\n\tmanifest: ConstructManifest,\n\tsources: Readonly<Record<string, ConstructSource>>,\n): LiveCredential[] {\n\treturn credentialKeys(manifest).flatMap(({ key, id, kind }) => {\n\t\tconst schema = (sources[id]?.construct as { credentialsSchema?: unknown })\n\t\t\t?.credentialsSchema;\n\t\treturn isStandardSchema(schema) ? [{ key, id, kind, schema }] : [];\n\t});\n}\n\nfunction isStandardSchema(value: unknown): value is StandardSchemaV1 {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\ttypeof (value as StandardSchemaV1)['~standard']?.validate === 'function'\n\t);\n}\n\n/**\n * A schema as JSON Schema: through the Standard JSON Schema extension where\n * the schema has it, as zod 4's does, else zod's own converter — or nothing,\n * for a schema neither can describe.\n */\nexport function jsonSchemaOf(\n\tschema: StandardSchemaV1,\n): Record<string, unknown> | undefined {\n\tconst standard = schema['~standard'] as StandardSchemaV1['~standard'] & {\n\t\tjsonSchema?: {\n\t\t\tinput?: (options: { target: string }) => Record<string, unknown>;\n\t\t};\n\t};\n\ttry {\n\t\tconst described = standard.jsonSchema?.input?.({\n\t\t\ttarget: 'draft-2020-12',\n\t\t});\n\t\tif (described) return described;\n\t} catch {\n\t\t// A type JSON Schema cannot express: try zod's converter, then nothing.\n\t}\n\tif (typeof schema === 'object' && schema !== null && '_zod' in schema) {\n\t\ttry {\n\t\t\treturn z.toJSONSchema(schema as unknown as z.ZodType, {\n\t\t\t\tio: 'input',\n\t\t\t}) as Record<string, unknown>;\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\treturn undefined;\n}\n\n/** A stored value against its schema, read the way the construct reads it. */\nexport async function checkCredential(\n\tschema: StandardSchemaV1,\n\traw: string,\n): Promise<CredentialCheck> {\n\tconst result = await schema['~standard'].validate(decodeCredentials(raw));\n\tif (!result.issues) return { ok: true, issues: [] };\n\treturn {\n\t\tok: false,\n\t\tissues: result.issues.map((issue) => ({\n\t\t\tpath: (issue.path ?? [])\n\t\t\t\t.map((segment) =>\n\t\t\t\t\ttypeof segment === 'object' ? String(segment.key) : String(segment),\n\t\t\t\t)\n\t\t\t\t.join('.'),\n\t\t\tmessage: issue.message,\n\t\t})),\n\t};\n}\n\n/** What a set of live credentials says about some values: data only. */\nexport async function inspectLive(\n\tlive: readonly LiveCredential[],\n\tvalues: Readonly<Record<string, string>>,\n): Promise<CredentialInspection> {\n\tconst checks: Record<string, CredentialCheck> = {};\n\tfor (const credential of live) {\n\t\tconst value = values[credential.key];\n\t\tif (value === undefined) continue;\n\t\tchecks[credential.key] = await checkCredential(credential.schema, value);\n\t}\n\treturn {\n\t\tschemas: live.map(({ key, id, kind, schema }) => {\n\t\t\tconst jsonSchema = jsonSchemaOf(schema);\n\t\t\treturn { key, id, kind, ...(jsonSchema ? { jsonSchema } : {}) };\n\t\t}),\n\t\tchecks,\n\t};\n}\n\nexport interface InspectOptions {\n\t/** The workspace root. */\n\troot: string;\n\t/** Its construct globs. */\n\tpatterns: readonly string[];\n\t/** The values to check, by key. Only credentials keys are looked at. */\n\tvalues?: Readonly<Record<string, string>>;\n}\n\nconst Issue = z.object({ path: z.string(), message: z.string() });\n\n/** What the credentials worker answers. Checked: the worker ran project code. */\nconst CredentialsAnswer = z.discriminatedUnion('reason', [\n\tz.object({\n\t\treason: z.literal('inspected'),\n\t\tschemas: z.array(\n\t\t\tz.object({\n\t\t\t\tkey: z.string(),\n\t\t\t\tid: z.string(),\n\t\t\t\tkind: z.enum(['external-api', 'credential']),\n\t\t\t\tjsonSchema: z.record(z.string(), z.unknown()).optional(),\n\t\t\t}),\n\t\t),\n\t\tchecks: z.record(\n\t\t\tz.string(),\n\t\t\tz.object({ ok: z.boolean(), issues: z.array(Issue) }),\n\t\t),\n\t}),\n\tz.object({\n\t\treason: z.literal('failed'),\n\t\terror: z.object({ name: z.string(), message: z.string() }).loose(),\n\t}),\n]);\n\n/** How long loading the constructs to check credentials may take. */\nconst INSPECT_TIMEOUT_MS = 60_000;\n\n/**\n * The workspace's credential schemas, and what each of `values` comes to —\n * loaded in the run's sandbox when there is one, here otherwise.\n */\nexport async function inspectCredentials(\n\toptions: InspectOptions,\n): Promise<CredentialInspection> {\n\tconst sandbox = activeSandbox();\n\tif (!sandbox) {\n\t\treturn (await loadCredentialSchemasHere(options)).inspect(\n\t\t\toptions.values ?? {},\n\t\t);\n\t}\n\n\tconst secrets = Object.fromEntries(\n\t\tObject.entries(options.values ?? {}).filter(([key]) =>\n\t\t\tkey.endsWith('_CREDENTIALS'),\n\t\t),\n\t);\n\tconst { value } = await runWorker(sandbox, 'credentials check', {\n\t\tname: 'credentials-worker',\n\t\targs: [JSON.stringify({ patterns: options.patterns, cwd: options.root })],\n\t\tcwd: options.root,\n\t\ttimeoutMs: INSPECT_TIMEOUT_MS,\n\t\tschema: CredentialsAnswer,\n\t\t...(Object.keys(secrets).length > 0 ? { secrets } : {}),\n\t});\n\tif (value.reason === 'failed') {\n\t\tthrow new ConstructDiscoveryFailed(value.error.name, value.error.message);\n\t}\n\tconst { schemas, checks } = value;\n\treturn {\n\t\tschemas: schemas.map(({ jsonSchema, ...rest }) => ({\n\t\t\t...rest,\n\t\t\t...(jsonSchema ? { jsonSchema } : {}),\n\t\t})),\n\t\tchecks,\n\t};\n}\n\n/** The constructs loaded once, here, and asked about as often as needed. */\nasync function loadCredentialSchemasHere(options: InspectOptions): Promise<{\n\tinspect(\n\t\tvalues: Readonly<Record<string, string>>,\n\t): Promise<CredentialInspection>;\n}> {\n\tconst sources: Record<string, ConstructSource> = {};\n\tconst manifest = await discover({\n\t\tpatterns: [...options.patterns],\n\t\tcwd: options.root,\n\t\tsources,\n\t});\n\tconst live = liveCredentials(manifest, sources);\n\treturn { inspect: (values) => inspectLive(live, values) };\n}\n\n/** The schemas, and a check of one candidate value at a time. */\nexport interface CredentialSchemas {\n\tschemas: CredentialSchemaInfo[];\n\t/** `raw` against `key`'s schema; ok for a key no schema describes. */\n\tcheck(key: string, raw: string): Promise<CredentialCheck>;\n}\n\n/**\n * The workspace's credential schemas, for a command that checks values one\n * at a time as they are typed. In-process the constructs are loaded once;\n * in a sandbox each check is a run of the worker.\n */\nexport async function loadCredentialSchemas(\n\toptions: Omit<InspectOptions, 'values'>,\n): Promise<CredentialSchemas> {\n\tconst here = activeSandbox()\n\t\t? undefined\n\t\t: await loadCredentialSchemasHere(options);\n\tconst inspect = (values: Readonly<Record<string, string>>) =>\n\t\there ? here.inspect(values) : inspectCredentials({ ...options, values });\n\n\tconst { schemas } = await inspect({});\n\treturn {\n\t\tschemas,\n\t\tasync check(key, raw) {\n\t\t\tif (!schemas.some((s) => s.key === key)) return { ok: true, issues: [] };\n\t\t\tconst { checks } = await inspect({ [key]: raw });\n\t\t\treturn checks[key] ?? { ok: true, issues: [] };\n\t\t},\n\t};\n}\n\n/** One stored credential its schema refuses. */\nexport interface InvalidCredential {\n\tkey: string;\n\tissues: CredentialIssue[];\n}\n\n/** An issue as the line that names it: `SHIPPING_CREDENTIALS.apiKey: …`. */\nexport function issueLine(key: string, issue: CredentialIssue): string {\n\treturn `${key}${issue.path ? `.${issue.path}` : ''}: ${issue.message}`;\n}\n\n/**\n * Credentials their construct's schema refuses — on their way into the\n * stage's secrets, or already there when a deploy reads them. The values are\n * never in the message: only where each is wrong, and why.\n */\nexport class CredentialsInvalid extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly invalid: readonly InvalidCredential[],\n\t\t/** Whether a value was being set (and was not saved), or deployed. */\n\t\treadonly during: 'set' | 'deploy',\n\t) {\n\t\tconst lines = invalid.flatMap(({ key, issues }) =>\n\t\t\tissues.map((issue) => ` ${issueLine(key, issue)}`),\n\t\t);\n\t\tconst keys = invalid.map((i) => i.key);\n\t\tsuper(\n\t\t\tduring === 'set'\n\t\t\t\t? `${keys.join(', ')} is not what its construct's schema describes, ` +\n\t\t\t\t\t\t`so nothing was saved:\\n\\n${lines.join('\\n')}\\n\\n` +\n\t\t\t\t\t\t`Set a value that matches, or let gkm ask for each field: ` +\n\t\t\t\t\t\t`gkm secrets:add --stage ${stage}`\n\t\t\t\t: `The stage '${stage}' holds ${keys.length === 1 ? 'a credential' : 'credentials'} ` +\n\t\t\t\t\t\t`${keys.length === 1 ? \"its construct's schema refuses\" : \"their constructs' schemas refuse\"}, ` +\n\t\t\t\t\t\t`and every app reading ${keys.length === 1 ? 'it' : 'them'} would fail ` +\n\t\t\t\t\t\t`as it starts:\\n\\n${lines.join('\\n')}\\n\\n` +\n\t\t\t\t\t\t`Set ${keys.length === 1 ? 'it' : 'them'} again, field by field: ` +\n\t\t\t\t\t\t`gkm secrets:add --stage ${stage}`,\n\t\t);\n\t\tthis.name = 'CredentialsInvalid';\n\t}\n}\n\n/**\n * Every credential the stage holds for a construct, against its schema —\n * before a deploy builds anything with one the app would refuse as it\n * starts. Loads nothing when the stage holds none.\n *\n * @throws {CredentialsInvalid} naming each key and every issue\n */\nexport async function assertStageCredentials(options: {\n\troot: string;\n\tpatterns: readonly string[];\n\tmanifest: ConstructManifest;\n\tstage: string;\n\tsupplied: Readonly<Record<string, string>>;\n}): Promise<void> {\n\tconst values = Object.fromEntries(\n\t\tcredentialKeys(options.manifest)\n\t\t\t.map(({ key }) => [key, options.supplied[key]] as const)\n\t\t\t.filter((entry): entry is [string, string] => entry[1] !== undefined),\n\t);\n\tif (Object.keys(values).length === 0) return;\n\n\tconst { checks } = await inspectCredentials({\n\t\troot: options.root,\n\t\tpatterns: options.patterns,\n\t\tvalues,\n\t});\n\tconst invalid = Object.entries(checks)\n\t\t.filter(([, check]) => !check.ok)\n\t\t.map(([key, check]) => ({ key, issues: check.issues }))\n\t\t.sort((a, b) => a.key.localeCompare(b.key));\n\tif (invalid.length > 0) {\n\t\tthrow new CredentialsInvalid(options.stage, invalid, 'deploy');\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;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CAAC,WAAW,GAAG;CAEtC,MAAM,EAAE,WAAW,MAAM,mBAAmB;EAC3C,MAAM,QAAQ;EACd,UAAU,QAAQ;EAClB;CACD,CAAC;CACD,MAAM,UAAU,OAAO,QAAQ,MAAM,CAAC,CACpC,QAAQ,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,CAChC,KAAK,CAAC,KAAK,YAAY;EAAE;EAAK,QAAQ,MAAM;CAAO,EAAE,CAAC,CACtD,MAAM,GAAG,MAAM,EAAE,IAAI,cAAc,EAAE,GAAG,CAAC;CAC3C,IAAI,QAAQ,SAAS,GACpB,MAAM,IAAI,mBAAmB,QAAQ,OAAO,SAAS,QAAQ;AAE/D"}
@@ -0,0 +1,272 @@
1
+ const require_errors = require("./errors-DMC4Umsb.cjs");
2
+ const require_schemas = require("./schemas-BQ_v0lEX.cjs");
3
+ const require_discover = require("./discover-Bsr7HjqJ.cjs");
4
+ const require_sandbox = require("./sandbox-CHv3OYXg.cjs");
5
+ let _geekmidas_manifest = require("@geekmidas/manifest");
6
+ let _geekmidas_constructs_credential = require("@geekmidas/constructs/credential");
7
+ //#region src/secrets/credentialSchemas.ts
8
+ /**
9
+ * A third party's credentials, checked against the schema of the construct
10
+ * that reads them — before they are stored, and before a deploy builds
11
+ * anything with them.
12
+ *
13
+ * The schema lives on the construct (`ExternalApi.credentialsSchema`,
14
+ * `Credential.credentialsSchema`), which is the project's code. So the
15
+ * constructs are loaded where a deploy loads them: in the run's sandbox when
16
+ * there is one, here otherwise. What comes back is data only — each schema as
17
+ * JSON Schema where it can say so, and `{ ok, issues }` for each value asked
18
+ * about — because a live schema cannot cross an isolating sandbox. A value
19
+ * asked about goes in as a secret file, never an argument, and no issue
20
+ * carries it back: an issue is a path and a message.
21
+ */
22
+ /** The credentials keys a manifest declares, by the construct that reads each. */
23
+ function credentialKeys(manifest) {
24
+ return Object.entries(manifest).flatMap(([id, declaration]) => declaration.kind === "external-api" || declaration.kind === "credential" ? [{
25
+ key: (0, _geekmidas_manifest.provideKey)(id, "credentials"),
26
+ id,
27
+ kind: declaration.kind
28
+ }] : []);
29
+ }
30
+ /** The constructs that read a third party's credentials, with their schemas. */
31
+ function liveCredentials(manifest, sources) {
32
+ return credentialKeys(manifest).flatMap(({ key, id, kind }) => {
33
+ const schema = (sources[id]?.construct)?.credentialsSchema;
34
+ return isStandardSchema(schema) ? [{
35
+ key,
36
+ id,
37
+ kind,
38
+ schema
39
+ }] : [];
40
+ });
41
+ }
42
+ function isStandardSchema(value) {
43
+ return typeof value === "object" && value !== null && typeof value["~standard"]?.validate === "function";
44
+ }
45
+ /**
46
+ * A schema as JSON Schema: through the Standard JSON Schema extension where
47
+ * the schema has it, as zod 4's does, else zod's own converter — or nothing,
48
+ * for a schema neither can describe.
49
+ */
50
+ function jsonSchemaOf(schema) {
51
+ const standard = schema["~standard"];
52
+ try {
53
+ const described = standard.jsonSchema?.input?.({ target: "draft-2020-12" });
54
+ if (described) return described;
55
+ } catch {}
56
+ if (typeof schema === "object" && schema !== null && "_zod" in schema) try {
57
+ return require_schemas.toJSONSchema(schema, { io: "input" });
58
+ } catch {
59
+ return;
60
+ }
61
+ }
62
+ /** A stored value against its schema, read the way the construct reads it. */
63
+ async function checkCredential(schema, raw) {
64
+ const result = await schema["~standard"].validate((0, _geekmidas_constructs_credential.decodeCredentials)(raw));
65
+ if (!result.issues) return {
66
+ ok: true,
67
+ issues: []
68
+ };
69
+ return {
70
+ ok: false,
71
+ issues: result.issues.map((issue) => ({
72
+ path: (issue.path ?? []).map((segment) => typeof segment === "object" ? String(segment.key) : String(segment)).join("."),
73
+ message: issue.message
74
+ }))
75
+ };
76
+ }
77
+ /** What a set of live credentials says about some values: data only. */
78
+ async function inspectLive(live, values) {
79
+ const checks = {};
80
+ for (const credential of live) {
81
+ const value = values[credential.key];
82
+ if (value === void 0) continue;
83
+ checks[credential.key] = await checkCredential(credential.schema, value);
84
+ }
85
+ return {
86
+ schemas: live.map(({ key, id, kind, schema }) => {
87
+ const jsonSchema = jsonSchemaOf(schema);
88
+ return {
89
+ key,
90
+ id,
91
+ kind,
92
+ ...jsonSchema ? { jsonSchema } : {}
93
+ };
94
+ }),
95
+ checks
96
+ };
97
+ }
98
+ const Issue = require_schemas.object({
99
+ path: require_schemas.string(),
100
+ message: require_schemas.string()
101
+ });
102
+ /** What the credentials worker answers. Checked: the worker ran project code. */
103
+ const CredentialsAnswer = require_schemas.discriminatedUnion("reason", [require_schemas.object({
104
+ reason: require_schemas.literal("inspected"),
105
+ schemas: require_schemas.array(require_schemas.object({
106
+ key: require_schemas.string(),
107
+ id: require_schemas.string(),
108
+ kind: require_schemas._enum(["external-api", "credential"]),
109
+ jsonSchema: require_schemas.record(require_schemas.string(), require_schemas.unknown()).optional()
110
+ })),
111
+ checks: require_schemas.record(require_schemas.string(), require_schemas.object({
112
+ ok: require_schemas.boolean(),
113
+ issues: require_schemas.array(Issue)
114
+ }))
115
+ }), require_schemas.object({
116
+ reason: require_schemas.literal("failed"),
117
+ error: require_schemas.object({
118
+ name: require_schemas.string(),
119
+ message: require_schemas.string()
120
+ }).loose()
121
+ })]);
122
+ /** How long loading the constructs to check credentials may take. */
123
+ const INSPECT_TIMEOUT_MS = 6e4;
124
+ /**
125
+ * The workspace's credential schemas, and what each of `values` comes to —
126
+ * loaded in the run's sandbox when there is one, here otherwise.
127
+ */
128
+ async function inspectCredentials(options) {
129
+ const sandbox = require_sandbox.activeSandbox();
130
+ if (!sandbox) return (await loadCredentialSchemasHere(options)).inspect(options.values ?? {});
131
+ const secrets = Object.fromEntries(Object.entries(options.values ?? {}).filter(([key]) => key.endsWith("_CREDENTIALS")));
132
+ const { value } = await require_discover.runWorker(sandbox, "credentials check", {
133
+ name: "credentials-worker",
134
+ args: [JSON.stringify({
135
+ patterns: options.patterns,
136
+ cwd: options.root
137
+ })],
138
+ cwd: options.root,
139
+ timeoutMs: INSPECT_TIMEOUT_MS,
140
+ schema: CredentialsAnswer,
141
+ ...Object.keys(secrets).length > 0 ? { secrets } : {}
142
+ });
143
+ if (value.reason === "failed") throw new require_discover.ConstructDiscoveryFailed(value.error.name, value.error.message);
144
+ const { schemas, checks } = value;
145
+ return {
146
+ schemas: schemas.map(({ jsonSchema, ...rest }) => ({
147
+ ...rest,
148
+ ...jsonSchema ? { jsonSchema } : {}
149
+ })),
150
+ checks
151
+ };
152
+ }
153
+ /** The constructs loaded once, here, and asked about as often as needed. */
154
+ async function loadCredentialSchemasHere(options) {
155
+ const sources = {};
156
+ const live = liveCredentials(await require_discover.discover({
157
+ patterns: [...options.patterns],
158
+ cwd: options.root,
159
+ sources
160
+ }), sources);
161
+ return { inspect: (values) => inspectLive(live, values) };
162
+ }
163
+ /**
164
+ * The workspace's credential schemas, for a command that checks values one
165
+ * at a time as they are typed. In-process the constructs are loaded once;
166
+ * in a sandbox each check is a run of the worker.
167
+ */
168
+ async function loadCredentialSchemas(options) {
169
+ const here = require_sandbox.activeSandbox() ? void 0 : await loadCredentialSchemasHere(options);
170
+ const inspect = (values) => here ? here.inspect(values) : inspectCredentials({
171
+ ...options,
172
+ values
173
+ });
174
+ const { schemas } = await inspect({});
175
+ return {
176
+ schemas,
177
+ async check(key, raw) {
178
+ if (!schemas.some((s) => s.key === key)) return {
179
+ ok: true,
180
+ issues: []
181
+ };
182
+ const { checks } = await inspect({ [key]: raw });
183
+ return checks[key] ?? {
184
+ ok: true,
185
+ issues: []
186
+ };
187
+ }
188
+ };
189
+ }
190
+ /** An issue as the line that names it: `SHIPPING_CREDENTIALS.apiKey: …`. */
191
+ function issueLine(key, issue) {
192
+ return `${key}${issue.path ? `.${issue.path}` : ""}: ${issue.message}`;
193
+ }
194
+ /**
195
+ * Credentials their construct's schema refuses — on their way into the
196
+ * stage's secrets, or already there when a deploy reads them. The values are
197
+ * never in the message: only where each is wrong, and why.
198
+ */
199
+ var CredentialsInvalid = class extends require_errors.GkmError {
200
+ stage;
201
+ invalid;
202
+ during;
203
+ constructor(stage, invalid, during) {
204
+ const lines = invalid.flatMap(({ key, issues }) => issues.map((issue) => ` ${issueLine(key, issue)}`));
205
+ const keys = invalid.map((i) => i.key);
206
+ super(during === "set" ? `${keys.join(", ")} is not what its construct's schema describes, so nothing was saved:\n\n${lines.join("\n")}\n\nSet a value that matches, or let gkm ask for each field: gkm secrets:add --stage ${stage}` : `The stage '${stage}' holds ${keys.length === 1 ? "a credential" : "credentials"} ${keys.length === 1 ? "its construct's schema refuses" : "their constructs' schemas refuse"}, and every app reading ${keys.length === 1 ? "it" : "them"} would fail as it starts:\n\n${lines.join("\n")}\n\nSet ${keys.length === 1 ? "it" : "them"} again, field by field: gkm secrets:add --stage ${stage}`);
207
+ this.stage = stage;
208
+ this.invalid = invalid;
209
+ this.during = during;
210
+ this.name = "CredentialsInvalid";
211
+ }
212
+ };
213
+ /**
214
+ * Every credential the stage holds for a construct, against its schema —
215
+ * before a deploy builds anything with one the app would refuse as it
216
+ * starts. Loads nothing when the stage holds none.
217
+ *
218
+ * @throws {CredentialsInvalid} naming each key and every issue
219
+ */
220
+ async function assertStageCredentials(options) {
221
+ const values = Object.fromEntries(credentialKeys(options.manifest).map(({ key }) => [key, options.supplied[key]]).filter((entry) => entry[1] !== void 0));
222
+ if (Object.keys(values).length === 0) return;
223
+ const { checks } = await inspectCredentials({
224
+ root: options.root,
225
+ patterns: options.patterns,
226
+ values
227
+ });
228
+ const invalid = Object.entries(checks).filter(([, check]) => !check.ok).map(([key, check]) => ({
229
+ key,
230
+ issues: check.issues
231
+ })).sort((a, b) => a.key.localeCompare(b.key));
232
+ if (invalid.length > 0) throw new CredentialsInvalid(options.stage, invalid, "deploy");
233
+ }
234
+ //#endregion
235
+ Object.defineProperty(exports, "CredentialsInvalid", {
236
+ enumerable: true,
237
+ get: function() {
238
+ return CredentialsInvalid;
239
+ }
240
+ });
241
+ Object.defineProperty(exports, "assertStageCredentials", {
242
+ enumerable: true,
243
+ get: function() {
244
+ return assertStageCredentials;
245
+ }
246
+ });
247
+ Object.defineProperty(exports, "inspectLive", {
248
+ enumerable: true,
249
+ get: function() {
250
+ return inspectLive;
251
+ }
252
+ });
253
+ Object.defineProperty(exports, "issueLine", {
254
+ enumerable: true,
255
+ get: function() {
256
+ return issueLine;
257
+ }
258
+ });
259
+ Object.defineProperty(exports, "liveCredentials", {
260
+ enumerable: true,
261
+ get: function() {
262
+ return liveCredentials;
263
+ }
264
+ });
265
+ Object.defineProperty(exports, "loadCredentialSchemas", {
266
+ enumerable: true,
267
+ get: function() {
268
+ return loadCredentialSchemas;
269
+ }
270
+ });
271
+
272
+ //# sourceMappingURL=credentialSchemas-D_VUCDUh.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentialSchemas-D_VUCDUh.cjs","names":["provideKey","decodeCredentials","activeSandbox","runWorker","ConstructDiscoveryFailed","discover","GkmError"],"sources":["../src/secrets/credentialSchemas.ts"],"sourcesContent":["/**\n * A third party's credentials, checked against the schema of the construct\n * that reads them — before they are stored, and before a deploy builds\n * anything with them.\n *\n * The schema lives on the construct (`ExternalApi.credentialsSchema`,\n * `Credential.credentialsSchema`), which is the project's code. So the\n * constructs are loaded where a deploy loads them: in the run's sandbox when\n * there is one, here otherwise. What comes back is data only — each schema as\n * JSON Schema where it can say so, and `{ ok, issues }` for each value asked\n * about — because a live schema cannot cross an isolating sandbox. A value\n * asked about goes in as a secret file, never an argument, and no issue\n * carries it back: an issue is a path and a message.\n */\n\nimport { decodeCredentials } from '@geekmidas/constructs/credential';\nimport { type ConstructManifest, provideKey } from '@geekmidas/manifest';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { z } from 'zod';\nimport { GkmError } from '../errors';\nimport {\n\tConstructDiscoveryFailed,\n\ttype ConstructSource,\n\tdiscover,\n} from '../reconcile/discover';\nimport { activeSandbox } from '../sandbox/sandbox';\nimport { runWorker } from '../sandbox/worker';\n\n/** One thing a schema refused: where in the value, and why. */\nexport interface CredentialIssue {\n\t/** Dotted, from the value's root — `apiKey`, `keys.0`; empty for the root. */\n\tpath: string;\n\tmessage: string;\n}\n\n/** What a candidate value came to. */\nexport interface CredentialCheck {\n\tok: boolean;\n\tissues: CredentialIssue[];\n}\n\n/** A construct's credentials key, and its schema as data. */\nexport interface CredentialSchemaInfo {\n\tkey: string;\n\tid: string;\n\tkind: 'external-api' | 'credential';\n\t/**\n\t * The schema as JSON Schema, where the schema can say — zod's, or any\n\t * Standard JSON Schema. Absent otherwise: the value is asked for as JSON.\n\t */\n\tjsonSchema?: Record<string, unknown>;\n}\n\n/** What loading the constructs answers. */\nexport interface CredentialInspection {\n\tschemas: CredentialSchemaInfo[];\n\t/** Each value asked about, by key. */\n\tchecks: Record<string, CredentialCheck>;\n}\n\n/** A construct whose credentials have a schema. */\ninterface LiveCredential {\n\tkey: string;\n\tid: string;\n\tkind: 'external-api' | 'credential';\n\tschema: StandardSchemaV1;\n}\n\n/** The credentials keys a manifest declares, by the construct that reads each. */\nexport function credentialKeys(\n\tmanifest: ConstructManifest,\n): { key: string; id: string; kind: 'external-api' | 'credential' }[] {\n\treturn Object.entries(manifest).flatMap(([id, declaration]) =>\n\t\tdeclaration.kind === 'external-api' || declaration.kind === 'credential'\n\t\t\t? [{ key: provideKey(id, 'credentials'), id, kind: declaration.kind }]\n\t\t\t: [],\n\t);\n}\n\n/** The constructs that read a third party's credentials, with their schemas. */\nexport function liveCredentials(\n\tmanifest: ConstructManifest,\n\tsources: Readonly<Record<string, ConstructSource>>,\n): LiveCredential[] {\n\treturn credentialKeys(manifest).flatMap(({ key, id, kind }) => {\n\t\tconst schema = (sources[id]?.construct as { credentialsSchema?: unknown })\n\t\t\t?.credentialsSchema;\n\t\treturn isStandardSchema(schema) ? [{ key, id, kind, schema }] : [];\n\t});\n}\n\nfunction isStandardSchema(value: unknown): value is StandardSchemaV1 {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\ttypeof (value as StandardSchemaV1)['~standard']?.validate === 'function'\n\t);\n}\n\n/**\n * A schema as JSON Schema: through the Standard JSON Schema extension where\n * the schema has it, as zod 4's does, else zod's own converter — or nothing,\n * for a schema neither can describe.\n */\nexport function jsonSchemaOf(\n\tschema: StandardSchemaV1,\n): Record<string, unknown> | undefined {\n\tconst standard = schema['~standard'] as StandardSchemaV1['~standard'] & {\n\t\tjsonSchema?: {\n\t\t\tinput?: (options: { target: string }) => Record<string, unknown>;\n\t\t};\n\t};\n\ttry {\n\t\tconst described = standard.jsonSchema?.input?.({\n\t\t\ttarget: 'draft-2020-12',\n\t\t});\n\t\tif (described) return described;\n\t} catch {\n\t\t// A type JSON Schema cannot express: try zod's converter, then nothing.\n\t}\n\tif (typeof schema === 'object' && schema !== null && '_zod' in schema) {\n\t\ttry {\n\t\t\treturn z.toJSONSchema(schema as unknown as z.ZodType, {\n\t\t\t\tio: 'input',\n\t\t\t}) as Record<string, unknown>;\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\treturn undefined;\n}\n\n/** A stored value against its schema, read the way the construct reads it. */\nexport async function checkCredential(\n\tschema: StandardSchemaV1,\n\traw: string,\n): Promise<CredentialCheck> {\n\tconst result = await schema['~standard'].validate(decodeCredentials(raw));\n\tif (!result.issues) return { ok: true, issues: [] };\n\treturn {\n\t\tok: false,\n\t\tissues: result.issues.map((issue) => ({\n\t\t\tpath: (issue.path ?? [])\n\t\t\t\t.map((segment) =>\n\t\t\t\t\ttypeof segment === 'object' ? String(segment.key) : String(segment),\n\t\t\t\t)\n\t\t\t\t.join('.'),\n\t\t\tmessage: issue.message,\n\t\t})),\n\t};\n}\n\n/** What a set of live credentials says about some values: data only. */\nexport async function inspectLive(\n\tlive: readonly LiveCredential[],\n\tvalues: Readonly<Record<string, string>>,\n): Promise<CredentialInspection> {\n\tconst checks: Record<string, CredentialCheck> = {};\n\tfor (const credential of live) {\n\t\tconst value = values[credential.key];\n\t\tif (value === undefined) continue;\n\t\tchecks[credential.key] = await checkCredential(credential.schema, value);\n\t}\n\treturn {\n\t\tschemas: live.map(({ key, id, kind, schema }) => {\n\t\t\tconst jsonSchema = jsonSchemaOf(schema);\n\t\t\treturn { key, id, kind, ...(jsonSchema ? { jsonSchema } : {}) };\n\t\t}),\n\t\tchecks,\n\t};\n}\n\nexport interface InspectOptions {\n\t/** The workspace root. */\n\troot: string;\n\t/** Its construct globs. */\n\tpatterns: readonly string[];\n\t/** The values to check, by key. Only credentials keys are looked at. */\n\tvalues?: Readonly<Record<string, string>>;\n}\n\nconst Issue = z.object({ path: z.string(), message: z.string() });\n\n/** What the credentials worker answers. Checked: the worker ran project code. */\nconst CredentialsAnswer = z.discriminatedUnion('reason', [\n\tz.object({\n\t\treason: z.literal('inspected'),\n\t\tschemas: z.array(\n\t\t\tz.object({\n\t\t\t\tkey: z.string(),\n\t\t\t\tid: z.string(),\n\t\t\t\tkind: z.enum(['external-api', 'credential']),\n\t\t\t\tjsonSchema: z.record(z.string(), z.unknown()).optional(),\n\t\t\t}),\n\t\t),\n\t\tchecks: z.record(\n\t\t\tz.string(),\n\t\t\tz.object({ ok: z.boolean(), issues: z.array(Issue) }),\n\t\t),\n\t}),\n\tz.object({\n\t\treason: z.literal('failed'),\n\t\terror: z.object({ name: z.string(), message: z.string() }).loose(),\n\t}),\n]);\n\n/** How long loading the constructs to check credentials may take. */\nconst INSPECT_TIMEOUT_MS = 60_000;\n\n/**\n * The workspace's credential schemas, and what each of `values` comes to —\n * loaded in the run's sandbox when there is one, here otherwise.\n */\nexport async function inspectCredentials(\n\toptions: InspectOptions,\n): Promise<CredentialInspection> {\n\tconst sandbox = activeSandbox();\n\tif (!sandbox) {\n\t\treturn (await loadCredentialSchemasHere(options)).inspect(\n\t\t\toptions.values ?? {},\n\t\t);\n\t}\n\n\tconst secrets = Object.fromEntries(\n\t\tObject.entries(options.values ?? {}).filter(([key]) =>\n\t\t\tkey.endsWith('_CREDENTIALS'),\n\t\t),\n\t);\n\tconst { value } = await runWorker(sandbox, 'credentials check', {\n\t\tname: 'credentials-worker',\n\t\targs: [JSON.stringify({ patterns: options.patterns, cwd: options.root })],\n\t\tcwd: options.root,\n\t\ttimeoutMs: INSPECT_TIMEOUT_MS,\n\t\tschema: CredentialsAnswer,\n\t\t...(Object.keys(secrets).length > 0 ? { secrets } : {}),\n\t});\n\tif (value.reason === 'failed') {\n\t\tthrow new ConstructDiscoveryFailed(value.error.name, value.error.message);\n\t}\n\tconst { schemas, checks } = value;\n\treturn {\n\t\tschemas: schemas.map(({ jsonSchema, ...rest }) => ({\n\t\t\t...rest,\n\t\t\t...(jsonSchema ? { jsonSchema } : {}),\n\t\t})),\n\t\tchecks,\n\t};\n}\n\n/** The constructs loaded once, here, and asked about as often as needed. */\nasync function loadCredentialSchemasHere(options: InspectOptions): Promise<{\n\tinspect(\n\t\tvalues: Readonly<Record<string, string>>,\n\t): Promise<CredentialInspection>;\n}> {\n\tconst sources: Record<string, ConstructSource> = {};\n\tconst manifest = await discover({\n\t\tpatterns: [...options.patterns],\n\t\tcwd: options.root,\n\t\tsources,\n\t});\n\tconst live = liveCredentials(manifest, sources);\n\treturn { inspect: (values) => inspectLive(live, values) };\n}\n\n/** The schemas, and a check of one candidate value at a time. */\nexport interface CredentialSchemas {\n\tschemas: CredentialSchemaInfo[];\n\t/** `raw` against `key`'s schema; ok for a key no schema describes. */\n\tcheck(key: string, raw: string): Promise<CredentialCheck>;\n}\n\n/**\n * The workspace's credential schemas, for a command that checks values one\n * at a time as they are typed. In-process the constructs are loaded once;\n * in a sandbox each check is a run of the worker.\n */\nexport async function loadCredentialSchemas(\n\toptions: Omit<InspectOptions, 'values'>,\n): Promise<CredentialSchemas> {\n\tconst here = activeSandbox()\n\t\t? undefined\n\t\t: await loadCredentialSchemasHere(options);\n\tconst inspect = (values: Readonly<Record<string, string>>) =>\n\t\there ? here.inspect(values) : inspectCredentials({ ...options, values });\n\n\tconst { schemas } = await inspect({});\n\treturn {\n\t\tschemas,\n\t\tasync check(key, raw) {\n\t\t\tif (!schemas.some((s) => s.key === key)) return { ok: true, issues: [] };\n\t\t\tconst { checks } = await inspect({ [key]: raw });\n\t\t\treturn checks[key] ?? { ok: true, issues: [] };\n\t\t},\n\t};\n}\n\n/** One stored credential its schema refuses. */\nexport interface InvalidCredential {\n\tkey: string;\n\tissues: CredentialIssue[];\n}\n\n/** An issue as the line that names it: `SHIPPING_CREDENTIALS.apiKey: …`. */\nexport function issueLine(key: string, issue: CredentialIssue): string {\n\treturn `${key}${issue.path ? `.${issue.path}` : ''}: ${issue.message}`;\n}\n\n/**\n * Credentials their construct's schema refuses — on their way into the\n * stage's secrets, or already there when a deploy reads them. The values are\n * never in the message: only where each is wrong, and why.\n */\nexport class CredentialsInvalid extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly invalid: readonly InvalidCredential[],\n\t\t/** Whether a value was being set (and was not saved), or deployed. */\n\t\treadonly during: 'set' | 'deploy',\n\t) {\n\t\tconst lines = invalid.flatMap(({ key, issues }) =>\n\t\t\tissues.map((issue) => ` ${issueLine(key, issue)}`),\n\t\t);\n\t\tconst keys = invalid.map((i) => i.key);\n\t\tsuper(\n\t\t\tduring === 'set'\n\t\t\t\t? `${keys.join(', ')} is not what its construct's schema describes, ` +\n\t\t\t\t\t\t`so nothing was saved:\\n\\n${lines.join('\\n')}\\n\\n` +\n\t\t\t\t\t\t`Set a value that matches, or let gkm ask for each field: ` +\n\t\t\t\t\t\t`gkm secrets:add --stage ${stage}`\n\t\t\t\t: `The stage '${stage}' holds ${keys.length === 1 ? 'a credential' : 'credentials'} ` +\n\t\t\t\t\t\t`${keys.length === 1 ? \"its construct's schema refuses\" : \"their constructs' schemas refuse\"}, ` +\n\t\t\t\t\t\t`and every app reading ${keys.length === 1 ? 'it' : 'them'} would fail ` +\n\t\t\t\t\t\t`as it starts:\\n\\n${lines.join('\\n')}\\n\\n` +\n\t\t\t\t\t\t`Set ${keys.length === 1 ? 'it' : 'them'} again, field by field: ` +\n\t\t\t\t\t\t`gkm secrets:add --stage ${stage}`,\n\t\t);\n\t\tthis.name = 'CredentialsInvalid';\n\t}\n}\n\n/**\n * Every credential the stage holds for a construct, against its schema —\n * before a deploy builds anything with one the app would refuse as it\n * starts. Loads nothing when the stage holds none.\n *\n * @throws {CredentialsInvalid} naming each key and every issue\n */\nexport async function assertStageCredentials(options: {\n\troot: string;\n\tpatterns: readonly string[];\n\tmanifest: ConstructManifest;\n\tstage: string;\n\tsupplied: Readonly<Record<string, string>>;\n}): Promise<void> {\n\tconst values = Object.fromEntries(\n\t\tcredentialKeys(options.manifest)\n\t\t\t.map(({ key }) => [key, options.supplied[key]] as const)\n\t\t\t.filter((entry): entry is [string, string] => entry[1] !== undefined),\n\t);\n\tif (Object.keys(values).length === 0) return;\n\n\tconst { checks } = await inspectCredentials({\n\t\troot: options.root,\n\t\tpatterns: options.patterns,\n\t\tvalues,\n\t});\n\tconst invalid = Object.entries(checks)\n\t\t.filter(([, check]) => !check.ok)\n\t\t.map(([key, check]) => ({ key, issues: check.issues }))\n\t\t.sort((a, b) => a.key.localeCompare(b.key));\n\tif (invalid.length > 0) {\n\t\tthrow new CredentialsInvalid(options.stage, invalid, 'deploy');\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAqEA,SAAgB,eACf,UACqE;CACrE,OAAO,OAAO,QAAQ,QAAQ,CAAC,CAAC,SAAS,CAAC,IAAI,iBAC7C,YAAY,SAAS,kBAAkB,YAAY,SAAS,eACzD,CAAC;EAAE,MAAA,GAAKA,oBAAAA,WAAAA,CAAW,IAAI,aAAa;EAAG;EAAI,MAAM,YAAY;CAAK,CAAC,IACnE,CAAC,CACL;AACD;;AAGA,SAAgB,gBACf,UACA,SACmB;CACnB,OAAO,eAAe,QAAQ,CAAC,CAAC,SAAS,EAAE,KAAK,IAAI,WAAW;EAC9D,MAAM,UAAU,QAAQ,GAAG,EAAE,UAAA,EAC1B;EACH,OAAO,iBAAiB,MAAM,IAAI,CAAC;GAAE;GAAK;GAAI;GAAM;EAAO,CAAC,IAAI,CAAC;CAClE,CAAC;AACF;AAEA,SAAS,iBAAiB,OAA2C;CACpE,OACC,OAAO,U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