alchemy 2.0.0-beta.65 → 2.0.0-beta.67

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 (959) hide show
  1. package/bin/exec.js +578 -224
  2. package/bin/exec.js.map +1 -1
  3. package/lib/AWS/ApiGateway/common.d.ts.map +1 -1
  4. package/lib/AWS/ApiGateway/common.js +8 -1
  5. package/lib/AWS/ApiGateway/common.js.map +1 -1
  6. package/lib/AWS/Bedrock/LanguageModel.d.ts +208 -0
  7. package/lib/AWS/Bedrock/LanguageModel.d.ts.map +1 -0
  8. package/lib/AWS/Bedrock/LanguageModel.js +508 -0
  9. package/lib/AWS/Bedrock/LanguageModel.js.map +1 -0
  10. package/lib/AWS/Bedrock/LanguageModelHttp.d.ts +10 -0
  11. package/lib/AWS/Bedrock/LanguageModelHttp.d.ts.map +1 -0
  12. package/lib/AWS/Bedrock/LanguageModelHttp.js +26 -0
  13. package/lib/AWS/Bedrock/LanguageModelHttp.js.map +1 -0
  14. package/lib/AWS/Bedrock/index.d.ts +2 -0
  15. package/lib/AWS/Bedrock/index.d.ts.map +1 -1
  16. package/lib/AWS/Bedrock/index.js +2 -0
  17. package/lib/AWS/Bedrock/index.js.map +1 -1
  18. package/lib/AWS/CloudFront/Distribution.d.ts +24 -0
  19. package/lib/AWS/CloudFront/Distribution.d.ts.map +1 -1
  20. package/lib/AWS/CloudFront/Distribution.js +89 -4
  21. package/lib/AWS/CloudFront/Distribution.js.map +1 -1
  22. package/lib/AWS/CostExplorer/AnomalyMonitor.d.ts +1 -1
  23. package/lib/AWS/CostExplorer/AnomalyMonitor.d.ts.map +1 -1
  24. package/lib/AWS/CostExplorer/AnomalySubscription.d.ts +1 -1
  25. package/lib/AWS/CostExplorer/AnomalySubscription.d.ts.map +1 -1
  26. package/lib/AWS/CostExplorer/BindingHttp.d.ts +3 -3
  27. package/lib/AWS/CostExplorer/BindingHttp.d.ts.map +1 -1
  28. package/lib/AWS/CostExplorer/CostCategory.d.ts +1 -1
  29. package/lib/AWS/CostExplorer/CostCategory.d.ts.map +1 -1
  30. package/lib/AWS/CostExplorer/GetAnomaliesHttp.d.ts +1 -1
  31. package/lib/AWS/CostExplorer/GetAnomaliesHttp.d.ts.map +1 -1
  32. package/lib/AWS/CostExplorer/GetApproximateUsageRecordsHttp.d.ts +1 -1
  33. package/lib/AWS/CostExplorer/GetApproximateUsageRecordsHttp.d.ts.map +1 -1
  34. package/lib/AWS/CostExplorer/GetCommitmentPurchaseAnalysisHttp.d.ts +1 -1
  35. package/lib/AWS/CostExplorer/GetCommitmentPurchaseAnalysisHttp.d.ts.map +1 -1
  36. package/lib/AWS/CostExplorer/GetCostAndUsageComparisonsHttp.d.ts +1 -1
  37. package/lib/AWS/CostExplorer/GetCostAndUsageComparisonsHttp.d.ts.map +1 -1
  38. package/lib/AWS/CostExplorer/GetCostAndUsageHttp.d.ts +1 -1
  39. package/lib/AWS/CostExplorer/GetCostAndUsageHttp.d.ts.map +1 -1
  40. package/lib/AWS/CostExplorer/GetCostAndUsageWithResourcesHttp.d.ts +1 -1
  41. package/lib/AWS/CostExplorer/GetCostAndUsageWithResourcesHttp.d.ts.map +1 -1
  42. package/lib/AWS/CostExplorer/GetCostCategoriesHttp.d.ts +1 -1
  43. package/lib/AWS/CostExplorer/GetCostCategoriesHttp.d.ts.map +1 -1
  44. package/lib/AWS/CostExplorer/GetCostComparisonDriversHttp.d.ts +1 -1
  45. package/lib/AWS/CostExplorer/GetCostComparisonDriversHttp.d.ts.map +1 -1
  46. package/lib/AWS/CostExplorer/GetCostForecastHttp.d.ts +1 -1
  47. package/lib/AWS/CostExplorer/GetCostForecastHttp.d.ts.map +1 -1
  48. package/lib/AWS/CostExplorer/GetDimensionValuesHttp.d.ts +1 -1
  49. package/lib/AWS/CostExplorer/GetDimensionValuesHttp.d.ts.map +1 -1
  50. package/lib/AWS/CostExplorer/GetReservationCoverageHttp.d.ts +1 -1
  51. package/lib/AWS/CostExplorer/GetReservationCoverageHttp.d.ts.map +1 -1
  52. package/lib/AWS/CostExplorer/GetReservationPurchaseRecommendationHttp.d.ts +1 -1
  53. package/lib/AWS/CostExplorer/GetReservationPurchaseRecommendationHttp.d.ts.map +1 -1
  54. package/lib/AWS/CostExplorer/GetReservationUtilizationHttp.d.ts +1 -1
  55. package/lib/AWS/CostExplorer/GetReservationUtilizationHttp.d.ts.map +1 -1
  56. package/lib/AWS/CostExplorer/GetRightsizingRecommendationHttp.d.ts +1 -1
  57. package/lib/AWS/CostExplorer/GetRightsizingRecommendationHttp.d.ts.map +1 -1
  58. package/lib/AWS/CostExplorer/GetSavingsPlanPurchaseRecommendationDetailsHttp.d.ts +1 -1
  59. package/lib/AWS/CostExplorer/GetSavingsPlanPurchaseRecommendationDetailsHttp.d.ts.map +1 -1
  60. package/lib/AWS/CostExplorer/GetSavingsPlansCoverageHttp.d.ts +1 -1
  61. package/lib/AWS/CostExplorer/GetSavingsPlansCoverageHttp.d.ts.map +1 -1
  62. package/lib/AWS/CostExplorer/GetSavingsPlansPurchaseRecommendationHttp.d.ts +1 -1
  63. package/lib/AWS/CostExplorer/GetSavingsPlansPurchaseRecommendationHttp.d.ts.map +1 -1
  64. package/lib/AWS/CostExplorer/GetSavingsPlansUtilizationDetailsHttp.d.ts +1 -1
  65. package/lib/AWS/CostExplorer/GetSavingsPlansUtilizationDetailsHttp.d.ts.map +1 -1
  66. package/lib/AWS/CostExplorer/GetSavingsPlansUtilizationHttp.d.ts +1 -1
  67. package/lib/AWS/CostExplorer/GetSavingsPlansUtilizationHttp.d.ts.map +1 -1
  68. package/lib/AWS/CostExplorer/GetTagsHttp.d.ts +1 -1
  69. package/lib/AWS/CostExplorer/GetTagsHttp.d.ts.map +1 -1
  70. package/lib/AWS/CostExplorer/GetUsageForecastHttp.d.ts +1 -1
  71. package/lib/AWS/CostExplorer/GetUsageForecastHttp.d.ts.map +1 -1
  72. package/lib/AWS/CostExplorer/ListCommitmentPurchaseAnalysesHttp.d.ts +1 -1
  73. package/lib/AWS/CostExplorer/ListCommitmentPurchaseAnalysesHttp.d.ts.map +1 -1
  74. package/lib/AWS/CostExplorer/ListCostAllocationTagBackfillHistoryHttp.d.ts +1 -1
  75. package/lib/AWS/CostExplorer/ListCostAllocationTagBackfillHistoryHttp.d.ts.map +1 -1
  76. package/lib/AWS/CostExplorer/ListCostAllocationTagsHttp.d.ts +1 -1
  77. package/lib/AWS/CostExplorer/ListCostAllocationTagsHttp.d.ts.map +1 -1
  78. package/lib/AWS/CostExplorer/ListCostCategoryResourceAssociationsHttp.d.ts +1 -1
  79. package/lib/AWS/CostExplorer/ListCostCategoryResourceAssociationsHttp.d.ts.map +1 -1
  80. package/lib/AWS/CostExplorer/ListSavingsPlansPurchaseRecommendationGenerationHttp.d.ts +1 -1
  81. package/lib/AWS/CostExplorer/ListSavingsPlansPurchaseRecommendationGenerationHttp.d.ts.map +1 -1
  82. package/lib/AWS/CostExplorer/ProvideAnomalyFeedbackHttp.d.ts +1 -1
  83. package/lib/AWS/CostExplorer/ProvideAnomalyFeedbackHttp.d.ts.map +1 -1
  84. package/lib/AWS/CostExplorer/StartCommitmentPurchaseAnalysisHttp.d.ts +1 -1
  85. package/lib/AWS/CostExplorer/StartCommitmentPurchaseAnalysisHttp.d.ts.map +1 -1
  86. package/lib/AWS/CostExplorer/StartCostAllocationTagBackfillHttp.d.ts +1 -1
  87. package/lib/AWS/CostExplorer/StartCostAllocationTagBackfillHttp.d.ts.map +1 -1
  88. package/lib/AWS/CostExplorer/StartSavingsPlansPurchaseRecommendationGenerationHttp.d.ts +1 -1
  89. package/lib/AWS/CostExplorer/StartSavingsPlansPurchaseRecommendationGenerationHttp.d.ts.map +1 -1
  90. package/lib/AWS/CostExplorer/UpdateCostAllocationTagsStatusHttp.d.ts +1 -1
  91. package/lib/AWS/CostExplorer/UpdateCostAllocationTagsStatusHttp.d.ts.map +1 -1
  92. package/lib/AWS/CostExplorer/common.d.ts +5 -3
  93. package/lib/AWS/CostExplorer/common.d.ts.map +1 -1
  94. package/lib/AWS/CostExplorer/common.js +16 -1
  95. package/lib/AWS/CostExplorer/common.js.map +1 -1
  96. package/lib/AWS/DataSync/Task.d.ts.map +1 -1
  97. package/lib/AWS/DataSync/Task.js +16 -2
  98. package/lib/AWS/DataSync/Task.js.map +1 -1
  99. package/lib/AWS/EC2/Vpc.d.ts.map +1 -1
  100. package/lib/AWS/EC2/Vpc.js +15 -2
  101. package/lib/AWS/EC2/Vpc.js.map +1 -1
  102. package/lib/AWS/EC2/hosted.d.ts.map +1 -1
  103. package/lib/AWS/EC2/hosted.js +10 -2
  104. package/lib/AWS/EC2/hosted.js.map +1 -1
  105. package/lib/AWS/ECR/Image.d.ts +132 -13
  106. package/lib/AWS/ECR/Image.d.ts.map +1 -1
  107. package/lib/AWS/ECR/ImageSource.d.ts.map +1 -1
  108. package/lib/AWS/ECR/ImageSource.js +10 -2
  109. package/lib/AWS/ECR/ImageSource.js.map +1 -1
  110. package/lib/AWS/ECR/Repository.d.ts +2 -0
  111. package/lib/AWS/ECR/Repository.d.ts.map +1 -1
  112. package/lib/AWS/ECR/Repository.js +28 -3
  113. package/lib/AWS/ECR/Repository.js.map +1 -1
  114. package/lib/AWS/ECS/Service.d.ts +27 -1
  115. package/lib/AWS/ECS/Service.d.ts.map +1 -1
  116. package/lib/AWS/ECS/Service.js +184 -22
  117. package/lib/AWS/ECS/Service.js.map +1 -1
  118. package/lib/AWS/ECS/Task.d.ts +32 -8
  119. package/lib/AWS/ECS/Task.d.ts.map +1 -1
  120. package/lib/AWS/ECS/Task.js +62 -29
  121. package/lib/AWS/ECS/Task.js.map +1 -1
  122. package/lib/AWS/EKS/Deployment.d.ts.map +1 -1
  123. package/lib/AWS/EKS/Deployment.js +10 -2
  124. package/lib/AWS/EKS/Deployment.js.map +1 -1
  125. package/lib/AWS/EKS/Job.d.ts.map +1 -1
  126. package/lib/AWS/EKS/Job.js +10 -2
  127. package/lib/AWS/EKS/Job.js.map +1 -1
  128. package/lib/AWS/Lambda/Function.d.ts +15 -0
  129. package/lib/AWS/Lambda/Function.d.ts.map +1 -1
  130. package/lib/AWS/Lambda/Function.js +67 -29
  131. package/lib/AWS/Lambda/Function.js.map +1 -1
  132. package/lib/AWS/Lambda/HttpServer.d.ts.map +1 -1
  133. package/lib/AWS/Lambda/HttpServer.js +7 -1
  134. package/lib/AWS/Lambda/HttpServer.js.map +1 -1
  135. package/lib/AWS/Lambda/LayerVersion.d.ts +176 -0
  136. package/lib/AWS/Lambda/LayerVersion.d.ts.map +1 -0
  137. package/lib/AWS/Lambda/LayerVersion.js +288 -0
  138. package/lib/AWS/Lambda/LayerVersion.js.map +1 -0
  139. package/lib/AWS/Lambda/MicrovmBundle.d.ts.map +1 -1
  140. package/lib/AWS/Lambda/MicrovmBundle.js +10 -2
  141. package/lib/AWS/Lambda/MicrovmBundle.js.map +1 -1
  142. package/lib/AWS/Lambda/index.d.ts +1 -0
  143. package/lib/AWS/Lambda/index.d.ts.map +1 -1
  144. package/lib/AWS/Lambda/index.js +1 -0
  145. package/lib/AWS/Lambda/index.js.map +1 -1
  146. package/lib/AWS/Providers.d.ts.map +1 -1
  147. package/lib/AWS/Providers.js +6 -1
  148. package/lib/AWS/Providers.js.map +1 -1
  149. package/lib/AWS/SES/ActiveReceiptRuleSet.d.ts +40 -0
  150. package/lib/AWS/SES/ActiveReceiptRuleSet.d.ts.map +1 -0
  151. package/lib/AWS/SES/ActiveReceiptRuleSet.js +58 -0
  152. package/lib/AWS/SES/ActiveReceiptRuleSet.js.map +1 -0
  153. package/lib/AWS/SES/ReceiptFilter.d.ts +67 -0
  154. package/lib/AWS/SES/ReceiptFilter.d.ts.map +1 -0
  155. package/lib/AWS/SES/ReceiptFilter.js +92 -0
  156. package/lib/AWS/SES/ReceiptFilter.js.map +1 -0
  157. package/lib/AWS/SES/ReceiptRule.d.ts +133 -0
  158. package/lib/AWS/SES/ReceiptRule.d.ts.map +1 -0
  159. package/lib/AWS/SES/ReceiptRule.js +178 -0
  160. package/lib/AWS/SES/ReceiptRule.js.map +1 -0
  161. package/lib/AWS/SES/ReceiptRuleSet.d.ts +55 -0
  162. package/lib/AWS/SES/ReceiptRuleSet.d.ts.map +1 -0
  163. package/lib/AWS/SES/ReceiptRuleSet.js +112 -0
  164. package/lib/AWS/SES/ReceiptRuleSet.js.map +1 -0
  165. package/lib/AWS/SES/SendBounce.d.ts +37 -0
  166. package/lib/AWS/SES/SendBounce.d.ts.map +1 -0
  167. package/lib/AWS/SES/SendBounce.js +3 -0
  168. package/lib/AWS/SES/SendBounce.js.map +1 -0
  169. package/lib/AWS/SES/SendBounceHttp.d.ts +4 -0
  170. package/lib/AWS/SES/SendBounceHttp.d.ts.map +1 -0
  171. package/lib/AWS/SES/SendBounceHttp.js +10 -0
  172. package/lib/AWS/SES/SendBounceHttp.js.map +1 -0
  173. package/lib/AWS/SES/index.d.ts +6 -0
  174. package/lib/AWS/SES/index.d.ts.map +1 -1
  175. package/lib/AWS/SES/index.js +6 -0
  176. package/lib/AWS/SES/index.js.map +1 -1
  177. package/lib/AWS/StateStore/State.d.ts +11 -0
  178. package/lib/AWS/StateStore/State.d.ts.map +1 -1
  179. package/lib/AWS/StateStore/State.js +117 -38
  180. package/lib/AWS/StateStore/State.js.map +1 -1
  181. package/lib/Apply.d.ts +37 -1
  182. package/lib/Apply.d.ts.map +1 -1
  183. package/lib/Apply.js +270 -194
  184. package/lib/Apply.js.map +1 -1
  185. package/lib/Axiom/Telemetry.d.ts +66 -0
  186. package/lib/Axiom/Telemetry.d.ts.map +1 -0
  187. package/lib/Axiom/Telemetry.js +69 -0
  188. package/lib/Axiom/Telemetry.js.map +1 -0
  189. package/lib/Axiom/index.d.ts +1 -0
  190. package/lib/Axiom/index.d.ts.map +1 -1
  191. package/lib/Axiom/index.js +1 -0
  192. package/lib/Axiom/index.js.map +1 -1
  193. package/lib/Bundle/Bundle.d.ts +1 -1
  194. package/lib/Bundle/Bundle.d.ts.map +1 -1
  195. package/lib/Bundle/Bundle.js +14 -6
  196. package/lib/Bundle/Bundle.js.map +1 -1
  197. package/lib/Bundle/BundleAnalyzerPlugin.d.ts +1 -1
  198. package/lib/Bundle/BundleAnalyzerPlugin.d.ts.map +1 -1
  199. package/lib/Bundle/BundleAnalyzerPlugin.js +10 -5
  200. package/lib/Bundle/BundleAnalyzerPlugin.js.map +1 -1
  201. package/lib/Bundle/PurePlugin.d.ts +1 -1
  202. package/lib/Bundle/PurePlugin.d.ts.map +1 -1
  203. package/lib/Bundle/PurePlugin.js +15 -7
  204. package/lib/Bundle/PurePlugin.js.map +1 -1
  205. package/lib/Cli/checkVersion.d.ts +11 -5
  206. package/lib/Cli/checkVersion.d.ts.map +1 -1
  207. package/lib/Cli/checkVersion.js +73 -12
  208. package/lib/Cli/checkVersion.js.map +1 -1
  209. package/lib/Cli/commands/_shared.d.ts.map +1 -1
  210. package/lib/Cli/commands/_shared.js +2 -1
  211. package/lib/Cli/commands/_shared.js.map +1 -1
  212. package/lib/Cli/commands/cloudflare.d.ts +1 -1
  213. package/lib/Cli/commands/deploy.d.ts.map +1 -1
  214. package/lib/Cli/commands/deploy.js +3 -11
  215. package/lib/Cli/commands/deploy.js.map +1 -1
  216. package/lib/Cli/commands/logs.d.ts.map +1 -1
  217. package/lib/Cli/commands/logs.js +3 -1
  218. package/lib/Cli/commands/logs.js.map +1 -1
  219. package/lib/Cli/commands/tail.d.ts.map +1 -1
  220. package/lib/Cli/commands/tail.js +3 -1
  221. package/lib/Cli/commands/tail.js.map +1 -1
  222. package/lib/Cli/main.d.ts.map +1 -1
  223. package/lib/Cli/main.js +5 -4
  224. package/lib/Cli/main.js.map +1 -1
  225. package/lib/Cloudflare/AI/Search.d.ts +4 -15
  226. package/lib/Cloudflare/AI/Search.d.ts.map +1 -1
  227. package/lib/Cloudflare/AI/Search.js +4 -6
  228. package/lib/Cloudflare/AI/Search.js.map +1 -1
  229. package/lib/Cloudflare/AI/SearchInstance.d.ts +7 -26
  230. package/lib/Cloudflare/AI/SearchInstance.d.ts.map +1 -1
  231. package/lib/Cloudflare/AI/SearchInstance.js +7 -26
  232. package/lib/Cloudflare/AI/SearchInstance.js.map +1 -1
  233. package/lib/Cloudflare/ApiToken/AccountApiToken.d.ts +3 -0
  234. package/lib/Cloudflare/ApiToken/AccountApiToken.d.ts.map +1 -1
  235. package/lib/Cloudflare/ApiToken/AccountApiToken.js +3 -0
  236. package/lib/Cloudflare/ApiToken/AccountApiToken.js.map +1 -1
  237. package/lib/Cloudflare/Auth/AuthProvider.d.ts +2 -1
  238. package/lib/Cloudflare/Auth/AuthProvider.d.ts.map +1 -1
  239. package/lib/Cloudflare/Auth/AuthProvider.js +8 -3
  240. package/lib/Cloudflare/Auth/AuthProvider.js.map +1 -1
  241. package/lib/Cloudflare/Auth/OAuthClient.d.ts +5 -0
  242. package/lib/Cloudflare/Auth/OAuthClient.d.ts.map +1 -1
  243. package/lib/Cloudflare/Auth/OAuthClient.js +50 -4
  244. package/lib/Cloudflare/Auth/OAuthClient.js.map +1 -1
  245. package/lib/Cloudflare/Containers/Container.d.ts +81 -3
  246. package/lib/Cloudflare/Containers/Container.d.ts.map +1 -1
  247. package/lib/Cloudflare/Containers/Container.js +70 -0
  248. package/lib/Cloudflare/Containers/Container.js.map +1 -1
  249. package/lib/Cloudflare/Containers/ContainerApplication.d.ts +22 -1
  250. package/lib/Cloudflare/Containers/ContainerApplication.d.ts.map +1 -1
  251. package/lib/Cloudflare/Containers/ContainerApplication.js +4 -1
  252. package/lib/Cloudflare/Containers/ContainerApplication.js.map +1 -1
  253. package/lib/Cloudflare/Containers/ContainerBundle.d.ts.map +1 -1
  254. package/lib/Cloudflare/Containers/ContainerBundle.js +10 -2
  255. package/lib/Cloudflare/Containers/ContainerBundle.js.map +1 -1
  256. package/lib/Cloudflare/Containers/ContainerProvider.d.ts.map +1 -1
  257. package/lib/Cloudflare/Containers/ContainerProvider.js +43 -0
  258. package/lib/Cloudflare/Containers/ContainerProvider.js.map +1 -1
  259. package/lib/Cloudflare/Credentials.d.ts +21 -1
  260. package/lib/Cloudflare/Credentials.d.ts.map +1 -1
  261. package/lib/Cloudflare/Credentials.js +52 -9
  262. package/lib/Cloudflare/Credentials.js.map +1 -1
  263. package/lib/Cloudflare/D1/ApplyMigrations.d.ts +30 -5
  264. package/lib/Cloudflare/D1/ApplyMigrations.d.ts.map +1 -1
  265. package/lib/Cloudflare/D1/ApplyMigrations.js +36 -26
  266. package/lib/Cloudflare/D1/ApplyMigrations.js.map +1 -1
  267. package/lib/Cloudflare/D1/Database.d.ts +18 -1
  268. package/lib/Cloudflare/D1/Database.d.ts.map +1 -1
  269. package/lib/Cloudflare/D1/Database.js +134 -2
  270. package/lib/Cloudflare/D1/Database.js.map +1 -1
  271. package/lib/Cloudflare/D1/LocalD1Gateway.d.ts +39 -0
  272. package/lib/Cloudflare/D1/LocalD1Gateway.d.ts.map +1 -0
  273. package/lib/Cloudflare/D1/LocalD1Gateway.js +100 -0
  274. package/lib/Cloudflare/D1/LocalD1Gateway.js.map +1 -0
  275. package/lib/Cloudflare/D1/QueryDatabaseHttpClient.d.ts +31 -0
  276. package/lib/Cloudflare/D1/QueryDatabaseHttpClient.d.ts.map +1 -1
  277. package/lib/Cloudflare/D1/QueryDatabaseHttpClient.js +13 -6
  278. package/lib/Cloudflare/D1/QueryDatabaseHttpClient.js.map +1 -1
  279. package/lib/Cloudflare/D1/QueryDatabaseLocal.d.ts.map +1 -1
  280. package/lib/Cloudflare/D1/QueryDatabaseLocal.js +21 -2
  281. package/lib/Cloudflare/D1/QueryDatabaseLocal.js.map +1 -1
  282. package/lib/Cloudflare/DNS/Record.d.ts +3 -1
  283. package/lib/Cloudflare/DNS/Record.d.ts.map +1 -1
  284. package/lib/Cloudflare/DNS/Record.js +23 -4
  285. package/lib/Cloudflare/DNS/Record.js.map +1 -1
  286. package/lib/Cloudflare/Email/Address.d.ts.map +1 -1
  287. package/lib/Cloudflare/Email/Address.js +15 -1
  288. package/lib/Cloudflare/Email/Address.js.map +1 -1
  289. package/lib/Cloudflare/Email/SendBinding.d.ts.map +1 -1
  290. package/lib/Cloudflare/Email/SendBinding.js +1 -0
  291. package/lib/Cloudflare/Email/SendBinding.js.map +1 -1
  292. package/lib/Cloudflare/Email/SendEmail.d.ts +12 -0
  293. package/lib/Cloudflare/Email/SendEmail.d.ts.map +1 -1
  294. package/lib/Cloudflare/Email/SendEmail.js +1 -0
  295. package/lib/Cloudflare/Email/SendEmail.js.map +1 -1
  296. package/lib/Cloudflare/Flagship/App.d.ts.map +1 -1
  297. package/lib/Cloudflare/Flagship/App.js +8 -3
  298. package/lib/Cloudflare/Flagship/App.js.map +1 -1
  299. package/lib/Cloudflare/KV/LocalKVGateway.d.ts +15 -0
  300. package/lib/Cloudflare/KV/LocalKVGateway.d.ts.map +1 -0
  301. package/lib/Cloudflare/KV/LocalKVGateway.js +64 -0
  302. package/lib/Cloudflare/KV/LocalKVGateway.js.map +1 -0
  303. package/lib/Cloudflare/KV/Namespace.d.ts +9 -1
  304. package/lib/Cloudflare/KV/Namespace.d.ts.map +1 -1
  305. package/lib/Cloudflare/KV/Namespace.js +45 -1
  306. package/lib/Cloudflare/KV/Namespace.js.map +1 -1
  307. package/lib/Cloudflare/KV/NamespaceLocal.d.ts +16 -5
  308. package/lib/Cloudflare/KV/NamespaceLocal.d.ts.map +1 -1
  309. package/lib/Cloudflare/KV/NamespaceLocal.js +21 -4
  310. package/lib/Cloudflare/KV/NamespaceLocal.js.map +1 -1
  311. package/lib/Cloudflare/KV/ReadNamespaceLocal.d.ts.map +1 -1
  312. package/lib/Cloudflare/KV/ReadNamespaceLocal.js +5 -1
  313. package/lib/Cloudflare/KV/ReadNamespaceLocal.js.map +1 -1
  314. package/lib/Cloudflare/KV/ReadWriteNamespaceLocal.d.ts.map +1 -1
  315. package/lib/Cloudflare/KV/ReadWriteNamespaceLocal.js +5 -1
  316. package/lib/Cloudflare/KV/ReadWriteNamespaceLocal.js.map +1 -1
  317. package/lib/Cloudflare/KV/WriteNamespaceLocal.d.ts.map +1 -1
  318. package/lib/Cloudflare/KV/WriteNamespaceLocal.js +5 -1
  319. package/lib/Cloudflare/KV/WriteNamespaceLocal.js.map +1 -1
  320. package/lib/Cloudflare/LocalGateway.d.ts +25 -0
  321. package/lib/Cloudflare/LocalGateway.d.ts.map +1 -0
  322. package/lib/Cloudflare/LocalGateway.js +70 -0
  323. package/lib/Cloudflare/LocalGateway.js.map +1 -0
  324. package/lib/Cloudflare/LocalRuntime.d.ts +14 -1
  325. package/lib/Cloudflare/LocalRuntime.d.ts.map +1 -1
  326. package/lib/Cloudflare/LocalRuntime.js +16 -1
  327. package/lib/Cloudflare/LocalRuntime.js.map +1 -1
  328. package/lib/Cloudflare/Logs.d.ts.map +1 -1
  329. package/lib/Cloudflare/Logs.js +18 -6
  330. package/lib/Cloudflare/Logs.js.map +1 -1
  331. package/lib/Cloudflare/Providers.d.ts +1 -1
  332. package/lib/Cloudflare/Providers.d.ts.map +1 -1
  333. package/lib/Cloudflare/Providers.js +6 -2
  334. package/lib/Cloudflare/Providers.js.map +1 -1
  335. package/lib/Cloudflare/Queues/Consumer.d.ts +16 -3
  336. package/lib/Cloudflare/Queues/Consumer.d.ts.map +1 -1
  337. package/lib/Cloudflare/Queues/Consumer.js +51 -3
  338. package/lib/Cloudflare/Queues/Consumer.js.map +1 -1
  339. package/lib/Cloudflare/Queues/Queue.d.ts +4 -3
  340. package/lib/Cloudflare/Queues/Queue.d.ts.map +1 -1
  341. package/lib/Cloudflare/Queues/Queue.js +7 -17
  342. package/lib/Cloudflare/Queues/Queue.js.map +1 -1
  343. package/lib/Cloudflare/Queues/QueueBinding.d.ts.map +1 -1
  344. package/lib/Cloudflare/Queues/QueueBinding.js +19 -0
  345. package/lib/Cloudflare/Queues/QueueBinding.js.map +1 -1
  346. package/lib/Cloudflare/Queues/QueueShim.d.ts +55 -0
  347. package/lib/Cloudflare/Queues/QueueShim.d.ts.map +1 -0
  348. package/lib/Cloudflare/Queues/QueueShim.js +177 -0
  349. package/lib/Cloudflare/Queues/QueueShim.js.map +1 -0
  350. package/lib/Cloudflare/R2/Bucket.d.ts +14 -1
  351. package/lib/Cloudflare/R2/Bucket.d.ts.map +1 -1
  352. package/lib/Cloudflare/R2/Bucket.js +53 -1
  353. package/lib/Cloudflare/R2/Bucket.js.map +1 -1
  354. package/lib/Cloudflare/R2/BucketBinding.d.ts +10 -0
  355. package/lib/Cloudflare/R2/BucketBinding.d.ts.map +1 -1
  356. package/lib/Cloudflare/R2/BucketBinding.js +14 -3
  357. package/lib/Cloudflare/R2/BucketBinding.js.map +1 -1
  358. package/lib/Cloudflare/R2/BucketLocal.d.ts +13 -6
  359. package/lib/Cloudflare/R2/BucketLocal.d.ts.map +1 -1
  360. package/lib/Cloudflare/R2/BucketLocal.js +19 -6
  361. package/lib/Cloudflare/R2/BucketLocal.js.map +1 -1
  362. package/lib/Cloudflare/R2/LocalR2Gateway.d.ts +15 -0
  363. package/lib/Cloudflare/R2/LocalR2Gateway.d.ts.map +1 -0
  364. package/lib/Cloudflare/R2/LocalR2Gateway.js +65 -0
  365. package/lib/Cloudflare/R2/LocalR2Gateway.js.map +1 -0
  366. package/lib/Cloudflare/R2/ReadBucketLocal.d.ts.map +1 -1
  367. package/lib/Cloudflare/R2/ReadBucketLocal.js +5 -1
  368. package/lib/Cloudflare/R2/ReadBucketLocal.js.map +1 -1
  369. package/lib/Cloudflare/R2/ReadWriteBucketLocal.d.ts.map +1 -1
  370. package/lib/Cloudflare/R2/ReadWriteBucketLocal.js +5 -1
  371. package/lib/Cloudflare/R2/ReadWriteBucketLocal.js.map +1 -1
  372. package/lib/Cloudflare/R2/WriteBucketLocal.d.ts.map +1 -1
  373. package/lib/Cloudflare/R2/WriteBucketLocal.js +5 -1
  374. package/lib/Cloudflare/R2/WriteBucketLocal.js.map +1 -1
  375. package/lib/Cloudflare/Ruleset/AccountEntrypoint.d.ts.map +1 -1
  376. package/lib/Cloudflare/Ruleset/AccountEntrypoint.js +5 -1
  377. package/lib/Cloudflare/Ruleset/AccountEntrypoint.js.map +1 -1
  378. package/lib/Cloudflare/Ruleset/Ruleset.d.ts.map +1 -1
  379. package/lib/Cloudflare/Ruleset/Ruleset.js +19 -6
  380. package/lib/Cloudflare/Ruleset/Ruleset.js.map +1 -1
  381. package/lib/Cloudflare/Rum/Site.js +10 -2
  382. package/lib/Cloudflare/Rum/Site.js.map +1 -1
  383. package/lib/Cloudflare/StateStore/Api.d.ts +31 -2
  384. package/lib/Cloudflare/StateStore/Api.js +1 -1
  385. package/lib/Cloudflare/StateStore/Api.js.map +1 -1
  386. package/lib/Cloudflare/StateStore/State.d.ts +1 -1
  387. package/lib/Cloudflare/StateStore/State.d.ts.map +1 -1
  388. package/lib/Cloudflare/Tunnel/Tunnel.d.ts.map +1 -1
  389. package/lib/Cloudflare/Tunnel/Tunnel.js +20 -1
  390. package/lib/Cloudflare/Tunnel/Tunnel.js.map +1 -1
  391. package/lib/Cloudflare/Website/StaticSite.d.ts +34 -7
  392. package/lib/Cloudflare/Website/StaticSite.d.ts.map +1 -1
  393. package/lib/Cloudflare/Website/StaticSite.js +108 -24
  394. package/lib/Cloudflare/Website/StaticSite.js.map +1 -1
  395. package/lib/Cloudflare/Website/Vite.d.ts +33 -19
  396. package/lib/Cloudflare/Website/Vite.d.ts.map +1 -1
  397. package/lib/Cloudflare/Website/Vite.js +33 -19
  398. package/lib/Cloudflare/Website/Vite.js.map +1 -1
  399. package/lib/Cloudflare/Workers/Compatibility.d.ts.map +1 -1
  400. package/lib/Cloudflare/Workers/Compatibility.js +26 -7
  401. package/lib/Cloudflare/Workers/Compatibility.js.map +1 -1
  402. package/lib/Cloudflare/Workers/DurableObject.d.ts +22 -0
  403. package/lib/Cloudflare/Workers/DurableObject.d.ts.map +1 -1
  404. package/lib/Cloudflare/Workers/DurableObject.js +22 -0
  405. package/lib/Cloudflare/Workers/DurableObject.js.map +1 -1
  406. package/lib/Cloudflare/Workers/DurableObjectBridge.d.ts.map +1 -1
  407. package/lib/Cloudflare/Workers/DurableObjectBridge.js +20 -5
  408. package/lib/Cloudflare/Workers/DurableObjectBridge.js.map +1 -1
  409. package/lib/Cloudflare/Workers/InferEnv.d.ts +4 -2
  410. package/lib/Cloudflare/Workers/InferEnv.d.ts.map +1 -1
  411. package/lib/Cloudflare/Workers/LocalWorkerProvider.d.ts +7 -3
  412. package/lib/Cloudflare/Workers/LocalWorkerProvider.d.ts.map +1 -1
  413. package/lib/Cloudflare/Workers/LocalWorkerProvider.js +483 -298
  414. package/lib/Cloudflare/Workers/LocalWorkerProvider.js.map +1 -1
  415. package/lib/Cloudflare/Workers/Worker.d.ts +612 -13
  416. package/lib/Cloudflare/Workers/Worker.d.ts.map +1 -1
  417. package/lib/Cloudflare/Workers/Worker.js +222 -1
  418. package/lib/Cloudflare/Workers/Worker.js.map +1 -1
  419. package/lib/Cloudflare/Workers/WorkerAsyncBindings.d.ts +13 -1
  420. package/lib/Cloudflare/Workers/WorkerAsyncBindings.d.ts.map +1 -1
  421. package/lib/Cloudflare/Workers/WorkerAsyncBindings.js +171 -21
  422. package/lib/Cloudflare/Workers/WorkerAsyncBindings.js.map +1 -1
  423. package/lib/Cloudflare/Workers/WorkerBinding.d.ts +130 -28
  424. package/lib/Cloudflare/Workers/WorkerBinding.d.ts.map +1 -1
  425. package/lib/Cloudflare/Workers/WorkerBinding.js.map +1 -1
  426. package/lib/Cloudflare/Workers/WorkerBridge.d.ts +6 -2
  427. package/lib/Cloudflare/Workers/WorkerBridge.d.ts.map +1 -1
  428. package/lib/Cloudflare/Workers/WorkerBridge.js +18 -2
  429. package/lib/Cloudflare/Workers/WorkerBridge.js.map +1 -1
  430. package/lib/Cloudflare/Workers/WorkerBundle.d.ts.map +1 -1
  431. package/lib/Cloudflare/Workers/WorkerBundle.js +4 -1
  432. package/lib/Cloudflare/Workers/WorkerBundle.js.map +1 -1
  433. package/lib/Cloudflare/Workers/WorkerProvider.d.ts +186 -11
  434. package/lib/Cloudflare/Workers/WorkerProvider.d.ts.map +1 -1
  435. package/lib/Cloudflare/Workers/WorkerProvider.js +1765 -236
  436. package/lib/Cloudflare/Workers/WorkerProvider.js.map +1 -1
  437. package/lib/Cloudflare/Workflows/WorkflowBridge.d.ts +7 -1
  438. package/lib/Cloudflare/Workflows/WorkflowBridge.d.ts.map +1 -1
  439. package/lib/Cloudflare/Workflows/WorkflowBridge.js +14 -4
  440. package/lib/Cloudflare/Workflows/WorkflowBridge.js.map +1 -1
  441. package/lib/Command/Build.d.ts +2 -2
  442. package/lib/Command/Build.d.ts.map +1 -1
  443. package/lib/Command/Build.js +4 -7
  444. package/lib/Command/Build.js.map +1 -1
  445. package/lib/Command/Command.d.ts +34 -4
  446. package/lib/Command/Command.d.ts.map +1 -1
  447. package/lib/Command/Command.js +125 -30
  448. package/lib/Command/Command.js.map +1 -1
  449. package/lib/Command/Dev.d.ts +2 -2
  450. package/lib/Command/Dev.d.ts.map +1 -1
  451. package/lib/Command/Dev.js +51 -73
  452. package/lib/Command/Dev.js.map +1 -1
  453. package/lib/Command/Exec.d.ts +11 -2
  454. package/lib/Command/Exec.d.ts.map +1 -1
  455. package/lib/Command/Exec.js +9 -0
  456. package/lib/Command/Exec.js.map +1 -1
  457. package/lib/Command/Memo.d.ts +9 -1
  458. package/lib/Command/Memo.d.ts.map +1 -1
  459. package/lib/Command/Memo.js +14 -2
  460. package/lib/Command/Memo.js.map +1 -1
  461. package/lib/Command/Providers.d.ts +1 -1
  462. package/lib/Command/Providers.d.ts.map +1 -1
  463. package/lib/Command/Redaction.d.ts +10 -0
  464. package/lib/Command/Redaction.d.ts.map +1 -0
  465. package/lib/Command/Redaction.js +119 -0
  466. package/lib/Command/Redaction.js.map +1 -0
  467. package/lib/Deploy.d.ts +2 -1
  468. package/lib/Deploy.d.ts.map +1 -1
  469. package/lib/Destroy.d.ts +2 -1
  470. package/lib/Destroy.d.ts.map +1 -1
  471. package/lib/Destroy.js +1 -9
  472. package/lib/Destroy.js.map +1 -1
  473. package/lib/Docker/Container.d.ts +15 -1
  474. package/lib/Docker/Container.d.ts.map +1 -1
  475. package/lib/Docker/Container.js +34 -11
  476. package/lib/Docker/Container.js.map +1 -1
  477. package/lib/Docker/Context.d.ts +84 -0
  478. package/lib/Docker/Context.d.ts.map +1 -0
  479. package/lib/Docker/Context.js +145 -0
  480. package/lib/Docker/Context.js.map +1 -0
  481. package/lib/Docker/Docker.d.ts +190 -14
  482. package/lib/Docker/Docker.d.ts.map +1 -1
  483. package/lib/Docker/Docker.js +149 -28
  484. package/lib/Docker/Docker.js.map +1 -1
  485. package/lib/Docker/Image.d.ts +12 -0
  486. package/lib/Docker/Image.d.ts.map +1 -1
  487. package/lib/Docker/Image.js +24 -7
  488. package/lib/Docker/Image.js.map +1 -1
  489. package/lib/Docker/Network.d.ts +7 -0
  490. package/lib/Docker/Network.d.ts.map +1 -1
  491. package/lib/Docker/Network.js +16 -7
  492. package/lib/Docker/Network.js.map +1 -1
  493. package/lib/Docker/Providers.d.ts +1 -1
  494. package/lib/Docker/Providers.d.ts.map +1 -1
  495. package/lib/Docker/Providers.js +13 -1
  496. package/lib/Docker/Providers.js.map +1 -1
  497. package/lib/Docker/RemoteImage.d.ts +12 -0
  498. package/lib/Docker/RemoteImage.d.ts.map +1 -1
  499. package/lib/Docker/RemoteImage.js +22 -8
  500. package/lib/Docker/RemoteImage.js.map +1 -1
  501. package/lib/Docker/Service.d.ts +445 -0
  502. package/lib/Docker/Service.d.ts.map +1 -0
  503. package/lib/Docker/Service.js +578 -0
  504. package/lib/Docker/Service.js.map +1 -0
  505. package/lib/Docker/ServiceImage.d.ts +78 -0
  506. package/lib/Docker/ServiceImage.d.ts.map +1 -0
  507. package/lib/Docker/ServiceImage.js +232 -0
  508. package/lib/Docker/ServiceImage.js.map +1 -0
  509. package/lib/Docker/Swarm.d.ts +117 -0
  510. package/lib/Docker/Swarm.d.ts.map +1 -0
  511. package/lib/Docker/Swarm.js +149 -0
  512. package/lib/Docker/Swarm.js.map +1 -0
  513. package/lib/Docker/Volume.d.ts +11 -0
  514. package/lib/Docker/Volume.d.ts.map +1 -1
  515. package/lib/Docker/Volume.js +21 -6
  516. package/lib/Docker/Volume.js.map +1 -1
  517. package/lib/Docker/index.d.ts +3 -0
  518. package/lib/Docker/index.d.ts.map +1 -1
  519. package/lib/Docker/index.js +3 -0
  520. package/lib/Docker/index.js.map +1 -1
  521. package/lib/Http.d.ts +8 -1
  522. package/lib/Http.d.ts.map +1 -1
  523. package/lib/Http.js +7 -2
  524. package/lib/Http.js.map +1 -1
  525. package/lib/Local/LocalProvider.d.ts +182 -0
  526. package/lib/Local/LocalProvider.d.ts.map +1 -0
  527. package/lib/Local/LocalProvider.js +226 -0
  528. package/lib/Local/LocalProvider.js.map +1 -0
  529. package/lib/Local/ProviderLayer.d.ts +43 -2
  530. package/lib/Local/ProviderLayer.d.ts.map +1 -1
  531. package/lib/Local/ProviderLayer.js +80 -2
  532. package/lib/Local/ProviderLayer.js.map +1 -1
  533. package/lib/Local/RpcProvider.d.ts +7 -0
  534. package/lib/Local/RpcProvider.d.ts.map +1 -1
  535. package/lib/Local/RpcProvider.js +8 -3
  536. package/lib/Local/RpcProvider.js.map +1 -1
  537. package/lib/Local/RpcProviderProxy.d.ts.map +1 -1
  538. package/lib/Local/RpcProviderProxy.js +3 -0
  539. package/lib/Local/RpcProviderProxy.js.map +1 -1
  540. package/lib/Local/RpcServer.d.ts +8 -1
  541. package/lib/Local/RpcServer.d.ts.map +1 -1
  542. package/lib/Local/RpcServer.js +4 -1
  543. package/lib/Local/RpcServer.js.map +1 -1
  544. package/lib/Plan.d.ts +34 -0
  545. package/lib/Plan.d.ts.map +1 -1
  546. package/lib/Plan.js +127 -40
  547. package/lib/Plan.js.map +1 -1
  548. package/lib/Planetscale/AuthProvider.d.ts.map +1 -1
  549. package/lib/Planetscale/AuthProvider.js +6 -2
  550. package/lib/Planetscale/AuthProvider.js.map +1 -1
  551. package/lib/Planetscale/Branch.d.ts.map +1 -1
  552. package/lib/Planetscale/Branch.js +36 -6
  553. package/lib/Planetscale/Branch.js.map +1 -1
  554. package/lib/Planetscale/MySQL/MySQLDatabase.d.ts.map +1 -1
  555. package/lib/Planetscale/MySQL/MySQLDatabase.js +31 -6
  556. package/lib/Planetscale/MySQL/MySQLDatabase.js.map +1 -1
  557. package/lib/Planetscale/OAuthClient.d.ts +7 -1
  558. package/lib/Planetscale/OAuthClient.d.ts.map +1 -1
  559. package/lib/Planetscale/OAuthClient.js +51 -4
  560. package/lib/Planetscale/OAuthClient.js.map +1 -1
  561. package/lib/Planetscale/Postgres/PostgresDatabase.d.ts.map +1 -1
  562. package/lib/Planetscale/Postgres/PostgresDatabase.js +30 -5
  563. package/lib/Planetscale/Postgres/PostgresDatabase.js.map +1 -1
  564. package/lib/Platform.d.ts.map +1 -1
  565. package/lib/Platform.js +25 -14
  566. package/lib/Platform.js.map +1 -1
  567. package/lib/Prisma/App.d.ts +93 -0
  568. package/lib/Prisma/App.d.ts.map +1 -0
  569. package/lib/Prisma/App.js +251 -0
  570. package/lib/Prisma/App.js.map +1 -0
  571. package/lib/Prisma/AuthProvider.d.ts +28 -0
  572. package/lib/Prisma/AuthProvider.d.ts.map +1 -0
  573. package/lib/Prisma/AuthProvider.js +131 -0
  574. package/lib/Prisma/AuthProvider.js.map +1 -0
  575. package/lib/Prisma/Branch.d.ts +96 -0
  576. package/lib/Prisma/Branch.d.ts.map +1 -0
  577. package/lib/Prisma/Branch.js +236 -0
  578. package/lib/Prisma/Branch.js.map +1 -0
  579. package/lib/Prisma/Client.d.ts +178 -0
  580. package/lib/Prisma/Client.d.ts.map +1 -0
  581. package/lib/Prisma/Client.js +562 -0
  582. package/lib/Prisma/Client.js.map +1 -0
  583. package/lib/Prisma/Compute.d.ts +585 -0
  584. package/lib/Prisma/Compute.d.ts.map +1 -0
  585. package/lib/Prisma/Compute.js +1545 -0
  586. package/lib/Prisma/Compute.js.map +1 -0
  587. package/lib/Prisma/ComputeArchive.d.ts +63 -0
  588. package/lib/Prisma/ComputeArchive.d.ts.map +1 -0
  589. package/lib/Prisma/ComputeArchive.js +227 -0
  590. package/lib/Prisma/ComputeArchive.js.map +1 -0
  591. package/lib/Prisma/ComputeBuild.d.ts +106 -0
  592. package/lib/Prisma/ComputeBuild.d.ts.map +1 -0
  593. package/lib/Prisma/ComputeBuild.js +987 -0
  594. package/lib/Prisma/ComputeBuild.js.map +1 -0
  595. package/lib/Prisma/ComputeLifecycle.d.ts +84 -0
  596. package/lib/Prisma/ComputeLifecycle.d.ts.map +1 -0
  597. package/lib/Prisma/ComputeLifecycle.js +186 -0
  598. package/lib/Prisma/ComputeLifecycle.js.map +1 -0
  599. package/lib/Prisma/Connect.d.ts +122 -0
  600. package/lib/Prisma/Connect.d.ts.map +1 -0
  601. package/lib/Prisma/Connect.js +187 -0
  602. package/lib/Prisma/Connect.js.map +1 -0
  603. package/lib/Prisma/Connection.d.ts +219 -0
  604. package/lib/Prisma/Connection.d.ts.map +1 -0
  605. package/lib/Prisma/Connection.js +360 -0
  606. package/lib/Prisma/Connection.js.map +1 -0
  607. package/lib/Prisma/CustomDomain.d.ts +91 -0
  608. package/lib/Prisma/CustomDomain.d.ts.map +1 -0
  609. package/lib/Prisma/CustomDomain.js +184 -0
  610. package/lib/Prisma/CustomDomain.js.map +1 -0
  611. package/lib/Prisma/Database.d.ts +222 -0
  612. package/lib/Prisma/Database.d.ts.map +1 -0
  613. package/lib/Prisma/Database.js +418 -0
  614. package/lib/Prisma/Database.js.map +1 -0
  615. package/lib/Prisma/Deployment.d.ts +141 -0
  616. package/lib/Prisma/Deployment.d.ts.map +1 -0
  617. package/lib/Prisma/Deployment.js +353 -0
  618. package/lib/Prisma/Deployment.js.map +1 -0
  619. package/lib/Prisma/EnvironmentVariable.d.ts +105 -0
  620. package/lib/Prisma/EnvironmentVariable.d.ts.map +1 -0
  621. package/lib/Prisma/EnvironmentVariable.js +229 -0
  622. package/lib/Prisma/EnvironmentVariable.js.map +1 -0
  623. package/lib/Prisma/Internal/AppIdentity.d.ts +10 -0
  624. package/lib/Prisma/Internal/AppIdentity.d.ts.map +1 -0
  625. package/lib/Prisma/Internal/AppIdentity.js +6 -0
  626. package/lib/Prisma/Internal/AppIdentity.js.map +1 -0
  627. package/lib/Prisma/Internal/AppPromotion.d.ts +19 -0
  628. package/lib/Prisma/Internal/AppPromotion.d.ts.map +1 -0
  629. package/lib/Prisma/Internal/AppPromotion.js +107 -0
  630. package/lib/Prisma/Internal/AppPromotion.js.map +1 -0
  631. package/lib/Prisma/Internal/ArchivePlatform.d.ts +42 -0
  632. package/lib/Prisma/Internal/ArchivePlatform.d.ts.map +1 -0
  633. package/lib/Prisma/Internal/ArchivePlatform.js +214 -0
  634. package/lib/Prisma/Internal/ArchivePlatform.js.map +1 -0
  635. package/lib/Prisma/Internal/ArtifactFile.d.ts +58 -0
  636. package/lib/Prisma/Internal/ArtifactFile.d.ts.map +1 -0
  637. package/lib/Prisma/Internal/ArtifactFile.js +134 -0
  638. package/lib/Prisma/Internal/ArtifactFile.js.map +1 -0
  639. package/lib/Prisma/Internal/ArtifactUpload.d.ts +5 -0
  640. package/lib/Prisma/Internal/ArtifactUpload.d.ts.map +1 -0
  641. package/lib/Prisma/Internal/ArtifactUpload.js +51 -0
  642. package/lib/Prisma/Internal/ArtifactUpload.js.map +1 -0
  643. package/lib/Prisma/Internal/BundlePaths.d.ts +4 -0
  644. package/lib/Prisma/Internal/BundlePaths.d.ts.map +1 -0
  645. package/lib/Prisma/Internal/BundlePaths.js +16 -0
  646. package/lib/Prisma/Internal/BundlePaths.js.map +1 -0
  647. package/lib/Prisma/Internal/CleanupFailure.d.ts +8 -0
  648. package/lib/Prisma/Internal/CleanupFailure.d.ts.map +1 -0
  649. package/lib/Prisma/Internal/CleanupFailure.js +8 -0
  650. package/lib/Prisma/Internal/CleanupFailure.js.map +1 -0
  651. package/lib/Prisma/Internal/DatabaseSecrets.d.ts +35 -0
  652. package/lib/Prisma/Internal/DatabaseSecrets.d.ts.map +1 -0
  653. package/lib/Prisma/Internal/DatabaseSecrets.js +85 -0
  654. package/lib/Prisma/Internal/DatabaseSecrets.js.map +1 -0
  655. package/lib/Prisma/Internal/DeploymentActions.d.ts +5 -0
  656. package/lib/Prisma/Internal/DeploymentActions.d.ts.map +1 -0
  657. package/lib/Prisma/Internal/DeploymentActions.js +16 -0
  658. package/lib/Prisma/Internal/DeploymentActions.js.map +1 -0
  659. package/lib/Prisma/Internal/DeploymentIdentity.d.ts +8 -0
  660. package/lib/Prisma/Internal/DeploymentIdentity.d.ts.map +1 -0
  661. package/lib/Prisma/Internal/DeploymentIdentity.js +12 -0
  662. package/lib/Prisma/Internal/DeploymentIdentity.js.map +1 -0
  663. package/lib/Prisma/Internal/DeploymentObserve.d.ts +3 -0
  664. package/lib/Prisma/Internal/DeploymentObserve.d.ts.map +1 -0
  665. package/lib/Prisma/Internal/DeploymentObserve.js +2 -0
  666. package/lib/Prisma/Internal/DeploymentObserve.js.map +1 -0
  667. package/lib/Prisma/Internal/EnvName.d.ts +7 -0
  668. package/lib/Prisma/Internal/EnvName.d.ts.map +1 -0
  669. package/lib/Prisma/Internal/EnvName.js +23 -0
  670. package/lib/Prisma/Internal/EnvName.js.map +1 -0
  671. package/lib/Prisma/Internal/HttpClient.d.ts +21 -0
  672. package/lib/Prisma/Internal/HttpClient.d.ts.map +1 -0
  673. package/lib/Prisma/Internal/HttpClient.js +23 -0
  674. package/lib/Prisma/Internal/HttpClient.js.map +1 -0
  675. package/lib/Prisma/Operations.d.ts +143 -0
  676. package/lib/Prisma/Operations.d.ts.map +1 -0
  677. package/lib/Prisma/Operations.js +75 -0
  678. package/lib/Prisma/Operations.js.map +1 -0
  679. package/lib/Prisma/Postgres.d.ts +25 -0
  680. package/lib/Prisma/Postgres.d.ts.map +1 -0
  681. package/lib/Prisma/Postgres.js +24 -0
  682. package/lib/Prisma/Postgres.js.map +1 -0
  683. package/lib/Prisma/PostgresOrigin.d.ts +31 -0
  684. package/lib/Prisma/PostgresOrigin.d.ts.map +1 -0
  685. package/lib/Prisma/PostgresOrigin.js +30 -0
  686. package/lib/Prisma/PostgresOrigin.js.map +1 -0
  687. package/lib/Prisma/PrismaDevDatabase.d.ts +25 -0
  688. package/lib/Prisma/PrismaDevDatabase.d.ts.map +1 -0
  689. package/lib/Prisma/PrismaDevDatabase.js +280 -0
  690. package/lib/Prisma/PrismaDevDatabase.js.map +1 -0
  691. package/lib/Prisma/PrismaEnvironment.d.ts +14 -0
  692. package/lib/Prisma/PrismaEnvironment.d.ts.map +1 -0
  693. package/lib/Prisma/PrismaEnvironment.js +50 -0
  694. package/lib/Prisma/PrismaEnvironment.js.map +1 -0
  695. package/lib/Prisma/PrismaLogs.d.ts +42 -0
  696. package/lib/Prisma/PrismaLogs.d.ts.map +1 -0
  697. package/lib/Prisma/PrismaLogs.js +318 -0
  698. package/lib/Prisma/PrismaLogs.js.map +1 -0
  699. package/lib/Prisma/Project.d.ts +123 -0
  700. package/lib/Prisma/Project.d.ts.map +1 -0
  701. package/lib/Prisma/Project.js +366 -0
  702. package/lib/Prisma/Project.js.map +1 -0
  703. package/lib/Prisma/Providers.d.ts +63 -0
  704. package/lib/Prisma/Providers.d.ts.map +1 -0
  705. package/lib/Prisma/Providers.js +306 -0
  706. package/lib/Prisma/Providers.js.map +1 -0
  707. package/lib/Prisma/Refs.d.ts +19 -0
  708. package/lib/Prisma/Refs.d.ts.map +1 -0
  709. package/lib/Prisma/Refs.js +25 -0
  710. package/lib/Prisma/Refs.js.map +1 -0
  711. package/lib/Prisma/SourceRepository.d.ts +127 -0
  712. package/lib/Prisma/SourceRepository.d.ts.map +1 -0
  713. package/lib/Prisma/SourceRepository.js +239 -0
  714. package/lib/Prisma/SourceRepository.js.map +1 -0
  715. package/lib/Prisma/Types.d.ts +539 -0
  716. package/lib/Prisma/Types.d.ts.map +1 -0
  717. package/lib/Prisma/Types.js +13 -0
  718. package/lib/Prisma/Types.js.map +1 -0
  719. package/lib/Prisma/index.d.ts +25 -0
  720. package/lib/Prisma/index.d.ts.map +1 -0
  721. package/lib/Prisma/index.js +24 -0
  722. package/lib/Prisma/index.js.map +1 -0
  723. package/lib/Provider.d.ts +57 -5
  724. package/lib/Provider.d.ts.map +1 -1
  725. package/lib/Provider.js +54 -30
  726. package/lib/Provider.js.map +1 -1
  727. package/lib/ProviderMode.d.ts +93 -0
  728. package/lib/ProviderMode.d.ts.map +1 -0
  729. package/lib/ProviderMode.js +77 -0
  730. package/lib/ProviderMode.js.map +1 -0
  731. package/lib/Resource.d.ts +8 -0
  732. package/lib/Resource.d.ts.map +1 -1
  733. package/lib/Resource.js +31 -0
  734. package/lib/Resource.js.map +1 -1
  735. package/lib/RuntimeContext.d.ts +7 -0
  736. package/lib/RuntimeContext.d.ts.map +1 -1
  737. package/lib/RuntimeContext.js.map +1 -1
  738. package/lib/Server/Process.d.ts +8 -0
  739. package/lib/Server/Process.d.ts.map +1 -1
  740. package/lib/Server/Process.js +29 -0
  741. package/lib/Server/Process.js.map +1 -1
  742. package/lib/State/InMemoryState.d.ts.map +1 -1
  743. package/lib/State/InMemoryState.js +2 -0
  744. package/lib/State/InMemoryState.js.map +1 -1
  745. package/lib/State/ResourceState.d.ts +18 -0
  746. package/lib/State/ResourceState.d.ts.map +1 -1
  747. package/lib/Sync.d.ts.map +1 -1
  748. package/lib/Sync.js +8 -2
  749. package/lib/Sync.js.map +1 -1
  750. package/lib/Telemetry.d.ts +150 -0
  751. package/lib/Telemetry.d.ts.map +1 -0
  752. package/lib/Telemetry.js +512 -0
  753. package/lib/Telemetry.js.map +1 -0
  754. package/lib/Test/Alchemy.d.ts.map +1 -1
  755. package/lib/Test/Alchemy.js +3 -1
  756. package/lib/Test/Alchemy.js.map +1 -1
  757. package/lib/Test/Core.d.ts +2 -2
  758. package/lib/Test/Core.d.ts.map +1 -1
  759. package/lib/Test/Core.js +1 -8
  760. package/lib/Test/Core.js.map +1 -1
  761. package/lib/Util/Clank.d.ts +11 -6
  762. package/lib/Util/Clank.d.ts.map +1 -1
  763. package/lib/Util/Clank.js +22 -9
  764. package/lib/Util/Clank.js.map +1 -1
  765. package/lib/Util/zip.d.ts +11 -0
  766. package/lib/Util/zip.d.ts.map +1 -1
  767. package/lib/Util/zip.js +30 -0
  768. package/lib/Util/zip.js.map +1 -1
  769. package/lib/index.d.ts +3 -0
  770. package/lib/index.d.ts.map +1 -1
  771. package/lib/index.js +3 -0
  772. package/lib/index.js.map +1 -1
  773. package/package.json +46 -13
  774. package/src/AWS/ApiGateway/common.ts +9 -0
  775. package/src/AWS/Bedrock/LanguageModel.ts +883 -0
  776. package/src/AWS/Bedrock/LanguageModelHttp.ts +36 -0
  777. package/src/AWS/Bedrock/index.ts +2 -0
  778. package/src/AWS/CloudFront/Distribution.ts +116 -6
  779. package/src/AWS/CostExplorer/common.ts +23 -2
  780. package/src/AWS/DataSync/Task.ts +30 -15
  781. package/src/AWS/EC2/Vpc.ts +35 -21
  782. package/src/AWS/EC2/hosted.ts +10 -2
  783. package/src/AWS/ECR/ImageSource.ts +10 -2
  784. package/src/AWS/ECR/Repository.ts +39 -4
  785. package/src/AWS/ECS/Service.ts +322 -22
  786. package/src/AWS/ECS/Task.ts +82 -32
  787. package/src/AWS/EKS/Deployment.ts +10 -2
  788. package/src/AWS/EKS/Job.ts +10 -2
  789. package/src/AWS/Lambda/Function.ts +101 -43
  790. package/src/AWS/Lambda/HttpServer.ts +7 -1
  791. package/src/AWS/Lambda/LayerVersion.ts +490 -0
  792. package/src/AWS/Lambda/MicrovmBundle.ts +10 -2
  793. package/src/AWS/Lambda/index.ts +1 -0
  794. package/src/AWS/Providers.ts +10 -0
  795. package/src/AWS/SES/ActiveReceiptRuleSet.ts +88 -0
  796. package/src/AWS/SES/ReceiptFilter.ts +169 -0
  797. package/src/AWS/SES/ReceiptRule.ts +300 -0
  798. package/src/AWS/SES/ReceiptRuleSet.ts +164 -0
  799. package/src/AWS/SES/SendBounce.ts +44 -0
  800. package/src/AWS/SES/SendBounceHttp.ts +13 -0
  801. package/src/AWS/SES/index.ts +6 -0
  802. package/src/AWS/StateStore/State.ts +159 -42
  803. package/src/Apply.ts +199 -83
  804. package/src/Axiom/Telemetry.ts +119 -0
  805. package/src/Axiom/index.ts +1 -0
  806. package/src/Bundle/Bundle.ts +17 -7
  807. package/src/Bundle/BundleAnalyzerPlugin.ts +9 -4
  808. package/src/Bundle/PurePlugin.ts +19 -9
  809. package/src/Cli/checkVersion.ts +102 -16
  810. package/src/Cli/commands/_shared.ts +2 -0
  811. package/src/Cli/commands/deploy.ts +3 -14
  812. package/src/Cli/commands/logs.ts +6 -1
  813. package/src/Cli/commands/tail.ts +6 -1
  814. package/src/Cli/main.ts +5 -4
  815. package/src/Cloudflare/AI/Search.ts +4 -18
  816. package/src/Cloudflare/AI/SearchInstance.ts +7 -26
  817. package/src/Cloudflare/ApiToken/AccountApiToken.ts +3 -0
  818. package/src/Cloudflare/Auth/AuthProvider.ts +17 -3
  819. package/src/Cloudflare/Auth/OAuthClient.ts +58 -2
  820. package/src/Cloudflare/Containers/Container.ts +92 -3
  821. package/src/Cloudflare/Containers/ContainerApplication.ts +31 -5
  822. package/src/Cloudflare/Containers/ContainerBundle.ts +10 -2
  823. package/src/Cloudflare/Containers/ContainerProvider.ts +62 -0
  824. package/src/Cloudflare/Credentials.ts +69 -9
  825. package/src/Cloudflare/D1/ApplyMigrations.ts +72 -77
  826. package/src/Cloudflare/D1/Database.ts +169 -2
  827. package/src/Cloudflare/D1/LocalD1Gateway.ts +150 -0
  828. package/src/Cloudflare/D1/QueryDatabaseHttpClient.ts +49 -11
  829. package/src/Cloudflare/D1/QueryDatabaseLocal.ts +44 -2
  830. package/src/Cloudflare/DNS/Record.ts +30 -4
  831. package/src/Cloudflare/Email/Address.ts +18 -1
  832. package/src/Cloudflare/Email/SendBinding.ts +1 -0
  833. package/src/Cloudflare/Email/SendEmail.ts +13 -0
  834. package/src/Cloudflare/Flagship/App.ts +18 -6
  835. package/src/Cloudflare/KV/LocalKVGateway.ts +86 -0
  836. package/src/Cloudflare/KV/Namespace.ts +47 -1
  837. package/src/Cloudflare/KV/NamespaceLocal.ts +29 -6
  838. package/src/Cloudflare/KV/ReadNamespaceLocal.ts +5 -1
  839. package/src/Cloudflare/KV/ReadWriteNamespaceLocal.ts +5 -1
  840. package/src/Cloudflare/KV/WriteNamespaceLocal.ts +5 -1
  841. package/src/Cloudflare/LocalGateway.ts +86 -0
  842. package/src/Cloudflare/LocalRuntime.ts +21 -1
  843. package/src/Cloudflare/Logs.ts +58 -28
  844. package/src/Cloudflare/Providers.ts +4 -2
  845. package/src/Cloudflare/Queues/Consumer.ts +70 -2
  846. package/src/Cloudflare/Queues/Queue.ts +7 -16
  847. package/src/Cloudflare/Queues/QueueBinding.ts +21 -0
  848. package/src/Cloudflare/Queues/QueueShim.ts +193 -0
  849. package/src/Cloudflare/R2/Bucket.ts +55 -1
  850. package/src/Cloudflare/R2/BucketBinding.ts +17 -3
  851. package/src/Cloudflare/R2/BucketLocal.ts +25 -8
  852. package/src/Cloudflare/R2/LocalR2Gateway.ts +84 -0
  853. package/src/Cloudflare/R2/ReadBucketLocal.ts +7 -1
  854. package/src/Cloudflare/R2/ReadWriteBucketLocal.ts +7 -1
  855. package/src/Cloudflare/R2/WriteBucketLocal.ts +7 -1
  856. package/src/Cloudflare/Ruleset/AccountEntrypoint.ts +5 -1
  857. package/src/Cloudflare/Ruleset/Ruleset.ts +20 -6
  858. package/src/Cloudflare/Rum/Site.ts +11 -4
  859. package/src/Cloudflare/StateStore/Api.ts +1 -1
  860. package/src/Cloudflare/Tunnel/Tunnel.ts +23 -1
  861. package/src/Cloudflare/Website/StaticSite.ts +117 -28
  862. package/src/Cloudflare/Website/Vite.ts +33 -19
  863. package/src/Cloudflare/Workers/Compatibility.ts +27 -7
  864. package/src/Cloudflare/Workers/DurableObject.ts +22 -0
  865. package/src/Cloudflare/Workers/DurableObjectBridge.ts +29 -10
  866. package/src/Cloudflare/Workers/InferEnv.ts +74 -59
  867. package/src/Cloudflare/Workers/LocalWorkerProvider.ts +619 -401
  868. package/src/Cloudflare/Workers/Worker.ts +676 -28
  869. package/src/Cloudflare/Workers/WorkerAsyncBindings.ts +209 -25
  870. package/src/Cloudflare/Workers/WorkerBinding.ts +67 -3
  871. package/src/Cloudflare/Workers/WorkerBridge.ts +26 -4
  872. package/src/Cloudflare/Workers/WorkerBundle.ts +6 -1
  873. package/src/Cloudflare/Workers/WorkerProvider.ts +2269 -277
  874. package/src/Cloudflare/Workflows/WorkflowBridge.ts +31 -13
  875. package/src/Command/Build.ts +8 -8
  876. package/src/Command/Command.ts +217 -42
  877. package/src/Command/Dev.ts +79 -107
  878. package/src/Command/Exec.ts +11 -2
  879. package/src/Command/Memo.ts +27 -3
  880. package/src/Command/Redaction.ts +181 -0
  881. package/src/Destroy.ts +1 -10
  882. package/src/Docker/Container.ts +55 -15
  883. package/src/Docker/Context.ts +236 -0
  884. package/src/Docker/Docker.ts +393 -43
  885. package/src/Docker/Image.ts +28 -7
  886. package/src/Docker/Network.ts +38 -14
  887. package/src/Docker/Providers.ts +16 -1
  888. package/src/Docker/RemoteImage.ts +23 -7
  889. package/src/Docker/Service.ts +1119 -0
  890. package/src/Docker/ServiceImage.ts +331 -0
  891. package/src/Docker/Swarm.ts +226 -0
  892. package/src/Docker/Volume.ts +25 -6
  893. package/src/Docker/index.ts +3 -0
  894. package/src/Http.ts +15 -2
  895. package/src/Local/LocalProvider.ts +518 -0
  896. package/src/Local/ProviderLayer.ts +113 -11
  897. package/src/Local/RpcProvider.ts +10 -5
  898. package/src/Local/RpcProviderProxy.ts +4 -1
  899. package/src/Local/RpcServer.ts +20 -2
  900. package/src/Plan.ts +182 -54
  901. package/src/Planetscale/AuthProvider.ts +15 -2
  902. package/src/Planetscale/Branch.ts +39 -6
  903. package/src/Planetscale/MySQL/MySQLDatabase.ts +34 -6
  904. package/src/Planetscale/OAuthClient.ts +59 -3
  905. package/src/Planetscale/Postgres/PostgresDatabase.ts +33 -5
  906. package/src/Platform.ts +29 -17
  907. package/src/Prisma/App.ts +433 -0
  908. package/src/Prisma/AuthProvider.ts +260 -0
  909. package/src/Prisma/Branch.ts +417 -0
  910. package/src/Prisma/Client.ts +1337 -0
  911. package/src/Prisma/Compute.ts +2878 -0
  912. package/src/Prisma/ComputeArchive.ts +432 -0
  913. package/src/Prisma/ComputeBuild.ts +1652 -0
  914. package/src/Prisma/ComputeLifecycle.ts +391 -0
  915. package/src/Prisma/Connect.ts +433 -0
  916. package/src/Prisma/Connection.ts +643 -0
  917. package/src/Prisma/CustomDomain.ts +373 -0
  918. package/src/Prisma/Database.ts +850 -0
  919. package/src/Prisma/Deployment.ts +661 -0
  920. package/src/Prisma/EnvironmentVariable.ts +417 -0
  921. package/src/Prisma/Internal/AppIdentity.ts +19 -0
  922. package/src/Prisma/Internal/AppPromotion.ts +172 -0
  923. package/src/Prisma/Internal/ArchivePlatform.ts +320 -0
  924. package/src/Prisma/Internal/ArtifactFile.ts +242 -0
  925. package/src/Prisma/Internal/ArtifactUpload.ts +86 -0
  926. package/src/Prisma/Internal/BundlePaths.ts +28 -0
  927. package/src/Prisma/Internal/CleanupFailure.ts +17 -0
  928. package/src/Prisma/Internal/DatabaseSecrets.ts +175 -0
  929. package/src/Prisma/Internal/DeploymentActions.ts +59 -0
  930. package/src/Prisma/Internal/DeploymentIdentity.ts +25 -0
  931. package/src/Prisma/Internal/DeploymentObserve.ts +6 -0
  932. package/src/Prisma/Internal/EnvName.ts +24 -0
  933. package/src/Prisma/Internal/HttpClient.ts +30 -0
  934. package/src/Prisma/Operations.ts +259 -0
  935. package/src/Prisma/Postgres.ts +25 -0
  936. package/src/Prisma/PostgresOrigin.ts +52 -0
  937. package/src/Prisma/PrismaDevDatabase.ts +395 -0
  938. package/src/Prisma/PrismaEnvironment.ts +89 -0
  939. package/src/Prisma/PrismaLogs.ts +434 -0
  940. package/src/Prisma/Project.ts +687 -0
  941. package/src/Prisma/Providers.ts +471 -0
  942. package/src/Prisma/Refs.ts +69 -0
  943. package/src/Prisma/SourceRepository.ts +455 -0
  944. package/src/Prisma/Types.ts +611 -0
  945. package/src/Prisma/index.ts +24 -0
  946. package/src/Provider.ts +155 -39
  947. package/src/ProviderMode.ts +123 -0
  948. package/src/Resource.ts +46 -0
  949. package/src/RuntimeContext.ts +7 -0
  950. package/src/Server/Process.ts +33 -0
  951. package/src/State/InMemoryState.ts +2 -0
  952. package/src/State/ResourceState.ts +18 -0
  953. package/src/Sync.ts +14 -2
  954. package/src/Telemetry.ts +736 -0
  955. package/src/Test/Alchemy.ts +3 -1
  956. package/src/Test/Core.ts +1 -8
  957. package/src/Util/Clank.ts +37 -11
  958. package/src/Util/zip.ts +39 -0
  959. package/src/index.ts +3 -0
@@ -0,0 +1,2878 @@
1
+ import * as Effect from "effect/Effect";
2
+ import * as Duration from "effect/Duration";
3
+ import * as Exit from "effect/Exit";
4
+ import * as FileSystem from "effect/FileSystem";
5
+ import * as Option from "effect/Option";
6
+ import * as Path from "effect/Path";
7
+ import * as Redacted from "effect/Redacted";
8
+ import * as Result from "effect/Result";
9
+ import * as Schedule from "effect/Schedule";
10
+ import * as Stream from "effect/Stream";
11
+ import * as FetchHttpClient from "effect/unstable/http/FetchHttpClient";
12
+ import * as HttpClient from "effect/unstable/http/HttpClient";
13
+ import * as HttpClientRequest from "effect/unstable/http/HttpClientRequest";
14
+ import type { HttpClientResponse } from "effect/unstable/http/HttpClientResponse";
15
+ import * as ChildProcess from "effect/unstable/process/ChildProcess";
16
+ import type { ChildProcessHandle } from "effect/unstable/process/ChildProcessSpawner";
17
+ import type * as rolldown from "rolldown";
18
+ import { AlchemyContext } from "../AlchemyContext.ts";
19
+ import { Unowned } from "../AdoptPolicy.ts";
20
+ import * as Bundle from "../Bundle/Bundle.ts";
21
+ import { findCwdForBundle } from "../Bundle/TempRoot.ts";
22
+ import { createPhysicalName } from "../PhysicalName.ts";
23
+ import { isResolved } from "../Diff.ts";
24
+ import { HttpServer, type HttpEffect } from "../Http.ts";
25
+ import type { InputProps } from "../Input.ts";
26
+ import * as Output from "../Output.ts";
27
+ import { Platform, type Main, type PlatformProps } from "../Platform.ts";
28
+ import * as Provider from "../Provider.ts";
29
+ import { Resource, type ResourceBinding } from "../Resource.ts";
30
+ import { RuntimeContext } from "../RuntimeContext.ts";
31
+ import type * as Server from "../Server/index.ts";
32
+ import { Self } from "../Self.ts";
33
+ import { Stack } from "../Stack.ts";
34
+ import { sha256Object } from "../Util/sha256.ts";
35
+ import {
36
+ PrismaApiError,
37
+ PrismaClient,
38
+ isNotFound,
39
+ type PrismaManagementClient,
40
+ } from "./Client.ts";
41
+ import {
42
+ runBuildCommand,
43
+ runComputeAutoBuild,
44
+ type ComputeAutoBuildFramework,
45
+ } from "./ComputeBuild.ts";
46
+ import { createComputeArchive, normalizeEntrypoint } from "./ComputeArchive.ts";
47
+ import {
48
+ destroyApp,
49
+ destroyDeployment,
50
+ isConflict,
51
+ toDeploymentUrl,
52
+ waitForDeploymentStatus,
53
+ } from "./ComputeLifecycle.ts";
54
+ import {
55
+ startDeploymentIdempotent,
56
+ stopDeploymentIdempotent,
57
+ } from "./Internal/DeploymentActions.ts";
58
+ import { ensureAppImmutableIdentity } from "./Internal/AppIdentity.ts";
59
+ import {
60
+ promoteAppObserved,
61
+ waitForAppDeploymentTarget,
62
+ } from "./Internal/AppPromotion.ts";
63
+ import { normalizeBundleFilePath } from "./Internal/BundlePaths.ts";
64
+ import { aggregateCleanupFailure } from "./Internal/CleanupFailure.ts";
65
+ import { ensureDeploymentMembership } from "./Internal/DeploymentIdentity.ts";
66
+ import { observeDeployment } from "./Internal/DeploymentObserve.ts";
67
+ import { tailDeploymentLogs } from "./PrismaLogs.ts";
68
+ import type { Project } from "./Project.ts";
69
+ import type { Providers } from "./Providers.ts";
70
+ import {
71
+ concreteIdsChanged,
72
+ isInputObject,
73
+ isPrismaDevId,
74
+ resolveProjectId,
75
+ unresolvedProjectIdOf,
76
+ } from "./Refs.ts";
77
+ import type {
78
+ App as ApiApp,
79
+ Deployment as ApiDeployment,
80
+ EnvironmentVariable as ApiEnvironmentVariable,
81
+ PrismaRegionId,
82
+ } from "./Types.ts";
83
+ import { readUploadArtifact, uploadArtifact } from "./Deployment.ts";
84
+
85
+ type ObservedDeployment = Omit<ApiDeployment, "createdAt"> & {
86
+ createdAt?: string;
87
+ };
88
+
89
+ const ComputeTypeId = "Prisma.Compute" as const;
90
+ type ComputeTypeId = typeof ComputeTypeId;
91
+
92
+ export interface ComputeCommandBuild {
93
+ /**
94
+ * Shell command that creates the deployable output directory.
95
+ */
96
+ command: string;
97
+ /**
98
+ * Working directory for the build command.
99
+ *
100
+ * @default path
101
+ */
102
+ cwd?: string;
103
+ /**
104
+ * Build output directory, relative to `cwd`.
105
+ */
106
+ outdir: string;
107
+ /**
108
+ * Entrypoint inside `outdir`.
109
+ */
110
+ entrypoint?: string;
111
+ /**
112
+ * Environment variables supplied to the build command.
113
+ * Ambient `PRISMA_SERVICE_TOKEN` and `PRISMA_API_TOKEN` credentials are not
114
+ * inherited; include one here explicitly only when the application build
115
+ * genuinely needs Prisma Management API access.
116
+ *
117
+ * Plain strings are persisted in Alchemy state. Wrap secrets with
118
+ * `Redacted.make(secret)`; Prisma-side encryption does not protect a value
119
+ * already stored in Alchemy state.
120
+ *
121
+ * ```typescript
122
+ * env: { NPM_TOKEN: Redacted.make(process.env.NPM_TOKEN!) }
123
+ * ```
124
+ */
125
+ env?: Record<string, string | Redacted.Redacted<string> | undefined>;
126
+ /**
127
+ * Maximum bytes retained from each build output stream.
128
+ *
129
+ * @default 1048576 (1 MiB)
130
+ */
131
+ outputLimitBytes?: number;
132
+ /**
133
+ * Maximum wall-clock time for the build command.
134
+ *
135
+ * @default 900 (15 minutes)
136
+ */
137
+ timeoutSeconds?: number;
138
+ }
139
+
140
+ export interface ComputeAutoBuild {
141
+ /**
142
+ * Auto-detect a Prisma Compute build strategy, or force one framework.
143
+ */
144
+ type: "auto";
145
+ /**
146
+ * Framework build strategy.
147
+ *
148
+ * @default "auto"
149
+ */
150
+ framework?: ComputeAutoBuildFramework;
151
+ /**
152
+ * Environment variables supplied to the build command.
153
+ * Ambient `PRISMA_SERVICE_TOKEN` and `PRISMA_API_TOKEN` credentials are not
154
+ * inherited; include one here explicitly only when the application build
155
+ * genuinely needs Prisma Management API access.
156
+ *
157
+ * Plain strings are persisted in Alchemy state. Wrap secrets with
158
+ * `Redacted.make(secret)`.
159
+ *
160
+ * ```typescript
161
+ * env: { NPM_TOKEN: Redacted.make(process.env.NPM_TOKEN!) }
162
+ * ```
163
+ */
164
+ env?: Record<string, string | Redacted.Redacted<string> | undefined>;
165
+ /**
166
+ * Maximum bytes retained from each framework build output stream.
167
+ *
168
+ * @default 1048576 (1 MiB)
169
+ */
170
+ outputLimitBytes?: number;
171
+ /**
172
+ * Maximum wall-clock time for the framework build command.
173
+ *
174
+ * @default 900 (15 minutes)
175
+ */
176
+ timeoutSeconds?: number;
177
+ }
178
+
179
+ export type ComputeBuild = ComputeCommandBuild | ComputeAutoBuild;
180
+
181
+ export interface ComputeBundleOptions {
182
+ /**
183
+ * Rolldown input options for effect-native Compute bundles.
184
+ */
185
+ input?: Partial<rolldown.InputOptions>;
186
+ /**
187
+ * Rolldown output options for effect-native Compute bundles.
188
+ */
189
+ output?: Partial<rolldown.OutputOptions>;
190
+ /**
191
+ * Additional Alchemy bundle options for effect-native Compute bundles.
192
+ */
193
+ extra?: Bundle.BundleExtraOptions;
194
+ }
195
+
196
+ export interface ComputeDev {
197
+ /**
198
+ * Local command to run during `alchemy dev`.
199
+ */
200
+ command?: string;
201
+ /**
202
+ * Working directory for the dev command.
203
+ *
204
+ * @default path
205
+ */
206
+ cwd?: string;
207
+ /**
208
+ * Local development port.
209
+ */
210
+ port?: number;
211
+ /**
212
+ * Explicit local URL to expose in the resource output.
213
+ */
214
+ url?: string;
215
+ /**
216
+ * Extra environment variables for the dev command.
217
+ * Plain strings are persisted in Alchemy state. Wrap secrets with
218
+ * `Redacted.make(secret)`.
219
+ */
220
+ env?: Record<string, string | Redacted.Redacted<string> | undefined>;
221
+ }
222
+
223
+ export interface ComputeHealthCheck {
224
+ /**
225
+ * Absolute application path to probe after the deployment starts and after
226
+ * promotion.
227
+ *
228
+ * @example "/api/health"
229
+ */
230
+ path: string;
231
+ /**
232
+ * Exact HTTP status codes that indicate readiness. When omitted, any 2xx
233
+ * response is healthy.
234
+ *
235
+ * @default Any status from 200 through 299
236
+ */
237
+ statusCodes?: readonly number[];
238
+ }
239
+
240
+ export interface ComputeProps extends PlatformProps {
241
+ /**
242
+ * Project ID or `project.projectId` output that owns the App.
243
+ */
244
+ project: string | Project;
245
+ /**
246
+ * App display name. If omitted, Alchemy generates a stable physical name.
247
+ */
248
+ appName?: string;
249
+ /**
250
+ * Region where the App is placed.
251
+ *
252
+ * @default The project's default region, falling back to "us-east-1"
253
+ */
254
+ regionId?: PrismaRegionId;
255
+ /**
256
+ * Branch ID to attach the App to. Mutually exclusive with branchGitName.
257
+ * If both branch fields are omitted, Alchemy attaches to the project's
258
+ * current default branch.
259
+ */
260
+ branchId?: string;
261
+ /**
262
+ * Branch git name to attach the App to. Mutually exclusive with branchId.
263
+ *
264
+ * @default The project's current default branch
265
+ */
266
+ branchGitName?: string;
267
+ /**
268
+ * Application directory used for pre-built artifacts and build commands.
269
+ *
270
+ * @default "."
271
+ */
272
+ path?: string;
273
+ /**
274
+ * Additional artifact-relative files or directories to exclude from path
275
+ * deployments. `*` and `**` wildcards are supported; absolute paths,
276
+ * parent segments, and negated patterns are rejected. `.env*`, `.git`, and
277
+ * `.alchemy` are always excluded.
278
+ */
279
+ archiveIgnore?: readonly string[];
280
+ /**
281
+ * Entrypoint relative to the deployed artifact directory.
282
+ * If omitted, Alchemy reads `package.json#main`.
283
+ */
284
+ entrypoint?: string;
285
+ /**
286
+ * Entry module for an effect-native Compute app.
287
+ *
288
+ * This is required when you pass an inline Effect implementation to
289
+ * `Prisma.Compute`, and ignored for external path deployments.
290
+ */
291
+ main?: string;
292
+ /**
293
+ * Exported symbol inside `main` for effect-native Compute apps.
294
+ *
295
+ * @default "default"
296
+ */
297
+ handler?: string;
298
+ /**
299
+ * Bundler options for effect-native Compute apps.
300
+ */
301
+ bundle?: ComputeBundleOptions;
302
+ /**
303
+ * Effect-native runtime exports populated by the Platform constructor.
304
+ *
305
+ * @internal
306
+ */
307
+ exports?: string[] | Record<string, unknown>;
308
+ /**
309
+ * Build command and output directory. Set to `"auto"` or `{ type: "auto" }`
310
+ * to use Prisma Compute-style framework detection for Next.js, Nuxt, Astro,
311
+ * TanStack Start, or Bun. Set to `false` to upload `path` as a pre-built
312
+ * artifact.
313
+ */
314
+ build?: ComputeBuild | false | "auto";
315
+ /**
316
+ * Path to a pre-created `tar.gz` artifact file. When supplied, Alchemy reads
317
+ * and uploads it directly.
318
+ */
319
+ artifactPath?: string;
320
+ /**
321
+ * HTTP port exposed by the application.
322
+ *
323
+ * @default 8080
324
+ */
325
+ port?: number;
326
+ /**
327
+ * Runtime environment variables to sync through Prisma's environment
328
+ * variable API before creating a new deployment. Set a value to `null`
329
+ * to delete that variable.
330
+ *
331
+ * Plain strings are persisted in Alchemy state. For secrets, use
332
+ * `Redacted.make(secret)`; encryption in the Prisma Management API does not
333
+ * protect a plain value already recorded in Alchemy state.
334
+ *
335
+ * The Management API exposes neither an idempotency key nor ownership
336
+ * metadata for environment variables, and reads return redacted values. If
337
+ * a process crashes after Prisma commits a create but before Alchemy saves
338
+ * its returned ID, the next deploy safely refuses to claim that natural-key
339
+ * match. Use standalone `Prisma.EnvironmentVariable` resources for critical
340
+ * keys that need independent lifecycle management and explicit adoption.
341
+ *
342
+ * ```typescript
343
+ * env: {
344
+ * LOG_LEVEL: "info",
345
+ * API_TOKEN: Redacted.make(process.env.API_TOKEN!),
346
+ * }
347
+ * ```
348
+ */
349
+ env?: Record<string, string | Redacted.Redacted<string> | null | undefined>;
350
+ /**
351
+ * Prisma environment variable class used by the `env` convenience property.
352
+ *
353
+ * @default "production"
354
+ */
355
+ envClass?: "production" | "preview";
356
+ /**
357
+ * Create the next deployment by reusing the previous code artifact.
358
+ *
359
+ * @default false
360
+ */
361
+ skipCodeUpload?: boolean;
362
+ /**
363
+ * Start the created/reused deployment.
364
+ * Set `skipPromote: true` when disabling start.
365
+ *
366
+ * @default true
367
+ */
368
+ start?: boolean;
369
+ /**
370
+ * Do not promote the deployment to the stable App endpoint.
371
+ *
372
+ * @default false
373
+ */
374
+ skipPromote?: boolean;
375
+ /**
376
+ * Delete the previously promoted deployment after the new one is promoted.
377
+ *
378
+ * @default false
379
+ */
380
+ destroyOldDeployment?: boolean;
381
+ /**
382
+ * Poll timeout while waiting for start/stop.
383
+ *
384
+ * @default 120
385
+ */
386
+ timeoutSeconds?: number;
387
+ /**
388
+ * Poll interval while waiting for start/stop.
389
+ *
390
+ * @default 1000
391
+ */
392
+ pollIntervalMs?: number;
393
+ /**
394
+ * Verify that Prisma's public preview/App URL has reached the edge after
395
+ * the Management API reports the deployment as running.
396
+ *
397
+ * @default true
398
+ */
399
+ verifyUrl?: boolean;
400
+ /**
401
+ * Optional application-level health check. Without this option, URL
402
+ * verification only waits for Prisma edge routing to stop returning its
403
+ * platform-level service-not-found response. With this option, Alchemy also
404
+ * sends a public GET to the preview URL before promotion and to the stable
405
+ * App URL afterward. Redirects are not followed. Each probe phase gets the
406
+ * full `urlReadinessTimeoutSeconds` budget.
407
+ *
408
+ * Health checks run only during cloud deployment, not `alchemy dev`, and
409
+ * cannot be combined with `verifyUrl: false` or `start: false`.
410
+ */
411
+ healthCheck?: ComputeHealthCheck;
412
+ /**
413
+ * Maximum time to wait for Prisma's public URL to stop returning the
414
+ * platform-level "Service not found" page.
415
+ *
416
+ * @default 60
417
+ */
418
+ urlReadinessTimeoutSeconds?: number;
419
+ /**
420
+ * Local development behavior for `alchemy dev`.
421
+ */
422
+ dev?: ComputeDev;
423
+ }
424
+
425
+ export interface Compute extends Resource<
426
+ ComputeTypeId,
427
+ ComputeProps,
428
+ {
429
+ /**
430
+ * Prisma App ID.
431
+ */
432
+ appId: string;
433
+ /**
434
+ * Prisma deployment ID created for the current deployment.
435
+ */
436
+ deploymentId: string | undefined;
437
+ /**
438
+ * Project ID that owns the app.
439
+ */
440
+ projectId: string;
441
+ /**
442
+ * App display name.
443
+ */
444
+ appName: string;
445
+ /**
446
+ * Region ID where the App is placed.
447
+ */
448
+ regionId: string;
449
+ /**
450
+ * Preview endpoint domain for the deployment.
451
+ */
452
+ deploymentEndpointDomain: string | undefined;
453
+ /**
454
+ * HTTPS URL for the deployment endpoint.
455
+ */
456
+ deploymentUrl: string | undefined;
457
+ /**
458
+ * Stable App endpoint domain after promotion.
459
+ */
460
+ appEndpointDomain: string | undefined;
461
+ /**
462
+ * Preferred URL for the app, local in dev or stable/preview in deploys.
463
+ */
464
+ url: string | undefined;
465
+ /**
466
+ * Whether the current deployment was promoted to the stable endpoint.
467
+ */
468
+ promoted: boolean;
469
+ /**
470
+ * Previously promoted deployment ID observed before deploy.
471
+ */
472
+ previousDeploymentId: string | null | undefined;
473
+ /**
474
+ * Action taken for the previous deployment.
475
+ */
476
+ previousDeploymentAction:
477
+ | "stopped"
478
+ | "destroyed"
479
+ | "still-active"
480
+ | null
481
+ | undefined;
482
+ /** Stable App endpoint readiness observed after promotion. */
483
+ readinessStatus?: "ready" | "pending" | "skipped";
484
+ /** Old deployment cleanup that will be retried before another generation. */
485
+ pendingDeploymentCleanup?: {
486
+ deploymentId: string;
487
+ action: "stop" | "destroy";
488
+ };
489
+ /**
490
+ * Environment variable keys managed by this Compute resource.
491
+ *
492
+ * This includes explicit `env` props and env vars added by bindings.
493
+ */
494
+ environmentKeys?: string[];
495
+ /**
496
+ * Environment variable IDs created by this Compute resource, keyed by
497
+ * variable name. IDs are the ownership boundary for shared branch/project
498
+ * environment-variable namespaces.
499
+ */
500
+ environmentVariableIds?: Record<string, string>;
501
+ /**
502
+ * Prisma environment class used for the managed environment variable keys.
503
+ */
504
+ environmentClass?: "production" | "preview";
505
+ /**
506
+ * Branch ID used for managed preview branch environment overrides, or null
507
+ * for project-level environment templates.
508
+ */
509
+ environmentBranchId?: string | null;
510
+ /**
511
+ * Fingerprint of the uploaded artifact/reused artifact inputs and the
512
+ * branch attachment that Prisma resolves environment variables from.
513
+ */
514
+ artifactHash: Redacted.Redacted<string> | undefined;
515
+ /**
516
+ * Whether the app output represents a local dev process.
517
+ */
518
+ local: boolean;
519
+ },
520
+ {
521
+ env?: Record<string, string | Redacted.Redacted<string> | null | undefined>;
522
+ },
523
+ Providers
524
+ > {}
525
+
526
+ export type ComputeRuntimeServices = Server.ProcessServices;
527
+
528
+ export type ComputeShape = Main<ComputeRuntimeServices>;
529
+
530
+ export interface ComputeRuntimeContext extends Server.ProcessContext {
531
+ readonly Type: ComputeTypeId;
532
+ }
533
+
534
+ export const isCompute = (value: unknown): value is Compute =>
535
+ typeof value === "object" &&
536
+ value !== null &&
537
+ "Type" in value &&
538
+ value.Type === ComputeTypeId;
539
+
540
+ const hasEffectNativeComputeInput = (props: ComputeProps) =>
541
+ props.isExternal !== true &&
542
+ (props.main !== undefined || props.exports !== undefined);
543
+
544
+ const isEffectNativeCompute = (props: ComputeProps) =>
545
+ hasEffectNativeComputeInput(props);
546
+
547
+ /**
548
+ * Build and deploy an application to Prisma Compute.
549
+ *
550
+ * Prisma's create-deployment API exposes neither an idempotency key nor a
551
+ * caller-defined recovery key. If the API commits a deployment but its create
552
+ * response is lost before Alchemy persists the returned ID, that deployment
553
+ * can remain orphaned and a later deploy may create another one. Alchemy does
554
+ * not guess that the App's latest deployment is owned, because it could belong
555
+ * to another actor. Use a durable, locked state backend and inspect the App's
556
+ * deployment history after an interrupted create.
557
+ *
558
+ * @section Deploying an App
559
+ * @example Deploy a directory with an entrypoint
560
+ * ```typescript
561
+ * const app = yield* Prisma.Compute("api", {
562
+ * project: project.projectId,
563
+ * path: "./apps/api",
564
+ * entrypoint: "server.ts",
565
+ * port: 3000,
566
+ * });
567
+ * ```
568
+ *
569
+ * @example Deploy an Effect-native HTTP app
570
+ * ```typescript
571
+ * export default Prisma.Compute(
572
+ * "api",
573
+ * {
574
+ * project,
575
+ * appName: "api",
576
+ * main: import.meta.filename,
577
+ * port: 8080,
578
+ * },
579
+ * Effect.gen(function* () {
580
+ * return {
581
+ * fetch: Effect.succeed(HttpServerResponse.text("ok")),
582
+ * };
583
+ * }),
584
+ * );
585
+ * ```
586
+ *
587
+ * @section Runtime Bindings
588
+ * @example Bind a Prisma Connection
589
+ * ```typescript
590
+ * export default Prisma.Compute(
591
+ * "api",
592
+ * {
593
+ * project,
594
+ * appName: "api",
595
+ * main: import.meta.filename,
596
+ * },
597
+ * Effect.gen(function* () {
598
+ * const db = yield* Prisma.Connect(connection);
599
+ * const sql = yield* SQL.Postgres({ url: db.databaseUrl });
600
+ *
601
+ * return {
602
+ * fetch: Effect.gen(function* () {
603
+ * const users = yield* sql`SELECT * FROM users`;
604
+ * return yield* HttpServerResponse.json(users);
605
+ * }),
606
+ * };
607
+ * }).pipe(Effect.provide(Prisma.ConnectBinding)),
608
+ * );
609
+ * ```
610
+ *
611
+ * @example Build before upload and replace old versions
612
+ * ```typescript
613
+ * const app = yield* Prisma.Compute("api", {
614
+ * project: project.projectId,
615
+ * path: "./apps/api",
616
+ * build: {
617
+ * command: "bun build src/server.ts --target bun --outdir dist",
618
+ * outdir: "dist",
619
+ * entrypoint: "server.js",
620
+ * },
621
+ * port: 8080,
622
+ * env: {
623
+ * // Use this for a standalone Connection. A project's default database
624
+ * // is injected by Prisma without an explicit DATABASE_URL entry.
625
+ * DATABASE_URL: connection.databaseUrl,
626
+ * },
627
+ * destroyOldDeployment: true,
628
+ * });
629
+ * ```
630
+ *
631
+ * @example Auto-build a framework app
632
+ * ```typescript
633
+ * const app = yield* Prisma.Compute("api", {
634
+ * project: project.projectId,
635
+ * path: "./apps/web",
636
+ * build: "auto",
637
+ * destroyOldDeployment: true,
638
+ * });
639
+ * ```
640
+ *
641
+ * @example Deploy a prebuilt tar.gz artifact
642
+ * ```typescript
643
+ * const app = yield* Prisma.Compute("api", {
644
+ * project: project.projectId,
645
+ * artifactPath: "./dist/app.tar.gz",
646
+ * port: 8080,
647
+ * });
648
+ * ```
649
+ *
650
+ * @section Deployment Health
651
+ * @example Require application readiness before promotion
652
+ * ```typescript
653
+ * const app = yield* Prisma.Compute("api", {
654
+ * project,
655
+ * path: "./apps/api",
656
+ * entrypoint: "server.ts",
657
+ * healthCheck: {
658
+ * path: "/api/health",
659
+ * // Defaults to any 2xx response when omitted.
660
+ * statusCodes: [200, 204],
661
+ * },
662
+ * });
663
+ * ```
664
+ *
665
+ * @section Local Development
666
+ * @example Run locally during alchemy dev
667
+ * ```typescript
668
+ * const app = yield* Prisma.Compute("api", {
669
+ * project: project.projectId,
670
+ * path: "./apps/api",
671
+ * entrypoint: "server.ts",
672
+ * dev: {
673
+ * command: "bun run dev",
674
+ * port: 3000,
675
+ * },
676
+ * });
677
+ * ```
678
+ *
679
+ * @resource
680
+ */
681
+ export const Compute: Platform<
682
+ Compute,
683
+ ComputeRuntimeServices,
684
+ ComputeShape,
685
+ ComputeRuntimeContext
686
+ > & {
687
+ <PropsReq = never>(
688
+ id: string,
689
+ props:
690
+ | InputProps<ComputeProps>
691
+ | Effect.Effect<InputProps<ComputeProps>, never, PropsReq>,
692
+ ): Effect.Effect<Compute, never, Providers | PropsReq>;
693
+ } = Platform(ComputeTypeId, {
694
+ createRuntimeContext: (id): ComputeRuntimeContext => {
695
+ const runners: Effect.Effect<void, never, unknown>[] = [];
696
+ const env: Record<string, unknown> = {};
697
+ let runtimeContext: ComputeRuntimeContext;
698
+ const run: Server.ProcessContext["run"] = (effect) =>
699
+ Effect.sync(() => {
700
+ runners.push(effect);
701
+ });
702
+
703
+ const serve = <Req = never>(handler: HttpEffect<Req>) =>
704
+ Effect.sync(() => {
705
+ runners.push(
706
+ Effect.gen(function* () {
707
+ const httpServer = yield* Effect.serviceOption(HttpServer).pipe(
708
+ Effect.map(Option.getOrUndefined),
709
+ );
710
+ if (httpServer) {
711
+ yield* httpServer.serve(
712
+ handler.pipe(
713
+ Effect.provideService(RuntimeContext, runtimeContext),
714
+ ),
715
+ );
716
+ yield* Effect.never;
717
+ }
718
+ }).pipe(Effect.catch((error: unknown) => Effect.die(error))),
719
+ );
720
+ });
721
+
722
+ runtimeContext = {
723
+ Type: ComputeTypeId,
724
+ id,
725
+ env,
726
+ set: (bindingId: string, output: Output.Output) =>
727
+ Effect.sync(() => {
728
+ const key = bindingId.replaceAll(/[^a-zA-Z0-9]/g, "_");
729
+ env[key] = output.pipe(
730
+ Output.map((value) =>
731
+ Redacted.isRedacted(value)
732
+ ? Redacted.make(
733
+ JSON.stringify({
734
+ _tag: "Redacted",
735
+ value: Redacted.value(value),
736
+ }),
737
+ )
738
+ : JSON.stringify(value),
739
+ ),
740
+ );
741
+ return key;
742
+ }),
743
+ get: <T>(key: string) =>
744
+ // Runtime ConfigProvider lookups call back into RuntimeContext.get.
745
+ // Read the process env directly here to avoid re-entering that path.
746
+ Effect.sync(() => {
747
+ const value = process.env[key];
748
+ if (value === undefined) {
749
+ return undefined;
750
+ }
751
+ try {
752
+ const parsed = JSON.parse(value);
753
+ if (
754
+ parsed !== null &&
755
+ typeof parsed === "object" &&
756
+ (parsed as { _tag?: unknown })._tag === "Redacted" &&
757
+ "value" in (parsed as object)
758
+ ) {
759
+ return Redacted.make((parsed as { value: string }).value) as T;
760
+ }
761
+ return parsed as T;
762
+ } catch {
763
+ return value as T;
764
+ }
765
+ }),
766
+ run,
767
+ serve,
768
+ exports: Effect.sync(() => ({
769
+ default: Effect.all(
770
+ runners.map((effect) =>
771
+ Effect.forever(
772
+ effect.pipe(
773
+ Effect.tapError((error) => Effect.logError(error)),
774
+ Effect.ignore,
775
+ ),
776
+ ),
777
+ ),
778
+ { concurrency: "unbounded" },
779
+ ),
780
+ })),
781
+ };
782
+ return runtimeContext;
783
+ },
784
+ });
785
+
786
+ const devProcesses = new Map<string, ChildProcessHandle>();
787
+
788
+ const stopTrackedDevProcess = Effect.fn(function* (processKey: string) {
789
+ const existing = devProcesses.get(processKey);
790
+ if (!existing) return;
791
+
792
+ const running = yield* existing.isRunning;
793
+ if (running) {
794
+ // Keep the handle tracked when termination fails so a later reconcile or
795
+ // destroy can retry instead of losing the only reference to the process.
796
+ yield* existing.kill();
797
+ }
798
+ devProcesses.delete(processKey);
799
+ });
800
+
801
+ const projectConsistencySchedule = Schedule.max([
802
+ Schedule.exponential(Duration.millis(500)),
803
+ Schedule.recurs(6),
804
+ ]);
805
+
806
+ const isAppProvisioningNotFound = (error: unknown): boolean =>
807
+ error instanceof PrismaApiError &&
808
+ error.status === 404 &&
809
+ (error.path.startsWith("/v1/projects/") ||
810
+ error.path === "/v1/apps" ||
811
+ error.path.startsWith("/v1/apps/"));
812
+
813
+ const desiredComputeBranchId = Effect.fn(function* (
814
+ client: PrismaManagementClient,
815
+ projectId: string,
816
+ props: Pick<ComputeProps, "branchId" | "branchGitName">,
817
+ ) {
818
+ if (props.branchId !== undefined && !isPrismaDevId(props.branchId)) {
819
+ return { resolved: true as const, id: props.branchId };
820
+ }
821
+ const branches = yield* client.listBranches(
822
+ projectId,
823
+ props.branchGitName === undefined
824
+ ? { limit: 100 }
825
+ : { gitName: props.branchGitName, limit: 100 },
826
+ );
827
+ const matchingBranches =
828
+ props.branchGitName === undefined
829
+ ? branches.filter((branch) => branch.isDefault)
830
+ : branches;
831
+ if (matchingBranches.length > 1) {
832
+ return yield* Effect.fail(
833
+ new Error(
834
+ props.branchGitName === undefined
835
+ ? `Prisma returned multiple default branches for project '${projectId}'; refusing an ambiguous Compute App match.`
836
+ : `Prisma returned multiple branches named '${props.branchGitName}' in project '${projectId}'; refusing an ambiguous Compute App match.`,
837
+ ),
838
+ );
839
+ }
840
+ const branch = matchingBranches[0];
841
+ return branch
842
+ ? { resolved: true as const, id: branch.id }
843
+ : { resolved: false as const };
844
+ });
845
+
846
+ const createAppName = (id: string, appName: string | undefined) =>
847
+ appName === undefined ? createPhysicalName({ id }) : Effect.succeed(appName);
848
+
849
+ const findApp = Effect.fn(function* (
850
+ client: PrismaManagementClient,
851
+ projectId: string,
852
+ appName: string,
853
+ props: Pick<ComputeProps, "branchId" | "branchGitName">,
854
+ ) {
855
+ const candidates = (yield* client.listApps({
856
+ projectId,
857
+ limit: 100,
858
+ })).filter((app) => app.name === appName);
859
+ if (candidates.length === 0) return undefined;
860
+ const branch = yield* desiredComputeBranchId(client, projectId, props);
861
+ if (!branch.resolved) return undefined;
862
+ const matches = candidates.filter((app) => app.branchId === branch.id);
863
+ if (matches.length > 1) {
864
+ return yield* Effect.fail(
865
+ new Error(
866
+ `Prisma returned multiple Apps named '${appName}' on branch '${branch.id}' in project '${projectId}'; refusing an ambiguous ownership match.`,
867
+ ),
868
+ );
869
+ }
870
+ return matches[0];
871
+ });
872
+
873
+ const createApp = (
874
+ client: PrismaManagementClient,
875
+ projectId: string,
876
+ props: ComputeProps & { appName: string },
877
+ branchId: string,
878
+ ) =>
879
+ client.createApp({
880
+ projectId,
881
+ displayName: props.appName,
882
+ regionId: props.regionId,
883
+ branchId,
884
+ branchGitName: undefined,
885
+ });
886
+
887
+ const plainEnv = (
888
+ env: Record<
889
+ string,
890
+ string | Redacted.Redacted<string> | null | undefined
891
+ > = {},
892
+ ) =>
893
+ Object.fromEntries(
894
+ Object.entries(env).flatMap(([key, value]) =>
895
+ value === undefined
896
+ ? []
897
+ : [[key, Redacted.isRedacted(value) ? Redacted.value(value) : value]],
898
+ ),
899
+ ) as Record<string, string | null>;
900
+
901
+ const persistedArtifactHashValue = (
902
+ value: Redacted.Redacted<string> | string | undefined,
903
+ ) => (Redacted.isRedacted(value) ? Redacted.value(value) : value);
904
+
905
+ const managedEnvKeys = (
906
+ env: Record<
907
+ string,
908
+ string | Redacted.Redacted<string> | null | undefined
909
+ > = {},
910
+ ) =>
911
+ Object.entries(plainEnv(env))
912
+ .flatMap(([key, value]) => (value === null ? [] : [key]))
913
+ .sort();
914
+
915
+ const ENV_KEY_PATTERN = /^[A-Z_][A-Z0-9_]*$/;
916
+ const ENV_VALUE_MAX_BYTES = 8 * 1024;
917
+ const EXPORT_IDENTIFIER_PATTERN = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
918
+
919
+ const computeEnvValue = (value: string | Redacted.Redacted<string>) =>
920
+ Redacted.isRedacted(value) ? Redacted.value(value) : value;
921
+
922
+ const validateComputeEnvironmentKey = (key: string) =>
923
+ Effect.gen(function* () {
924
+ if (key.length < 1 || key.length > 256 || !ENV_KEY_PATTERN.test(key)) {
925
+ return yield* Effect.fail(
926
+ new Error(
927
+ `Prisma environment variable key '${key}' must match POSIX env-var key shape: [A-Z_][A-Z0-9_]* and be at most 256 characters.`,
928
+ ),
929
+ );
930
+ }
931
+ });
932
+
933
+ const validateComputeEnvironmentWrite = (
934
+ key: string,
935
+ value: string | Redacted.Redacted<string>,
936
+ ) =>
937
+ Effect.gen(function* () {
938
+ yield* validateComputeEnvironmentKey(key);
939
+ const raw = computeEnvValue(value);
940
+ if (raw.length === 0) {
941
+ return yield* Effect.fail(
942
+ new Error(
943
+ `Prisma environment variable '${key}' value must be non-empty.`,
944
+ ),
945
+ );
946
+ }
947
+ const byteLength = yield* Effect.sync(
948
+ () => new TextEncoder().encode(raw).byteLength,
949
+ );
950
+ if (byteLength > ENV_VALUE_MAX_BYTES) {
951
+ return yield* Effect.fail(
952
+ new Error(
953
+ `Prisma environment variable '${key}' value exceeds ${ENV_VALUE_MAX_BYTES} bytes.`,
954
+ ),
955
+ );
956
+ }
957
+ });
958
+
959
+ const validateComputeHealthCheck = (
960
+ healthCheck: ComputeHealthCheck | undefined,
961
+ ) =>
962
+ Effect.gen(function* () {
963
+ if (healthCheck === undefined) return;
964
+ if (
965
+ !healthCheck.path.startsWith("/") ||
966
+ healthCheck.path.startsWith("//") ||
967
+ healthCheck.path.includes("\\") ||
968
+ /\s/.test(healthCheck.path)
969
+ ) {
970
+ return yield* Effect.fail(
971
+ new Error(
972
+ "healthCheck.path must be an absolute application path beginning with one '/'.",
973
+ ),
974
+ );
975
+ }
976
+ if (
977
+ healthCheck.statusCodes !== undefined &&
978
+ healthCheck.statusCodes.length === 0
979
+ ) {
980
+ return yield* Effect.fail(
981
+ new Error("healthCheck.statusCodes must contain at least one status."),
982
+ );
983
+ }
984
+ for (const status of healthCheck.statusCodes ?? []) {
985
+ if (!Number.isInteger(status) || status < 100 || status > 599) {
986
+ return yield* Effect.fail(
987
+ new Error(
988
+ "healthCheck.statusCodes must contain HTTP status integers from 100 through 599.",
989
+ ),
990
+ );
991
+ }
992
+ }
993
+ });
994
+
995
+ const validateComputeProps = (props: ComputeProps) =>
996
+ Effect.gen(function* () {
997
+ yield* validateComputeHealthCheck(props.healthCheck);
998
+ if (props.healthCheck !== undefined && props.verifyUrl === false) {
999
+ return yield* Effect.fail(
1000
+ new Error("healthCheck cannot be combined with verifyUrl: false."),
1001
+ );
1002
+ }
1003
+ if (props.healthCheck !== undefined && props.start === false) {
1004
+ return yield* Effect.fail(
1005
+ new Error("healthCheck requires start to be enabled."),
1006
+ );
1007
+ }
1008
+ for (const [name, value] of [
1009
+ ["timeoutSeconds", props.timeoutSeconds],
1010
+ ["pollIntervalMs", props.pollIntervalMs],
1011
+ ["urlReadinessTimeoutSeconds", props.urlReadinessTimeoutSeconds],
1012
+ ] as const) {
1013
+ if (value !== undefined && (!Number.isFinite(value) || value <= 0)) {
1014
+ return yield* Effect.fail(
1015
+ new Error(`${name} must be a positive finite number.`),
1016
+ );
1017
+ }
1018
+ }
1019
+ for (const [name, value] of [
1020
+ ["port", props.port],
1021
+ ["dev.port", props.dev?.port],
1022
+ ] as const) {
1023
+ if (
1024
+ value !== undefined &&
1025
+ (!Number.isInteger(value) || value < 1 || value > 65_535)
1026
+ ) {
1027
+ return yield* Effect.fail(
1028
+ new Error(`${name} must be an integer between 1 and 65535.`),
1029
+ );
1030
+ }
1031
+ }
1032
+ for (const [key, value] of Object.entries(props.env ?? {})) {
1033
+ if (value === undefined) continue;
1034
+ if (value === null) {
1035
+ yield* validateComputeEnvironmentKey(key);
1036
+ } else {
1037
+ yield* validateComputeEnvironmentWrite(key, value);
1038
+ }
1039
+ }
1040
+ if ((props.skipPromote ?? false) && (props.destroyOldDeployment ?? false)) {
1041
+ return yield* Effect.fail(
1042
+ new Error(
1043
+ "destroyOldDeployment cannot be combined with skipPromote because the previous deployment stays active when promotion is skipped.",
1044
+ ),
1045
+ );
1046
+ }
1047
+ if (props.start === false && !(props.skipPromote ?? false)) {
1048
+ return yield* Effect.fail(
1049
+ new Error(
1050
+ "start: false requires skipPromote: true because Prisma Compute promotion requires a running deployment.",
1051
+ ),
1052
+ );
1053
+ }
1054
+ if (props.branchId !== undefined && props.branchGitName !== undefined) {
1055
+ return yield* Effect.fail(
1056
+ new Error("branchId and branchGitName are mutually exclusive."),
1057
+ );
1058
+ }
1059
+ if (props.branchId === null || props.branchGitName === null) {
1060
+ return yield* Effect.fail(
1061
+ new Error(
1062
+ "Prisma.Compute requires an attached branch because deployment creation resolves environment variables from the App branch. Omit branchGitName to use the project's default branch, or set branchId/branchGitName.",
1063
+ ),
1064
+ );
1065
+ }
1066
+ if ((props.skipCodeUpload ?? false) && props.artifactPath !== undefined) {
1067
+ return yield* Effect.fail(
1068
+ new Error("skipCodeUpload cannot be combined with artifactPath."),
1069
+ );
1070
+ }
1071
+ if ((props.skipCodeUpload ?? false) && props.build !== undefined) {
1072
+ return yield* Effect.fail(
1073
+ new Error("skipCodeUpload cannot be combined with build."),
1074
+ );
1075
+ }
1076
+ if (hasEffectNativeComputeInput(props)) {
1077
+ const handler = props.handler ?? "default";
1078
+ if (handler !== "default" && !EXPORT_IDENTIFIER_PATTERN.test(handler)) {
1079
+ return yield* Effect.fail(
1080
+ new Error(
1081
+ "Effect-native Prisma Compute handler must be `default` or a valid JavaScript export identifier.",
1082
+ ),
1083
+ );
1084
+ }
1085
+ if (props.main === undefined) {
1086
+ return yield* Effect.fail(
1087
+ new Error(
1088
+ "Effect-native Prisma Compute apps require `main`. Set `main: import.meta.filename`.",
1089
+ ),
1090
+ );
1091
+ }
1092
+ if (props.artifactPath !== undefined) {
1093
+ return yield* Effect.fail(
1094
+ new Error(
1095
+ "Effect-native Prisma Compute apps cannot use artifactPath.",
1096
+ ),
1097
+ );
1098
+ }
1099
+ if (props.build !== undefined) {
1100
+ return yield* Effect.fail(
1101
+ new Error("Effect-native Prisma Compute apps cannot use build."),
1102
+ );
1103
+ }
1104
+ if (props.skipCodeUpload) {
1105
+ return yield* Effect.fail(
1106
+ new Error(
1107
+ "Effect-native Prisma Compute apps cannot skip code upload.",
1108
+ ),
1109
+ );
1110
+ }
1111
+ }
1112
+ });
1113
+
1114
+ const processEnv = (
1115
+ env: Record<
1116
+ string,
1117
+ string | Redacted.Redacted<string> | null | undefined
1118
+ > = {},
1119
+ ) =>
1120
+ Object.fromEntries(
1121
+ Object.entries(env).flatMap(([key, value]) =>
1122
+ value === undefined || value === null
1123
+ ? []
1124
+ : [[key, Redacted.isRedacted(value) ? Redacted.value(value) : value]],
1125
+ ),
1126
+ ) as Record<string, string>;
1127
+
1128
+ const isPrismaEdgeServiceNotFound = (status: number, body: string) =>
1129
+ status === 404 &&
1130
+ (body.includes("There is no service on this URL") ||
1131
+ body.includes("<title>Service not found</title>"));
1132
+
1133
+ const URL_READINESS_BODY_PREFIX_BYTES = 64 * 1024;
1134
+
1135
+ const readResponseBodyPrefix = (response: HttpClientResponse) =>
1136
+ Effect.gen(function* () {
1137
+ const chunks: Uint8Array[] = [];
1138
+ let bytes = 0;
1139
+ yield* Stream.runForEachWhile(response.stream, (chunk) =>
1140
+ Effect.sync(() => {
1141
+ const remaining = URL_READINESS_BODY_PREFIX_BYTES - bytes;
1142
+ if (remaining <= 0) return false;
1143
+ const kept =
1144
+ chunk.byteLength > remaining ? chunk.slice(0, remaining) : chunk;
1145
+ chunks.push(kept);
1146
+ bytes += kept.byteLength;
1147
+ return bytes < URL_READINESS_BODY_PREFIX_BYTES;
1148
+ }),
1149
+ );
1150
+ const prefix = new Uint8Array(bytes);
1151
+ let offset = 0;
1152
+ for (const chunk of chunks) {
1153
+ prefix.set(chunk, offset);
1154
+ offset += chunk.byteLength;
1155
+ }
1156
+ return new TextDecoder().decode(prefix);
1157
+ });
1158
+
1159
+ export const waitForDeploymentUrl = Effect.fn(function* (
1160
+ url: string | undefined,
1161
+ props: ComputeProps,
1162
+ ) {
1163
+ yield* validateComputeHealthCheck(props.healthCheck);
1164
+ if (props.healthCheck !== undefined && props.verifyUrl === false) {
1165
+ return yield* Effect.fail(
1166
+ new Error("healthCheck cannot be combined with verifyUrl: false."),
1167
+ );
1168
+ }
1169
+ if (props.verifyUrl === false) return;
1170
+ if (!url) {
1171
+ return yield* Effect.fail(
1172
+ new Error(
1173
+ props.healthCheck === undefined
1174
+ ? "Prisma Compute did not return a public URL for readiness verification."
1175
+ : "Prisma Compute did not return a public URL for the configured healthCheck.",
1176
+ ),
1177
+ );
1178
+ }
1179
+ const httpOption = yield* Effect.serviceOption(HttpClient.HttpClient);
1180
+ if (Option.isNone(httpOption)) {
1181
+ return props.healthCheck === undefined
1182
+ ? undefined
1183
+ : yield* Effect.fail(
1184
+ new Error(
1185
+ "Prisma Compute healthCheck requires an HTTP client service.",
1186
+ ),
1187
+ );
1188
+ }
1189
+
1190
+ const http = httpOption.value;
1191
+ const probeUrl =
1192
+ props.healthCheck === undefined
1193
+ ? url
1194
+ : new URL(props.healthCheck.path, url).toString();
1195
+ const acceptsStatus = (status: number) =>
1196
+ props.healthCheck === undefined ||
1197
+ (props.healthCheck.statusCodes === undefined
1198
+ ? status >= 200 && status <= 299
1199
+ : props.healthCheck.statusCodes.includes(status));
1200
+ const timeoutSeconds = props.urlReadinessTimeoutSeconds ?? 60;
1201
+ const intervalMs = props.pollIntervalMs ?? 1_000;
1202
+ if (!Number.isFinite(timeoutSeconds) || timeoutSeconds <= 0) {
1203
+ return yield* Effect.fail(
1204
+ new Error("urlReadinessTimeoutSeconds must be a positive finite number."),
1205
+ );
1206
+ }
1207
+ if (!Number.isFinite(intervalMs) || intervalMs <= 0) {
1208
+ return yield* Effect.fail(
1209
+ new Error("pollIntervalMs must be a positive finite number."),
1210
+ );
1211
+ }
1212
+ const timeoutMs = timeoutSeconds * 1_000;
1213
+ const startedAt = yield* Effect.sync(() => Date.now());
1214
+ let lastStatus: number | undefined;
1215
+ let lastBody = "";
1216
+
1217
+ while (true) {
1218
+ const beforeRequest = yield* Effect.sync(() => Date.now());
1219
+ const remainingBeforeRequest = timeoutMs - (beforeRequest - startedAt);
1220
+ if (remainingBeforeRequest <= 0) {
1221
+ return yield* Effect.fail(
1222
+ deploymentUrlTimeoutError(probeUrl, lastStatus, lastBody),
1223
+ );
1224
+ }
1225
+ const requestTimeoutMs = Math.min(5_000, remainingBeforeRequest);
1226
+ const response = yield* http.execute(HttpClientRequest.get(probeUrl)).pipe(
1227
+ Effect.provideService(FetchHttpClient.RequestInit, {
1228
+ redirect: "manual",
1229
+ }),
1230
+ Effect.timeoutOption(Duration.millis(requestTimeoutMs)),
1231
+ Effect.map(Option.getOrUndefined),
1232
+ Effect.catch(() => Effect.succeed(undefined)),
1233
+ );
1234
+ if (response) {
1235
+ lastStatus = response.status;
1236
+ // Without an application health check, any non-404 response proves that
1237
+ // edge routing is live. A configured health check must also match its
1238
+ // status contract. Do not consume non-404 bodies: application responses
1239
+ // may intentionally stream.
1240
+ if (response.status !== 404 && acceptsStatus(response.status)) {
1241
+ return;
1242
+ }
1243
+ const beforeBody = yield* Effect.sync(() => Date.now());
1244
+ const remainingBeforeBody = timeoutMs - (beforeBody - startedAt);
1245
+ if (remainingBeforeBody > 0) {
1246
+ const bodyPrefix = yield* readResponseBodyPrefix(response).pipe(
1247
+ Effect.timeoutOption(
1248
+ Duration.millis(Math.min(2_000, remainingBeforeBody)),
1249
+ ),
1250
+ Effect.catch(() => Effect.succeed(Option.none<string>())),
1251
+ );
1252
+ if (Option.isSome(bodyPrefix)) {
1253
+ lastBody = bodyPrefix.value;
1254
+ if (
1255
+ !isPrismaEdgeServiceNotFound(response.status, lastBody) &&
1256
+ acceptsStatus(response.status)
1257
+ ) {
1258
+ return;
1259
+ }
1260
+ }
1261
+ }
1262
+ }
1263
+
1264
+ const elapsed = yield* Effect.sync(() => Date.now() - startedAt);
1265
+ if (elapsed >= timeoutMs) {
1266
+ return yield* Effect.fail(
1267
+ deploymentUrlTimeoutError(probeUrl, lastStatus, lastBody),
1268
+ );
1269
+ }
1270
+
1271
+ yield* Effect.sleep(
1272
+ Duration.millis(Math.min(intervalMs, timeoutMs - elapsed)),
1273
+ );
1274
+ }
1275
+ });
1276
+
1277
+ const deploymentUrlTimeoutError = (
1278
+ url: string,
1279
+ lastStatus: number | undefined,
1280
+ lastBody: string,
1281
+ ) =>
1282
+ new Error(
1283
+ [
1284
+ `Timed out waiting for Prisma Compute URL '${url}' to become reachable.`,
1285
+ lastStatus
1286
+ ? `Last response: HTTP ${lastStatus}.`
1287
+ : "No HTTP response was received.",
1288
+ lastBody.includes("There is no service on this URL")
1289
+ ? "The Prisma edge returned: There is no service on this URL."
1290
+ : undefined,
1291
+ ]
1292
+ .filter((line): line is string => line !== undefined)
1293
+ .join(" "),
1294
+ );
1295
+
1296
+ const isAutoBuild = (
1297
+ build: ComputeProps["build"],
1298
+ ): build is "auto" | ComputeAutoBuild =>
1299
+ build === "auto" ||
1300
+ (typeof build === "object" &&
1301
+ build !== null &&
1302
+ "type" in build &&
1303
+ build.type === "auto");
1304
+
1305
+ const readPackageMain = Effect.fn(function* (directory: string) {
1306
+ const fs = yield* FileSystem.FileSystem;
1307
+ const path = yield* Path.Path;
1308
+ const text = yield* fs
1309
+ .readFileString(path.join(directory, "package.json"))
1310
+ .pipe(
1311
+ Effect.catchIf(
1312
+ (error) =>
1313
+ error._tag === "PlatformError" && error.reason._tag === "NotFound",
1314
+ () => Effect.succeed(undefined),
1315
+ ),
1316
+ );
1317
+ if (!text) return undefined;
1318
+ return yield* Effect.try({
1319
+ try: () => {
1320
+ const parsed = JSON.parse(text) as { main?: unknown };
1321
+ return typeof parsed.main === "string" ? parsed.main : undefined;
1322
+ },
1323
+ catch: (cause) =>
1324
+ new Error(`Failed to parse package.json in ${directory}: ${cause}`),
1325
+ });
1326
+ });
1327
+
1328
+ const writeBundleDirectory = Effect.fn(function* (bundle: Bundle.BundleOutput) {
1329
+ const fs = yield* FileSystem.FileSystem;
1330
+ const path = yield* Path.Path;
1331
+ if (bundle.files.length === 0) {
1332
+ return yield* Effect.fail(
1333
+ new Error("Effect-native Compute bundler produced no output files."),
1334
+ );
1335
+ }
1336
+ const normalizedFiles = yield* Effect.forEach(bundle.files, (file) =>
1337
+ normalizeBundleFilePath(file.path).pipe(
1338
+ Effect.map((normalizedPath) => ({ file, normalizedPath })),
1339
+ ),
1340
+ );
1341
+ const seen = new Set<string>();
1342
+ for (const { normalizedPath } of normalizedFiles) {
1343
+ if (seen.has(normalizedPath)) {
1344
+ return yield* Effect.fail(
1345
+ new Error(
1346
+ `Effect-native Compute bundler produced duplicate output path '${normalizedPath}'.`,
1347
+ ),
1348
+ );
1349
+ }
1350
+ seen.add(normalizedPath);
1351
+ }
1352
+ const directory = yield* fs.makeTempDirectory({
1353
+ prefix: "alchemy-prisma-compute-",
1354
+ });
1355
+
1356
+ return yield* Effect.gen(function* () {
1357
+ for (const { file, normalizedPath } of normalizedFiles) {
1358
+ const target = path.join(directory, normalizedPath);
1359
+ yield* fs.makeDirectory(path.dirname(target), { recursive: true });
1360
+ if (typeof file.content === "string") {
1361
+ yield* fs.writeFileString(target, file.content);
1362
+ } else {
1363
+ yield* fs.writeFile(target, file.content);
1364
+ }
1365
+ }
1366
+
1367
+ return {
1368
+ directory,
1369
+ entrypoint: normalizedFiles[0].normalizedPath,
1370
+ cleanup: fs
1371
+ .remove(directory, { recursive: true })
1372
+ .pipe(Effect.catch(() => Effect.void)),
1373
+ };
1374
+ }).pipe(
1375
+ Effect.onError(() =>
1376
+ fs.remove(directory, { recursive: true }).pipe(Effect.ignore),
1377
+ ),
1378
+ );
1379
+ });
1380
+
1381
+ const bundleEffectCompute = Effect.fn(function* (props: ComputeProps) {
1382
+ if (!props.main) {
1383
+ return yield* Effect.fail(
1384
+ new Error(
1385
+ "Effect-native Prisma Compute apps require `main`. Set `main: import.meta.filename`.",
1386
+ ),
1387
+ );
1388
+ }
1389
+
1390
+ const fs = yield* FileSystem.FileSystem;
1391
+ const stack = yield* Effect.serviceOption(Stack).pipe(
1392
+ Effect.map(
1393
+ Option.getOrElse(() => ({
1394
+ name: "alchemy",
1395
+ stage: "dev",
1396
+ bindings: {},
1397
+ resources: {},
1398
+ })),
1399
+ ),
1400
+ );
1401
+ const virtualEntryPlugin = yield* Bundle.virtualEntryPlugin;
1402
+ const realMain = yield* fs.realPath(props.main);
1403
+ const cwd = yield* findCwdForBundle(realMain);
1404
+ const handler = props.handler ?? "default";
1405
+ const defaultPort = props.port ?? 8080;
1406
+
1407
+ const importEntrypoint =
1408
+ handler === "default"
1409
+ ? "import entrypoint"
1410
+ : `import { ${handler} as entrypoint }`;
1411
+
1412
+ const bundle = yield* Bundle.build(
1413
+ {
1414
+ ...props.bundle?.input,
1415
+ input: realMain,
1416
+ cwd,
1417
+ platform: "node",
1418
+ plugins: [
1419
+ props.bundle?.input?.plugins,
1420
+ virtualEntryPlugin(
1421
+ (importPath) => `
1422
+ import { BunServices } from "@effect/platform-bun";
1423
+ import { BunHttpServer } from "alchemy/Http";
1424
+ import { Stack } from "alchemy/Stack";
1425
+ import { Stage } from "alchemy/Stage";
1426
+ import { makeEntrypointLayer } from "alchemy/Runtime";
1427
+ import * as ConfigProvider from "effect/ConfigProvider";
1428
+ import * as Context from "effect/Context";
1429
+ import * as Effect from "effect/Effect";
1430
+ import * as FetchHttpClient from "effect/unstable/http/FetchHttpClient";
1431
+ import * as Layer from "effect/Layer";
1432
+ import * as Logger from "effect/Logger";
1433
+ import { MinimumLogLevel } from "effect/References";
1434
+
1435
+ ${importEntrypoint} from ${JSON.stringify(importPath)};
1436
+
1437
+ process.env.PORT ??= ${JSON.stringify(String(defaultPort))};
1438
+
1439
+ const tag = Context.Service("${Self.key}");
1440
+ const layer = makeEntrypointLayer(tag, entrypoint);
1441
+
1442
+ const platform = Layer.mergeAll(
1443
+ BunServices.layer,
1444
+ FetchHttpClient.layer,
1445
+ Logger.layer([Logger.consolePretty()]),
1446
+ );
1447
+
1448
+ const stack = Layer.mergeAll(
1449
+ Layer.succeed(Stack, {
1450
+ name: ${JSON.stringify(stack.name)},
1451
+ stage: ${JSON.stringify(stack.stage)},
1452
+ bindings: {},
1453
+ resources: {},
1454
+ }),
1455
+ Layer.succeed(Stage, ${JSON.stringify(stack.stage)}),
1456
+ );
1457
+
1458
+ const program = tag.pipe(
1459
+ Effect.flatMap((app) => app.RuntimeContext.exports),
1460
+ Effect.flatMap((exports) => exports.default),
1461
+ Effect.provide(
1462
+ layer.pipe(
1463
+ Layer.provideMerge(stack),
1464
+ Layer.provideMerge(BunHttpServer({ hostname: "0.0.0.0" })),
1465
+ Layer.provideMerge(platform),
1466
+ Layer.provideMerge(
1467
+ Layer.succeed(
1468
+ ConfigProvider.ConfigProvider,
1469
+ ConfigProvider.orElse(
1470
+ ConfigProvider.fromUnknown({ ALCHEMY_PHASE: "runtime" }),
1471
+ ConfigProvider.fromEnv(),
1472
+ ),
1473
+ ),
1474
+ ),
1475
+ Layer.provideMerge(
1476
+ Layer.succeed(
1477
+ MinimumLogLevel,
1478
+ process.env.DEBUG ? "Debug" : "Info",
1479
+ ),
1480
+ ),
1481
+ ),
1482
+ ),
1483
+ Effect.scoped,
1484
+ );
1485
+
1486
+ console.log("Prisma Compute bootstrap starting...");
1487
+ await Effect.runPromise(program).catch((error) => {
1488
+ console.error("Prisma Compute bootstrap failed:", error);
1489
+ process.exit(1);
1490
+ });
1491
+ `,
1492
+ ),
1493
+ ],
1494
+ checks: {
1495
+ unresolvedImport: false,
1496
+ ineffectiveDynamicImport: false,
1497
+ },
1498
+ },
1499
+ {
1500
+ ...props.bundle?.output,
1501
+ format: "esm",
1502
+ sourcemap: props.bundle?.output?.sourcemap ?? "hidden",
1503
+ minify: props.bundle?.output?.minify ?? true,
1504
+ entryFileNames: "index.js",
1505
+ },
1506
+ props.bundle?.extra,
1507
+ );
1508
+
1509
+ const artifact = yield* writeBundleDirectory(bundle);
1510
+ const file = yield* createComputeArchive({
1511
+ directory: artifact.directory,
1512
+ entrypoint: artifact.entrypoint,
1513
+ ignore: props.archiveIgnore,
1514
+ output: "file",
1515
+ }).pipe(Effect.ensuring(artifact.cleanup));
1516
+
1517
+ return {
1518
+ file,
1519
+ bundleHash: bundle.hash,
1520
+ };
1521
+ });
1522
+
1523
+ const resolveArtifact = Effect.fn(function* (props: ComputeProps) {
1524
+ const env = plainEnv(props.env);
1525
+ const envClass = props.envClass ?? "production";
1526
+ const defaultPort = props.port ?? 8080;
1527
+ if (isEffectNativeCompute(props)) {
1528
+ if (props.artifactPath !== undefined) {
1529
+ return yield* Effect.fail(
1530
+ new Error("Effect-native Prisma Compute apps cannot use artifactPath."),
1531
+ );
1532
+ }
1533
+ if (props.skipCodeUpload) {
1534
+ return yield* Effect.fail(
1535
+ new Error("Effect-native Prisma Compute apps cannot skip code upload."),
1536
+ );
1537
+ }
1538
+ if (props.build !== undefined) {
1539
+ return yield* Effect.fail(
1540
+ new Error("Effect-native Prisma Compute apps cannot use build."),
1541
+ );
1542
+ }
1543
+ const artifact = yield* bundleEffectCompute(props);
1544
+ return {
1545
+ file: artifact.file,
1546
+ hash: yield* sha256Object({
1547
+ bundle: artifact.bundleHash,
1548
+ env,
1549
+ envClass,
1550
+ port: defaultPort,
1551
+ }),
1552
+ port: defaultPort,
1553
+ };
1554
+ }
1555
+
1556
+ if (props.skipCodeUpload) {
1557
+ return {
1558
+ file: undefined,
1559
+ hash: yield* sha256Object({
1560
+ skipCodeUpload: true,
1561
+ env,
1562
+ envClass,
1563
+ port: defaultPort,
1564
+ }),
1565
+ port: defaultPort,
1566
+ };
1567
+ }
1568
+
1569
+ if (props.artifactPath !== undefined) {
1570
+ const file = yield* readUploadArtifact({
1571
+ artifactPath: props.artifactPath,
1572
+ output: "file",
1573
+ });
1574
+ return {
1575
+ file: file!,
1576
+ hash: yield* sha256Object({
1577
+ artifact: file!.sha256,
1578
+ env,
1579
+ envClass,
1580
+ port: defaultPort,
1581
+ }),
1582
+ port: defaultPort,
1583
+ };
1584
+ }
1585
+
1586
+ const path = yield* Path.Path;
1587
+ const appPath = path.resolve(props.path ?? ".");
1588
+ let directory = appPath;
1589
+ let entrypoint = props.entrypoint;
1590
+ let port = defaultPort;
1591
+
1592
+ if (isAutoBuild(props.build)) {
1593
+ const auto = props.build === "auto" ? undefined : props.build;
1594
+ const artifact = yield* runComputeAutoBuild({
1595
+ appPath,
1596
+ entrypoint,
1597
+ framework: auto?.framework,
1598
+ env: auto?.env,
1599
+ outputLimitBytes: auto?.outputLimitBytes,
1600
+ timeoutSeconds: auto?.timeoutSeconds,
1601
+ });
1602
+ const file = yield* createComputeArchive({
1603
+ directory: artifact.directory,
1604
+ entrypoint: artifact.entrypoint,
1605
+ ignore: props.archiveIgnore,
1606
+ output: "file",
1607
+ }).pipe(Effect.ensuring(artifact.cleanup));
1608
+ port = props.port ?? artifact.defaultPort ?? 8080;
1609
+ return {
1610
+ file,
1611
+ hash: yield* sha256Object({
1612
+ artifact: file.sha256,
1613
+ env,
1614
+ envClass,
1615
+ port,
1616
+ }),
1617
+ port,
1618
+ };
1619
+ }
1620
+
1621
+ if (props.build) {
1622
+ const cwd = props.build.cwd ? path.resolve(props.build.cwd) : appPath;
1623
+ yield* runBuildCommand({
1624
+ command: props.build.command,
1625
+ cwd,
1626
+ env: processEnv(props.build.env),
1627
+ outputLimitBytes: props.build.outputLimitBytes,
1628
+ timeoutSeconds: props.build.timeoutSeconds,
1629
+ });
1630
+ directory = path.resolve(cwd, props.build.outdir);
1631
+ entrypoint = props.build.entrypoint ?? entrypoint;
1632
+ }
1633
+
1634
+ entrypoint ??= yield* readPackageMain(directory);
1635
+ if (!entrypoint) {
1636
+ return yield* Effect.fail(
1637
+ new Error(
1638
+ "Prisma Compute app entrypoint is required. Set `entrypoint` or package.json `main`.",
1639
+ ),
1640
+ );
1641
+ }
1642
+
1643
+ const normalizedEntrypoint = yield* normalizeEntrypoint(entrypoint);
1644
+ const file = yield* createComputeArchive({
1645
+ directory,
1646
+ entrypoint: normalizedEntrypoint,
1647
+ ignore: props.archiveIgnore,
1648
+ output: "file",
1649
+ });
1650
+ return {
1651
+ file,
1652
+ hash: yield* sha256Object({
1653
+ artifact: file.sha256,
1654
+ env,
1655
+ envClass,
1656
+ port,
1657
+ }),
1658
+ port,
1659
+ };
1660
+ });
1661
+
1662
+ const findExistingApp = Effect.fn(function* (
1663
+ client: PrismaManagementClient,
1664
+ output: Compute["Attributes"] | undefined,
1665
+ ) {
1666
+ const appId =
1667
+ output?.appId && !isPrismaDevId(output.appId) ? output.appId : undefined;
1668
+ return appId
1669
+ ? yield* client
1670
+ .getApp(appId)
1671
+ .pipe(Effect.catchIf(isNotFound, () => Effect.succeed(undefined)))
1672
+ : undefined;
1673
+ });
1674
+
1675
+ const ensureApp = Effect.fn(function* (
1676
+ client: PrismaManagementClient,
1677
+ projectId: string,
1678
+ props: ComputeProps & { appName: string },
1679
+ output: Compute["Attributes"] | undefined,
1680
+ observedApp?: ApiApp,
1681
+ ) {
1682
+ let app = observedApp ?? (yield* findExistingApp(client, output));
1683
+ const branch = yield* desiredComputeBranchId(client, projectId, props);
1684
+ if (!branch.resolved) {
1685
+ return yield* Effect.fail(
1686
+ new Error(
1687
+ props.branchGitName === undefined
1688
+ ? `Prisma project '${projectId}' has no default branch to attach Compute App '${props.appName}'. Create or promote a default branch, or specify branchId/branchGitName.`
1689
+ : `Prisma project '${projectId}' has no branch named '${props.branchGitName}' to attach Compute App '${props.appName}'.`,
1690
+ ),
1691
+ );
1692
+ }
1693
+
1694
+ let createdApp = false;
1695
+ if (!app) {
1696
+ const result = yield* createApp(client, projectId, props, branch.id).pipe(
1697
+ Effect.map((app) => ({ app, created: true })),
1698
+ Effect.catchIf(isConflict, (conflict) =>
1699
+ findApp(client, projectId, props.appName, props).pipe(
1700
+ Effect.flatMap((app) =>
1701
+ app && output?.appId !== undefined && app.id === output.appId
1702
+ ? Effect.succeed({ app, created: false })
1703
+ : Effect.fail(
1704
+ new Error(
1705
+ `Prisma App '${props.appName}' already exists on the requested branch but is not owned by this Compute resource. Import it with explicit adoption or choose a different App name.`,
1706
+ { cause: conflict },
1707
+ ),
1708
+ ),
1709
+ ),
1710
+ ),
1711
+ ),
1712
+ );
1713
+ app = result.app;
1714
+ createdApp = result.created;
1715
+ }
1716
+
1717
+ yield* ensureAppImmutableIdentity(
1718
+ app,
1719
+ projectId,
1720
+ props.regionId ?? output?.regionId ?? app.region.id,
1721
+ );
1722
+ if (app.name !== props.appName || app.branchId !== branch.id) {
1723
+ app = yield* client.updateApp(app.id, {
1724
+ displayName: props.appName,
1725
+ branchId: branch.id,
1726
+ branchGitName: undefined,
1727
+ });
1728
+ }
1729
+
1730
+ return { app, created: createdApp };
1731
+ });
1732
+
1733
+ const ensureSkipCodeUploadCanFork = (
1734
+ props: ComputeProps,
1735
+ app: ApiApp | undefined,
1736
+ ) =>
1737
+ Effect.gen(function* () {
1738
+ if (!(props.skipCodeUpload ?? false)) return;
1739
+ if (app?.latestDeploymentId) return;
1740
+ return yield* Effect.fail(
1741
+ new Error(
1742
+ "skipCodeUpload requires an existing Prisma deployment to fork from. Upload and start a deployment first, or remove skipCodeUpload.",
1743
+ ),
1744
+ );
1745
+ });
1746
+
1747
+ const findEnvironmentVariable = (
1748
+ client: PrismaManagementClient,
1749
+ projectId: string,
1750
+ cls: "production" | "preview",
1751
+ key: string,
1752
+ branchId?: string | null,
1753
+ ) =>
1754
+ client
1755
+ .listEnvironmentVariables({
1756
+ projectId,
1757
+ class: cls,
1758
+ key,
1759
+ ...(branchId ? { branchId } : {}),
1760
+ limit: 100,
1761
+ })
1762
+ .pipe(
1763
+ Effect.map((variables: ApiEnvironmentVariable[]) =>
1764
+ variables.find((variable) => variable.branchId === (branchId ?? null)),
1765
+ ),
1766
+ );
1767
+
1768
+ const systemManagedEnvironmentVariableError = (key: string) =>
1769
+ new Error(
1770
+ `Prisma environment variable '${key}' is managed by Prisma and cannot be managed by Alchemy.`,
1771
+ );
1772
+
1773
+ const ensureUserManagedEnvironmentVariable = (
1774
+ variable: ApiEnvironmentVariable,
1775
+ ) =>
1776
+ Effect.gen(function* () {
1777
+ if (variable.isManagedBySystem) {
1778
+ return yield* Effect.fail(
1779
+ systemManagedEnvironmentVariableError(variable.key),
1780
+ );
1781
+ }
1782
+ });
1783
+
1784
+ const environmentVariableOwnershipError = (key: string, variableId: string) =>
1785
+ new Error(
1786
+ `Prisma environment variable '${key}' (${variableId}) already exists in this branch/class scope but is not owned by this Compute resource. It may be foreign or left by an interrupted prior Compute deploy; the Management API exposes no ownership marker or plaintext value that would make takeover safe. Use one standalone Prisma.EnvironmentVariable resource as the independently manageable owner, choose a different key, explicitly adopt that resource, or remove the existing variable before deploying.`,
1787
+ );
1788
+
1789
+ interface ComputeEnvironmentScope {
1790
+ class: "production" | "preview";
1791
+ branchId: string | null;
1792
+ }
1793
+
1794
+ const environmentScope = (
1795
+ cls: "production" | "preview",
1796
+ branchId?: string | null,
1797
+ ): ComputeEnvironmentScope => ({
1798
+ class: cls,
1799
+ branchId: branchId ?? null,
1800
+ });
1801
+
1802
+ const sameEnvironmentScope = (
1803
+ left: ComputeEnvironmentScope,
1804
+ right: ComputeEnvironmentScope,
1805
+ ) => left.class === right.class && left.branchId === right.branchId;
1806
+
1807
+ const resolveComputeEnvironmentScope = Effect.fn(function* (
1808
+ client: PrismaManagementClient,
1809
+ app: ApiApp,
1810
+ props: ComputeProps,
1811
+ ) {
1812
+ if (!app.branchId) {
1813
+ return yield* Effect.fail(
1814
+ new Error(
1815
+ "Prisma.Compute requires an attached branch because deployment creation resolves environment variables from the App branch.",
1816
+ ),
1817
+ );
1818
+ }
1819
+
1820
+ const branch = yield* client.getBranch(app.branchId);
1821
+ const inferredClass = branch.role;
1822
+ if (props.envClass !== undefined && props.envClass !== inferredClass) {
1823
+ return yield* Effect.fail(
1824
+ new Error(
1825
+ `Prisma.Compute envClass '${props.envClass}' does not match attached branch role '${inferredClass}'. Omit envClass to let Alchemy infer the correct environment variable scope.`,
1826
+ ),
1827
+ );
1828
+ }
1829
+
1830
+ return environmentScope(
1831
+ inferredClass,
1832
+ inferredClass === "preview" ? app.branchId : null,
1833
+ );
1834
+ });
1835
+
1836
+ interface ComputeEnvironmentPlan {
1837
+ key: string;
1838
+ value: string | null;
1839
+ variable: ApiEnvironmentVariable | undefined;
1840
+ }
1841
+
1842
+ const rollbackCreatedEnvironmentVariables = Effect.fn(function* (
1843
+ client: PrismaManagementClient,
1844
+ createdIds: ReadonlyArray<{ key: string; id: string }>,
1845
+ originalError: unknown,
1846
+ ) {
1847
+ if (createdIds.length === 0) {
1848
+ return yield* Effect.fail(originalError);
1849
+ }
1850
+ const cleanupErrors: unknown[] = [];
1851
+ for (const created of [...createdIds].reverse()) {
1852
+ const result = yield* Effect.result(
1853
+ client
1854
+ .deleteEnvironmentVariable(created.id)
1855
+ .pipe(Effect.catchIf(isNotFound, () => Effect.void)),
1856
+ );
1857
+ if (Result.isFailure(result)) {
1858
+ cleanupErrors.push(result.failure);
1859
+ }
1860
+ }
1861
+ if (cleanupErrors.length > 0) {
1862
+ return yield* Effect.fail(
1863
+ new AggregateError(
1864
+ [originalError, ...cleanupErrors],
1865
+ `Failed to roll back newly created Prisma environment variables after reconcile failed. Manual cleanup: ${createdIds.map(({ id }) => `DELETE /v1/environment-variables/${id}`).join(", ")}.`,
1866
+ ),
1867
+ );
1868
+ }
1869
+ return yield* Effect.fail(originalError);
1870
+ });
1871
+
1872
+ const syncComputeEnvironmentInternal = Effect.fn(function* (
1873
+ client: PrismaManagementClient,
1874
+ projectId: string,
1875
+ cls: "production" | "preview",
1876
+ env: Record<
1877
+ string,
1878
+ string | Redacted.Redacted<string> | null | undefined
1879
+ > = {},
1880
+ branchId?: string | null,
1881
+ ownedIds: Readonly<Record<string, string>> = {},
1882
+ ) {
1883
+ const synced: string[] = [];
1884
+ const deleted: string[] = [];
1885
+ const nextOwnedIds: Record<string, string> = {};
1886
+ const createdIds: Array<{ key: string; id: string }> = [];
1887
+ const plans: ComputeEnvironmentPlan[] = [];
1888
+
1889
+ // Observe and validate the entire scope before the first write. In
1890
+ // particular, a foreign/system-owned key discovered late in the input must
1891
+ // not leave earlier keys partially created.
1892
+ for (const [key, value] of Object.entries(plainEnv(env))) {
1893
+ if (value === null) {
1894
+ yield* validateComputeEnvironmentKey(key);
1895
+ } else {
1896
+ yield* validateComputeEnvironmentWrite(key, value);
1897
+ }
1898
+ const variable = yield* findEnvironmentVariable(
1899
+ client,
1900
+ projectId,
1901
+ cls,
1902
+ key,
1903
+ branchId,
1904
+ );
1905
+ if (variable) {
1906
+ yield* ensureUserManagedEnvironmentVariable(variable);
1907
+ if (ownedIds[key] !== variable.id) {
1908
+ return yield* Effect.fail(
1909
+ environmentVariableOwnershipError(key, variable.id),
1910
+ );
1911
+ }
1912
+ }
1913
+ plans.push({ key, value, variable });
1914
+ }
1915
+
1916
+ const apply = Effect.gen(function* () {
1917
+ for (const { key, value, variable } of plans) {
1918
+ if (value === null) continue;
1919
+ if (variable) {
1920
+ yield* client.updateEnvironmentVariable(variable.id, { value });
1921
+ nextOwnedIds[key] = variable.id;
1922
+ } else {
1923
+ const created = yield* client.createEnvironmentVariable({
1924
+ projectId,
1925
+ ...(branchId ? { branchId } : {}),
1926
+ class: cls,
1927
+ key,
1928
+ value,
1929
+ });
1930
+ createdIds.push({ key, id: created.id });
1931
+ nextOwnedIds[key] = created.id;
1932
+ }
1933
+ synced.push(key);
1934
+ }
1935
+ // Apply explicit deletions only after all ownership checks and upserts.
1936
+ for (const { key, value, variable } of plans) {
1937
+ if (value !== null || !variable) continue;
1938
+ yield* client
1939
+ .deleteEnvironmentVariable(variable.id)
1940
+ .pipe(Effect.catchIf(isNotFound, () => Effect.void));
1941
+ deleted.push(key);
1942
+ }
1943
+ return { synced, deleted, ownedIds: nextOwnedIds, createdIds };
1944
+ });
1945
+
1946
+ return yield* apply.pipe(
1947
+ Effect.catch((error) =>
1948
+ rollbackCreatedEnvironmentVariables(client, createdIds, error),
1949
+ ),
1950
+ );
1951
+ });
1952
+
1953
+ export const syncComputeEnvironment = Effect.fn(function* (
1954
+ client: PrismaManagementClient,
1955
+ projectId: string,
1956
+ cls: "production" | "preview",
1957
+ env: Record<
1958
+ string,
1959
+ string | Redacted.Redacted<string> | null | undefined
1960
+ > = {},
1961
+ branchId?: string | null,
1962
+ ownedIds: Readonly<Record<string, string>> = {},
1963
+ ) {
1964
+ const result = yield* syncComputeEnvironmentInternal(
1965
+ client,
1966
+ projectId,
1967
+ cls,
1968
+ env,
1969
+ branchId,
1970
+ ownedIds,
1971
+ );
1972
+ return {
1973
+ synced: result.synced,
1974
+ deleted: result.deleted,
1975
+ ownedIds: result.ownedIds,
1976
+ };
1977
+ });
1978
+
1979
+ const destroyComputeEnvironment = Effect.fn(function* (
1980
+ client: PrismaManagementClient,
1981
+ projectId: string,
1982
+ scope: ComputeEnvironmentScope,
1983
+ ownedIds: Readonly<Record<string, string>> = {},
1984
+ ) {
1985
+ const deleted: string[] = [];
1986
+ for (const [key, ownedId] of Object.entries(ownedIds)) {
1987
+ const variable = yield* findEnvironmentVariable(
1988
+ client,
1989
+ projectId,
1990
+ scope.class,
1991
+ key,
1992
+ scope.branchId,
1993
+ ).pipe(Effect.catchIf(isNotFound, () => Effect.succeed(undefined)));
1994
+ if (!variable) continue;
1995
+ if (variable.id !== ownedId || variable.isManagedBySystem) continue;
1996
+ yield* client
1997
+ .deleteEnvironmentVariable(variable.id)
1998
+ .pipe(Effect.catchIf(isNotFound, () => Effect.void));
1999
+ deleted.push(key);
2000
+ }
2001
+ return { deleted };
2002
+ });
2003
+
2004
+ const cleanupRemovedComputeEnvironment = Effect.fn(function* (
2005
+ client: PrismaManagementClient,
2006
+ projectId: string,
2007
+ oldScope: ComputeEnvironmentScope,
2008
+ oldOwnedIds: Readonly<Record<string, string>>,
2009
+ newScope: ComputeEnvironmentScope,
2010
+ newEnv:
2011
+ | Record<string, string | Redacted.Redacted<string> | null | undefined>
2012
+ | undefined,
2013
+ ) {
2014
+ const newValues = plainEnv(newEnv);
2015
+ const deleted: string[] = [];
2016
+ for (const [key, ownedId] of Object.entries(oldOwnedIds)) {
2017
+ if (sameEnvironmentScope(oldScope, newScope) && key in newValues) continue;
2018
+ const variable = yield* findEnvironmentVariable(
2019
+ client,
2020
+ projectId,
2021
+ oldScope.class,
2022
+ key,
2023
+ oldScope.branchId,
2024
+ );
2025
+ if (!variable) continue;
2026
+ if (variable.id !== ownedId || variable.isManagedBySystem) continue;
2027
+ yield* client
2028
+ .deleteEnvironmentVariable(variable.id)
2029
+ .pipe(Effect.catchIf(isNotFound, () => Effect.void));
2030
+ deleted.push(key);
2031
+ }
2032
+ return { deleted };
2033
+ });
2034
+
2035
+ const startDev = Effect.fn(function* (id: string, props: ComputeProps) {
2036
+ const path = yield* Path.Path;
2037
+ const dev = props.dev;
2038
+ const processKey = `dev:${id}`;
2039
+ const localUrl =
2040
+ dev?.url ??
2041
+ ((dev?.port ?? props.port)
2042
+ ? `http://localhost:${dev?.port ?? props.port}`
2043
+ : undefined);
2044
+ if (!dev?.command) {
2045
+ return localUrl;
2046
+ }
2047
+
2048
+ yield* stopTrackedDevProcess(processKey);
2049
+
2050
+ const cwd = dev.cwd ? path.resolve(dev.cwd) : path.resolve(props.path ?? ".");
2051
+ const env = {
2052
+ ...processEnv(props.env),
2053
+ ...processEnv(dev.env),
2054
+ ...((dev.port ?? props.port)
2055
+ ? { PORT: String(dev.port ?? props.port) }
2056
+ : {}),
2057
+ };
2058
+ const handle = yield* ChildProcess.make(dev.command, [], {
2059
+ shell: true,
2060
+ cwd,
2061
+ env,
2062
+ extendEnv: true,
2063
+ stdin: "inherit",
2064
+ stdout: "inherit",
2065
+ stderr: "inherit",
2066
+ detached: false,
2067
+ });
2068
+ devProcesses.set(processKey, handle);
2069
+ return localUrl;
2070
+ });
2071
+
2072
+ const activeBindingEnv = (
2073
+ bindings: ResourceBinding<Compute["Binding"]>[],
2074
+ ): Record<string, string | Redacted.Redacted<string> | null | undefined> =>
2075
+ bindings
2076
+ .filter(
2077
+ (binding: ResourceBinding<Compute["Binding"]> & { action?: string }) =>
2078
+ binding.action !== "delete",
2079
+ )
2080
+ .map((binding) => binding.data?.env)
2081
+ .reduce<
2082
+ Record<string, string | Redacted.Redacted<string> | null | undefined>
2083
+ >(
2084
+ (acc, env) => (env ? { ...acc, ...env } : acc),
2085
+ {} as Record<
2086
+ string,
2087
+ string | Redacted.Redacted<string> | null | undefined
2088
+ >,
2089
+ );
2090
+
2091
+ export const ComputeProvider = () =>
2092
+ Provider.effect(
2093
+ Compute,
2094
+ Effect.gen(function* () {
2095
+ const client = yield* PrismaClient;
2096
+ return {
2097
+ stables: ["appId"],
2098
+ // Compute is a composite over App + Deployment. AppProvider owns nuke
2099
+ // enumeration to avoid deleting the same canonical App twice.
2100
+ list: () => Effect.succeed([]),
2101
+ diff: Effect.fn(function* ({ olds, news, output }) {
2102
+ if (!isInputObject(news)) return undefined;
2103
+ if (output?.local || isPrismaDevId(output?.appId)) {
2104
+ return { action: "update" } as const;
2105
+ }
2106
+ const oldProjectId =
2107
+ output?.projectId ?? unresolvedProjectIdOf(olds.project);
2108
+ const newProjectId = isResolved(news.project)
2109
+ ? unresolvedProjectIdOf(news.project)
2110
+ : undefined;
2111
+ if (concreteIdsChanged(oldProjectId, newProjectId)) {
2112
+ // A different project is a distinct API uniqueness scope, so the
2113
+ // old and replacement Apps can safely coexist.
2114
+ return { action: "replace" } as const;
2115
+ }
2116
+ if (isResolved(news.regionId) && news.regionId !== undefined) {
2117
+ const currentRegionId = output?.regionId ?? olds.regionId;
2118
+ if (
2119
+ currentRegionId !== undefined &&
2120
+ news.regionId !== currentRegionId
2121
+ ) {
2122
+ return yield* Effect.fail(
2123
+ new Error(
2124
+ `Prisma Compute App region is immutable and cannot be changed atomically without deleting the live App first. Deploy a second Compute App under a different appName in the target region, cut traffic over, then remove the original.`,
2125
+ ),
2126
+ );
2127
+ }
2128
+ }
2129
+ // Source files/build output can change with no prop change, so
2130
+ // reconcile must rerun and decide from the computed artifact hash.
2131
+ return { action: "update" } as const;
2132
+ }),
2133
+ read: Effect.fn(function* ({ id, output, olds }) {
2134
+ if (output?.local) return output;
2135
+ const appId =
2136
+ output?.appId && !isPrismaDevId(output.appId)
2137
+ ? output.appId
2138
+ : undefined;
2139
+ const app = appId
2140
+ ? yield* client
2141
+ .getApp(appId)
2142
+ .pipe(
2143
+ Effect.catchIf(isNotFound, () => Effect.succeed(undefined)),
2144
+ )
2145
+ : yield* Effect.gen(function* () {
2146
+ const projectId = unresolvedProjectIdOf(olds.project);
2147
+ return projectId
2148
+ ? yield* findApp(
2149
+ client,
2150
+ projectId,
2151
+ yield* createAppName(id, olds.appName),
2152
+ olds,
2153
+ )
2154
+ : undefined;
2155
+ });
2156
+ if (!app) return undefined;
2157
+ const readDeployment = (id: string) =>
2158
+ observeDeployment(client, id).pipe(
2159
+ Effect.catchIf(isNotFound, () => Effect.succeed(undefined)),
2160
+ );
2161
+ const outputDeployment = output?.deploymentId
2162
+ ? yield* readDeployment(output.deploymentId)
2163
+ : undefined;
2164
+ if (outputDeployment) {
2165
+ yield* ensureDeploymentMembership(
2166
+ client,
2167
+ app.id,
2168
+ outputDeployment,
2169
+ app.latestDeploymentId,
2170
+ );
2171
+ }
2172
+ const latestDeployment =
2173
+ !outputDeployment && app.latestDeploymentId
2174
+ ? yield* readDeployment(app.latestDeploymentId)
2175
+ : undefined;
2176
+ const deployment = outputDeployment ?? latestDeployment;
2177
+ const deploymentUrl = toDeploymentUrl(
2178
+ deployment?.previewDomain ?? undefined,
2179
+ );
2180
+ const appUrl = toDeploymentUrl(app.appEndpointDomain);
2181
+ const promoted =
2182
+ app.latestDeploymentId !== null &&
2183
+ deployment?.id === app.latestDeploymentId;
2184
+ const attrs: Compute["Attributes"] = {
2185
+ appId: app.id,
2186
+ deploymentId: deployment?.id,
2187
+ projectId: app.projectId ?? output?.projectId,
2188
+ appName: app.name,
2189
+ regionId: app.region.id,
2190
+ deploymentEndpointDomain: deployment?.previewDomain ?? undefined,
2191
+ deploymentUrl,
2192
+ appEndpointDomain:
2193
+ app.appEndpointDomain ?? output?.appEndpointDomain,
2194
+ url: promoted ? (appUrl ?? deploymentUrl) : deploymentUrl,
2195
+ promoted,
2196
+ previousDeploymentId: output?.previousDeploymentId,
2197
+ previousDeploymentAction: output?.previousDeploymentAction,
2198
+ readinessStatus: output?.readinessStatus,
2199
+ pendingDeploymentCleanup: output?.pendingDeploymentCleanup,
2200
+ environmentKeys: output?.environmentKeys,
2201
+ environmentVariableIds: output?.environmentVariableIds,
2202
+ environmentClass: output?.environmentClass ?? olds.envClass,
2203
+ environmentBranchId: output?.environmentBranchId,
2204
+ // A latest-deployment fallback is unrelated to a missing saved
2205
+ // deployment. Never transfer its artifact identity to other code.
2206
+ artifactHash: outputDeployment ? output?.artifactHash : undefined,
2207
+ local: false,
2208
+ };
2209
+ return appId ? attrs : Unowned(attrs);
2210
+ }),
2211
+ reconcile: Effect.fn(function* ({ id, news, olds, output, bindings }) {
2212
+ const bindingEnv = activeBindingEnv(bindings);
2213
+ const effectiveNews = {
2214
+ ...news,
2215
+ appName: yield* createAppName(id, news.appName),
2216
+ env: {
2217
+ ...bindingEnv,
2218
+ ...news.env,
2219
+ },
2220
+ };
2221
+ yield* validateComputeProps(effectiveNews);
2222
+ const projectId = yield* resolveProjectId(effectiveNews.project);
2223
+ const artifact = yield* resolveArtifact(effectiveNews);
2224
+ const cleanupArtifact = artifact.file?.cleanup ?? Effect.void;
2225
+ const releaseArtifactOnFailure = <A, E, R>(
2226
+ effect: Effect.Effect<A, E, R>,
2227
+ ) =>
2228
+ effect.pipe(
2229
+ Effect.onExit((exit) =>
2230
+ Exit.isSuccess(exit) ? Effect.void : cleanupArtifact,
2231
+ ),
2232
+ );
2233
+ const observedApp = effectiveNews.skipCodeUpload
2234
+ ? yield* releaseArtifactOnFailure(
2235
+ findExistingApp(client, output).pipe(
2236
+ Effect.retry({
2237
+ while: isAppProvisioningNotFound,
2238
+ schedule: projectConsistencySchedule,
2239
+ }),
2240
+ ),
2241
+ )
2242
+ : undefined;
2243
+ yield* releaseArtifactOnFailure(
2244
+ ensureSkipCodeUploadCanFork(effectiveNews, observedApp),
2245
+ );
2246
+ const ensuredApp = yield* releaseArtifactOnFailure(
2247
+ ensureApp(
2248
+ client,
2249
+ projectId,
2250
+ effectiveNews,
2251
+ output,
2252
+ observedApp,
2253
+ ).pipe(
2254
+ Effect.retry({
2255
+ while: isAppProvisioningNotFound,
2256
+ schedule: projectConsistencySchedule,
2257
+ }),
2258
+ ),
2259
+ );
2260
+ let app = ensuredApp.app;
2261
+ let preserveCreatedAppOnFailure = false;
2262
+ const cleanupCreatedAppOnFailure = (error: unknown) =>
2263
+ ensuredApp.created && !preserveCreatedAppOnFailure
2264
+ ? destroyApp(client, app.id).pipe(
2265
+ Effect.catch((cleanupError) =>
2266
+ Effect.fail(
2267
+ aggregateCleanupFailure(
2268
+ "App",
2269
+ app.id,
2270
+ `/v1/apps/${app.id}`,
2271
+ error,
2272
+ cleanupError,
2273
+ ),
2274
+ ),
2275
+ ),
2276
+ Effect.andThen(() => Effect.fail(error)),
2277
+ )
2278
+ : Effect.fail(error);
2279
+
2280
+ let createdEnvironmentVariableIds: Array<{
2281
+ key: string;
2282
+ id: string;
2283
+ }> = [];
2284
+ let deploymentConverged = false;
2285
+
2286
+ return yield* Effect.gen(function* () {
2287
+ const currentEnvironmentScope =
2288
+ yield* resolveComputeEnvironmentScope(client, app, effectiveNews);
2289
+ const deploymentHash = yield* sha256Object({
2290
+ artifact: artifact.hash,
2291
+ branchId: app.branchId,
2292
+ environmentClass: currentEnvironmentScope.class,
2293
+ environmentBranchId: currentEnvironmentScope.branchId,
2294
+ });
2295
+ const outputArtifactHash = persistedArtifactHashValue(
2296
+ output?.artifactHash as
2297
+ | Redacted.Redacted<string>
2298
+ | string
2299
+ | undefined,
2300
+ );
2301
+ const persistedDeployment = output?.deploymentId
2302
+ ? yield* observeDeployment(client, output.deploymentId).pipe(
2303
+ Effect.catchIf(isNotFound, () => Effect.succeed(undefined)),
2304
+ )
2305
+ : undefined;
2306
+ const terminalFailedDeploymentId =
2307
+ persistedDeployment?.status === "failed"
2308
+ ? persistedDeployment.id
2309
+ : undefined;
2310
+ const promotionRequested = !(effectiveNews.skipPromote ?? false);
2311
+ let persistedPendingCleanup = output?.pendingDeploymentCleanup;
2312
+ const cleanupPreviousDeployment = Effect.fn(function* (
2313
+ deploymentId: string,
2314
+ action: "stop" | "destroy",
2315
+ ) {
2316
+ const observed = yield* observeDeployment(
2317
+ client,
2318
+ deploymentId,
2319
+ ).pipe(
2320
+ Effect.catchIf(isNotFound, () => Effect.succeed(undefined)),
2321
+ );
2322
+ if (!observed) {
2323
+ return (action === "destroy" ? "destroyed" : "stopped") as
2324
+ | "destroyed"
2325
+ | "stopped";
2326
+ }
2327
+ yield* ensureDeploymentMembership(
2328
+ client,
2329
+ app.id,
2330
+ observed,
2331
+ app.latestDeploymentId,
2332
+ );
2333
+ if (action === "destroy") {
2334
+ yield* destroyDeployment(client, deploymentId, effectiveNews);
2335
+ return "destroyed" as const;
2336
+ }
2337
+ yield* stopDeploymentIdempotent(client, deploymentId).pipe(
2338
+ Effect.catchIf(isNotFound, () => Effect.void),
2339
+ );
2340
+ yield* waitForDeploymentStatus(
2341
+ client,
2342
+ deploymentId,
2343
+ "stopped",
2344
+ effectiveNews,
2345
+ ).pipe(
2346
+ Effect.catchIf(isNotFound, () => Effect.succeed(undefined)),
2347
+ );
2348
+ return "stopped" as const;
2349
+ });
2350
+
2351
+ if (
2352
+ terminalFailedDeploymentId !== undefined &&
2353
+ promotionRequested &&
2354
+ output?.promoted === true &&
2355
+ app.latestDeploymentId !== null &&
2356
+ app.latestDeploymentId !== terminalFailedDeploymentId
2357
+ ) {
2358
+ return yield* Effect.fail(
2359
+ new AggregateError(
2360
+ [],
2361
+ `Prisma Compute state preserves terminal failed deployment '${terminalFailedDeploymentId}', but App '${app.id}' reports deployment '${app.latestDeploymentId}' as latest. Alchemy cannot prove that the live deployment is the interrupted replacement, and the persisted failed deployment is not a safe rollback target. No new deployment was created and neither deployment was deleted.`,
2362
+ ),
2363
+ );
2364
+ }
2365
+
2366
+ // Apply persists the previous stable Attributes before reconcile.
2367
+ // If a prior attempt promoted a new generation, failed its stable
2368
+ // health check, and could not roll back, that durable output still
2369
+ // identifies the deployment we must restore while the App points
2370
+ // at the displaced unhealthy generation. Recover that transition
2371
+ // before changing env or creating another deployment, otherwise a
2372
+ // retry would use the unhealthy generation as its rollback target.
2373
+ if (
2374
+ promotionRequested &&
2375
+ output?.promoted === true &&
2376
+ output.deploymentId !== undefined &&
2377
+ terminalFailedDeploymentId === undefined &&
2378
+ outputArtifactHash !== deploymentHash &&
2379
+ app.latestDeploymentId !== null &&
2380
+ app.latestDeploymentId !== output.deploymentId
2381
+ ) {
2382
+ const persistedDeploymentId = output.deploymentId;
2383
+ const displacedDeploymentId = app.latestDeploymentId;
2384
+ const rollback = yield* client
2385
+ .rollbackApp(app.id, {
2386
+ deploymentId: persistedDeploymentId,
2387
+ })
2388
+ .pipe(Effect.result);
2389
+ const observedAfterRollback = yield* waitForAppDeploymentTarget(
2390
+ client,
2391
+ app.id,
2392
+ persistedDeploymentId,
2393
+ effectiveNews,
2394
+ ).pipe(Effect.result);
2395
+
2396
+ if (Result.isFailure(observedAfterRollback)) {
2397
+ return yield* Effect.fail(
2398
+ new AggregateError(
2399
+ [
2400
+ ...(Result.isFailure(rollback) ? [rollback.failure] : []),
2401
+ ...(Result.isFailure(observedAfterRollback)
2402
+ ? [observedAfterRollback.failure]
2403
+ : []),
2404
+ ],
2405
+ `Prisma App '${app.id}' has live deployment '${displacedDeploymentId}', while Alchemy state preserves deployment '${persistedDeploymentId}' as the prior promoted generation. Recovery via POST /v1/apps/${app.id}/rollback did not converge, so no environment variables or new deployment were changed and neither deployment was deleted.`,
2406
+ ),
2407
+ );
2408
+ }
2409
+
2410
+ app = observedAfterRollback.success;
2411
+ yield* destroyDeployment(
2412
+ client,
2413
+ displacedDeploymentId,
2414
+ effectiveNews,
2415
+ ).pipe(
2416
+ Effect.catch((cleanupError) =>
2417
+ Effect.fail(
2418
+ new AggregateError(
2419
+ [
2420
+ ...(Result.isFailure(rollback)
2421
+ ? [rollback.failure]
2422
+ : []),
2423
+ cleanupError,
2424
+ ],
2425
+ `Prisma App '${app.id}' was restored to deployment '${persistedDeploymentId}', but displaced deployment '${displacedDeploymentId}' could not be deleted. No new deployment was created; retry cleanup with DELETE /v1/deployments/${displacedDeploymentId}.`,
2426
+ ),
2427
+ ),
2428
+ ),
2429
+ );
2430
+ }
2431
+
2432
+ if (
2433
+ output?.readinessStatus === "pending" &&
2434
+ outputArtifactHash !== deploymentHash
2435
+ ) {
2436
+ return yield* Effect.fail(
2437
+ new Error(
2438
+ `Prisma Compute deployment '${output.deploymentId ?? "unknown"}' still has pending stable-endpoint readiness. Reconcile the existing generation before changing code or environment inputs.`,
2439
+ ),
2440
+ );
2441
+ }
2442
+ // Keep one cleanup candidate. A non-live older candidate is
2443
+ // drained before any env/deploy mutation; a candidate that is
2444
+ // still live is derived from app.latestDeploymentId below.
2445
+ if (
2446
+ persistedPendingCleanup !== undefined &&
2447
+ output?.readinessStatus !== "pending" &&
2448
+ persistedPendingCleanup.deploymentId !== app.latestDeploymentId
2449
+ ) {
2450
+ yield* cleanupPreviousDeployment(
2451
+ persistedPendingCleanup.deploymentId,
2452
+ persistedPendingCleanup.action,
2453
+ );
2454
+ persistedPendingCleanup = undefined;
2455
+ } else if (
2456
+ persistedPendingCleanup?.deploymentId === app.latestDeploymentId
2457
+ ) {
2458
+ persistedPendingCleanup = undefined;
2459
+ }
2460
+ const previousEnvironmentScope = environmentScope(
2461
+ olds?.envClass ?? output?.environmentClass ?? "production",
2462
+ output?.environmentBranchId,
2463
+ );
2464
+ const previousEnvironmentVariableIds =
2465
+ output?.environmentVariableIds ?? {};
2466
+ const environmentResult = yield* syncComputeEnvironmentInternal(
2467
+ client,
2468
+ projectId,
2469
+ currentEnvironmentScope.class,
2470
+ effectiveNews.env,
2471
+ currentEnvironmentScope.branchId,
2472
+ sameEnvironmentScope(
2473
+ previousEnvironmentScope,
2474
+ currentEnvironmentScope,
2475
+ )
2476
+ ? previousEnvironmentVariableIds
2477
+ : {},
2478
+ );
2479
+ createdEnvironmentVariableIds = environmentResult.createdIds;
2480
+
2481
+ // Deployment creation snapshots the App branch environment. Remove
2482
+ // formerly-owned keys before creating it so deleted keys cannot be
2483
+ // captured into the new runtime. Any failure here happens before
2484
+ // deployment creation and rolls back newly-created variables.
2485
+ yield* cleanupRemovedComputeEnvironment(
2486
+ client,
2487
+ projectId,
2488
+ previousEnvironmentScope,
2489
+ previousEnvironmentVariableIds,
2490
+ currentEnvironmentScope,
2491
+ effectiveNews.env,
2492
+ );
2493
+
2494
+ let deployment: ObservedDeployment | undefined =
2495
+ outputArtifactHash === deploymentHash
2496
+ ? persistedDeployment
2497
+ : undefined;
2498
+ // A failed deployment is terminal and cannot be repaired by
2499
+ // replaying start/promotion. Preserve it as the cleanup target,
2500
+ // but create a fresh generation and do not delete the failed one
2501
+ // until the replacement has passed preview + stable readiness and
2502
+ // promotion is observed.
2503
+ if (
2504
+ persistedDeployment !== undefined &&
2505
+ (deployment !== undefined ||
2506
+ terminalFailedDeploymentId !== undefined)
2507
+ ) {
2508
+ yield* ensureDeploymentMembership(
2509
+ client,
2510
+ app.id,
2511
+ persistedDeployment,
2512
+ app.latestDeploymentId,
2513
+ );
2514
+ }
2515
+ if (terminalFailedDeploymentId !== undefined) {
2516
+ deployment = undefined;
2517
+ }
2518
+ let createdDeploymentId: string | undefined;
2519
+ const cleanupCreatedDeploymentOnFailure = (
2520
+ failedDeploymentId: string,
2521
+ error: unknown,
2522
+ ) =>
2523
+ createdDeploymentId === failedDeploymentId
2524
+ ? destroyDeployment(
2525
+ client,
2526
+ failedDeploymentId,
2527
+ effectiveNews,
2528
+ ).pipe(
2529
+ Effect.catch((cleanupError) =>
2530
+ Effect.fail(
2531
+ aggregateCleanupFailure(
2532
+ "deployment",
2533
+ failedDeploymentId,
2534
+ `/v1/deployments/${failedDeploymentId}`,
2535
+ error,
2536
+ cleanupError,
2537
+ ),
2538
+ ),
2539
+ ),
2540
+ Effect.andThen(() => Effect.fail(error)),
2541
+ )
2542
+ : Effect.fail(error);
2543
+
2544
+ if (!deployment) {
2545
+ const created = yield* client.createAppDeployment(app.id, {
2546
+ portMapping: { http: artifact.port },
2547
+ skipCodeUpload: effectiveNews.skipCodeUpload,
2548
+ });
2549
+ createdDeploymentId = created.id;
2550
+ if (artifact.file !== undefined && !created.uploadUrl) {
2551
+ return yield* cleanupCreatedDeploymentOnFailure(
2552
+ created.id,
2553
+ new Error(
2554
+ "Prisma deployment creation did not return an upload URL.",
2555
+ ),
2556
+ );
2557
+ }
2558
+ if (created.uploadUrl && artifact.file !== undefined) {
2559
+ yield* uploadArtifact(
2560
+ created.uploadUrl,
2561
+ artifact.file,
2562
+ "application/gzip",
2563
+ ).pipe(
2564
+ Effect.catch((error) =>
2565
+ cleanupCreatedDeploymentOnFailure(created.id, error),
2566
+ ),
2567
+ );
2568
+ }
2569
+ deployment = yield* observeDeployment(client, created.id).pipe(
2570
+ Effect.catchIf(isNotFound, () =>
2571
+ Effect.succeed({
2572
+ id: created.id,
2573
+ type: "deployment" as const,
2574
+ url: created.url,
2575
+ foundryVersionId: created.foundryVersionId,
2576
+ status: "new",
2577
+ previewDomain: null,
2578
+ createdAt: undefined,
2579
+ }),
2580
+ ),
2581
+ Effect.catch((error) =>
2582
+ cleanupCreatedDeploymentOnFailure(created.id, error),
2583
+ ),
2584
+ );
2585
+ }
2586
+ if (!deployment) {
2587
+ return yield* Effect.fail(
2588
+ new Error(
2589
+ "Prisma deployment could not be resolved after creation.",
2590
+ ),
2591
+ );
2592
+ }
2593
+
2594
+ const previousDeploymentId =
2595
+ terminalFailedDeploymentId ??
2596
+ persistedPendingCleanup?.deploymentId ??
2597
+ (app.latestDeploymentId !== null &&
2598
+ app.latestDeploymentId !== deployment.id
2599
+ ? app.latestDeploymentId
2600
+ : null);
2601
+ const rollbackDeploymentId =
2602
+ previousDeploymentId === terminalFailedDeploymentId
2603
+ ? null
2604
+ : previousDeploymentId;
2605
+
2606
+ if (effectiveNews.start ?? true) {
2607
+ const currentDeployment = deployment;
2608
+ const currentDeploymentId = currentDeployment.id;
2609
+ deployment = yield* Effect.gen(function* () {
2610
+ if (
2611
+ currentDeployment.status !== "running" &&
2612
+ currentDeployment.status !== "provisioning"
2613
+ ) {
2614
+ yield* startDeploymentIdempotent(
2615
+ client,
2616
+ currentDeployment.id,
2617
+ );
2618
+ }
2619
+ const running = yield* waitForDeploymentStatus(
2620
+ client,
2621
+ currentDeployment.id,
2622
+ "running",
2623
+ effectiveNews,
2624
+ );
2625
+ yield* waitForDeploymentUrl(
2626
+ toDeploymentUrl(running.previewDomain),
2627
+ effectiveNews,
2628
+ );
2629
+ return running;
2630
+ }).pipe(
2631
+ Effect.catch((error) =>
2632
+ cleanupCreatedDeploymentOnFailure(currentDeploymentId, error),
2633
+ ),
2634
+ );
2635
+ }
2636
+
2637
+ let appEndpointDomain = app.appEndpointDomain;
2638
+ let previousDeploymentAction:
2639
+ | "stopped"
2640
+ | "destroyed"
2641
+ | "still-active"
2642
+ | null = previousDeploymentId ? "still-active" : null;
2643
+ let promoted = app.latestDeploymentId === deployment.id;
2644
+ if (promotionRequested) {
2645
+ // Replay promotion even when latestDeploymentId already matches.
2646
+ // Promotion also repairs endpoint/custom-domain routing drift.
2647
+ preserveCreatedAppOnFailure = true;
2648
+ const promotedApp = yield* promoteAppObserved(
2649
+ client,
2650
+ app.id,
2651
+ deployment.id,
2652
+ effectiveNews,
2653
+ );
2654
+ appEndpointDomain = promotedApp.appEndpointDomain;
2655
+ promoted = true;
2656
+ }
2657
+
2658
+ const deploymentUrl = toDeploymentUrl(deployment.previewDomain);
2659
+ const appUrl =
2660
+ toDeploymentUrl(appEndpointDomain) ??
2661
+ toDeploymentUrl(deployment.previewDomain);
2662
+ let readinessStatus: "ready" | "pending" | "skipped" = "skipped";
2663
+ if (promoted && effectiveNews.verifyUrl !== false) {
2664
+ const readiness = yield* waitForDeploymentUrl(
2665
+ appUrl,
2666
+ effectiveNews,
2667
+ ).pipe(Effect.result);
2668
+ if (Result.isSuccess(readiness)) {
2669
+ readinessStatus = "ready";
2670
+ } else if (rollbackDeploymentId) {
2671
+ const rollback = yield* client
2672
+ .rollbackApp(app.id, {
2673
+ deploymentId: rollbackDeploymentId,
2674
+ })
2675
+ .pipe(Effect.result);
2676
+ const observedAfterRollback = yield* waitForAppDeploymentTarget(
2677
+ client,
2678
+ app.id,
2679
+ rollbackDeploymentId,
2680
+ effectiveNews,
2681
+ ).pipe(Effect.result);
2682
+ if (Result.isSuccess(observedAfterRollback)) {
2683
+ return yield* cleanupCreatedDeploymentOnFailure(
2684
+ deployment.id,
2685
+ Result.isSuccess(rollback)
2686
+ ? readiness.failure
2687
+ : new AggregateError(
2688
+ [readiness.failure, rollback.failure],
2689
+ `Prisma App '${app.id}' endpoint was restored to deployment '${rollbackDeploymentId}', but the rollback response was lost.`,
2690
+ ),
2691
+ );
2692
+ }
2693
+
2694
+ return yield* Effect.fail(
2695
+ new AggregateError(
2696
+ [
2697
+ readiness.failure,
2698
+ ...(Result.isFailure(rollback) ? [rollback.failure] : []),
2699
+ observedAfterRollback.failure,
2700
+ ],
2701
+ `Prisma App '${app.id}' promoted deployment '${deployment.id}', but its stable endpoint failed readiness and rollback to deployment '${rollbackDeploymentId}' did not converge. Alchemy preserved the prior deployment in state and deleted neither deployment; the next reconcile will retry recovery via POST /v1/apps/${app.id}/rollback before making any new cloud changes.`,
2702
+ ),
2703
+ );
2704
+ } else {
2705
+ // A first deployment has no safe rollback target. Never report
2706
+ // a successful stack deployment while the production endpoint
2707
+ // is unreachable. A newly created App can be fully cleaned up;
2708
+ // a pre-existing App is preserved for observed-state recovery.
2709
+ if (ensuredApp.created) {
2710
+ preserveCreatedAppOnFailure = false;
2711
+ } else {
2712
+ deploymentConverged = true;
2713
+ }
2714
+ if (terminalFailedDeploymentId !== undefined) {
2715
+ return yield* Effect.fail(
2716
+ new AggregateError(
2717
+ [readiness.failure],
2718
+ `Prisma App '${app.id}' promoted replacement deployment '${deployment.id}', but stable readiness failed and persisted deployment '${terminalFailedDeploymentId}' is terminal failed, so no safe rollback target exists. Neither deployment was deleted; a retry will refuse to create another generation while the live target differs from persisted state.`,
2719
+ ),
2720
+ );
2721
+ }
2722
+ return yield* Effect.fail(readiness.failure);
2723
+ }
2724
+ }
2725
+
2726
+ deploymentConverged = true;
2727
+ let pendingDeploymentCleanup =
2728
+ promoted &&
2729
+ previousDeploymentId &&
2730
+ previousDeploymentId !== deployment.id
2731
+ ? {
2732
+ deploymentId: previousDeploymentId,
2733
+ action:
2734
+ persistedPendingCleanup?.deploymentId ===
2735
+ previousDeploymentId
2736
+ ? persistedPendingCleanup.action
2737
+ : previousDeploymentId === terminalFailedDeploymentId
2738
+ ? ("destroy" as const)
2739
+ : effectiveNews.destroyOldDeployment
2740
+ ? ("destroy" as const)
2741
+ : ("stop" as const),
2742
+ }
2743
+ : undefined;
2744
+ if (promoted && pendingDeploymentCleanup) {
2745
+ const cleanup = yield* cleanupPreviousDeployment(
2746
+ pendingDeploymentCleanup.deploymentId,
2747
+ pendingDeploymentCleanup.action,
2748
+ ).pipe(Effect.result);
2749
+ if (Result.isSuccess(cleanup)) {
2750
+ previousDeploymentAction = cleanup.success;
2751
+ pendingDeploymentCleanup = undefined;
2752
+ } else {
2753
+ yield* Effect.logWarning(
2754
+ `Prisma deployment '${pendingDeploymentCleanup.deploymentId}' cleanup is pending and will be retried before another Compute generation is created.`,
2755
+ );
2756
+ }
2757
+ }
2758
+
2759
+ return {
2760
+ appId: app.id,
2761
+ deploymentId: deployment.id,
2762
+ projectId,
2763
+ appName: app.name,
2764
+ regionId: app.region.id,
2765
+ deploymentEndpointDomain: deployment.previewDomain ?? undefined,
2766
+ deploymentUrl,
2767
+ appEndpointDomain,
2768
+ url: promoted ? appUrl : deploymentUrl,
2769
+ promoted,
2770
+ previousDeploymentId,
2771
+ previousDeploymentAction,
2772
+ readinessStatus,
2773
+ pendingDeploymentCleanup,
2774
+ environmentKeys: managedEnvKeys(effectiveNews.env),
2775
+ environmentVariableIds: environmentResult.ownedIds,
2776
+ environmentClass: currentEnvironmentScope.class,
2777
+ environmentBranchId: currentEnvironmentScope.branchId,
2778
+ artifactHash: Redacted.make(deploymentHash),
2779
+ local: false,
2780
+ };
2781
+ }).pipe(
2782
+ Effect.catch((error) =>
2783
+ deploymentConverged
2784
+ ? Effect.fail(error)
2785
+ : rollbackCreatedEnvironmentVariables(
2786
+ client,
2787
+ createdEnvironmentVariableIds,
2788
+ error,
2789
+ ),
2790
+ ),
2791
+ Effect.catch(cleanupCreatedAppOnFailure),
2792
+ Effect.ensuring(cleanupArtifact),
2793
+ );
2794
+ }),
2795
+ delete: Effect.fn(function* ({ olds, output }) {
2796
+ if (output.local || isPrismaDevId(output.appId)) {
2797
+ yield* stopTrackedDevProcess(output.appId);
2798
+ return;
2799
+ }
2800
+ yield* destroyComputeEnvironment(
2801
+ client,
2802
+ output.projectId,
2803
+ environmentScope(
2804
+ olds?.envClass ?? output.environmentClass ?? "production",
2805
+ output.environmentBranchId,
2806
+ ),
2807
+ output.environmentVariableIds,
2808
+ );
2809
+ yield* destroyApp(client, output.appId);
2810
+ }),
2811
+ tail: ({ output }) =>
2812
+ output.deploymentId
2813
+ ? tailDeploymentLogs(client, output.deploymentId)
2814
+ : Stream.empty,
2815
+ };
2816
+ }),
2817
+ );
2818
+
2819
+ export const ComputeDevProvider = () =>
2820
+ Provider.effect(
2821
+ Compute,
2822
+ Effect.gen(function* () {
2823
+ const ctx = yield* AlchemyContext;
2824
+ return {
2825
+ stables: ["appId"],
2826
+ list: () => Effect.succeed([]),
2827
+ diff: Effect.fn(function* () {
2828
+ return { action: "update" } as const;
2829
+ }),
2830
+ read: Effect.fn(function* ({ output }) {
2831
+ return output?.local ? output : undefined;
2832
+ }),
2833
+ reconcile: Effect.fn(function* ({ id, news, output, bindings }) {
2834
+ const bindingEnv = activeBindingEnv(bindings);
2835
+ const effectiveNews = {
2836
+ ...news,
2837
+ env: {
2838
+ ...bindingEnv,
2839
+ ...news.env,
2840
+ },
2841
+ };
2842
+ yield* validateComputeProps(effectiveNews);
2843
+ const projectId = yield* resolveProjectId(effectiveNews.project);
2844
+ if (!ctx.dev) {
2845
+ return yield* Effect.fail(
2846
+ new Error("ComputeDevProvider requires Alchemy dev mode."),
2847
+ );
2848
+ }
2849
+ const localUrl = yield* startDev(id, effectiveNews);
2850
+ return {
2851
+ appId: output?.appId ?? `dev:${id}`,
2852
+ deploymentId: undefined,
2853
+ projectId,
2854
+ appName: effectiveNews.appName ?? id,
2855
+ regionId: effectiveNews.regionId ?? "us-east-1",
2856
+ deploymentEndpointDomain: localUrl,
2857
+ deploymentUrl: localUrl,
2858
+ appEndpointDomain: localUrl,
2859
+ url: localUrl,
2860
+ promoted: false,
2861
+ previousDeploymentId: undefined,
2862
+ previousDeploymentAction: undefined,
2863
+ readinessStatus: "skipped",
2864
+ pendingDeploymentCleanup: undefined,
2865
+ environmentKeys: managedEnvKeys(effectiveNews.env),
2866
+ environmentVariableIds: {},
2867
+ environmentClass: effectiveNews.envClass ?? "production",
2868
+ environmentBranchId: null,
2869
+ artifactHash: undefined,
2870
+ local: true,
2871
+ };
2872
+ }),
2873
+ delete: Effect.fn(function* ({ output }) {
2874
+ yield* stopTrackedDevProcess(output.appId);
2875
+ }),
2876
+ };
2877
+ }),
2878
+ );