alchemy-effect 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (428) hide show
  1. package/bin/alchemy-effect.js +55038 -8
  2. package/bin/alchemy-effect.js.map +1 -1
  3. package/bin/alchemy-effect.ts +266 -10
  4. package/lib/$.d.ts +5 -0
  5. package/lib/$.d.ts.map +1 -0
  6. package/lib/$.js +9 -0
  7. package/lib/$.js.map +1 -0
  8. package/lib/app.d.ts +4 -17
  9. package/lib/app.d.ts.map +1 -1
  10. package/lib/app.js +0 -20
  11. package/lib/app.js.map +1 -1
  12. package/lib/apply.d.ts +14 -74
  13. package/lib/apply.d.ts.map +1 -1
  14. package/lib/apply.js +62 -57
  15. package/lib/apply.js.map +1 -1
  16. package/lib/assert-never.d.ts +12 -0
  17. package/lib/assert-never.d.ts.map +1 -0
  18. package/lib/assert-never.js +11 -0
  19. package/lib/assert-never.js.map +1 -0
  20. package/lib/aws/account.d.ts +10 -1
  21. package/lib/aws/account.d.ts.map +1 -1
  22. package/lib/aws/account.js +18 -3
  23. package/lib/aws/account.js.map +1 -1
  24. package/lib/aws/client.d.ts.map +1 -1
  25. package/lib/aws/client.js +0 -1
  26. package/lib/aws/client.js.map +1 -1
  27. package/lib/aws/config.d.ts +15 -0
  28. package/lib/aws/config.d.ts.map +1 -0
  29. package/lib/aws/config.js +1 -0
  30. package/lib/aws/config.js.map +1 -0
  31. package/lib/aws/credentials.d.ts +10 -0
  32. package/lib/aws/credentials.d.ts.map +1 -1
  33. package/lib/aws/credentials.js +73 -47
  34. package/lib/aws/credentials.js.map +1 -1
  35. package/lib/aws/dynamodb/client.d.ts +1 -1
  36. package/lib/aws/dynamodb/client.d.ts.map +1 -1
  37. package/lib/aws/dynamodb/index.d.ts +2 -1
  38. package/lib/aws/dynamodb/index.d.ts.map +1 -1
  39. package/lib/aws/dynamodb/index.js +1 -2
  40. package/lib/aws/dynamodb/index.js.map +1 -1
  41. package/lib/aws/dynamodb/secondary-index.d.ts +5 -4
  42. package/lib/aws/dynamodb/secondary-index.d.ts.map +1 -1
  43. package/lib/aws/dynamodb/table.d.ts +23 -20
  44. package/lib/aws/dynamodb/table.d.ts.map +1 -1
  45. package/lib/aws/dynamodb/table.get-item.d.ts +8 -6
  46. package/lib/aws/dynamodb/table.get-item.d.ts.map +1 -1
  47. package/lib/aws/dynamodb/table.get-item.js +4 -2
  48. package/lib/aws/dynamodb/table.get-item.js.map +1 -1
  49. package/lib/aws/dynamodb/table.js.map +1 -1
  50. package/lib/aws/dynamodb/table.provider.d.ts +3 -4
  51. package/lib/aws/dynamodb/table.provider.d.ts.map +1 -1
  52. package/lib/aws/dynamodb/table.provider.js +17 -29
  53. package/lib/aws/dynamodb/table.provider.js.map +1 -1
  54. package/lib/aws/ec2/client.d.ts +1 -1
  55. package/lib/aws/ec2/client.d.ts.map +1 -1
  56. package/lib/aws/ec2/index.d.ts +3 -0
  57. package/lib/aws/ec2/index.d.ts.map +1 -1
  58. package/lib/aws/ec2/index.js +3 -0
  59. package/lib/aws/ec2/index.js.map +1 -1
  60. package/lib/aws/ec2/subnet.d.ts +175 -0
  61. package/lib/aws/ec2/subnet.d.ts.map +1 -0
  62. package/lib/aws/ec2/subnet.js +4 -0
  63. package/lib/aws/ec2/subnet.js.map +1 -0
  64. package/lib/aws/ec2/subnet.provider.d.ts +4 -0
  65. package/lib/aws/ec2/subnet.provider.d.ts.map +1 -0
  66. package/lib/aws/ec2/subnet.provider.js +250 -0
  67. package/lib/aws/ec2/subnet.provider.js.map +1 -0
  68. package/lib/aws/ec2/vpc.d.ts +12 -8
  69. package/lib/aws/ec2/vpc.d.ts.map +1 -1
  70. package/lib/aws/ec2/vpc.js +1 -0
  71. package/lib/aws/ec2/vpc.js.map +1 -1
  72. package/lib/aws/ec2/vpc.provider.d.ts +3 -4
  73. package/lib/aws/ec2/vpc.provider.d.ts.map +1 -1
  74. package/lib/aws/ec2/vpc.provider.js +11 -26
  75. package/lib/aws/ec2/vpc.provider.js.map +1 -1
  76. package/lib/aws/index.d.ts +16 -19
  77. package/lib/aws/index.d.ts.map +1 -1
  78. package/lib/aws/index.js +7 -10
  79. package/lib/aws/index.js.map +1 -1
  80. package/lib/aws/lambda/consume.d.ts +10 -11
  81. package/lib/aws/lambda/consume.d.ts.map +1 -1
  82. package/lib/aws/lambda/consume.js +3 -3
  83. package/lib/aws/lambda/consume.js.map +1 -1
  84. package/lib/aws/lambda/function.d.ts +7 -7
  85. package/lib/aws/lambda/function.d.ts.map +1 -1
  86. package/lib/aws/lambda/function.handler.d.ts +1 -1
  87. package/lib/aws/lambda/function.handler.d.ts.map +1 -1
  88. package/lib/aws/lambda/function.handler.js.map +1 -1
  89. package/lib/aws/lambda/function.invoke.d.ts +6 -4
  90. package/lib/aws/lambda/function.invoke.d.ts.map +1 -1
  91. package/lib/aws/lambda/function.invoke.js +3 -1
  92. package/lib/aws/lambda/function.invoke.js.map +1 -1
  93. package/lib/aws/lambda/function.js +1 -1
  94. package/lib/aws/lambda/function.js.map +1 -1
  95. package/lib/aws/lambda/function.provider.d.ts +5 -4
  96. package/lib/aws/lambda/function.provider.d.ts.map +1 -1
  97. package/lib/aws/lambda/function.provider.js +16 -14
  98. package/lib/aws/lambda/function.provider.js.map +1 -1
  99. package/lib/aws/lambda/index.d.ts +1 -0
  100. package/lib/aws/lambda/index.d.ts.map +1 -1
  101. package/lib/aws/lambda/index.js +1 -0
  102. package/lib/aws/lambda/index.js.map +1 -1
  103. package/lib/aws/lambda/serve.d.ts +2 -4
  104. package/lib/aws/lambda/serve.d.ts.map +1 -1
  105. package/lib/aws/profile.d.ts +2 -2
  106. package/lib/aws/profile.d.ts.map +1 -1
  107. package/lib/aws/profile.js +1 -1
  108. package/lib/aws/profile.js.map +1 -1
  109. package/lib/aws/region.d.ts +14 -2
  110. package/lib/aws/region.d.ts.map +1 -1
  111. package/lib/aws/region.js +26 -1
  112. package/lib/aws/region.js.map +1 -1
  113. package/lib/aws/sqs/client.d.ts +1 -1
  114. package/lib/aws/sqs/client.d.ts.map +1 -1
  115. package/lib/aws/sqs/index.d.ts +1 -0
  116. package/lib/aws/sqs/index.d.ts.map +1 -1
  117. package/lib/aws/sqs/index.js +1 -0
  118. package/lib/aws/sqs/index.js.map +1 -1
  119. package/lib/aws/sqs/queue.consume.d.ts +1 -1
  120. package/lib/aws/sqs/queue.consume.d.ts.map +1 -1
  121. package/lib/aws/sqs/queue.consume.js +0 -1
  122. package/lib/aws/sqs/queue.consume.js.map +1 -1
  123. package/lib/aws/sqs/queue.d.ts +6 -4
  124. package/lib/aws/sqs/queue.d.ts.map +1 -1
  125. package/lib/aws/sqs/queue.event-source.d.ts +8 -6
  126. package/lib/aws/sqs/queue.event-source.d.ts.map +1 -1
  127. package/lib/aws/sqs/queue.event-source.js +26 -44
  128. package/lib/aws/sqs/queue.event-source.js.map +1 -1
  129. package/lib/aws/sqs/queue.js +1 -1
  130. package/lib/aws/sqs/queue.js.map +1 -1
  131. package/lib/aws/sqs/queue.provider.d.ts +4 -4
  132. package/lib/aws/sqs/queue.provider.d.ts.map +1 -1
  133. package/lib/aws/sqs/queue.provider.js +3 -3
  134. package/lib/aws/sqs/queue.provider.js.map +1 -1
  135. package/lib/aws/sqs/queue.send-message.d.ts +7 -5
  136. package/lib/aws/sqs/queue.send-message.d.ts.map +1 -1
  137. package/lib/aws/sqs/queue.send-message.js +4 -2
  138. package/lib/aws/sqs/queue.send-message.js.map +1 -1
  139. package/lib/binding.d.ts +12 -12
  140. package/lib/binding.d.ts.map +1 -1
  141. package/lib/binding.js.map +1 -1
  142. package/lib/cli/components/ApprovePlan.d.ts +2 -2
  143. package/lib/cli/components/ApprovePlan.d.ts.map +1 -1
  144. package/lib/cli/components/ApprovePlan.js.map +1 -1
  145. package/lib/cli/components/Plan.d.ts +2 -2
  146. package/lib/cli/components/Plan.d.ts.map +1 -1
  147. package/lib/cli/components/Plan.js.map +1 -1
  148. package/lib/cli/components/PlanProgress.d.ts +8 -4
  149. package/lib/cli/components/PlanProgress.d.ts.map +1 -1
  150. package/lib/cli/components/PlanProgress.js +11 -1
  151. package/lib/cli/components/PlanProgress.js.map +1 -1
  152. package/lib/cli/index.d.ts +265 -224
  153. package/lib/cli/index.d.ts.map +1 -1
  154. package/lib/cli/index.js +57 -65
  155. package/lib/cli/index.js.map +1 -1
  156. package/lib/cli/ink-service.d.ts +4 -0
  157. package/lib/cli/ink-service.d.ts.map +1 -0
  158. package/lib/cli/ink-service.js +43 -0
  159. package/lib/cli/ink-service.js.map +1 -0
  160. package/lib/cli/service.d.ts +21 -0
  161. package/lib/cli/service.d.ts.map +1 -0
  162. package/lib/cli/service.js +5 -0
  163. package/lib/cli/service.js.map +1 -0
  164. package/lib/cloudflare/account.d.ts +10 -0
  165. package/lib/cloudflare/account.d.ts.map +1 -0
  166. package/lib/cloudflare/account.js +24 -0
  167. package/lib/cloudflare/account.js.map +1 -0
  168. package/lib/cloudflare/api.d.ts +7 -7
  169. package/lib/cloudflare/api.d.ts.map +1 -1
  170. package/lib/cloudflare/api.js +18 -17
  171. package/lib/cloudflare/api.js.map +1 -1
  172. package/lib/cloudflare/config.d.ts +9 -0
  173. package/lib/cloudflare/config.d.ts.map +1 -0
  174. package/lib/cloudflare/config.js +1 -0
  175. package/lib/cloudflare/config.js.map +1 -0
  176. package/lib/cloudflare/index.d.ts +3 -1
  177. package/lib/cloudflare/index.d.ts.map +1 -1
  178. package/lib/cloudflare/index.js +3 -0
  179. package/lib/cloudflare/index.js.map +1 -1
  180. package/lib/cloudflare/kv/namespace.binding.d.ts +5 -3
  181. package/lib/cloudflare/kv/namespace.binding.d.ts.map +1 -1
  182. package/lib/cloudflare/kv/namespace.binding.js +1 -1
  183. package/lib/cloudflare/kv/namespace.binding.js.map +1 -1
  184. package/lib/cloudflare/kv/namespace.d.ts +3 -2
  185. package/lib/cloudflare/kv/namespace.d.ts.map +1 -1
  186. package/lib/cloudflare/kv/namespace.js.map +1 -1
  187. package/lib/cloudflare/kv/namespace.provider.d.ts +3 -2
  188. package/lib/cloudflare/kv/namespace.provider.d.ts.map +1 -1
  189. package/lib/cloudflare/kv/namespace.provider.js +8 -7
  190. package/lib/cloudflare/kv/namespace.provider.js.map +1 -1
  191. package/lib/cloudflare/live.d.ts +5 -5
  192. package/lib/cloudflare/live.d.ts.map +1 -1
  193. package/lib/cloudflare/live.js +5 -8
  194. package/lib/cloudflare/live.js.map +1 -1
  195. package/lib/cloudflare/r2/bucket.binding.d.ts +5 -3
  196. package/lib/cloudflare/r2/bucket.binding.d.ts.map +1 -1
  197. package/lib/cloudflare/r2/bucket.binding.js +1 -1
  198. package/lib/cloudflare/r2/bucket.binding.js.map +1 -1
  199. package/lib/cloudflare/r2/bucket.d.ts +3 -2
  200. package/lib/cloudflare/r2/bucket.d.ts.map +1 -1
  201. package/lib/cloudflare/r2/bucket.js.map +1 -1
  202. package/lib/cloudflare/r2/bucket.provider.d.ts +3 -2
  203. package/lib/cloudflare/r2/bucket.provider.d.ts.map +1 -1
  204. package/lib/cloudflare/r2/bucket.provider.js +8 -7
  205. package/lib/cloudflare/r2/bucket.provider.js.map +1 -1
  206. package/lib/cloudflare/worker/assets.fetch.d.ts +3 -2
  207. package/lib/cloudflare/worker/assets.fetch.d.ts.map +1 -1
  208. package/lib/cloudflare/worker/assets.fetch.js +2 -1
  209. package/lib/cloudflare/worker/assets.fetch.js.map +1 -1
  210. package/lib/cloudflare/worker/assets.provider.d.ts +1 -1
  211. package/lib/cloudflare/worker/assets.provider.d.ts.map +1 -1
  212. package/lib/cloudflare/worker/index.d.ts +0 -1
  213. package/lib/cloudflare/worker/index.d.ts.map +1 -1
  214. package/lib/cloudflare/worker/worker.d.ts +5 -6
  215. package/lib/cloudflare/worker/worker.d.ts.map +1 -1
  216. package/lib/cloudflare/worker/worker.handler.d.ts +1 -1
  217. package/lib/cloudflare/worker/worker.handler.d.ts.map +1 -1
  218. package/lib/cloudflare/worker/worker.handler.js.map +1 -1
  219. package/lib/cloudflare/worker/worker.js.map +1 -1
  220. package/lib/cloudflare/worker/worker.provider.d.ts +3 -2
  221. package/lib/cloudflare/worker/worker.provider.d.ts.map +1 -1
  222. package/lib/cloudflare/worker/worker.provider.js +7 -6
  223. package/lib/cloudflare/worker/worker.provider.js.map +1 -1
  224. package/lib/cloudflare/worker/worker.serve.d.ts +7 -7
  225. package/lib/cloudflare/worker/worker.serve.d.ts.map +1 -1
  226. package/lib/cloudflare/worker/worker.serve.js.map +1 -1
  227. package/lib/data.d.ts +3 -0
  228. package/lib/data.d.ts.map +1 -0
  229. package/lib/data.js +8 -0
  230. package/lib/data.js.map +1 -0
  231. package/lib/destroy.d.ts +1 -1
  232. package/lib/destroy.d.ts.map +1 -1
  233. package/lib/destroy.js +1 -4
  234. package/lib/destroy.js.map +1 -1
  235. package/lib/diff.d.ts +16 -0
  236. package/lib/diff.d.ts.map +1 -0
  237. package/lib/diff.js +9 -0
  238. package/lib/diff.js.map +1 -0
  239. package/lib/env.d.ts +5 -0
  240. package/lib/env.d.ts.map +1 -1
  241. package/lib/env.js +15 -29
  242. package/lib/env.js.map +1 -1
  243. package/lib/exports.d.ts +9 -0
  244. package/lib/exports.d.ts.map +1 -0
  245. package/lib/exports.js +13 -0
  246. package/lib/exports.js.map +1 -0
  247. package/lib/index.d.ts +10 -2
  248. package/lib/index.d.ts.map +1 -1
  249. package/lib/index.js +10 -5
  250. package/lib/index.js.map +1 -1
  251. package/lib/input.d.ts +32 -0
  252. package/lib/input.d.ts.map +1 -0
  253. package/lib/input.js +1 -0
  254. package/lib/input.js.map +1 -0
  255. package/lib/output.d.ts +143 -0
  256. package/lib/output.d.ts.map +1 -0
  257. package/lib/output.js +269 -0
  258. package/lib/output.js.map +1 -0
  259. package/lib/plan.d.ts +47 -28
  260. package/lib/plan.d.ts.map +1 -1
  261. package/lib/plan.js +257 -151
  262. package/lib/plan.js.map +1 -1
  263. package/lib/policy.d.ts +3 -4
  264. package/lib/policy.d.ts.map +1 -1
  265. package/lib/policy.js +0 -1
  266. package/lib/policy.js.map +1 -1
  267. package/lib/provider.d.ts +14 -16
  268. package/lib/provider.d.ts.map +1 -1
  269. package/lib/ref.d.ts +14 -0
  270. package/lib/ref.d.ts.map +1 -0
  271. package/lib/ref.js +21 -0
  272. package/lib/ref.js.map +1 -0
  273. package/lib/resource.d.ts +11 -6
  274. package/lib/resource.d.ts.map +1 -1
  275. package/lib/resource.js.map +1 -1
  276. package/lib/runtime.d.ts +7 -6
  277. package/lib/runtime.d.ts.map +1 -1
  278. package/lib/runtime.js.map +1 -1
  279. package/lib/service.d.ts +9 -6
  280. package/lib/service.d.ts.map +1 -1
  281. package/lib/service.js.map +1 -1
  282. package/lib/stack.d.ts +60 -0
  283. package/lib/stack.d.ts.map +1 -0
  284. package/lib/stack.js +11 -0
  285. package/lib/stack.js.map +1 -0
  286. package/lib/stage.d.ts +39 -0
  287. package/lib/stage.d.ts.map +1 -0
  288. package/lib/stage.js +32 -0
  289. package/lib/stage.js.map +1 -0
  290. package/lib/state.d.ts +51 -10
  291. package/lib/state.d.ts.map +1 -1
  292. package/lib/state.js +30 -29
  293. package/lib/state.js.map +1 -1
  294. package/lib/test.d.ts +25 -4
  295. package/lib/test.d.ts.map +1 -1
  296. package/lib/test.js +54 -14
  297. package/lib/test.js.map +1 -1
  298. package/lib/tsconfig.test.tsbuildinfo +1 -1
  299. package/lib/type.d.ts +3 -0
  300. package/lib/type.d.ts.map +1 -1
  301. package/lib/unknown.d.ts +4 -0
  302. package/lib/unknown.d.ts.map +1 -0
  303. package/lib/unknown.js +4 -0
  304. package/lib/unknown.js.map +1 -0
  305. package/lib/user.d.ts +3 -0
  306. package/lib/user.d.ts.map +1 -0
  307. package/lib/user.js +3 -0
  308. package/lib/user.js.map +1 -0
  309. package/lib/util.d.ts +6 -0
  310. package/lib/util.d.ts.map +1 -0
  311. package/lib/util.js +9 -0
  312. package/lib/util.js.map +1 -0
  313. package/package.json +18 -12
  314. package/src/$.ts +17 -0
  315. package/src/app.ts +3 -32
  316. package/src/apply.ts +429 -441
  317. package/src/assert-never.ts +18 -0
  318. package/src/aws/account.ts +23 -3
  319. package/src/aws/client.ts +0 -1
  320. package/src/aws/config.ts +16 -0
  321. package/src/aws/credentials.ts +212 -177
  322. package/src/aws/dynamodb/index.ts +3 -3
  323. package/src/aws/dynamodb/table.get-item.ts +5 -9
  324. package/src/aws/dynamodb/table.provider.ts +35 -39
  325. package/src/aws/dynamodb/table.ts +29 -84
  326. package/src/aws/ec2/index.ts +4 -0
  327. package/src/aws/ec2/subnet.provider.ts +358 -0
  328. package/src/aws/ec2/subnet.ts +213 -0
  329. package/src/aws/ec2/vpc.provider.ts +20 -36
  330. package/src/aws/ec2/vpc.ts +19 -8
  331. package/src/aws/index.ts +46 -40
  332. package/src/aws/lambda/consume.ts +8 -7
  333. package/src/aws/lambda/function.handler.ts +1 -1
  334. package/src/aws/lambda/function.invoke.ts +6 -2
  335. package/src/aws/lambda/function.provider.ts +28 -21
  336. package/src/aws/lambda/function.ts +7 -4
  337. package/src/aws/lambda/index.ts +2 -0
  338. package/src/aws/profile.ts +1 -4
  339. package/src/aws/region.ts +42 -3
  340. package/src/aws/sqs/index.ts +2 -0
  341. package/src/aws/sqs/queue.consume.ts +1 -1
  342. package/src/aws/sqs/queue.event-source.ts +29 -55
  343. package/src/aws/sqs/queue.provider.ts +11 -4
  344. package/src/aws/sqs/queue.send-message.ts +5 -8
  345. package/src/aws/sqs/queue.ts +9 -4
  346. package/src/binding.ts +19 -19
  347. package/src/cli/components/ApprovePlan.tsx +2 -2
  348. package/src/cli/components/Plan.tsx +3 -2
  349. package/src/cli/components/PlanProgress.tsx +32 -14
  350. package/src/cli/index.ts +2 -6
  351. package/src/cli/ink-service.tsx +61 -0
  352. package/src/cli/service.ts +23 -0
  353. package/src/cloudflare/account.ts +37 -0
  354. package/src/cloudflare/api.ts +33 -29
  355. package/src/cloudflare/config.ts +7 -0
  356. package/src/cloudflare/index.ts +3 -1
  357. package/src/cloudflare/kv/namespace.binding.ts +3 -1
  358. package/src/cloudflare/kv/namespace.provider.ts +9 -8
  359. package/src/cloudflare/kv/namespace.ts +3 -2
  360. package/src/cloudflare/live.ts +11 -17
  361. package/src/cloudflare/r2/bucket.binding.ts +3 -1
  362. package/src/cloudflare/r2/bucket.provider.ts +9 -8
  363. package/src/cloudflare/r2/bucket.ts +8 -2
  364. package/src/cloudflare/worker/assets.fetch.ts +3 -1
  365. package/src/cloudflare/worker/assets.provider.ts +1 -1
  366. package/src/cloudflare/worker/index.ts +0 -2
  367. package/src/cloudflare/worker/worker.handler.ts +1 -1
  368. package/src/cloudflare/worker/worker.provider.ts +16 -13
  369. package/src/cloudflare/worker/worker.serve.ts +5 -2
  370. package/src/cloudflare/worker/worker.ts +4 -3
  371. package/src/data.ts +18 -0
  372. package/src/destroy.ts +1 -5
  373. package/src/diff.ts +30 -0
  374. package/src/env.ts +20 -32
  375. package/src/exports.ts +21 -0
  376. package/src/index.ts +10 -5
  377. package/src/input.ts +81 -0
  378. package/src/output.ts +518 -0
  379. package/src/plan.ts +380 -192
  380. package/src/policy.ts +3 -5
  381. package/src/provider.ts +25 -23
  382. package/src/ref.ts +48 -0
  383. package/src/resource.ts +20 -6
  384. package/src/runtime.ts +15 -8
  385. package/src/service.ts +11 -7
  386. package/src/stack.ts +116 -0
  387. package/src/stage.ts +85 -0
  388. package/src/state.ts +138 -60
  389. package/src/test.ts +117 -16
  390. package/src/type.ts +4 -0
  391. package/src/unknown.ts +6 -0
  392. package/src/user.ts +4 -0
  393. package/src/util.ts +21 -0
  394. package/lib/approve.d.ts +0 -15
  395. package/lib/approve.d.ts.map +0 -1
  396. package/lib/approve.js +0 -7
  397. package/lib/approve.js.map +0 -1
  398. package/lib/cli/approve.d.ts +0 -4
  399. package/lib/cli/approve.d.ts.map +0 -1
  400. package/lib/cli/approve.js +0 -18
  401. package/lib/cli/approve.js.map +0 -1
  402. package/lib/cli/clack.d.ts +0 -14
  403. package/lib/cli/clack.d.ts.map +0 -1
  404. package/lib/cli/clack.js +0 -12
  405. package/lib/cli/clack.js.map +0 -1
  406. package/lib/cli/main.d.ts +0 -2
  407. package/lib/cli/main.d.ts.map +0 -1
  408. package/lib/cli/main.js +0 -1
  409. package/lib/cli/main.js.map +0 -1
  410. package/lib/cli/plan.d.ts +0 -13
  411. package/lib/cli/plan.d.ts.map +0 -1
  412. package/lib/cli/plan.js +0 -1
  413. package/lib/cli/plan.js.map +0 -1
  414. package/lib/cli/progress.d.ts +0 -7
  415. package/lib/cli/progress.d.ts.map +0 -1
  416. package/lib/cli/progress.js +0 -30
  417. package/lib/cli/progress.js.map +0 -1
  418. package/lib/cli/spinner.d.ts +0 -2
  419. package/lib/cli/spinner.d.ts.map +0 -1
  420. package/lib/cli/spinner.js +0 -13
  421. package/lib/cli/spinner.js.map +0 -1
  422. package/src/approve.ts +0 -13
  423. package/src/cli/approve.tsx +0 -30
  424. package/src/cli/clack.ts +0 -22
  425. package/src/cli/main.ts +0 -0
  426. package/src/cli/plan.ts +0 -16
  427. package/src/cli/progress.tsx +0 -46
  428. package/src/cli/spinner.ts +0 -14
package/src/plan.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as Context from "effect/Context";
2
+ import { App } from "./app.ts";
2
3
  import * as Data from "effect/Data";
3
4
  import * as Effect from "effect/Effect";
4
5
  import { omit } from "effect/Struct";
@@ -8,10 +9,12 @@ import type {
8
9
  BindingService,
9
10
  } from "./binding.ts";
10
11
  import type { Capability } from "./capability.ts";
11
- import type { Phase } from "./phase.ts";
12
+ import type { Diff } from "./diff.ts";
13
+ import * as Output from "./output.ts";
12
14
  import type { Instance } from "./policy.ts";
13
- import { type Diff, type ProviderService } from "./provider.ts";
14
- import type { Resource, ResourceTags } from "./resource.ts";
15
+ import type { Provider } from "./provider.ts";
16
+ import { type ProviderService } from "./provider.ts";
17
+ import type { AnyResource, Resource, ResourceTags } from "./resource.ts";
15
18
  import { isService, type IService, type Service } from "./service.ts";
16
19
  import { State, StateStoreError, type ResourceState } from "./state.ts";
17
20
 
@@ -76,14 +79,14 @@ export const isCRUD = (node: any): node is CRUD => {
76
79
  /**
77
80
  * A node in the plan that represents a resource CRUD operation.
78
81
  */
79
- export type CRUD<R extends Resource = Resource> =
82
+ export type CRUD<R extends Resource = AnyResource> =
80
83
  | Create<R>
81
84
  | Update<R>
82
85
  | Delete<R>
83
86
  | Replace<R>
84
87
  | NoopUpdate<R>;
85
88
 
86
- export type Apply<R extends Resource = Resource> =
89
+ export type Apply<R extends Resource = AnyResource> =
87
90
  | Create<R>
88
91
  | Update<R>
89
92
  | Replace<R>
@@ -99,109 +102,170 @@ const Node = <T extends Apply>(node: T) => ({
99
102
  },
100
103
  });
101
104
 
102
- export type Create<R extends Resource> = {
105
+ export type Create<R extends Resource = AnyResource> = {
103
106
  action: "create";
104
107
  resource: R;
105
108
  news: any;
106
- provider: ProviderService;
109
+ provider: ProviderService<R>;
107
110
  attributes: R["attr"];
108
111
  bindings: BindNode[];
109
112
  };
110
113
 
111
- export type Update<R extends Resource> = {
114
+ export type Update<R extends Resource = AnyResource> = {
112
115
  action: "update";
113
116
  resource: R;
114
117
  olds: any;
115
118
  news: any;
116
119
  output: any;
117
- provider: ProviderService;
120
+ provider: ProviderService<R>;
118
121
  attributes: R["attr"];
119
122
  bindings: BindNode[];
120
123
  };
121
124
 
122
- export type Delete<R extends Resource> = {
125
+ export type Delete<R extends Resource = AnyResource> = {
123
126
  action: "delete";
124
127
  resource: R;
125
128
  olds: any;
126
129
  output: any;
127
- provider: ProviderService;
130
+ provider: ProviderService<R>;
128
131
  bindings: BindNode[];
129
132
  attributes: R["attr"];
130
133
  downstream: string[];
131
134
  };
132
135
 
133
- export type NoopUpdate<R extends Resource> = {
136
+ export type NoopUpdate<R extends Resource = AnyResource> = {
134
137
  action: "noop";
135
138
  resource: R;
136
139
  attributes: R["attr"];
137
140
  bindings: BindNode[];
138
141
  };
139
142
 
140
- export type Replace<R extends Resource> = {
143
+ export type Replace<R extends Resource = AnyResource> = {
141
144
  action: "replace";
142
145
  resource: R;
143
146
  olds: any;
144
147
  news: any;
145
148
  output: any;
146
- provider: ProviderService;
149
+ provider: ProviderService<R>;
147
150
  bindings: BindNode[];
148
151
  attributes: R["attr"];
149
152
  deleteFirst?: boolean;
150
153
  };
151
154
 
152
- export type Plan = {
153
- phase: Phase;
155
+ export type ResourceGraph<Resources extends Service | Resource> = ToGraph<
156
+ TraverseResources<Resources>
157
+ >;
158
+
159
+ export type TraverseResources<Resources extends Service | Resource> =
160
+ | Resources
161
+ | BoundResources<Resources>
162
+ | TransitiveResources<Resources>;
163
+
164
+ type ToGraph<Resources extends Service | Resource> = {
165
+ [ID in Resources["id"]]: Apply<Extract<Resources, { id: ID }>>;
166
+ };
167
+
168
+ export type BoundResources<Resources extends Service | Resource> = NeverUnknown<
169
+ Extract<
170
+ Resources,
171
+ IService
172
+ >["props"]["bindings"]["capabilities"][number]["resource"]
173
+ >;
174
+
175
+ // finds transitive dependencies at most two levels deep
176
+ // TODO(sam): figure out an efficient way to do arbitrary depth
177
+ export type TransitiveResources<
178
+ Resources extends Service | Resource,
179
+ Found extends Service | Resource = never,
180
+ > = Extract<
181
+ | Found
182
+ | {
183
+ [prop in keyof Resources["props"]]: IsAny<
184
+ Resources["props"][prop]
185
+ > extends true
186
+ ? Found
187
+ : Resources["props"][prop] extends { kind: "alchemy/Policy" }
188
+ ? Found
189
+ : Resources["props"][prop] extends Output.Output<any, infer Src, any>
190
+ ? Src extends Found
191
+ ? Found
192
+ : TransitiveResources<Src, Src | Found>
193
+ : {
194
+ [p in keyof Resources["props"][prop]]: IsAny<
195
+ Resources["props"][prop][p]
196
+ > extends true
197
+ ? Found
198
+ : Resources["props"][prop][p] extends Output.Output<
199
+ any,
200
+ infer Src,
201
+ any
202
+ >
203
+ ? Src extends Found
204
+ ? Found
205
+ : TransitiveResources<Src, Src | Found>
206
+ : Found;
207
+ }[keyof Resources["props"][prop]];
208
+ }[keyof Resources["props"]],
209
+ Service | Resource
210
+ >;
211
+
212
+ export type Providers<Resources extends Service | Resource> =
213
+ | ResourceProviders<Resources>
214
+ | BindingTags<Resources>;
215
+
216
+ export type ResourceProviders<Res extends Service | Resource> = Res extends any
217
+ ? Provider<Extract<Res["base"], Service | Resource>>
218
+ : never;
219
+
220
+ export type BindingTags<Resources extends Service | Resource> = NeverUnknown<
221
+ Extract<Resources, Service>["props"]["bindings"]["tags"][number]
222
+ >;
223
+
224
+ type NeverUnknown<T> = unknown extends T ? never : T;
225
+
226
+ type IsAny<T> = 0 extends 1 & T ? true : false;
227
+
228
+ export type DerivePlan<Resources extends Service | Resource> = {
154
229
  resources: {
155
- [id in string]: CRUD;
230
+ [ID in keyof ResourceGraph<Resources>]: ResourceGraph<Resources>[ID];
156
231
  };
157
232
  deletions: {
158
- [id in string]?: Delete<Resource>;
233
+ [ID in string]: Delete<AnyResource>;
159
234
  };
160
235
  };
161
236
 
162
- export const plan = <
163
- const Phase extends "update" | "destroy",
164
- const Resources extends (Service | Resource)[],
165
- >({
166
- phase,
167
- resources,
168
- }: {
169
- phase: Phase;
170
- resources: Resources;
171
- }) => {
172
- type Services = Extract<Resources[number], IService>[];
173
- type ServiceIDs = Services[number]["id"];
174
- type ServiceHosts = {
175
- [ID in ServiceIDs]: Extract<Services[number], Service<Extract<ID, string>>>;
237
+ export type IPlan = {
238
+ resources: {
239
+ [id in string]: CRUD<any>;
176
240
  };
177
- type UpstreamTags = {
178
- [ID in ServiceIDs]: ServiceHosts[ID]["props"]["bindings"]["tags"][number];
179
- }[ServiceIDs];
180
- type UpstreamResources = {
181
- [ID in ServiceIDs]: Extract<
182
- ServiceHosts[ID]["props"]["bindings"]["capabilities"][number]["resource"],
183
- Resource
184
- >;
185
- }[ServiceIDs];
186
- type ExplicitResources = Resources[number];
187
- type ResourceGraph = {
188
- [ID in ServiceIDs]: Apply<Extract<Instance<ServiceHosts[ID]>, Resource>>;
189
- } & {
190
- [ID in UpstreamResources["id"]]: Apply<
191
- Extract<UpstreamResources, { id: ID }>
192
- >;
193
- } & {
194
- [ID in ExplicitResources["id"]]: Apply<
195
- Extract<ExplicitResources, { id: ID }>
196
- >;
241
+ deletions: {
242
+ [id in string]?: Delete<Resource>;
197
243
  };
244
+ };
245
+
246
+ export type Plan<Resources extends Service | Resource> = Effect.Effect<
247
+ DerivePlan<Resources>,
248
+ never,
249
+ Providers<Resources> | State
250
+ >;
198
251
 
199
- return Effect.gen(function* () {
252
+ export const plan = <const Resources extends (Service | Resource)[]>(
253
+ ...resources: Resources
254
+ ): Plan<Instance<Resources[number]>> =>
255
+ Effect.gen(function* () {
200
256
  const state = yield* State;
201
257
 
202
- const resourceIds = yield* state.list();
258
+ // TODO(sam): rename terminology to Stack
259
+ const app = yield* App;
260
+
261
+ const resourceIds = yield* state.list({
262
+ stack: app.name,
263
+ stage: app.stage,
264
+ });
203
265
  const resourcesState = yield* Effect.all(
204
- resourceIds.map((id) => state.get(id)),
266
+ resourceIds.map((id) =>
267
+ state.get({ stack: app.name, stage: app.stage, resourceId: id }),
268
+ ),
205
269
  );
206
270
  // map of resource ID -> its downstream dependencies (resources that depend on it)
207
271
  const downstream = resourcesState
@@ -225,134 +289,273 @@ export const plan = <
225
289
  {} as Record<string, string[]>,
226
290
  );
227
291
 
228
- const resourceGraph =
229
- phase === "update"
230
- ? (Object.fromEntries(
231
- (yield* Effect.all(
232
- resources
233
- .flatMap((resource) => [
234
- ...(isService(resource)
235
- ? resource.props.bindings.capabilities.map(
236
- (cap: Capability) => cap.resource as Resource,
237
- )
238
- : []),
239
- resource,
240
- ])
241
- .filter(
242
- (node, i, arr) =>
243
- arr.findIndex((n) => n.id === node.id) === i,
292
+ type ResolveEffect<T> = Effect.Effect<T, ResolveErr, ResolveReq>;
293
+ type ResolveErr = StateStoreError;
294
+ type ResolveReq =
295
+ | Context.TagClass<
296
+ Provider<Resource<string, string, any, any>>,
297
+ string,
298
+ ProviderService<Resource<string, string, any, any>>
299
+ >
300
+ | State;
301
+
302
+ const resolvedResources: Record<
303
+ string,
304
+ ResolveEffect<{
305
+ [attr in string]: any;
306
+ }>
307
+ > = {};
308
+
309
+ const resolveResource = (
310
+ resourceExpr: Output.ResourceExpr<any, any, any>,
311
+ ) =>
312
+ Effect.gen(function* () {
313
+ return yield* (resolvedResources[resourceExpr.src.id] ??=
314
+ yield* Effect.cached(
315
+ Effect.gen(function* () {
316
+ const resource = resourceExpr.src as Resource & {
317
+ provider: ResourceTags<Resource<string, string, any, any>>;
318
+ };
319
+ const provider = yield* resource.provider.tag;
320
+ const props = yield* resolveInput(resource.props);
321
+ const oldState = yield* state.get({
322
+ stack: app.name,
323
+ stage: app.stage,
324
+ resourceId: resource.id,
325
+ });
326
+
327
+ if (!oldState) {
328
+ return resourceExpr;
329
+ }
330
+
331
+ const diff = yield* provider.diff
332
+ ? provider.diff({
333
+ id: resource.id,
334
+ olds: oldState.props,
335
+ news: props,
336
+ output: oldState.output,
337
+ })
338
+ : Effect.succeed(undefined);
339
+
340
+ if (diff == null) {
341
+ if (arePropsChanged(oldState, props)) {
342
+ // the props have changed but the provider did not provide any hints as to what is stable
343
+ // so we must assume everything has changed
344
+ return resourceExpr;
345
+ }
346
+ } else if (diff.action === "update") {
347
+ const output = oldState?.output;
348
+ if (diff.stables) {
349
+ return new Output.ResourceExpr(
350
+ resourceExpr.src,
351
+ Object.fromEntries(
352
+ diff.stables.map((stable) => [stable, output?.[stable]]),
353
+ ),
354
+ );
355
+ } else {
356
+ // if there are no stable properties, treat every property as changed
357
+ return resourceExpr;
358
+ }
359
+ } else if (diff.action === "replace") {
360
+ }
361
+ return oldState?.output;
362
+ }),
363
+ ));
364
+ });
365
+
366
+ const resolveInput = (input: any): ResolveEffect<any> =>
367
+ Effect.gen(function* () {
368
+ if (!input) {
369
+ return input;
370
+ } else if (Output.isExpr(input)) {
371
+ return yield* resolveOutput(input);
372
+ } else if (Array.isArray(input)) {
373
+ return yield* Effect.all(input.map(resolveInput));
374
+ } else if (typeof input === "object") {
375
+ return Object.fromEntries(
376
+ yield* Effect.all(
377
+ Object.entries(input).map(([key, value]) =>
378
+ resolveInput(value).pipe(Effect.map((value) => [key, value])),
379
+ ),
380
+ ),
381
+ );
382
+ }
383
+ return input;
384
+ });
385
+
386
+ const resolveOutput = (expr: Output.Expr<any>): ResolveEffect<any> =>
387
+ Effect.gen(function* () {
388
+ if (Output.isResourceExpr(expr)) {
389
+ return yield* resolveResource(expr);
390
+ } else if (Output.isPropExpr(expr)) {
391
+ const upstream = yield* resolveOutput(expr.expr);
392
+ return upstream?.[expr.identifier];
393
+ } else if (Output.isApplyExpr(expr)) {
394
+ const upstream = yield* resolveOutput(expr.expr);
395
+ return Output.isOutput(upstream) ? expr : expr.f(upstream);
396
+ } else if (Output.isEffectExpr(expr)) {
397
+ const upstream = yield* resolveOutput(expr.expr);
398
+ return Output.isOutput(upstream) ? expr : yield* expr.f(upstream);
399
+ } else if (Output.isAllExpr(expr)) {
400
+ return yield* Effect.all(expr.outs.map(resolveOutput));
401
+ }
402
+ return yield* Effect.die(new Error("Not implemented yet"));
403
+ });
404
+
405
+ const resolveUpstream = (
406
+ value: any,
407
+ ): {
408
+ [ID in string]: Resource;
409
+ } => {
410
+ if (Output.isExpr(value)) {
411
+ return Output.upstream(value);
412
+ } else if (Array.isArray(value)) {
413
+ return Object.assign({}, ...value.map(resolveUpstream));
414
+ } else if (
415
+ value &&
416
+ (typeof value === "object" || typeof value === "function")
417
+ ) {
418
+ return Object.assign(
419
+ {},
420
+ ...Object.values(value).map((value) => resolveUpstream(value)),
421
+ );
422
+ }
423
+ return {};
424
+ };
425
+
426
+ const resourceGraph = Object.fromEntries(
427
+ (yield* Effect.all(
428
+ resources
429
+ .flatMap((resource) => [
430
+ ...(isService(resource)
431
+ ? resource.props.bindings.capabilities.map(
432
+ (cap: Capability) => cap.resource as Resource,
244
433
  )
245
- .map(
246
- Effect.fn(function* (node) {
247
- const id = node.id;
248
- const resource = node as Resource & {
249
- provider: ResourceTags<Resource>;
250
- };
251
- const news = resource.props;
252
-
253
- const oldState = yield* state.get(id);
254
- const provider = yield* resource.provider.tag;
255
-
256
- const bindings = isService(node)
257
- ? yield* diffBindings({
258
- oldState,
259
- bindings: (
260
- node.props.bindings as unknown as {
261
- bindings: AnyBinding[];
262
- }
263
- ).bindings,
264
- target: {
265
- id: node.id,
266
- props: node.props,
267
- oldAttr: oldState?.output,
268
- oldProps: oldState?.props,
269
- },
270
- })
271
- : []; // TODO(sam): return undefined instead of empty array
272
-
273
- if (
274
- oldState === undefined ||
275
- oldState.status === "creating"
276
- ) {
277
- return Node<Create<Resource>>({
278
- action: "create",
279
- news,
280
- provider,
281
- resource,
282
- bindings,
283
- // phantom
284
- attributes: undefined!,
285
- });
286
- }
287
-
288
- const diff = provider.diff
289
- ? yield* provider.diff({
290
- id,
291
- olds: oldState.props,
292
- news,
293
- output: oldState.output,
294
- })
295
- : undefined;
296
-
297
- if (!diff && arePropsChanged(oldState, resource.props)) {
298
- return Node<Update<Resource>>({
299
- action: "update",
300
- olds: oldState.props,
301
- news,
302
- output: oldState.output,
303
- provider,
304
- resource,
305
- bindings,
306
- // phantom
307
- attributes: undefined!,
308
- });
309
- } else if (diff?.action === "replace") {
310
- return Node<Replace<Resource>>({
311
- action: "replace",
312
- olds: oldState.props,
313
- news,
314
- output: oldState.output,
315
- provider,
316
- resource,
317
- bindings,
318
- // phantom
319
- attributes: undefined!,
320
- });
321
- } else if (diff?.action === "update") {
322
- return Node<Update<Resource>>({
323
- action: "update",
324
- olds: oldState.props,
325
- news,
326
- output: oldState.output,
327
- provider,
328
- resource,
329
- bindings,
330
- // phantom
331
- attributes: undefined!,
332
- });
333
- } else {
334
- return Node<NoopUpdate<Resource>>({
335
- action: "noop",
336
- resource,
337
- bindings,
338
- // phantom
339
- attributes: undefined!,
340
- });
341
- }
342
- }),
343
- ),
344
- )).map((update) => [update.resource.id, update]),
345
- ) as Plan["resources"])
346
- : ({} as Plan["resources"]);
434
+ : []),
435
+ ...Object.values(resolveUpstream(resource.props)),
436
+ resource,
437
+ ])
438
+ .filter(
439
+ (node, i, arr) => arr.findIndex((n) => n.id === node.id) === i,
440
+ )
441
+ .map(
442
+ Effect.fn(function* (node) {
443
+ const id = node.id;
444
+ const resource = node as Resource & {
445
+ provider: ResourceTags<Resource<string, string, any, any>>;
446
+ };
447
+ const news = yield* resolveInput(resource.props);
448
+
449
+ const oldState = yield* state.get({
450
+ stack: app.name,
451
+ stage: app.stage,
452
+ resourceId: id,
453
+ });
454
+ const provider = yield* resource.provider.tag;
455
+
456
+ const bindings = isService(node)
457
+ ? yield* diffBindings({
458
+ oldState,
459
+ bindings: (
460
+ node.props.bindings as unknown as {
461
+ bindings: AnyBinding[];
462
+ }
463
+ ).bindings,
464
+ target: {
465
+ id: node.id,
466
+ props: node.props,
467
+ oldAttr: oldState?.output,
468
+ oldProps: oldState?.props,
469
+ },
470
+ })
471
+ : []; // TODO(sam): return undefined instead of empty array
472
+
473
+ if (oldState === undefined || oldState.status === "creating") {
474
+ return Node<Create<Resource>>({
475
+ action: "create",
476
+ news,
477
+ provider,
478
+ resource,
479
+ bindings,
480
+ // phantom
481
+ attributes: undefined!,
482
+ });
483
+ }
484
+
485
+ const diff = provider.diff
486
+ ? yield* (() => {
487
+ const diff = provider.diff({
488
+ id,
489
+ olds: oldState.props,
490
+ news,
491
+ output: oldState.output,
492
+ });
493
+ return Effect.isEffect(diff) ? diff : Effect.succeed(diff);
494
+ })()
495
+ : undefined;
496
+
497
+ if (!diff && arePropsChanged(oldState, news)) {
498
+ return Node<Update<Resource>>({
499
+ action: "update",
500
+ olds: oldState.props,
501
+ news,
502
+ output: oldState.output,
503
+ provider,
504
+ resource,
505
+ bindings,
506
+ // phantom
507
+ attributes: undefined!,
508
+ });
509
+ } else if (diff?.action === "replace") {
510
+ return Node<Replace<Resource>>({
511
+ action: "replace",
512
+ olds: oldState.props,
513
+ news,
514
+ output: oldState.output,
515
+ provider,
516
+ resource,
517
+ bindings,
518
+ // phantom
519
+ attributes: undefined!,
520
+ });
521
+ } else if (diff?.action === "update") {
522
+ return Node<Update<Resource>>({
523
+ action: "update",
524
+ olds: oldState.props,
525
+ news,
526
+ output: oldState.output,
527
+ provider,
528
+ resource,
529
+ bindings,
530
+ // phantom
531
+ attributes: undefined!,
532
+ });
533
+ } else {
534
+ return Node<NoopUpdate<Resource>>({
535
+ action: "noop",
536
+ resource,
537
+ bindings,
538
+ // phantom
539
+ attributes: undefined!,
540
+ });
541
+ }
542
+ }),
543
+ ),
544
+ )).map((update) => [update.resource.id, update]),
545
+ ) as IPlan["resources"];
347
546
 
348
547
  const deletions = Object.fromEntries(
349
548
  (yield* Effect.all(
350
- (yield* state.list()).map(
549
+ (yield* state.list({ stack: app.name, stage: app.stage })).map(
351
550
  Effect.fn(function* (id) {
352
551
  if (id in resourceGraph) {
353
552
  return;
354
553
  }
355
- const oldState = yield* state.get(id);
554
+ const oldState = yield* state.get({
555
+ stack: app.name,
556
+ stage: app.stage,
557
+ resourceId: id,
558
+ });
356
559
  const context = yield* Effect.context<never>();
357
560
  if (oldState) {
358
561
  const provider: ProviderService = context.unsafeMap.get(
@@ -375,7 +578,6 @@ export const plan = <
375
578
  bindings: [],
376
579
  resource: {
377
580
  id: id,
378
- parent: undefined,
379
581
  type: oldState.type,
380
582
  attr: oldState.output,
381
583
  props: oldState.props,
@@ -405,24 +607,10 @@ export const plan = <
405
607
  }
406
608
 
407
609
  return {
408
- phase,
409
610
  resources: resourceGraph,
410
611
  deletions,
411
- } satisfies Plan as Plan;
412
- }) as Effect.Effect<
413
- {
414
- phase: Phase;
415
- resources: {
416
- [ID in keyof ResourceGraph]: ResourceGraph[ID];
417
- };
418
- deletions: {
419
- [id in Exclude<string, keyof ResourceGraph>]?: Delete<Resource>;
420
- };
421
- },
422
- never,
423
- UpstreamTags | State
424
- >;
425
- };
612
+ } satisfies IPlan as IPlan;
613
+ }) as any;
426
614
 
427
615
  class DeleteResourceHasDownstreamDependencies extends Data.TaggedError(
428
616
  "DeleteResourceHasDownstreamDependencies",