alchemy-effect 0.2.0 → 0.4.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 (494) hide show
  1. package/bin/alchemy-effect.js +55354 -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 +15 -75
  13. package/lib/apply.d.ts.map +1 -1
  14. package/lib/apply.js +439 -154
  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 +18 -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 +11 -0
  57. package/lib/aws/ec2/index.d.ts.map +1 -1
  58. package/lib/aws/ec2/index.js +11 -0
  59. package/lib/aws/ec2/index.js.map +1 -1
  60. package/lib/aws/ec2/internet-gateway.d.ts +65 -0
  61. package/lib/aws/ec2/internet-gateway.d.ts.map +1 -0
  62. package/lib/aws/ec2/internet-gateway.js +4 -0
  63. package/lib/aws/ec2/internet-gateway.js.map +1 -0
  64. package/lib/aws/ec2/internet-gateway.provider.d.ts +6 -0
  65. package/lib/aws/ec2/internet-gateway.provider.d.ts.map +1 -0
  66. package/lib/aws/ec2/internet-gateway.provider.js +193 -0
  67. package/lib/aws/ec2/internet-gateway.provider.js.map +1 -0
  68. package/lib/aws/ec2/route-table-association.d.ts +63 -0
  69. package/lib/aws/ec2/route-table-association.d.ts.map +1 -0
  70. package/lib/aws/ec2/route-table-association.js +4 -0
  71. package/lib/aws/ec2/route-table-association.js.map +1 -0
  72. package/lib/aws/ec2/route-table-association.provider.d.ts +4 -0
  73. package/lib/aws/ec2/route-table-association.provider.d.ts.map +1 -0
  74. package/lib/aws/ec2/route-table-association.provider.js +121 -0
  75. package/lib/aws/ec2/route-table-association.provider.js.map +1 -0
  76. package/lib/aws/ec2/route-table.d.ts +159 -0
  77. package/lib/aws/ec2/route-table.d.ts.map +1 -0
  78. package/lib/aws/ec2/route-table.js +4 -0
  79. package/lib/aws/ec2/route-table.js.map +1 -0
  80. package/lib/aws/ec2/route-table.provider.d.ts +6 -0
  81. package/lib/aws/ec2/route-table.provider.d.ts.map +1 -0
  82. package/lib/aws/ec2/route-table.provider.js +213 -0
  83. package/lib/aws/ec2/route-table.provider.js.map +1 -0
  84. package/lib/aws/ec2/route.d.ts +155 -0
  85. package/lib/aws/ec2/route.d.ts.map +1 -0
  86. package/lib/aws/ec2/route.js +3 -0
  87. package/lib/aws/ec2/route.js.map +1 -0
  88. package/lib/aws/ec2/route.provider.d.ts +4 -0
  89. package/lib/aws/ec2/route.provider.d.ts.map +1 -0
  90. package/lib/aws/ec2/route.provider.js +166 -0
  91. package/lib/aws/ec2/route.provider.js.map +1 -0
  92. package/lib/aws/ec2/subnet.d.ts +175 -0
  93. package/lib/aws/ec2/subnet.d.ts.map +1 -0
  94. package/lib/aws/ec2/subnet.js +4 -0
  95. package/lib/aws/ec2/subnet.js.map +1 -0
  96. package/lib/aws/ec2/subnet.provider.d.ts +4 -0
  97. package/lib/aws/ec2/subnet.provider.d.ts.map +1 -0
  98. package/lib/aws/ec2/subnet.provider.js +250 -0
  99. package/lib/aws/ec2/subnet.provider.js.map +1 -0
  100. package/lib/aws/ec2/vpc.d.ts +13 -8
  101. package/lib/aws/ec2/vpc.d.ts.map +1 -1
  102. package/lib/aws/ec2/vpc.js +1 -0
  103. package/lib/aws/ec2/vpc.js.map +1 -1
  104. package/lib/aws/ec2/vpc.provider.d.ts +1 -2
  105. package/lib/aws/ec2/vpc.provider.d.ts.map +1 -1
  106. package/lib/aws/ec2/vpc.provider.js +45 -37
  107. package/lib/aws/ec2/vpc.provider.js.map +1 -1
  108. package/lib/aws/index.d.ts +15 -19
  109. package/lib/aws/index.d.ts.map +1 -1
  110. package/lib/aws/index.js +8 -10
  111. package/lib/aws/index.js.map +1 -1
  112. package/lib/aws/lambda/consume.d.ts +10 -11
  113. package/lib/aws/lambda/consume.d.ts.map +1 -1
  114. package/lib/aws/lambda/consume.js +3 -3
  115. package/lib/aws/lambda/consume.js.map +1 -1
  116. package/lib/aws/lambda/function.d.ts +7 -7
  117. package/lib/aws/lambda/function.d.ts.map +1 -1
  118. package/lib/aws/lambda/function.handler.d.ts +1 -1
  119. package/lib/aws/lambda/function.handler.d.ts.map +1 -1
  120. package/lib/aws/lambda/function.handler.js.map +1 -1
  121. package/lib/aws/lambda/function.invoke.d.ts +6 -4
  122. package/lib/aws/lambda/function.invoke.d.ts.map +1 -1
  123. package/lib/aws/lambda/function.invoke.js +3 -1
  124. package/lib/aws/lambda/function.invoke.js.map +1 -1
  125. package/lib/aws/lambda/function.js +1 -1
  126. package/lib/aws/lambda/function.js.map +1 -1
  127. package/lib/aws/lambda/function.provider.d.ts +3 -2
  128. package/lib/aws/lambda/function.provider.d.ts.map +1 -1
  129. package/lib/aws/lambda/function.provider.js +28 -25
  130. package/lib/aws/lambda/function.provider.js.map +1 -1
  131. package/lib/aws/lambda/index.d.ts +1 -0
  132. package/lib/aws/lambda/index.d.ts.map +1 -1
  133. package/lib/aws/lambda/index.js +1 -0
  134. package/lib/aws/lambda/index.js.map +1 -1
  135. package/lib/aws/lambda/serve.d.ts +2 -4
  136. package/lib/aws/lambda/serve.d.ts.map +1 -1
  137. package/lib/aws/profile.d.ts +2 -2
  138. package/lib/aws/profile.d.ts.map +1 -1
  139. package/lib/aws/profile.js +1 -1
  140. package/lib/aws/profile.js.map +1 -1
  141. package/lib/aws/region.d.ts +14 -2
  142. package/lib/aws/region.d.ts.map +1 -1
  143. package/lib/aws/region.js +26 -1
  144. package/lib/aws/region.js.map +1 -1
  145. package/lib/aws/sqs/client.d.ts +1 -1
  146. package/lib/aws/sqs/client.d.ts.map +1 -1
  147. package/lib/aws/sqs/index.d.ts +1 -0
  148. package/lib/aws/sqs/index.d.ts.map +1 -1
  149. package/lib/aws/sqs/index.js +1 -0
  150. package/lib/aws/sqs/index.js.map +1 -1
  151. package/lib/aws/sqs/queue.consume.d.ts +1 -1
  152. package/lib/aws/sqs/queue.consume.d.ts.map +1 -1
  153. package/lib/aws/sqs/queue.consume.js +0 -1
  154. package/lib/aws/sqs/queue.consume.js.map +1 -1
  155. package/lib/aws/sqs/queue.d.ts +6 -4
  156. package/lib/aws/sqs/queue.d.ts.map +1 -1
  157. package/lib/aws/sqs/queue.event-source.d.ts +8 -6
  158. package/lib/aws/sqs/queue.event-source.d.ts.map +1 -1
  159. package/lib/aws/sqs/queue.event-source.js +26 -44
  160. package/lib/aws/sqs/queue.event-source.js.map +1 -1
  161. package/lib/aws/sqs/queue.js +1 -1
  162. package/lib/aws/sqs/queue.js.map +1 -1
  163. package/lib/aws/sqs/queue.provider.d.ts +2 -2
  164. package/lib/aws/sqs/queue.provider.d.ts.map +1 -1
  165. package/lib/aws/sqs/queue.provider.js +2 -1
  166. package/lib/aws/sqs/queue.provider.js.map +1 -1
  167. package/lib/aws/sqs/queue.send-message.d.ts +7 -5
  168. package/lib/aws/sqs/queue.send-message.d.ts.map +1 -1
  169. package/lib/aws/sqs/queue.send-message.js +4 -2
  170. package/lib/aws/sqs/queue.send-message.js.map +1 -1
  171. package/lib/binding.d.ts +12 -12
  172. package/lib/binding.d.ts.map +1 -1
  173. package/lib/binding.js.map +1 -1
  174. package/lib/cli/components/ApprovePlan.d.ts +2 -2
  175. package/lib/cli/components/ApprovePlan.d.ts.map +1 -1
  176. package/lib/cli/components/ApprovePlan.js.map +1 -1
  177. package/lib/cli/components/Plan.d.ts +2 -2
  178. package/lib/cli/components/Plan.d.ts.map +1 -1
  179. package/lib/cli/components/Plan.js.map +1 -1
  180. package/lib/cli/components/PlanProgress.d.ts +8 -4
  181. package/lib/cli/components/PlanProgress.d.ts.map +1 -1
  182. package/lib/cli/components/PlanProgress.js +11 -1
  183. package/lib/cli/components/PlanProgress.js.map +1 -1
  184. package/lib/cli/index.d.ts +384 -264
  185. package/lib/cli/index.d.ts.map +1 -1
  186. package/lib/cli/index.js +57 -65
  187. package/lib/cli/index.js.map +1 -1
  188. package/lib/cli/ink-service.d.ts +4 -0
  189. package/lib/cli/ink-service.d.ts.map +1 -0
  190. package/lib/cli/ink-service.js +43 -0
  191. package/lib/cli/ink-service.js.map +1 -0
  192. package/lib/cli/service.d.ts +21 -0
  193. package/lib/cli/service.d.ts.map +1 -0
  194. package/lib/cli/service.js +5 -0
  195. package/lib/cli/service.js.map +1 -0
  196. package/lib/cloudflare/account.d.ts +10 -0
  197. package/lib/cloudflare/account.d.ts.map +1 -0
  198. package/lib/cloudflare/account.js +24 -0
  199. package/lib/cloudflare/account.js.map +1 -0
  200. package/lib/cloudflare/api.d.ts +7 -7
  201. package/lib/cloudflare/api.d.ts.map +1 -1
  202. package/lib/cloudflare/api.js +18 -17
  203. package/lib/cloudflare/api.js.map +1 -1
  204. package/lib/cloudflare/config.d.ts +9 -0
  205. package/lib/cloudflare/config.d.ts.map +1 -0
  206. package/lib/cloudflare/config.js +1 -0
  207. package/lib/cloudflare/config.js.map +1 -0
  208. package/lib/cloudflare/index.d.ts +3 -1
  209. package/lib/cloudflare/index.d.ts.map +1 -1
  210. package/lib/cloudflare/index.js +3 -0
  211. package/lib/cloudflare/index.js.map +1 -1
  212. package/lib/cloudflare/kv/namespace.binding.d.ts +5 -3
  213. package/lib/cloudflare/kv/namespace.binding.d.ts.map +1 -1
  214. package/lib/cloudflare/kv/namespace.binding.js +1 -1
  215. package/lib/cloudflare/kv/namespace.binding.js.map +1 -1
  216. package/lib/cloudflare/kv/namespace.client.d.ts +1 -1
  217. package/lib/cloudflare/kv/namespace.d.ts +3 -2
  218. package/lib/cloudflare/kv/namespace.d.ts.map +1 -1
  219. package/lib/cloudflare/kv/namespace.js.map +1 -1
  220. package/lib/cloudflare/kv/namespace.provider.d.ts +3 -2
  221. package/lib/cloudflare/kv/namespace.provider.d.ts.map +1 -1
  222. package/lib/cloudflare/kv/namespace.provider.js +9 -7
  223. package/lib/cloudflare/kv/namespace.provider.js.map +1 -1
  224. package/lib/cloudflare/live.d.ts +5 -5
  225. package/lib/cloudflare/live.d.ts.map +1 -1
  226. package/lib/cloudflare/live.js +5 -8
  227. package/lib/cloudflare/live.js.map +1 -1
  228. package/lib/cloudflare/r2/bucket.binding.d.ts +5 -3
  229. package/lib/cloudflare/r2/bucket.binding.d.ts.map +1 -1
  230. package/lib/cloudflare/r2/bucket.binding.js +1 -1
  231. package/lib/cloudflare/r2/bucket.binding.js.map +1 -1
  232. package/lib/cloudflare/r2/bucket.d.ts +3 -2
  233. package/lib/cloudflare/r2/bucket.d.ts.map +1 -1
  234. package/lib/cloudflare/r2/bucket.js.map +1 -1
  235. package/lib/cloudflare/r2/bucket.provider.d.ts +3 -2
  236. package/lib/cloudflare/r2/bucket.provider.d.ts.map +1 -1
  237. package/lib/cloudflare/r2/bucket.provider.js +14 -8
  238. package/lib/cloudflare/r2/bucket.provider.js.map +1 -1
  239. package/lib/cloudflare/worker/assets.fetch.d.ts +3 -2
  240. package/lib/cloudflare/worker/assets.fetch.d.ts.map +1 -1
  241. package/lib/cloudflare/worker/assets.fetch.js +2 -1
  242. package/lib/cloudflare/worker/assets.fetch.js.map +1 -1
  243. package/lib/cloudflare/worker/assets.provider.d.ts +1 -1
  244. package/lib/cloudflare/worker/assets.provider.d.ts.map +1 -1
  245. package/lib/cloudflare/worker/index.d.ts +0 -1
  246. package/lib/cloudflare/worker/index.d.ts.map +1 -1
  247. package/lib/cloudflare/worker/worker.d.ts +5 -6
  248. package/lib/cloudflare/worker/worker.d.ts.map +1 -1
  249. package/lib/cloudflare/worker/worker.handler.d.ts +1 -1
  250. package/lib/cloudflare/worker/worker.handler.d.ts.map +1 -1
  251. package/lib/cloudflare/worker/worker.handler.js.map +1 -1
  252. package/lib/cloudflare/worker/worker.js.map +1 -1
  253. package/lib/cloudflare/worker/worker.provider.d.ts +3 -2
  254. package/lib/cloudflare/worker/worker.provider.d.ts.map +1 -1
  255. package/lib/cloudflare/worker/worker.provider.js +12 -7
  256. package/lib/cloudflare/worker/worker.provider.js.map +1 -1
  257. package/lib/cloudflare/worker/worker.serve.d.ts +7 -7
  258. package/lib/cloudflare/worker/worker.serve.d.ts.map +1 -1
  259. package/lib/cloudflare/worker/worker.serve.js.map +1 -1
  260. package/lib/data.d.ts +3 -0
  261. package/lib/data.d.ts.map +1 -0
  262. package/lib/data.js +8 -0
  263. package/lib/data.js.map +1 -0
  264. package/lib/destroy.d.ts +1 -1
  265. package/lib/destroy.d.ts.map +1 -1
  266. package/lib/destroy.js +1 -4
  267. package/lib/destroy.js.map +1 -1
  268. package/lib/diff.d.ts +18 -0
  269. package/lib/diff.d.ts.map +1 -0
  270. package/lib/diff.js +22 -0
  271. package/lib/diff.js.map +1 -0
  272. package/lib/env.d.ts +5 -0
  273. package/lib/env.d.ts.map +1 -1
  274. package/lib/env.js +15 -29
  275. package/lib/env.js.map +1 -1
  276. package/lib/event.d.ts +1 -1
  277. package/lib/event.d.ts.map +1 -1
  278. package/lib/exports.d.ts +9 -0
  279. package/lib/exports.d.ts.map +1 -0
  280. package/lib/exports.js +13 -0
  281. package/lib/exports.js.map +1 -0
  282. package/lib/index.d.ts +10 -2
  283. package/lib/index.d.ts.map +1 -1
  284. package/lib/index.js +10 -5
  285. package/lib/index.js.map +1 -1
  286. package/lib/input.d.ts +32 -0
  287. package/lib/input.d.ts.map +1 -0
  288. package/lib/input.js +1 -0
  289. package/lib/input.js.map +1 -0
  290. package/lib/instance-id.d.ts +8 -0
  291. package/lib/instance-id.d.ts.map +1 -0
  292. package/lib/instance-id.js +12 -0
  293. package/lib/instance-id.js.map +1 -0
  294. package/lib/output.d.ts +145 -0
  295. package/lib/output.d.ts.map +1 -0
  296. package/lib/output.js +283 -0
  297. package/lib/output.js.map +1 -0
  298. package/lib/physical-name.d.ts +14 -1
  299. package/lib/physical-name.d.ts.map +1 -1
  300. package/lib/physical-name.js +41 -2
  301. package/lib/physical-name.js.map +1 -1
  302. package/lib/plan.d.ts +84 -58
  303. package/lib/plan.d.ts.map +1 -1
  304. package/lib/plan.js +504 -166
  305. package/lib/plan.js.map +1 -1
  306. package/lib/policy.d.ts +3 -4
  307. package/lib/policy.d.ts.map +1 -1
  308. package/lib/policy.js +0 -1
  309. package/lib/policy.js.map +1 -1
  310. package/lib/provider.d.ts +39 -24
  311. package/lib/provider.d.ts.map +1 -1
  312. package/lib/provider.js +9 -0
  313. package/lib/provider.js.map +1 -1
  314. package/lib/ref.d.ts +14 -0
  315. package/lib/ref.d.ts.map +1 -0
  316. package/lib/ref.js +21 -0
  317. package/lib/ref.js.map +1 -0
  318. package/lib/resource.d.ts +13 -8
  319. package/lib/resource.d.ts.map +1 -1
  320. package/lib/resource.js.map +1 -1
  321. package/lib/runtime.d.ts +7 -6
  322. package/lib/runtime.d.ts.map +1 -1
  323. package/lib/runtime.js.map +1 -1
  324. package/lib/service.d.ts +9 -6
  325. package/lib/service.d.ts.map +1 -1
  326. package/lib/service.js.map +1 -1
  327. package/lib/stack.d.ts +60 -0
  328. package/lib/stack.d.ts.map +1 -0
  329. package/lib/stack.js +11 -0
  330. package/lib/stack.js.map +1 -0
  331. package/lib/stage.d.ts +39 -0
  332. package/lib/stage.d.ts.map +1 -0
  333. package/lib/stage.js +32 -0
  334. package/lib/stage.js.map +1 -0
  335. package/lib/state.d.ts +135 -17
  336. package/lib/state.d.ts.map +1 -1
  337. package/lib/state.js +34 -30
  338. package/lib/state.js.map +1 -1
  339. package/lib/tags.d.ts +15 -0
  340. package/lib/tags.d.ts.map +1 -1
  341. package/lib/tags.js +27 -0
  342. package/lib/tags.js.map +1 -1
  343. package/lib/test.d.ts +25 -4
  344. package/lib/test.d.ts.map +1 -1
  345. package/lib/test.js +54 -14
  346. package/lib/test.js.map +1 -1
  347. package/lib/todo.d.ts +3 -0
  348. package/lib/todo.d.ts.map +1 -0
  349. package/lib/todo.js +3 -0
  350. package/lib/todo.js.map +1 -0
  351. package/lib/tsconfig.test.tsbuildinfo +1 -1
  352. package/lib/type.d.ts +3 -0
  353. package/lib/type.d.ts.map +1 -1
  354. package/lib/unknown.d.ts +4 -0
  355. package/lib/unknown.d.ts.map +1 -0
  356. package/lib/unknown.js +4 -0
  357. package/lib/unknown.js.map +1 -0
  358. package/lib/user.d.ts +3 -0
  359. package/lib/user.d.ts.map +1 -0
  360. package/lib/user.js +3 -0
  361. package/lib/user.js.map +1 -0
  362. package/lib/util.d.ts +6 -0
  363. package/lib/util.d.ts.map +1 -0
  364. package/lib/util.js +9 -0
  365. package/lib/util.js.map +1 -0
  366. package/package.json +18 -12
  367. package/src/$.ts +17 -0
  368. package/src/app.ts +3 -32
  369. package/src/apply.ts +824 -452
  370. package/src/assert-never.ts +18 -0
  371. package/src/aws/account.ts +23 -3
  372. package/src/aws/client.ts +0 -1
  373. package/src/aws/config.ts +16 -0
  374. package/src/aws/credentials.ts +212 -177
  375. package/src/aws/dynamodb/index.ts +3 -3
  376. package/src/aws/dynamodb/table.get-item.ts +5 -9
  377. package/src/aws/dynamodb/table.provider.ts +36 -39
  378. package/src/aws/dynamodb/table.ts +29 -84
  379. package/src/aws/ec2/index.ts +12 -0
  380. package/src/aws/ec2/internet-gateway.provider.ts +316 -0
  381. package/src/aws/ec2/internet-gateway.ts +79 -0
  382. package/src/aws/ec2/route-table-association.provider.ts +214 -0
  383. package/src/aws/ec2/route-table-association.ts +82 -0
  384. package/src/aws/ec2/route-table.provider.ts +306 -0
  385. package/src/aws/ec2/route-table.ts +175 -0
  386. package/src/aws/ec2/route.provider.ts +213 -0
  387. package/src/aws/ec2/route.ts +192 -0
  388. package/src/aws/ec2/subnet.provider.ts +358 -0
  389. package/src/aws/ec2/subnet.ts +213 -0
  390. package/src/aws/ec2/vpc.provider.ts +58 -50
  391. package/src/aws/ec2/vpc.ts +21 -8
  392. package/src/aws/index.ts +49 -40
  393. package/src/aws/lambda/consume.ts +8 -7
  394. package/src/aws/lambda/function.handler.ts +1 -1
  395. package/src/aws/lambda/function.invoke.ts +6 -2
  396. package/src/aws/lambda/function.provider.ts +41 -32
  397. package/src/aws/lambda/function.ts +7 -4
  398. package/src/aws/lambda/index.ts +2 -0
  399. package/src/aws/profile.ts +1 -4
  400. package/src/aws/region.ts +42 -3
  401. package/src/aws/sqs/index.ts +2 -0
  402. package/src/aws/sqs/queue.consume.ts +1 -1
  403. package/src/aws/sqs/queue.event-source.ts +29 -55
  404. package/src/aws/sqs/queue.provider.ts +10 -2
  405. package/src/aws/sqs/queue.send-message.ts +5 -8
  406. package/src/aws/sqs/queue.ts +9 -4
  407. package/src/binding.ts +19 -19
  408. package/src/cli/components/ApprovePlan.tsx +2 -2
  409. package/src/cli/components/Plan.tsx +3 -2
  410. package/src/cli/components/PlanProgress.tsx +32 -14
  411. package/src/cli/index.ts +2 -6
  412. package/src/cli/ink-service.tsx +61 -0
  413. package/src/cli/service.ts +23 -0
  414. package/src/cloudflare/account.ts +37 -0
  415. package/src/cloudflare/api.ts +33 -29
  416. package/src/cloudflare/config.ts +7 -0
  417. package/src/cloudflare/index.ts +3 -1
  418. package/src/cloudflare/kv/namespace.binding.ts +3 -1
  419. package/src/cloudflare/kv/namespace.provider.ts +10 -8
  420. package/src/cloudflare/kv/namespace.ts +3 -2
  421. package/src/cloudflare/live.ts +11 -17
  422. package/src/cloudflare/r2/bucket.binding.ts +3 -1
  423. package/src/cloudflare/r2/bucket.provider.ts +16 -9
  424. package/src/cloudflare/r2/bucket.ts +8 -2
  425. package/src/cloudflare/worker/assets.fetch.ts +3 -1
  426. package/src/cloudflare/worker/assets.provider.ts +1 -1
  427. package/src/cloudflare/worker/index.ts +0 -2
  428. package/src/cloudflare/worker/worker.handler.ts +1 -1
  429. package/src/cloudflare/worker/worker.provider.ts +21 -14
  430. package/src/cloudflare/worker/worker.serve.ts +5 -2
  431. package/src/cloudflare/worker/worker.ts +4 -3
  432. package/src/data.ts +18 -0
  433. package/src/destroy.ts +1 -5
  434. package/src/diff.ts +48 -0
  435. package/src/env.ts +20 -32
  436. package/src/event.ts +6 -0
  437. package/src/exports.ts +21 -0
  438. package/src/index.ts +10 -5
  439. package/src/input.ts +81 -0
  440. package/src/instance-id.ts +16 -0
  441. package/src/output.ts +542 -0
  442. package/src/physical-name.ts +57 -2
  443. package/src/plan.ts +757 -278
  444. package/src/policy.ts +3 -5
  445. package/src/provider.ts +70 -31
  446. package/src/ref.ts +48 -0
  447. package/src/resource.ts +70 -10
  448. package/src/runtime.ts +15 -8
  449. package/src/service.ts +11 -7
  450. package/src/stack.ts +116 -0
  451. package/src/stage.ts +85 -0
  452. package/src/state.ts +269 -76
  453. package/src/tags.ts +31 -0
  454. package/src/test.ts +118 -17
  455. package/src/todo.ts +4 -0
  456. package/src/type.ts +4 -0
  457. package/src/unknown.ts +6 -0
  458. package/src/user.ts +4 -0
  459. package/src/util.ts +21 -0
  460. package/lib/approve.d.ts +0 -15
  461. package/lib/approve.d.ts.map +0 -1
  462. package/lib/approve.js +0 -7
  463. package/lib/approve.js.map +0 -1
  464. package/lib/cli/approve.d.ts +0 -4
  465. package/lib/cli/approve.d.ts.map +0 -1
  466. package/lib/cli/approve.js +0 -18
  467. package/lib/cli/approve.js.map +0 -1
  468. package/lib/cli/clack.d.ts +0 -14
  469. package/lib/cli/clack.d.ts.map +0 -1
  470. package/lib/cli/clack.js +0 -12
  471. package/lib/cli/clack.js.map +0 -1
  472. package/lib/cli/main.d.ts +0 -2
  473. package/lib/cli/main.d.ts.map +0 -1
  474. package/lib/cli/main.js +0 -1
  475. package/lib/cli/main.js.map +0 -1
  476. package/lib/cli/plan.d.ts +0 -13
  477. package/lib/cli/plan.d.ts.map +0 -1
  478. package/lib/cli/plan.js +0 -1
  479. package/lib/cli/plan.js.map +0 -1
  480. package/lib/cli/progress.d.ts +0 -7
  481. package/lib/cli/progress.d.ts.map +0 -1
  482. package/lib/cli/progress.js +0 -30
  483. package/lib/cli/progress.js.map +0 -1
  484. package/lib/cli/spinner.d.ts +0 -2
  485. package/lib/cli/spinner.d.ts.map +0 -1
  486. package/lib/cli/spinner.js +0 -13
  487. package/lib/cli/spinner.js.map +0 -1
  488. package/src/approve.ts +0 -13
  489. package/src/cli/approve.tsx +0 -30
  490. package/src/cli/clack.ts +0 -22
  491. package/src/cli/main.ts +0 -0
  492. package/src/cli/plan.ts +0 -16
  493. package/src/cli/progress.tsx +0 -46
  494. package/src/cli/spinner.ts +0 -14
@@ -1,64 +1,54 @@
1
1
  import * as Effect from "effect/Effect";
2
2
  import * as Schedule from "effect/Schedule";
3
3
 
4
- import { App, type ProviderService } from "alchemy-effect";
5
- import type { ScopedPlanStatusSession } from "../../apply.ts";
6
- import { createTagger, createTagsList } from "../../tags.ts";
4
+ import type { EC2 } from "itty-aws/ec2";
5
+
6
+ import type { ScopedPlanStatusSession } from "../../cli/service.ts";
7
+ import { somePropsAreDifferent } from "../../diff.ts";
8
+ import type { ProviderService } from "../../provider.ts";
9
+ import { createTagger, createTagsList, diffTags } from "../../tags.ts";
7
10
  import { Account } from "../account.ts";
8
11
  import { Region } from "../region.ts";
9
12
  import { EC2Client } from "./client.ts";
13
+ import type { VpcId } from "./vpc.ts";
10
14
  import { Vpc, type VpcAttrs, type VpcProps } from "./vpc.ts";
11
15
 
12
- import type { EC2 } from "itty-aws/ec2";
13
-
14
16
  export const vpcProvider = () =>
15
17
  Vpc.provider.effect(
16
18
  Effect.gen(function* () {
17
19
  const ec2 = yield* EC2Client;
18
- const app = yield* App;
19
20
  const region = yield* Region;
20
21
  const accountId = yield* Account;
21
22
  const tagged = yield* createTagger();
22
23
 
23
- return {
24
- diff: Effect.fn(function* ({ id, news, olds }) {
25
- // 1. CIDR block changes
26
- if (olds.cidrBlock !== news.cidrBlock) {
27
- return { action: "replace" } as const;
28
- }
29
-
30
- // 2. Instance tenancy changes
31
- if (olds.instanceTenancy !== news.instanceTenancy) {
32
- return { action: "replace" } as const;
33
- }
34
-
35
- // 3. IPAM pool changes
36
- if (olds.ipv4IpamPoolId !== news.ipv4IpamPoolId) {
37
- return { action: "replace" } as const;
38
- }
39
-
40
- if (olds.ipv6IpamPoolId !== news.ipv6IpamPoolId) {
41
- return { action: "replace" } as const;
42
- }
24
+ const createTags = (
25
+ id: string,
26
+ tags?: Record<string, string>,
27
+ ): Record<string, string> => ({
28
+ Name: id,
29
+ ...tagged(id),
30
+ ...tags,
31
+ });
43
32
 
44
- // 4. IPv6 CIDR block changes
45
- if (olds.ipv6CidrBlock !== news.ipv6CidrBlock) {
46
- return { action: "replace" } as const;
47
- }
48
-
49
- // 5. IPv6 pool changes
50
- if (olds.ipv6Pool !== news.ipv6Pool) {
51
- return { action: "replace" } as const;
33
+ return {
34
+ stables: ["vpcId", "vpcArn", "ownerId", "isDefault"],
35
+ diff: Effect.fn(function* ({ news, olds }) {
36
+ if (
37
+ somePropsAreDifferent(olds, news, [
38
+ "cidrBlock",
39
+ "instanceTenancy",
40
+ "ipv4IpamPoolId",
41
+ "ipv6IpamPoolId",
42
+ "ipv6CidrBlock",
43
+ ])
44
+ ) {
45
+ return { action: "replace" };
52
46
  }
53
47
  }),
54
-
55
48
  create: Effect.fn(function* ({ id, news, session }) {
56
- // 1. Prepare tags
57
- const alchemyTags = tagged(id);
58
- const userTags = news.tags ?? {};
59
- const allTags = { ...alchemyTags, ...userTags };
49
+ const tags = createTags(id, news.tags);
60
50
 
61
- // 2. Call CreateVpc
51
+ // 1. Call CreateVpc
62
52
  const createResult = yield* ec2.createVpc({
63
53
  // TODO(sam): add all properties
64
54
  AmazonProvidedIpv6CidrBlock: news.amazonProvidedIpv6CidrBlock,
@@ -75,16 +65,16 @@ export const vpcProvider = () =>
75
65
  TagSpecifications: [
76
66
  {
77
67
  ResourceType: "vpc",
78
- Tags: createTagsList(allTags),
68
+ Tags: createTagsList(tags),
79
69
  },
80
70
  ],
81
71
  DryRun: false,
82
72
  });
83
73
 
84
- const vpcId = createResult.Vpc!.VpcId!;
74
+ const vpcId = createResult.Vpc!.VpcId! as VpcId;
85
75
  yield* session.note(`VPC created: ${vpcId}`);
86
76
 
87
- // 3. Modify DNS attributes if specified (separate API calls)
77
+ // 2. Modify DNS attributes if specified (separate API calls)
88
78
  yield* ec2.modifyVpcAttribute({
89
79
  VpcId: vpcId,
90
80
  EnableDnsSupport: { Value: news.enableDnsSupport ?? true },
@@ -132,10 +122,11 @@ export const vpcProvider = () =>
132
122
  ipv6Pool: assoc.Ipv6Pool,
133
123
  }),
134
124
  ),
125
+ tags,
135
126
  } satisfies VpcAttrs<VpcProps>;
136
127
  }),
137
128
 
138
- update: Effect.fn(function* ({ news, olds, output, session }) {
129
+ update: Effect.fn(function* ({ id, news, olds, output, session }) {
139
130
  const vpcId = output.vpcId;
140
131
 
141
132
  // Only DNS and metrics settings can be updated
@@ -157,9 +148,29 @@ export const vpcProvider = () =>
157
148
  yield* session.note("Updated DNS hostnames");
158
149
  }
159
150
 
160
- // Note: Tag updates would go here if we support user tag changes
151
+ // Handle user tag updates
152
+ const newTags = createTags(id, news.tags);
153
+ const oldTags = output.tags ?? {};
154
+ const { removed, upsert } = diffTags(oldTags, newTags);
155
+ if (removed.length > 0) {
156
+ yield* ec2.deleteTags({
157
+ Resources: [vpcId],
158
+ Tags: removed.map((key) => ({ Key: key })),
159
+ DryRun: false,
160
+ });
161
+ }
162
+ if (upsert.length > 0) {
163
+ yield* ec2.createTags({
164
+ Resources: [vpcId],
165
+ Tags: upsert,
166
+ DryRun: false,
167
+ });
168
+ }
161
169
 
162
- return output; // VPC attributes don't change from these updates
170
+ return {
171
+ ...output,
172
+ tags: newTags,
173
+ }; // VPC attributes don't change from these updates
163
174
  }),
164
175
 
165
176
  delete: Effect.fn(function* ({ output, session }) {
@@ -181,10 +192,7 @@ export const vpcProvider = () =>
181
192
  while: (e) => {
182
193
  // DependencyViolation means there are still dependent resources
183
194
  // This can happen if subnets/IGW are being deleted concurrently
184
- return (
185
- e._tag === "ValidationError" &&
186
- e.message?.includes("DependencyViolation")
187
- );
195
+ return e._tag === "DependencyViolation";
188
196
  },
189
197
  schedule: Schedule.exponential(1000, 1.5).pipe(
190
198
  Schedule.intersect(Schedule.recurs(10)), // Try up to 10 times
@@ -1,4 +1,5 @@
1
1
  import type * as EC2 from "itty-aws/ec2";
2
+ import type { Input } from "../../input.ts";
2
3
  import { Resource } from "../../resource.ts";
3
4
  import type { AccountID } from "../account.ts";
4
5
  import type { RegionID } from "../region.ts";
@@ -13,7 +14,17 @@ export const Vpc = Resource<{
13
14
  export interface Vpc<
14
15
  ID extends string = string,
15
16
  Props extends VpcProps = VpcProps,
16
- > extends Resource<"AWS.EC2.VPC", ID, Props, VpcAttrs<Props>> {}
17
+ > extends Resource<
18
+ "AWS.EC2.VPC",
19
+ ID,
20
+ Props,
21
+ VpcAttrs<Input.Resolve<Props>>,
22
+ Vpc
23
+ > {}
24
+
25
+ export type VpcId = `vpc-${string}`;
26
+ export const VpcId = <const S extends string>(value: S): S & VpcId =>
27
+ value as S & VpcId;
17
28
 
18
29
  export interface VpcProps {
19
30
  /**
@@ -26,7 +37,7 @@ export interface VpcProps {
26
37
  /**
27
38
  * The ID of an IPv4 IPAM pool you want to use for allocating this VPC's CIDR.
28
39
  */
29
- ipv4IpamPoolId?: string;
40
+ ipv4IpamPoolId?: Input<string>;
30
41
 
31
42
  /**
32
43
  * The netmask length of the IPv4 CIDR you want to allocate to this VPC from an IPAM pool.
@@ -36,7 +47,7 @@ export interface VpcProps {
36
47
  /**
37
48
  * The ID of an IPv6 IPAM pool which will be used to allocate this VPC an IPv6 CIDR.
38
49
  */
39
- ipv6IpamPoolId?: string;
50
+ ipv6IpamPoolId?: Input<string>;
40
51
 
41
52
  /**
42
53
  * The netmask length of the IPv6 CIDR you want to allocate to this VPC from an IPAM pool.
@@ -51,12 +62,12 @@ export interface VpcProps {
51
62
  /**
52
63
  * The ID of an IPv6 address pool from which to allocate the IPv6 CIDR block.
53
64
  */
54
- ipv6Pool?: string;
65
+ ipv6Pool?: Input<string>;
55
66
 
56
67
  /**
57
68
  * The Availability Zone or Local Zone Group name for the IPv6 CIDR block.
58
69
  */
59
- ipv6CidrBlockNetworkBorderGroup?: string;
70
+ ipv6CidrBlockNetworkBorderGroup?: Input<string>;
60
71
 
61
72
  /**
62
73
  * The tenancy options for instances launched into the VPC.
@@ -85,14 +96,14 @@ export interface VpcProps {
85
96
  * Tags to assign to the VPC.
86
97
  * These will be merged with alchemy auto-tags (alchemy::app, alchemy::stage, alchemy::id).
87
98
  */
88
- tags?: Record<string, string>;
99
+ tags?: Record<string, Input<string>>;
89
100
  }
90
101
 
91
- export interface VpcAttrs<Props extends VpcProps> {
102
+ export interface VpcAttrs<_Props extends VpcProps = VpcProps> {
92
103
  /**
93
104
  * The ID of the VPC.
94
105
  */
95
- vpcId: string;
106
+ vpcId: VpcId;
96
107
 
97
108
  /**
98
109
  * The Amazon Resource Name (ARN) of the VPC.
@@ -149,4 +160,6 @@ export interface VpcAttrs<Props extends VpcProps> {
149
160
  networkBorderGroup?: string;
150
161
  ipv6Pool?: string;
151
162
  }>;
163
+
164
+ tags?: Record<string, string>;
152
165
  }
package/src/aws/index.ts CHANGED
@@ -1,4 +1,7 @@
1
1
  import * as Layer from "effect/Layer";
2
+
3
+ // oxlint-disable-next-line no-unused-vars - needed or else provider types are transitively resolved through DynamoDB.Provider<..> lol
4
+
2
5
  import * as ESBuild from "../esbuild.ts";
3
6
  import * as Account from "./account.ts";
4
7
  import * as Credentials from "./credentials.ts";
@@ -10,45 +13,51 @@ import * as Region from "./region.ts";
10
13
  import * as S3 from "./s3.ts";
11
14
  import * as SQS from "./sqs/index.ts";
12
15
  import * as STS from "./sts.ts";
13
- // TODO(sam): should this be named?
14
- export * from "./profile.ts";
15
16
 
16
- export const providers = Layer.mergeAll(
17
- Layer.provide(
18
- Layer.provideMerge(Lambda.functionProvider(), ESBuild.layer()),
17
+ export { loadProfile, loadSSOCredentials } from "./credentials.ts";
18
+
19
+ import "./config.ts";
20
+
21
+ export const resources = () =>
22
+ Layer.mergeAll(
23
+ DynamoDB.tableProvider(),
24
+ EC2.internetGatewayProvider(),
25
+ EC2.routeProvider(),
26
+ EC2.routeTableAssociationProvider(),
27
+ EC2.routeTableProvider(),
28
+ EC2.subnetProvider(),
29
+ EC2.vpcProvider(),
30
+ Lambda.functionProvider(),
31
+ SQS.queueProvider(),
32
+ );
33
+
34
+ export const bindings = () =>
35
+ Layer.mergeAll(
36
+ DynamoDB.getItemFromLambdaFunction(),
37
+ SQS.queueEventSourceProvider(),
38
+ SQS.sendMessageFromLambdaFunction(),
39
+ );
40
+
41
+ export const clients = () =>
42
+ Layer.mergeAll(
43
+ DynamoDB.client(),
44
+ EC2.client(),
45
+ IAM.client(),
19
46
  Lambda.client(),
20
- ),
21
- Layer.provide(SQS.queueProvider(), SQS.client()),
22
- Layer.provide(DynamoDB.tableProvider(), DynamoDB.client()),
23
- Layer.provide(EC2.vpcProvider(), EC2.client()),
24
- );
25
-
26
- export const bindings = Layer.mergeAll(
27
- //
28
- SQS.sendMessageFromLambdaFunction(),
29
- SQS.queueEventSourceProvider(),
30
- DynamoDB.getItemFromLambdaFunction(),
31
- );
32
-
33
- export const clients = Layer.mergeAll(
34
- STS.client(),
35
- IAM.client(),
36
- S3.client(),
37
- SQS.client(),
38
- Lambda.client(),
39
- DynamoDB.client(),
40
- EC2.client(),
41
- );
42
-
43
- export const defaultProviders = providers.pipe(
44
- Layer.provideMerge(bindings),
45
- Layer.provideMerge(Account.fromIdentity()),
46
- Layer.provideMerge(clients),
47
- );
48
-
49
- export const live = defaultProviders.pipe(
50
- Layer.provide(Region.fromEnv()),
51
- Layer.provide(Credentials.fromSSO()),
52
- );
53
-
54
- export default live;
47
+ S3.client(),
48
+ SQS.client(),
49
+ // STS.client(),
50
+ );
51
+
52
+ export const utils = () => Layer.mergeAll(ESBuild.layer());
53
+
54
+ export const providers = () =>
55
+ resources().pipe(
56
+ Layer.provideMerge(bindings()),
57
+ Layer.provideMerge(clients()),
58
+ Layer.provideMerge(utils()),
59
+ Layer.provideMerge(Account.fromStageConfig()),
60
+ Layer.provideMerge(STS.client()),
61
+ Layer.provideMerge(Region.fromStageConfig()),
62
+ Layer.provideMerge(Credentials.fromStageConfig()),
63
+ );
@@ -1,5 +1,3 @@
1
- import type { From } from "alchemy-effect";
2
- import { declare } from "alchemy-effect";
3
1
  import type {
4
2
  Context as LambdaContext,
5
3
  SQSBatchResponse,
@@ -7,11 +5,14 @@ import type {
7
5
  } from "aws-lambda";
8
6
  import * as Effect from "effect/Effect";
9
7
  import * as S from "effect/Schema";
10
- import * as SQS from "../sqs/index.ts";
8
+ import { declare, type From } from "../../policy.ts";
11
9
  import * as Lambda from "./function.ts";
10
+ import type { Queue } from "../sqs/queue.ts";
11
+ import type { Consume, QueueEvent } from "../sqs/queue.consume.ts";
12
+ import { QueueEventSource } from "../sqs/queue.event-source.ts";
12
13
 
13
14
  export const consume =
14
- <Q extends SQS.Queue, ID extends string, Req>(
15
+ <Q extends Queue, ID extends string, Req>(
15
16
  id: ID,
16
17
  {
17
18
  queue,
@@ -19,7 +20,7 @@ export const consume =
19
20
  }: {
20
21
  queue: Q;
21
22
  handle: (
22
- event: SQS.QueueEvent<Q["props"]["schema"]["Type"]>,
23
+ event: QueueEvent<Q["props"]["schema"]["Type"]>,
23
24
  context: LambdaContext,
24
25
  ) => Effect.Effect<SQSBatchResponse | void, never, Req>;
25
26
  },
@@ -30,7 +31,7 @@ export const consume =
30
31
  }: Props) =>
31
32
  Lambda.Function(id, {
32
33
  handle: Effect.fn(function* (event: SQSEvent, context: LambdaContext) {
33
- yield* declare<SQS.Consume<From<Q>>>();
34
+ yield* declare<Consume<From<Q>>>();
34
35
  const records = yield* Effect.all(
35
36
  event.Records.map(
36
37
  Effect.fn(function* (record) {
@@ -60,4 +61,4 @@ export const consume =
60
61
  ],
61
62
  } satisfies SQSBatchResponse;
62
63
  }),
63
- })({ ...props, bindings: bindings.and(SQS.QueueEventSource(queue)) });
64
+ })({ ...props, bindings: bindings.and(QueueEventSource(queue)) });
@@ -1,6 +1,6 @@
1
- import type { Capability } from "alchemy-effect";
2
1
  import type { Context as LambdaContext } from "aws-lambda";
3
2
  import * as Effect from "effect/Effect";
3
+ import type { Capability } from "../../capability.ts";
4
4
 
5
5
  type Handler = (
6
6
  event: any,
@@ -1,6 +1,10 @@
1
1
  import * as Effect from "effect/Effect";
2
2
 
3
- import { $, Binding, type Capability, declare, toEnvKey } from "alchemy-effect";
3
+ import { Binding } from "../../binding.ts";
4
+ import type { Capability } from "../../capability.ts";
5
+ import { toEnvKey } from "../../env.ts";
6
+ import { declare, type On } from "../../policy.ts";
7
+ import type { $ } from "../../$.ts";
4
8
  import { LambdaClient } from "./client.ts";
5
9
  import { Function } from "./function.ts";
6
10
 
@@ -8,7 +12,7 @@ export interface InvokeFunction<Resource = unknown>
8
12
  extends Capability<"AWS.Lambda.InvokeFunction", Resource> {}
9
13
 
10
14
  export const InvokeFunction = Binding<
11
- <F extends Function>(func: F) => Binding<Function, InvokeFunction<$<F>>>
15
+ <F extends Function>(func: F) => Binding<Function, InvokeFunction<On<F>>>
12
16
  >(Function, "AWS.Lambda.InvokeFunction");
13
17
 
14
18
  export const invoke = <F extends Function>(func: F, input: any) =>
@@ -5,13 +5,14 @@ import { FileSystem } from "@effect/platform";
5
5
  import * as Effect from "effect/Effect";
6
6
  import * as Schedule from "effect/Schedule";
7
7
 
8
- import { App, DotAlchemy, type ProviderService } from "alchemy-effect";
9
-
10
8
  import type {
11
9
  CreateFunctionRequest,
12
10
  CreateFunctionUrlConfigRequest,
13
11
  UpdateFunctionUrlConfigRequest,
14
12
  } from "itty-aws/lambda";
13
+ import { App } from "../../app.ts";
14
+ import { DotAlchemy } from "../../dot-alchemy.ts";
15
+ import type { ProviderService } from "../../provider.ts";
15
16
  import { createTagger, createTagsList, hasTags } from "../../tags.ts";
16
17
  import { Account } from "../account.ts";
17
18
  import * as IAM from "../iam.ts";
@@ -25,9 +26,9 @@ export const functionProvider = () =>
25
26
  Effect.gen(function* () {
26
27
  const lambda = yield* LambdaClient;
27
28
  const iam = yield* IAM.IAMClient;
29
+ const app = yield* App;
28
30
  const accountId = yield* Account;
29
31
  const region = yield* Region;
30
- const app = yield* App;
31
32
  const dotAlchemy = yield* DotAlchemy;
32
33
  const fs = yield* FileSystem.FileSystem;
33
34
 
@@ -68,7 +69,7 @@ export const functionProvider = () =>
68
69
  }) {
69
70
  const env = bindings
70
71
  .map((binding) => binding?.env)
71
- .reduce((acc, env) => ({ ...acc, ...(env ?? {}) }), {});
72
+ .reduce((acc, env) => ({ ...acc, ...env }), {});
72
73
  const policyStatements = bindings.flatMap(
73
74
  (binding) =>
74
75
  binding?.policyStatements?.map((stmt: IAM.PolicyStatement) => ({
@@ -156,7 +157,10 @@ export const functionProvider = () =>
156
157
 
157
158
  const bundleCode = Effect.fn(function* (
158
159
  id: string,
159
- props: FunctionProps,
160
+ props: {
161
+ main: string;
162
+ handler?: string;
163
+ },
160
164
  ) {
161
165
  const handler = props.handler ?? "default";
162
166
  let file = path.relative(process.cwd(), props.main);
@@ -215,7 +219,7 @@ export const functionProvider = () =>
215
219
  functionName,
216
220
  }: {
217
221
  id: string;
218
- news: FunctionProps;
222
+ news: FunctionProps<any>;
219
223
  roleArn: string;
220
224
  code: string | Uint8Array<ArrayBufferLike>;
221
225
  env: Record<string, string> | undefined;
@@ -264,17 +268,13 @@ export const functionProvider = () =>
264
268
  })
265
269
  .pipe(
266
270
  Effect.retry({
267
- while: (e) => {
268
- console.log({ e });
269
- return (
270
- e._tag === "ResourceConflictException" ||
271
- (e._tag === "InvalidParameterValueException" &&
272
- e.message?.includes(
273
- "The role defined for the function cannot be assumed by Lambda.",
274
- ))
275
- );
276
- },
277
- schedule: Schedule.fixed(100),
271
+ while: (e) =>
272
+ e._tag === "ResourceConflictException" ||
273
+ (e._tag === "InvalidParameterValueException" &&
274
+ e.message?.includes(
275
+ "The role defined for the function cannot be assumed by Lambda.",
276
+ )),
277
+ schedule: Schedule.exponential(100),
278
278
  }),
279
279
  );
280
280
  yield* Effect.logDebug(`updated function code ${id}`);
@@ -426,6 +426,28 @@ export const functionProvider = () =>
426
426
  }`;
427
427
 
428
428
  return {
429
+ stables: ["functionArn", "functionName", "roleName"],
430
+ diff: Effect.fn(function* ({ id, olds, news, output }) {
431
+ if (
432
+ // function name changed
433
+ output.functionName !==
434
+ (news.functionName ?? createFunctionName(id)) ||
435
+ // url changed
436
+ olds.url !== news.url
437
+ ) {
438
+ return { action: "replace" };
439
+ }
440
+ if (
441
+ output.code.hash !==
442
+ (yield* bundleCode(id, {
443
+ main: news.main,
444
+ handler: news.handler,
445
+ })).hash
446
+ ) {
447
+ // code changed
448
+ return { action: "update" };
449
+ }
450
+ }),
429
451
  read: Effect.fn(function* ({ id, output }) {
430
452
  if (output) {
431
453
  yield* Effect.logDebug(`reading function ${id}`);
@@ -452,21 +474,8 @@ export const functionProvider = () =>
452
474
  }
453
475
  return output;
454
476
  }),
455
- diff: Effect.fn(function* ({ id, olds, news, output }) {
456
- if (
457
- // function name changed
458
- output.functionName !==
459
- (news.functionName ?? createFunctionName(id)) ||
460
- // url changed
461
- olds.url !== news.url
462
- ) {
463
- return { action: "replace" };
464
- } else if (output.code.hash !== (yield* bundleCode(id, news)).hash) {
465
- // code changed
466
- return { action: "update" };
467
- }
468
- }),
469
- precreate: Effect.fn(function* ({ id, news, session }) {
477
+
478
+ precreate: Effect.fn(function* ({ id, news }) {
470
479
  const { roleName, functionName, roleArn } = createPhysicalNames(id);
471
480
 
472
481
  const role = yield* createRoleIfNotExists({ id, roleName });
@@ -1,9 +1,11 @@
1
- import { Runtime, type Capability, type RuntimeProps } from "alchemy-effect";
1
+ import type { Capability } from "../../capability.ts";
2
+ import { Runtime, type RuntimeProps } from "../../runtime.ts";
2
3
  import type * as IAM from "../iam.ts";
3
4
 
4
5
  export type { Context } from "aws-lambda";
5
6
 
6
- export interface FunctionProps<Req = any> extends RuntimeProps<Function, Req> {
7
+ export interface FunctionProps<Req = unknown>
8
+ extends RuntimeProps<Function, Req> {
7
9
  functionName?: string;
8
10
  functionArn?: string;
9
11
  main: string;
@@ -38,8 +40,9 @@ export interface FunctionBinding {
38
40
  }
39
41
 
40
42
  export interface Function extends Runtime<"AWS.Lambda.Function"> {
41
- props: FunctionProps;
42
- attr: FunctionAttr<Extract<this["props"], FunctionProps>>;
43
+ props: FunctionProps<any>;
44
+ attr: FunctionAttr<Extract<this["props"], FunctionProps<any>>>;
43
45
  binding: FunctionBinding;
46
+ base: Function;
44
47
  }
45
48
  export const Function = Runtime("AWS.Lambda.Function")<Function>();
@@ -7,3 +7,5 @@ export * from "./serve.ts";
7
7
  export * from "./consume.ts";
8
8
 
9
9
  // export type * as lambda from "aws-lambda";
10
+
11
+ import "../config.ts";
@@ -1,6 +1,3 @@
1
1
  import * as Context from "effect/Context";
2
2
 
3
- export class AwsProfile extends Context.Tag("AWS::Profile")<
4
- AwsProfile,
5
- string
6
- >() {}
3
+ export class Profile extends Context.Tag("AWS::Profile")<Profile, string>() {}
package/src/aws/region.ts CHANGED
@@ -1,12 +1,16 @@
1
+ import * as Config from "effect/Config";
2
+ import * as Option from "effect/Option";
1
3
  import * as Context from "effect/Context";
2
4
  import * as Data from "effect/Data";
3
5
  import * as Effect from "effect/Effect";
4
6
  import * as Layer from "effect/Layer";
5
-
6
- export type RegionID = string;
7
+ import { App } from "../app.ts";
8
+ import { loadProfile } from "./credentials.ts";
7
9
 
8
10
  export class Region extends Context.Tag("AWS::Region")<Region, RegionID>() {}
9
11
 
12
+ export type RegionID = string;
13
+
10
14
  export const of = (region: string) => Layer.succeed(Region, region);
11
15
 
12
16
  export const fromEnvOrElse = (region: string) =>
@@ -19,11 +23,16 @@ export class EnvironmentVariableNotSet extends Data.TaggedError(
19
23
  variable: string;
20
24
  }> {}
21
25
 
26
+ export const AWS_REGION = Config.string("AWS_REGION");
27
+
28
+ const tryGetAWSRegion = () =>
29
+ Config.option(AWS_REGION).pipe(Effect.map(Option.getOrUndefined));
30
+
22
31
  export const fromEnv = () =>
23
32
  Layer.effect(
24
33
  Region,
25
34
  Effect.gen(function* () {
26
- const region = process.env.AWS_REGION;
35
+ const region = yield* tryGetAWSRegion();
27
36
  if (!region) {
28
37
  return yield* Effect.fail(
29
38
  new EnvironmentVariableNotSet({
@@ -35,3 +44,33 @@ export const fromEnv = () =>
35
44
  return region;
36
45
  }),
37
46
  );
47
+
48
+ export class AWSStageConfigRegionMissing extends Data.TaggedError(
49
+ "AWSStageConfigMissing",
50
+ )<{
51
+ message: string;
52
+ stage: string;
53
+ }> {}
54
+
55
+ export const fromStageConfig = () =>
56
+ Layer.effect(
57
+ Region,
58
+ Effect.gen(function* () {
59
+ const app = yield* App;
60
+ if (app.config.aws?.region) {
61
+ return app.config.aws.region;
62
+ } else if (app.config.aws?.profile) {
63
+ const profile = yield* loadProfile(app.config.aws.profile);
64
+ if (profile.region) {
65
+ return profile.region;
66
+ }
67
+ }
68
+ const region = yield* tryGetAWSRegion();
69
+ if (region) {
70
+ return region;
71
+ }
72
+ return yield* Effect.dieMessage(
73
+ "No AWS region found in stage config, SSO profile, or environment variable",
74
+ );
75
+ }),
76
+ );