alchemy-effect 0.1.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 (590) 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 +7 -15
  9. package/lib/app.d.ts.map +1 -1
  10. package/lib/app.js +1 -20
  11. package/lib/app.js.map +1 -1
  12. package/lib/apply.d.ts +15 -19
  13. package/lib/apply.d.ts.map +1 -1
  14. package/lib/apply.js +173 -82
  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 +13 -3
  21. package/lib/aws/account.d.ts.map +1 -1
  22. package/lib/aws/account.js +19 -4
  23. package/lib/aws/account.js.map +1 -1
  24. package/lib/aws/arn.d.ts +1 -5
  25. package/lib/aws/arn.d.ts.map +1 -1
  26. package/lib/aws/client.d.ts.map +1 -1
  27. package/lib/aws/client.js +8 -1
  28. package/lib/aws/client.js.map +1 -1
  29. package/lib/aws/config.d.ts +15 -0
  30. package/lib/aws/config.d.ts.map +1 -0
  31. package/lib/aws/config.js +1 -0
  32. package/lib/aws/config.js.map +1 -0
  33. package/lib/aws/credentials.d.ts +11 -1
  34. package/lib/aws/credentials.d.ts.map +1 -1
  35. package/lib/aws/credentials.js +73 -47
  36. package/lib/aws/credentials.js.map +1 -1
  37. package/lib/aws/dynamodb/attribute-value.d.ts +20 -0
  38. package/lib/aws/dynamodb/attribute-value.d.ts.map +1 -0
  39. package/lib/aws/dynamodb/attribute-value.js +217 -0
  40. package/lib/aws/dynamodb/attribute-value.js.map +1 -0
  41. package/lib/aws/dynamodb/client.d.ts +12 -0
  42. package/lib/aws/dynamodb/client.d.ts.map +1 -0
  43. package/lib/aws/{sqs/queue.client.js → dynamodb/client.js} +6 -6
  44. package/lib/aws/dynamodb/client.js.map +1 -0
  45. package/lib/aws/dynamodb/expr.d.ts +41 -0
  46. package/lib/aws/dynamodb/expr.d.ts.map +1 -0
  47. package/lib/aws/dynamodb/expr.js +1 -0
  48. package/lib/aws/dynamodb/expr.js.map +1 -0
  49. package/lib/aws/dynamodb/index.d.ts +10 -0
  50. package/lib/aws/dynamodb/index.d.ts.map +1 -0
  51. package/lib/aws/dynamodb/index.js +9 -0
  52. package/lib/aws/dynamodb/index.js.map +1 -0
  53. package/lib/aws/dynamodb/projection.d.ts +25 -0
  54. package/lib/aws/dynamodb/projection.d.ts.map +1 -0
  55. package/lib/aws/dynamodb/projection.js +1 -0
  56. package/lib/aws/dynamodb/projection.js.map +1 -0
  57. package/lib/aws/dynamodb/secondary-index.d.ts +26 -0
  58. package/lib/aws/dynamodb/secondary-index.d.ts.map +1 -0
  59. package/lib/aws/dynamodb/secondary-index.js +4 -0
  60. package/lib/aws/dynamodb/secondary-index.js.map +1 -0
  61. package/lib/aws/dynamodb/table.d.ts +59 -0
  62. package/lib/aws/dynamodb/table.d.ts.map +1 -0
  63. package/lib/aws/dynamodb/table.get-item.d.ts +57 -0
  64. package/lib/aws/dynamodb/table.get-item.d.ts.map +1 -0
  65. package/lib/aws/dynamodb/table.get-item.js +77 -0
  66. package/lib/aws/dynamodb/table.get-item.js.map +1 -0
  67. package/lib/aws/dynamodb/table.js +4 -0
  68. package/lib/aws/dynamodb/table.js.map +1 -0
  69. package/lib/aws/dynamodb/table.provider.d.ts +7 -0
  70. package/lib/aws/dynamodb/table.provider.d.ts.map +1 -0
  71. package/lib/aws/dynamodb/table.provider.js +187 -0
  72. package/lib/aws/dynamodb/table.provider.js.map +1 -0
  73. package/lib/aws/ec2/client.d.ts +12 -0
  74. package/lib/aws/ec2/client.d.ts.map +1 -0
  75. package/lib/aws/ec2/client.js +11 -0
  76. package/lib/aws/ec2/client.js.map +1 -0
  77. package/lib/aws/ec2/index.d.ts +7 -0
  78. package/lib/aws/ec2/index.d.ts.map +1 -0
  79. package/lib/aws/ec2/index.js +7 -0
  80. package/lib/aws/ec2/index.js.map +1 -0
  81. package/lib/aws/ec2/subnet.d.ts +175 -0
  82. package/lib/aws/ec2/subnet.d.ts.map +1 -0
  83. package/lib/aws/ec2/subnet.js +4 -0
  84. package/lib/aws/ec2/subnet.js.map +1 -0
  85. package/lib/aws/ec2/subnet.provider.d.ts +4 -0
  86. package/lib/aws/ec2/subnet.provider.d.ts.map +1 -0
  87. package/lib/aws/ec2/subnet.provider.js +250 -0
  88. package/lib/aws/ec2/subnet.provider.js.map +1 -0
  89. package/lib/aws/ec2/vpc.d.ts +135 -0
  90. package/lib/aws/ec2/vpc.d.ts.map +1 -0
  91. package/lib/aws/ec2/vpc.js +4 -0
  92. package/lib/aws/ec2/vpc.js.map +1 -0
  93. package/lib/aws/ec2/vpc.provider.d.ts +6 -0
  94. package/lib/aws/ec2/vpc.provider.d.ts.map +1 -0
  95. package/lib/aws/ec2/vpc.provider.js +183 -0
  96. package/lib/aws/ec2/vpc.provider.js.map +1 -0
  97. package/lib/aws/index.d.ts +23 -16
  98. package/lib/aws/index.d.ts.map +1 -1
  99. package/lib/aws/index.js +10 -18
  100. package/lib/aws/index.js.map +1 -1
  101. package/lib/aws/lambda/client.d.ts +8 -0
  102. package/lib/aws/lambda/client.d.ts.map +1 -0
  103. package/lib/aws/lambda/client.js +7 -0
  104. package/lib/aws/lambda/client.js.map +1 -0
  105. package/lib/aws/lambda/consume.d.ts +10 -11
  106. package/lib/aws/lambda/consume.d.ts.map +1 -1
  107. package/lib/aws/lambda/consume.js +3 -3
  108. package/lib/aws/lambda/consume.js.map +1 -1
  109. package/lib/aws/lambda/function.d.ts +18 -15
  110. package/lib/aws/lambda/function.d.ts.map +1 -1
  111. package/lib/aws/lambda/function.handler.d.ts +1 -1
  112. package/lib/aws/lambda/function.handler.d.ts.map +1 -1
  113. package/lib/aws/lambda/function.handler.js.map +1 -1
  114. package/lib/aws/lambda/function.invoke.d.ts +7 -5
  115. package/lib/aws/lambda/function.invoke.d.ts.map +1 -1
  116. package/lib/aws/lambda/function.invoke.js +5 -3
  117. package/lib/aws/lambda/function.invoke.js.map +1 -1
  118. package/lib/aws/lambda/function.js +1 -1
  119. package/lib/aws/lambda/function.js.map +1 -1
  120. package/lib/aws/lambda/function.provider.d.ts +6 -5
  121. package/lib/aws/lambda/function.provider.d.ts.map +1 -1
  122. package/lib/aws/lambda/function.provider.js +150 -58
  123. package/lib/aws/lambda/function.provider.js.map +1 -1
  124. package/lib/aws/lambda/index.d.ts +2 -2
  125. package/lib/aws/lambda/index.d.ts.map +1 -1
  126. package/lib/aws/lambda/index.js +2 -1
  127. package/lib/aws/lambda/index.js.map +1 -1
  128. package/lib/aws/lambda/serve.d.ts +2 -4
  129. package/lib/aws/lambda/serve.d.ts.map +1 -1
  130. package/lib/aws/lambda/serve.js.map +1 -1
  131. package/lib/aws/profile.d.ts +2 -2
  132. package/lib/aws/profile.d.ts.map +1 -1
  133. package/lib/aws/profile.js +1 -1
  134. package/lib/aws/profile.js.map +1 -1
  135. package/lib/aws/region.d.ts +14 -1
  136. package/lib/aws/region.d.ts.map +1 -1
  137. package/lib/aws/region.js +26 -1
  138. package/lib/aws/region.js.map +1 -1
  139. package/lib/aws/sqs/client.d.ts +12 -0
  140. package/lib/aws/sqs/client.d.ts.map +1 -0
  141. package/lib/aws/sqs/client.js +11 -0
  142. package/lib/aws/sqs/client.js.map +1 -0
  143. package/lib/aws/sqs/index.d.ts +3 -1
  144. package/lib/aws/sqs/index.d.ts.map +1 -1
  145. package/lib/aws/sqs/index.js +3 -1
  146. package/lib/aws/sqs/index.js.map +1 -1
  147. package/lib/aws/sqs/queue.consume.d.ts +1 -10
  148. package/lib/aws/sqs/queue.consume.d.ts.map +1 -1
  149. package/lib/aws/sqs/queue.consume.js +0 -19
  150. package/lib/aws/sqs/queue.consume.js.map +1 -1
  151. package/lib/aws/sqs/queue.d.ts +6 -12
  152. package/lib/aws/sqs/queue.d.ts.map +1 -1
  153. package/lib/aws/sqs/queue.event-source.d.ts +22 -0
  154. package/lib/aws/sqs/queue.event-source.d.ts.map +1 -0
  155. package/lib/aws/sqs/queue.event-source.js +130 -0
  156. package/lib/aws/sqs/queue.event-source.js.map +1 -0
  157. package/lib/aws/sqs/queue.js +1 -1
  158. package/lib/aws/sqs/queue.js.map +1 -1
  159. package/lib/aws/sqs/queue.provider.d.ts +5 -4
  160. package/lib/aws/sqs/queue.provider.d.ts.map +1 -1
  161. package/lib/aws/sqs/queue.provider.js +6 -6
  162. package/lib/aws/sqs/queue.provider.js.map +1 -1
  163. package/lib/aws/sqs/queue.send-message.d.ts +8 -6
  164. package/lib/aws/sqs/queue.send-message.d.ts.map +1 -1
  165. package/lib/aws/sqs/queue.send-message.js +6 -4
  166. package/lib/aws/sqs/queue.send-message.js.map +1 -1
  167. package/lib/binding.d.ts +74 -26
  168. package/lib/binding.d.ts.map +1 -1
  169. package/lib/binding.js.map +1 -1
  170. package/lib/capability.d.ts +38 -0
  171. package/lib/capability.d.ts.map +1 -1
  172. package/lib/cli/components/ApprovePlan.d.ts +2 -2
  173. package/lib/cli/components/ApprovePlan.d.ts.map +1 -1
  174. package/lib/cli/components/ApprovePlan.js.map +1 -1
  175. package/lib/cli/components/Plan.d.ts +2 -2
  176. package/lib/cli/components/Plan.d.ts.map +1 -1
  177. package/lib/cli/components/Plan.js +3 -1
  178. package/lib/cli/components/Plan.js.map +1 -1
  179. package/lib/cli/components/PlanProgress.d.ts +8 -4
  180. package/lib/cli/components/PlanProgress.d.ts.map +1 -1
  181. package/lib/cli/components/PlanProgress.js +11 -1
  182. package/lib/cli/components/PlanProgress.js.map +1 -1
  183. package/lib/cli/index.d.ts +342 -213
  184. package/lib/cli/index.d.ts.map +1 -1
  185. package/lib/cli/index.js +26047 -11403
  186. package/lib/cli/index.js.map +1 -1
  187. package/lib/cli/ink-service.d.ts +4 -0
  188. package/lib/cli/ink-service.d.ts.map +1 -0
  189. package/lib/cli/ink-service.js +43 -0
  190. package/lib/cli/ink-service.js.map +1 -0
  191. package/lib/cli/service.d.ts +21 -0
  192. package/lib/cli/service.d.ts.map +1 -0
  193. package/lib/cli/service.js +5 -0
  194. package/lib/cli/service.js.map +1 -0
  195. package/lib/cloudflare/account.d.ts +10 -0
  196. package/lib/cloudflare/account.d.ts.map +1 -0
  197. package/lib/cloudflare/account.js +24 -0
  198. package/lib/cloudflare/account.js.map +1 -0
  199. package/lib/cloudflare/api.d.ts +31 -19
  200. package/lib/cloudflare/api.d.ts.map +1 -1
  201. package/lib/cloudflare/api.js +95 -29
  202. package/lib/cloudflare/api.js.map +1 -1
  203. package/lib/cloudflare/config.d.ts +9 -0
  204. package/lib/cloudflare/config.d.ts.map +1 -0
  205. package/lib/cloudflare/config.js +1 -0
  206. package/lib/cloudflare/config.js.map +1 -0
  207. package/lib/cloudflare/context.d.ts +27 -0
  208. package/lib/cloudflare/context.d.ts.map +1 -0
  209. package/lib/cloudflare/context.js +24 -0
  210. package/lib/cloudflare/context.js.map +1 -0
  211. package/lib/cloudflare/index.d.ts +7 -4
  212. package/lib/cloudflare/index.d.ts.map +1 -1
  213. package/lib/cloudflare/index.js +7 -4
  214. package/lib/cloudflare/index.js.map +1 -1
  215. package/lib/cloudflare/kv/index.d.ts +4 -0
  216. package/lib/cloudflare/kv/index.d.ts.map +1 -0
  217. package/lib/cloudflare/kv/index.js +4 -0
  218. package/lib/cloudflare/kv/index.js.map +1 -0
  219. package/lib/cloudflare/kv/namespace.binding.d.ts +10 -0
  220. package/lib/cloudflare/kv/namespace.binding.d.ts.map +1 -0
  221. package/lib/cloudflare/kv/namespace.binding.js +15 -0
  222. package/lib/cloudflare/kv/namespace.binding.js.map +1 -0
  223. package/lib/cloudflare/kv/namespace.client.d.ts +11 -0
  224. package/lib/cloudflare/kv/namespace.client.d.ts.map +1 -0
  225. package/lib/cloudflare/kv/namespace.client.js +31 -0
  226. package/lib/cloudflare/kv/namespace.client.js.map +1 -0
  227. package/lib/cloudflare/kv/namespace.d.ts +24 -0
  228. package/lib/cloudflare/kv/namespace.d.ts.map +1 -0
  229. package/lib/cloudflare/kv/namespace.js +3 -0
  230. package/lib/cloudflare/kv/namespace.js.map +1 -0
  231. package/lib/cloudflare/kv/namespace.provider.d.ts +6 -0
  232. package/lib/cloudflare/kv/namespace.provider.d.ts.map +1 -0
  233. package/lib/cloudflare/kv/namespace.provider.js +81 -0
  234. package/lib/cloudflare/kv/namespace.provider.js.map +1 -0
  235. package/lib/cloudflare/live.d.ts +11 -0
  236. package/lib/cloudflare/live.d.ts.map +1 -0
  237. package/lib/cloudflare/live.js +15 -0
  238. package/lib/cloudflare/live.js.map +1 -0
  239. package/lib/cloudflare/r2/bucket.binding.d.ts +10 -0
  240. package/lib/cloudflare/r2/bucket.binding.d.ts.map +1 -0
  241. package/lib/cloudflare/r2/bucket.binding.js +18 -0
  242. package/lib/cloudflare/r2/bucket.binding.js.map +1 -0
  243. package/lib/cloudflare/r2/bucket.client.d.ts +8 -0
  244. package/lib/cloudflare/r2/bucket.client.d.ts.map +1 -0
  245. package/lib/cloudflare/r2/bucket.client.js +9 -0
  246. package/lib/cloudflare/r2/bucket.client.js.map +1 -0
  247. package/lib/cloudflare/r2/bucket.d.ts +33 -0
  248. package/lib/cloudflare/r2/bucket.d.ts.map +1 -0
  249. package/lib/cloudflare/r2/bucket.del.d.ts +4 -0
  250. package/lib/cloudflare/r2/bucket.del.d.ts.map +1 -0
  251. package/lib/cloudflare/r2/bucket.del.js +7 -0
  252. package/lib/cloudflare/r2/bucket.del.js.map +1 -0
  253. package/lib/cloudflare/r2/bucket.get.d.ts +5 -0
  254. package/lib/cloudflare/r2/bucket.get.d.ts.map +1 -0
  255. package/lib/cloudflare/r2/bucket.get.js +7 -0
  256. package/lib/cloudflare/r2/bucket.get.js.map +1 -0
  257. package/lib/cloudflare/r2/bucket.head.d.ts +4 -0
  258. package/lib/cloudflare/r2/bucket.head.d.ts.map +1 -0
  259. package/lib/cloudflare/r2/bucket.head.js +7 -0
  260. package/lib/cloudflare/r2/bucket.head.js.map +1 -0
  261. package/lib/cloudflare/r2/bucket.js +3 -0
  262. package/lib/cloudflare/r2/bucket.js.map +1 -0
  263. package/lib/cloudflare/r2/bucket.list.d.ts +5 -0
  264. package/lib/cloudflare/r2/bucket.list.d.ts.map +1 -0
  265. package/lib/cloudflare/r2/bucket.list.js +7 -0
  266. package/lib/cloudflare/r2/bucket.list.js.map +1 -0
  267. package/lib/cloudflare/r2/bucket.multipart.d.ts +19 -0
  268. package/lib/cloudflare/r2/bucket.multipart.d.ts.map +1 -0
  269. package/lib/cloudflare/r2/bucket.multipart.js +25 -0
  270. package/lib/cloudflare/r2/bucket.multipart.js.map +1 -0
  271. package/lib/cloudflare/r2/bucket.provider.d.ts +6 -0
  272. package/lib/cloudflare/r2/bucket.provider.d.ts.map +1 -0
  273. package/lib/cloudflare/r2/bucket.provider.js +67 -0
  274. package/lib/cloudflare/r2/bucket.provider.js.map +1 -0
  275. package/lib/cloudflare/r2/bucket.put.d.ts +6 -0
  276. package/lib/cloudflare/r2/bucket.put.d.ts.map +1 -0
  277. package/lib/cloudflare/r2/bucket.put.js +8 -0
  278. package/lib/cloudflare/r2/bucket.put.js.map +1 -0
  279. package/lib/cloudflare/r2/index.d.ts +10 -0
  280. package/lib/cloudflare/r2/index.d.ts.map +1 -0
  281. package/lib/cloudflare/r2/index.js +10 -0
  282. package/lib/cloudflare/r2/index.js.map +1 -0
  283. package/lib/cloudflare/stream.d.ts +10 -0
  284. package/lib/cloudflare/stream.d.ts.map +1 -0
  285. package/lib/cloudflare/stream.js +16 -0
  286. package/lib/cloudflare/stream.js.map +1 -0
  287. package/lib/cloudflare/worker/assets.fetch.d.ts +9 -0
  288. package/lib/cloudflare/worker/assets.fetch.d.ts.map +1 -0
  289. package/lib/cloudflare/worker/assets.fetch.js +12 -0
  290. package/lib/cloudflare/worker/assets.fetch.js.map +1 -0
  291. package/lib/cloudflare/worker/assets.provider.d.ts +66 -0
  292. package/lib/cloudflare/worker/assets.provider.d.ts.map +1 -0
  293. package/lib/cloudflare/worker/assets.provider.js +145 -0
  294. package/lib/cloudflare/worker/assets.provider.js.map +1 -0
  295. package/lib/cloudflare/worker/index.d.ts +5 -0
  296. package/lib/cloudflare/worker/index.d.ts.map +1 -0
  297. package/lib/cloudflare/worker/index.js +5 -0
  298. package/lib/cloudflare/worker/index.js.map +1 -0
  299. package/lib/cloudflare/worker/worker.d.ts +66 -0
  300. package/lib/cloudflare/worker/worker.d.ts.map +1 -0
  301. package/lib/cloudflare/worker/worker.handler.d.ts +11 -0
  302. package/lib/cloudflare/worker/worker.handler.d.ts.map +1 -0
  303. package/lib/cloudflare/worker/worker.handler.js +15 -0
  304. package/lib/cloudflare/worker/worker.handler.js.map +1 -0
  305. package/lib/cloudflare/worker/worker.js +4 -0
  306. package/lib/cloudflare/worker/worker.js.map +1 -0
  307. package/lib/cloudflare/worker/worker.provider.d.ts +11 -0
  308. package/lib/cloudflare/worker/worker.provider.d.ts.map +1 -0
  309. package/lib/cloudflare/worker/worker.provider.js +194 -0
  310. package/lib/cloudflare/worker/worker.provider.js.map +1 -0
  311. package/lib/cloudflare/worker/worker.serve.d.ts +39 -0
  312. package/lib/cloudflare/worker/worker.serve.d.ts.map +1 -0
  313. package/lib/cloudflare/worker/worker.serve.js +4 -0
  314. package/lib/cloudflare/worker/worker.serve.js.map +1 -0
  315. package/lib/data.d.ts +3 -0
  316. package/lib/data.d.ts.map +1 -0
  317. package/lib/data.js +8 -0
  318. package/lib/data.js.map +1 -0
  319. package/lib/destroy.d.ts +1 -3
  320. package/lib/destroy.d.ts.map +1 -1
  321. package/lib/destroy.js +2 -0
  322. package/lib/destroy.js.map +1 -1
  323. package/lib/diff.d.ts +16 -0
  324. package/lib/diff.d.ts.map +1 -0
  325. package/lib/diff.js +9 -0
  326. package/lib/diff.js.map +1 -0
  327. package/lib/dot-alchemy.d.ts +3 -2
  328. package/lib/dot-alchemy.d.ts.map +1 -1
  329. package/lib/dot-alchemy.js +3 -2
  330. package/lib/dot-alchemy.js.map +1 -1
  331. package/lib/env.d.ts +5 -0
  332. package/lib/env.d.ts.map +1 -1
  333. package/lib/env.js +15 -29
  334. package/lib/env.js.map +1 -1
  335. package/lib/esbuild.d.ts +28 -0
  336. package/lib/esbuild.d.ts.map +1 -0
  337. package/lib/esbuild.js +63 -0
  338. package/lib/esbuild.js.map +1 -0
  339. package/lib/exports.d.ts +9 -0
  340. package/lib/exports.d.ts.map +1 -0
  341. package/lib/exports.js +13 -0
  342. package/lib/exports.js.map +1 -0
  343. package/lib/index.d.ts +11 -5
  344. package/lib/index.d.ts.map +1 -1
  345. package/lib/index.js +11 -5
  346. package/lib/index.js.map +1 -1
  347. package/lib/input.d.ts +32 -0
  348. package/lib/input.d.ts.map +1 -0
  349. package/lib/input.js +1 -0
  350. package/lib/input.js.map +1 -0
  351. package/lib/output.d.ts +143 -0
  352. package/lib/output.d.ts.map +1 -0
  353. package/lib/output.js +269 -0
  354. package/lib/output.js.map +1 -0
  355. package/lib/plan.d.ts +59 -29
  356. package/lib/plan.d.ts.map +1 -1
  357. package/lib/plan.js +347 -169
  358. package/lib/plan.js.map +1 -1
  359. package/lib/policy.d.ts +22 -5
  360. package/lib/policy.d.ts.map +1 -1
  361. package/lib/policy.js +10 -2
  362. package/lib/policy.js.map +1 -1
  363. package/lib/provider.d.ts +16 -18
  364. package/lib/provider.d.ts.map +1 -1
  365. package/lib/ref.d.ts +14 -0
  366. package/lib/ref.d.ts.map +1 -0
  367. package/lib/ref.js +21 -0
  368. package/lib/ref.js.map +1 -0
  369. package/lib/resource.d.ts +13 -16
  370. package/lib/resource.d.ts.map +1 -1
  371. package/lib/resource.js +1 -0
  372. package/lib/resource.js.map +1 -1
  373. package/lib/runtime.d.ts +8 -7
  374. package/lib/runtime.d.ts.map +1 -1
  375. package/lib/runtime.js.map +1 -1
  376. package/lib/schema.d.ts +37 -0
  377. package/lib/schema.d.ts.map +1 -0
  378. package/lib/schema.js +61 -0
  379. package/lib/schema.js.map +1 -0
  380. package/lib/service.d.ts +9 -6
  381. package/lib/service.d.ts.map +1 -1
  382. package/lib/service.js.map +1 -1
  383. package/lib/sha256.d.ts +5 -0
  384. package/lib/sha256.d.ts.map +1 -0
  385. package/lib/sha256.js +16 -0
  386. package/lib/sha256.js.map +1 -0
  387. package/lib/stack.d.ts +60 -0
  388. package/lib/stack.d.ts.map +1 -0
  389. package/lib/stack.js +11 -0
  390. package/lib/stack.js.map +1 -0
  391. package/lib/stage.d.ts +39 -0
  392. package/lib/stage.d.ts.map +1 -0
  393. package/lib/stage.js +32 -0
  394. package/lib/stage.js.map +1 -0
  395. package/lib/state.d.ts +53 -11
  396. package/lib/state.d.ts.map +1 -1
  397. package/lib/state.js +33 -31
  398. package/lib/state.js.map +1 -1
  399. package/lib/tags.d.ts +17 -0
  400. package/lib/tags.d.ts.map +1 -0
  401. package/lib/tags.js +22 -0
  402. package/lib/tags.js.map +1 -0
  403. package/lib/test.d.ts +35 -0
  404. package/lib/test.d.ts.map +1 -0
  405. package/lib/test.js +68 -0
  406. package/lib/test.js.map +1 -0
  407. package/lib/tsconfig.test.tsbuildinfo +1 -0
  408. package/lib/type.d.ts +6 -0
  409. package/lib/type.d.ts.map +1 -0
  410. package/lib/type.js +3 -0
  411. package/lib/type.js.map +1 -0
  412. package/lib/unknown.d.ts +4 -0
  413. package/lib/unknown.d.ts.map +1 -0
  414. package/lib/unknown.js +4 -0
  415. package/lib/unknown.js.map +1 -0
  416. package/lib/user.d.ts +3 -0
  417. package/lib/user.d.ts.map +1 -0
  418. package/lib/user.js +3 -0
  419. package/lib/user.js.map +1 -0
  420. package/lib/util.d.ts +6 -0
  421. package/lib/util.d.ts.map +1 -0
  422. package/lib/util.js +9 -0
  423. package/lib/util.js.map +1 -0
  424. package/package.json +58 -7
  425. package/src/$.ts +17 -0
  426. package/src/app.ts +9 -37
  427. package/src/apply.ts +435 -289
  428. package/src/assert-never.ts +18 -0
  429. package/src/aws/account.ts +29 -7
  430. package/src/aws/arn.ts +1 -7
  431. package/src/aws/client.ts +14 -1
  432. package/src/aws/config.ts +16 -0
  433. package/src/aws/credentials.ts +213 -177
  434. package/src/aws/dynamodb/attribute-value.ts +240 -0
  435. package/src/aws/{sqs/queue.client.ts → dynamodb/client.ts} +9 -9
  436. package/src/aws/dynamodb/expr.ts +90 -0
  437. package/src/aws/dynamodb/index.ts +12 -0
  438. package/src/aws/dynamodb/projection.ts +159 -0
  439. package/src/aws/dynamodb/secondary-index.ts +45 -0
  440. package/src/aws/dynamodb/table.get-item.ts +173 -0
  441. package/src/aws/dynamodb/table.provider.ts +276 -0
  442. package/src/aws/dynamodb/table.ts +101 -0
  443. package/src/aws/ec2/client.ts +20 -0
  444. package/src/aws/ec2/index.ts +7 -0
  445. package/src/aws/ec2/subnet.provider.ts +358 -0
  446. package/src/aws/ec2/subnet.ts +213 -0
  447. package/src/aws/ec2/vpc.provider.ts +269 -0
  448. package/src/aws/ec2/vpc.ts +163 -0
  449. package/src/aws/index.ts +50 -45
  450. package/src/aws/lambda/client.ts +14 -0
  451. package/src/aws/lambda/consume.ts +8 -8
  452. package/src/aws/lambda/function.handler.ts +1 -1
  453. package/src/aws/lambda/function.invoke.ts +8 -4
  454. package/src/aws/lambda/function.provider.ts +208 -109
  455. package/src/aws/lambda/function.ts +21 -12
  456. package/src/aws/lambda/index.ts +3 -4
  457. package/src/aws/lambda/serve.ts +1 -1
  458. package/src/aws/profile.ts +1 -4
  459. package/src/aws/region.ts +43 -2
  460. package/src/aws/sqs/client.ts +20 -0
  461. package/src/aws/sqs/index.ts +4 -1
  462. package/src/aws/sqs/queue.consume.ts +1 -34
  463. package/src/aws/sqs/queue.event-source.ts +227 -0
  464. package/src/aws/sqs/queue.provider.ts +14 -7
  465. package/src/aws/sqs/queue.send-message.ts +7 -10
  466. package/src/aws/sqs/queue.ts +9 -4
  467. package/src/binding.ts +130 -34
  468. package/src/capability.ts +44 -0
  469. package/src/cli/components/ApprovePlan.tsx +2 -2
  470. package/src/cli/components/Plan.tsx +6 -3
  471. package/src/cli/components/PlanProgress.tsx +32 -14
  472. package/src/cli/index.ts +2 -6
  473. package/src/cli/ink-service.tsx +61 -0
  474. package/src/cli/service.ts +23 -0
  475. package/src/cloudflare/account.ts +37 -0
  476. package/src/cloudflare/api.ts +147 -63
  477. package/src/cloudflare/config.ts +7 -0
  478. package/src/cloudflare/context.ts +49 -0
  479. package/src/cloudflare/index.ts +8 -4
  480. package/src/cloudflare/kv/index.ts +3 -0
  481. package/src/cloudflare/kv/namespace.binding.ts +27 -0
  482. package/src/cloudflare/kv/namespace.client.ts +70 -0
  483. package/src/cloudflare/kv/namespace.provider.ts +100 -0
  484. package/src/cloudflare/kv/namespace.ts +30 -0
  485. package/src/cloudflare/live.ts +32 -0
  486. package/src/cloudflare/r2/bucket.binding.ts +29 -0
  487. package/src/cloudflare/r2/bucket.client.ts +22 -0
  488. package/src/cloudflare/r2/bucket.del.ts +11 -0
  489. package/src/cloudflare/r2/bucket.get.ts +13 -0
  490. package/src/cloudflare/r2/bucket.head.ts +11 -0
  491. package/src/cloudflare/r2/bucket.list.ts +12 -0
  492. package/src/cloudflare/r2/bucket.multipart.ts +55 -0
  493. package/src/cloudflare/r2/bucket.provider.ts +84 -0
  494. package/src/cloudflare/r2/bucket.put.ts +17 -0
  495. package/src/cloudflare/r2/bucket.ts +44 -0
  496. package/src/cloudflare/r2/index.ts +9 -0
  497. package/src/cloudflare/stream.ts +21 -0
  498. package/src/cloudflare/worker/assets.fetch.ts +29 -0
  499. package/src/cloudflare/worker/assets.provider.ts +249 -0
  500. package/src/cloudflare/worker/index.ts +4 -0
  501. package/src/cloudflare/worker/worker.handler.ts +39 -0
  502. package/src/cloudflare/worker/worker.provider.ts +249 -0
  503. package/src/cloudflare/worker/worker.serve.ts +22 -0
  504. package/src/cloudflare/worker/worker.ts +77 -0
  505. package/src/data.ts +18 -0
  506. package/src/destroy.ts +2 -3
  507. package/src/diff.ts +30 -0
  508. package/src/dot-alchemy.ts +3 -2
  509. package/src/env.ts +20 -32
  510. package/src/esbuild.ts +98 -0
  511. package/src/exports.ts +21 -0
  512. package/src/index.ts +12 -6
  513. package/src/input.ts +81 -0
  514. package/src/output.ts +518 -0
  515. package/src/plan.ts +544 -243
  516. package/src/policy.ts +58 -7
  517. package/src/provider.ts +27 -25
  518. package/src/ref.ts +48 -0
  519. package/src/resource.ts +23 -8
  520. package/src/runtime.ts +16 -9
  521. package/src/schema.ts +102 -0
  522. package/src/service.ts +11 -7
  523. package/src/sha256.ts +23 -0
  524. package/src/stack.ts +116 -0
  525. package/src/stage.ts +85 -0
  526. package/src/state.ts +141 -62
  527. package/src/tags.ts +38 -0
  528. package/src/test.ts +172 -0
  529. package/src/type.ts +6 -0
  530. package/src/unknown.ts +6 -0
  531. package/src/user.ts +4 -0
  532. package/src/util.ts +21 -0
  533. package/lib/approve.d.ts +0 -15
  534. package/lib/approve.d.ts.map +0 -1
  535. package/lib/approve.js +0 -7
  536. package/lib/approve.js.map +0 -1
  537. package/lib/aws/lambda/function.client.d.ts +0 -8
  538. package/lib/aws/lambda/function.client.d.ts.map +0 -1
  539. package/lib/aws/lambda/function.client.js +0 -7
  540. package/lib/aws/lambda/function.client.js.map +0 -1
  541. package/lib/aws/sqs/queue.client.d.ts +0 -12
  542. package/lib/aws/sqs/queue.client.d.ts.map +0 -1
  543. package/lib/aws/sqs/queue.client.js.map +0 -1
  544. package/lib/cli/approve.d.ts +0 -4
  545. package/lib/cli/approve.d.ts.map +0 -1
  546. package/lib/cli/approve.js +0 -18
  547. package/lib/cli/approve.js.map +0 -1
  548. package/lib/cli/clack.d.ts +0 -14
  549. package/lib/cli/clack.d.ts.map +0 -1
  550. package/lib/cli/clack.js +0 -12
  551. package/lib/cli/clack.js.map +0 -1
  552. package/lib/cli/main.d.ts +0 -2
  553. package/lib/cli/main.d.ts.map +0 -1
  554. package/lib/cli/main.js +0 -1
  555. package/lib/cli/main.js.map +0 -1
  556. package/lib/cli/plan.d.ts +0 -13
  557. package/lib/cli/plan.d.ts.map +0 -1
  558. package/lib/cli/plan.js +0 -1
  559. package/lib/cli/plan.js.map +0 -1
  560. package/lib/cli/progress.d.ts +0 -7
  561. package/lib/cli/progress.d.ts.map +0 -1
  562. package/lib/cli/progress.js +0 -29
  563. package/lib/cli/progress.js.map +0 -1
  564. package/lib/cli/spinner.d.ts +0 -2
  565. package/lib/cli/spinner.d.ts.map +0 -1
  566. package/lib/cli/spinner.js +0 -13
  567. package/lib/cli/spinner.js.map +0 -1
  568. package/lib/cloudflare/kv.d.ts +0 -29
  569. package/lib/cloudflare/kv.d.ts.map +0 -1
  570. package/lib/cloudflare/kv.js +0 -3
  571. package/lib/cloudflare/kv.js.map +0 -1
  572. package/lib/cloudflare/kv.provider.d.ts +0 -4
  573. package/lib/cloudflare/kv.provider.d.ts.map +0 -1
  574. package/lib/cloudflare/kv.provider.js +0 -39
  575. package/lib/cloudflare/kv.provider.js.map +0 -1
  576. package/lib/cloudflare/worker.d.ts +0 -33
  577. package/lib/cloudflare/worker.d.ts.map +0 -1
  578. package/lib/cloudflare/worker.js +0 -4
  579. package/lib/cloudflare/worker.js.map +0 -1
  580. package/src/approve.ts +0 -13
  581. package/src/aws/lambda/function.client.ts +0 -14
  582. package/src/cli/approve.tsx +0 -30
  583. package/src/cli/clack.ts +0 -22
  584. package/src/cli/main.ts +0 -0
  585. package/src/cli/plan.ts +0 -16
  586. package/src/cli/progress.tsx +0 -45
  587. package/src/cli/spinner.ts +0 -14
  588. package/src/cloudflare/kv.provider.ts +0 -51
  589. package/src/cloudflare/kv.ts +0 -20
  590. package/src/cloudflare/worker.ts +0 -34
package/src/stage.ts ADDED
@@ -0,0 +1,85 @@
1
+ import * as Context from "effect/Context";
2
+ import * as Effect from "effect/Effect";
3
+ import type { StackName, StackRef, Stack, StackResources } from "./stack.ts";
4
+ import { ref } from "./ref.ts";
5
+
6
+ export interface StageConfig {
7
+ /**
8
+ * Whether to retain the stage when destroying the stack.
9
+ *
10
+ * @default - true if the current stage starts with "prod"
11
+ */
12
+ retain?: boolean;
13
+
14
+ /**
15
+ * Whether to adopt resources that already exist during the created phase.
16
+ *
17
+ * @default false
18
+ */
19
+ adopt?: boolean;
20
+ }
21
+
22
+ export class Stage extends Context.Tag("Stage")<Stage, string>() {}
23
+
24
+ export type Stages<Req = never, Err = never> = {
25
+ config: (stage: string) => StageConfig | Effect.Effect<StageConfig, Err, Req>;
26
+ ref<S extends Stack>(name: StackName<S>): StackRefs<S>;
27
+ };
28
+
29
+ export const defineStages = <Req = never, Err = never>(
30
+ config: (stage: string) => StageConfig | Effect.Effect<StageConfig, Err, Req>,
31
+ ): Stages<Req, Err> => ({
32
+ config,
33
+ ref: <S extends Stack>(stack: StackName<NoInfer<S>>): StackRefs<S> => {
34
+ const proxy = (get: (id: string) => any) =>
35
+ new Proxy({}, { get: (_, id: string) => get(id) });
36
+ const proxyStage = (stage: string) =>
37
+ proxy((resourceId: string) =>
38
+ ref({
39
+ stack,
40
+ stage,
41
+ resourceId,
42
+ }),
43
+ );
44
+ return proxy((stage) =>
45
+ stage == "as"
46
+ ? (builders: StackRefBuilders) =>
47
+ proxy((stage: string) => {
48
+ if (stage in builders) {
49
+ const builder = builders[stage as keyof typeof builders];
50
+ return typeof builder === "string"
51
+ ? proxyStage(stage)
52
+ : (...args: any[]) => proxyStage(builder(...args));
53
+ }
54
+ return proxyStage(stage);
55
+ })
56
+ : proxy((resourceId: string) =>
57
+ ref({
58
+ stack,
59
+ stage,
60
+ resourceId,
61
+ }),
62
+ ),
63
+ ) as StackRefs<S>;
64
+ },
65
+ });
66
+
67
+ export interface StackRefBuilders {
68
+ [stage: string]: string | ((...args: any[]) => string);
69
+ }
70
+
71
+ export type StackRefs<S extends Stack> = {
72
+ [stage in string]: StackRef<StackResources<S>>;
73
+ } & {
74
+ as<Builders extends StackRefBuilders>(
75
+ stages?: Builders,
76
+ ): {
77
+ [stage in Exclude<string, keyof Builders>]: StackRef<StackResources<S>>;
78
+ } & {
79
+ [builder in keyof Builders]: Builders[builder] extends string
80
+ ? StackRef<StackResources<S>>
81
+ : Builders[builder] extends (...args: infer Args) => any
82
+ ? (...args: Args) => StackRef<StackResources<S>>
83
+ : never;
84
+ };
85
+ };
package/src/state.ts CHANGED
@@ -1,11 +1,10 @@
1
- import { FileSystem } from "@effect/platform";
2
1
  import type { PlatformError } from "@effect/platform/Error";
2
+ import * as FileSystem from "@effect/platform/FileSystem";
3
+ import * as Path from "@effect/platform/Path";
3
4
  import * as Context from "effect/Context";
4
5
  import * as Data from "effect/Data";
5
6
  import * as Effect from "effect/Effect";
6
7
  import * as Layer from "effect/Layer";
7
- import path from "node:path";
8
- import { App } from "./app.ts";
9
8
  import type { BindNode } from "./plan.ts";
10
9
  import { isResource } from "./resource.ts";
11
10
 
@@ -75,18 +74,29 @@ export class StateStoreError extends Data.TaggedError("StateStoreError")<{
75
74
  }> {}
76
75
 
77
76
  export interface StateService {
78
- listApps(): Effect.Effect<string[], StateStoreError, never>;
79
- listStages(appName?: string): Effect.Effect<string[], StateStoreError, never>;
77
+ listStacks(): Effect.Effect<string[], StateStoreError, never>;
78
+ listStages(stack: string): Effect.Effect<string[], StateStoreError, never>;
80
79
  // stub
81
- get(
82
- id: string,
83
- ): Effect.Effect<ResourceState | undefined, StateStoreError, never>;
84
- set<V extends ResourceState>(
85
- id: string,
86
- value: V,
87
- ): Effect.Effect<V, StateStoreError, never>;
88
- delete(id: string): Effect.Effect<void, StateStoreError, never>;
89
- list(): Effect.Effect<string[], StateStoreError, never>;
80
+ get(request: {
81
+ stack: string;
82
+ stage: string;
83
+ resourceId: string;
84
+ }): Effect.Effect<ResourceState | undefined, StateStoreError, never>;
85
+ set<V extends ResourceState>(request: {
86
+ stack: string;
87
+ stage: string;
88
+ resourceId: string;
89
+ value: V;
90
+ }): Effect.Effect<V, StateStoreError, never>;
91
+ delete(request: {
92
+ stack: string;
93
+ stage: string;
94
+ resourceId: string;
95
+ }): Effect.Effect<void, StateStoreError, never>;
96
+ list(request: {
97
+ stack: string;
98
+ stage: string;
99
+ }): Effect.Effect<string[], StateStoreError, never>;
90
100
  }
91
101
 
92
102
  export class State extends Context.Tag("AWS::Lambda::State")<
@@ -97,13 +107,12 @@ export class State extends Context.Tag("AWS::Lambda::State")<
97
107
  // TODO(sam): implement with SQLite3
98
108
  export const localFs = Layer.effect(
99
109
  State,
110
+ // @ts-expect-error -
100
111
  Effect.gen(function* () {
101
- const app = yield* App;
102
112
  const fs = yield* FileSystem.FileSystem;
113
+ const path = yield* Path.Path;
103
114
  const dotAlchemy = path.join(process.cwd(), ".alchemy");
104
115
  const stateDir = path.join(dotAlchemy, "state");
105
- const appDir = path.join(stateDir, app.name);
106
- const stageDir = path.join(appDir, app.stage);
107
116
 
108
117
  const fail = (err: PlatformError) =>
109
118
  Effect.fail(
@@ -120,9 +129,22 @@ export const localFs = Layer.effect(
120
129
  Effect.catchTag("BadArgument", (e) => fail(e)),
121
130
  );
122
131
 
123
- const resourceFile = (id: string) => path.join(stageDir, `${id}.json`);
132
+ const stage = ({ stack, stage }: { stack: string; stage: string }) =>
133
+ path.join(stateDir, stack, stage);
124
134
 
125
- yield* fs.makeDirectory(stageDir, { recursive: true });
135
+ const resource = ({
136
+ stack,
137
+ stage,
138
+ resourceId,
139
+ }: {
140
+ stack: string;
141
+ stage: string;
142
+ resourceId: string;
143
+ }) => path.join(stateDir, stack, stage, `${resourceId}.json`);
144
+
145
+ const ensure = yield* Effect.cachedFunction((dir: string) =>
146
+ fs.makeDirectory(dir, { recursive: true }),
147
+ );
126
148
 
127
149
  return {
128
150
  listApps: () =>
@@ -130,43 +152,44 @@ export const localFs = Layer.effect(
130
152
  recover,
131
153
  Effect.map((files) => files ?? []),
132
154
  ),
133
- listStages: (appName: string = app.name) =>
134
- fs.readDirectory(path.join(stateDir, appName)).pipe(
155
+ listStages: (stack: string) =>
156
+ fs.readDirectory(path.join(stateDir, stack)).pipe(
135
157
  recover,
136
158
  Effect.map((files) => files ?? []),
137
159
  ),
138
- get: (id) =>
139
- fs.readFile(resourceFile(id)).pipe(
160
+ get: (request) =>
161
+ fs.readFile(resource(request)).pipe(
140
162
  Effect.map((file) => JSON.parse(file.toString())),
141
163
  recover,
142
164
  ),
143
- set: <V extends ResourceState>(id: string, value: V) =>
144
- fs
145
- .writeFileString(
146
- resourceFile(id),
147
- JSON.stringify(
148
- value,
149
- (k, v) => {
150
- if (isResource(v)) {
151
- return {
152
- id: v.id,
153
- type: v.type,
154
- props: v.props,
155
- attr: v.attr,
156
- };
157
- }
158
- return v;
159
- },
160
- 2,
165
+ set: (request) =>
166
+ ensure(stage(request)).pipe(
167
+ Effect.flatMap(() =>
168
+ fs.writeFileString(
169
+ resource(request),
170
+ JSON.stringify(
171
+ request.value,
172
+ (k, v) => {
173
+ if (isResource(v)) {
174
+ return {
175
+ id: v.id,
176
+ type: v.type,
177
+ props: v.props,
178
+ attr: v.attr,
179
+ };
180
+ }
181
+ return v;
182
+ },
183
+ 2,
184
+ ),
161
185
  ),
162
- )
163
- .pipe(
164
- recover,
165
- Effect.map(() => value),
166
186
  ),
167
- delete: (id) => fs.remove(resourceFile(id)).pipe(recover),
168
- list: () =>
169
- fs.readDirectory(stageDir).pipe(
187
+ recover,
188
+ Effect.map(() => request.value),
189
+ ),
190
+ delete: (request) => fs.remove(resource(request)).pipe(recover),
191
+ list: (request) =>
192
+ fs.readDirectory(stage(request)).pipe(
170
193
  recover,
171
194
  Effect.map(
172
195
  (files) => files?.map((file) => file.replace(/\.json$/, "")) ?? [],
@@ -176,21 +199,77 @@ export const localFs = Layer.effect(
176
199
  }),
177
200
  );
178
201
 
179
- export const inMemory = () => {
180
- const state = new Map<string, any>();
181
- return Layer.succeed(State, {
182
- listApps: () => Effect.succeed([]),
202
+ type StackId = string;
203
+ type StageId = string;
204
+ type ResourceId = string;
205
+
206
+ export const inMemory = (
207
+ initialState: Record<
208
+ StackId,
209
+ Record<StageId, Record<ResourceId, ResourceState>>
210
+ > = {},
211
+ ) =>
212
+ Layer.succeed(State, inMemoryService(initialState)) as Layer.Layer<
213
+ State,
214
+ never,
215
+ never
216
+ >;
217
+
218
+ export const inMemoryService = (
219
+ initialState: Record<
220
+ StackId,
221
+ Record<StageId, Record<ResourceId, ResourceState>>
222
+ > = {},
223
+ ) => {
224
+ const state = new Map<StackId, Map<StageId, Map<ResourceId, ResourceState>>>(
225
+ Object.entries(initialState).map(([stack, stages]) => [
226
+ stack,
227
+ new Map(
228
+ Object.entries(stages).map(([stage, resources]) => [
229
+ stage,
230
+ new Map(Object.entries(resources)),
231
+ ]),
232
+ ),
233
+ ]),
234
+ );
235
+ return {
236
+ listStacks: () => Effect.succeed(Array.from(state.keys())),
183
237
  // oxlint-disable-next-line require-yield
184
- listStages: (_appName?: string) => Effect.succeed([]),
185
- get: (id: string) => Effect.succeed(state.get(id)),
186
- set: <V>(id: string, value: V) => {
187
- state.set(id, value);
238
+ listStages: (stack: string) =>
239
+ Effect.succeed(Array.from(state.get(stack)?.keys() ?? [])),
240
+ get: ({
241
+ stack,
242
+ stage,
243
+ resourceId,
244
+ }: {
245
+ stack: string;
246
+ stage: string;
247
+ resourceId: string;
248
+ }) => Effect.succeed(state.get(stack)?.get(stage)?.get(resourceId)),
249
+ set: <V extends ResourceState>({
250
+ stack,
251
+ stage,
252
+ resourceId,
253
+ value,
254
+ }: {
255
+ stack: string;
256
+ stage: string;
257
+ resourceId: string;
258
+ value: V;
259
+ }) => {
260
+ state.get(stack)?.get(stage)?.set(resourceId, value);
188
261
  return Effect.succeed(value);
189
262
  },
190
- delete: (id: string) => {
191
- state.delete(id);
192
- return Effect.succeed(undefined);
193
- },
194
- list: () => Effect.succeed(Array.from(state.keys())),
195
- });
263
+ delete: ({
264
+ stack,
265
+ stage,
266
+ resourceId,
267
+ }: {
268
+ stack: string;
269
+ stage: string;
270
+ resourceId: string;
271
+ }) => Effect.succeed(state.get(stack)?.get(stage)?.delete(resourceId)),
272
+ list: ({ stack, stage }: { stack: string; stage: string }) =>
273
+ Effect.succeed(Array.from(state.get(stack)?.get(stage)?.keys() ?? [])),
274
+ };
196
275
  };
package/src/tags.ts ADDED
@@ -0,0 +1,38 @@
1
+ import * as Effect from "effect/Effect";
2
+ import { App } from "./app.ts";
3
+
4
+ export type Tags =
5
+ | Record<string, string>
6
+ | [string, string][]
7
+ | { Key: string; Value: string }[];
8
+
9
+ const normalizeTags = (tags: Tags) =>
10
+ Array.isArray(tags)
11
+ ? Object.fromEntries(
12
+ tags.map((tag) =>
13
+ Array.isArray(tag) ? [tag[0], tag[1]] : [tag.Key, tag.Value],
14
+ ),
15
+ )
16
+ : tags;
17
+
18
+ export const hasTags = (expectedTags: Tags, tags: Tags | undefined) => {
19
+ const actualTags = normalizeTags(tags ?? []);
20
+ return Object.entries(normalizeTags(expectedTags)).every(
21
+ ([key, value]) => actualTags[key] === value,
22
+ );
23
+ };
24
+
25
+ export const createTagsList = (tags: Tags) =>
26
+ Object.entries(normalizeTags(tags)).map(([Key, Value]) => ({
27
+ Key,
28
+ Value,
29
+ }));
30
+
31
+ export const createTagger = Effect.fn(function* () {
32
+ const app = yield* App;
33
+ return (id: string) => ({
34
+ "alchemy::app": app.name,
35
+ "alchemy::stage": app.stage,
36
+ "alchemy::id": id,
37
+ });
38
+ });
package/src/test.ts ADDED
@@ -0,0 +1,172 @@
1
+ import { FetchHttpClient, FileSystem, HttpClient } from "@effect/platform";
2
+ import * as PlatformConfigProvider from "@effect/platform/PlatformConfigProvider";
3
+ import { NodeContext } from "@effect/platform-node";
4
+ import * as Path from "@effect/platform/Path";
5
+ import { it, expect } from "@effect/vitest";
6
+ import { ConfigProvider, LogLevel } from "effect";
7
+ import * as Effect from "effect/Effect";
8
+ import * as Layer from "effect/Layer";
9
+ import * as Logger from "effect/Logger";
10
+ import * as Scope from "effect/Scope";
11
+ import * as App from "./app.ts";
12
+ import { DotAlchemy, dotAlchemy } from "./dot-alchemy.ts";
13
+ import * as State from "./state.ts";
14
+ import type { Resource } from "./resource.ts";
15
+ import { CLI } from "./cli/service.ts";
16
+
17
+ declare module "@effect/vitest" {
18
+ interface ExpectStatic {
19
+ emptyObject(): any;
20
+ propExpr(identifier: string, src: Resource): any;
21
+ }
22
+ }
23
+
24
+ expect.emptyObject = () =>
25
+ expect.toSatisfy(
26
+ (deletions) => Object.keys(deletions).length === 0,
27
+ "empty object",
28
+ );
29
+
30
+ expect.propExpr = (identifier: string, src: Resource) =>
31
+ expect.objectContaining({
32
+ kind: "PropExpr",
33
+ identifier,
34
+ expr: expect.objectContaining({
35
+ kind: "ResourceExpr",
36
+ src,
37
+ }),
38
+ });
39
+
40
+ type Provided =
41
+ | Scope.Scope
42
+ | App.App
43
+ | State.State
44
+ | DotAlchemy
45
+ | HttpClient.HttpClient
46
+ | FileSystem.FileSystem
47
+ | Path.Path;
48
+
49
+ export function test(
50
+ name: string,
51
+ options: {
52
+ timeout?: number;
53
+ state?: Layer.Layer<State.State, never, App.App>;
54
+ },
55
+ testCase: Effect.Effect<void, any, Provided>,
56
+ ): void;
57
+
58
+ export function test(
59
+ name: string,
60
+ testCase: Effect.Effect<void, any, Provided>,
61
+ ): void;
62
+
63
+ export function test(
64
+ name: string,
65
+ ...args:
66
+ | [
67
+ {
68
+ timeout?: number;
69
+ state?: Layer.Layer<State.State, never, App.App>;
70
+ },
71
+ Effect.Effect<void, any, Provided>,
72
+ ]
73
+ | [Effect.Effect<void, any, Provided>]
74
+ ) {
75
+ const [options = {}, testCase] =
76
+ args.length === 1 ? [undefined, args[0]] : args;
77
+ const platform = Layer.mergeAll(
78
+ NodeContext.layer,
79
+ FetchHttpClient.layer,
80
+ Logger.pretty,
81
+ );
82
+
83
+ const alchemy = Layer.provideMerge(
84
+ Layer.mergeAll(options.state ?? State.localFs, testCLI),
85
+ Layer.mergeAll(
86
+ App.make({
87
+ name: name.replaceAll(/[^a-zA-Z0-9_]/g, "-"),
88
+ stage: "test",
89
+ config: {
90
+ adopt: true,
91
+ aws: {
92
+ profile: "default",
93
+ },
94
+ },
95
+ }),
96
+ dotAlchemy,
97
+ ),
98
+ );
99
+
100
+ return it.scopedLive(
101
+ name,
102
+ () =>
103
+ Effect.gen(function* () {
104
+ const configProvider = ConfigProvider.orElse(
105
+ yield* PlatformConfigProvider.fromDotEnv(".env"),
106
+ ConfigProvider.fromEnv,
107
+ );
108
+ return yield* testCase.pipe(Effect.withConfigProvider(configProvider));
109
+ }).pipe(
110
+ Effect.provide(Layer.provideMerge(alchemy, platform)),
111
+ Logger.withMinimumLogLevel(
112
+ process.env.DEBUG ? LogLevel.Debug : LogLevel.Info,
113
+ ),
114
+ Effect.provide(NodeContext.layer),
115
+ Effect.provide(NodeContext.layer),
116
+ ),
117
+ options.timeout,
118
+ );
119
+ }
120
+
121
+ export namespace test {
122
+ export const state = (resources: Record<string, State.ResourceState> = {}) =>
123
+ Layer.effect(
124
+ State.State,
125
+ Effect.gen(function* () {
126
+ const app = yield* App.App;
127
+ return State.inMemoryService({
128
+ [app.name]: {
129
+ [app.stage]: resources,
130
+ },
131
+ });
132
+ }),
133
+ );
134
+
135
+ export const defaultState = (
136
+ resources: Record<string, State.ResourceState> = {},
137
+ other?: {
138
+ [stack: string]: {
139
+ [stage: string]: {
140
+ [resourceId: string]: State.ResourceState;
141
+ };
142
+ };
143
+ },
144
+ ) =>
145
+ Layer.succeed(
146
+ State.State,
147
+ State.inMemoryService({
148
+ ["test-app"]: {
149
+ ["test-stage"]: resources,
150
+ },
151
+ ...other,
152
+ }),
153
+ );
154
+ }
155
+
156
+ export const testCLI = Layer.succeed(
157
+ CLI,
158
+ CLI.of({
159
+ approvePlan: () => Effect.succeed(true),
160
+ displayPlan: () => Effect.void,
161
+ startApplySession: () =>
162
+ Effect.succeed({
163
+ done: () => Effect.void,
164
+ emit: (event) =>
165
+ Effect.log(
166
+ event.kind === "status-change"
167
+ ? `${event.status} ${event.id}(${event.type})`
168
+ : event.message,
169
+ ),
170
+ }),
171
+ }),
172
+ );
package/src/type.ts ADDED
@@ -0,0 +1,6 @@
1
+ export type type<T> = new () => T;
2
+ export const type = class {} as new <T>() => T;
3
+
4
+ export declare namespace type {
5
+ export type of<T extends type<any>> = InstanceType<T>;
6
+ }
package/src/unknown.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { type Output, isOutput } from "./output.ts";
2
+ import type { Input } from "./input.ts";
3
+
4
+ // @ts-expect-error - we want to allow any value to be checked for unknown
5
+ export const isUnknown = <V>(value: V): value is Output<Input.Resolve<V>> =>
6
+ isOutput(value);
package/src/user.ts ADDED
@@ -0,0 +1,4 @@
1
+ import { env } from "./env.ts";
2
+
3
+ export type USER = typeof USER;
4
+ export const USER = env.USER ?? env.USERNAME ?? "unknown";
package/src/util.ts ADDED
@@ -0,0 +1,21 @@
1
+ import * as Effect from "effect/Effect";
2
+
3
+ export type IsAny<T> = 0 extends 1 & T ? true : false;
4
+
5
+ export type UnionToIntersection<U> = (
6
+ U extends any ? (k: U) => void : never
7
+ ) extends (k: infer I) => void
8
+ ? I
9
+ : never;
10
+
11
+ export const assertDefined = <T>(value: T | undefined, message: string): T => {
12
+ if (!value) {
13
+ throw new Error(message);
14
+ }
15
+ return value;
16
+ };
17
+
18
+ export const asEffect = <T, Err = never, Req = never>(
19
+ effect: T | Effect.Effect<T, Err, Req>,
20
+ ): Effect.Effect<T, Err, Req> =>
21
+ Effect.isEffect(effect) ? effect : Effect.succeed(effect);
package/lib/approve.d.ts DELETED
@@ -1,15 +0,0 @@
1
- import * as Context from "effect/Context";
2
- import type * as Effect from "effect/Effect";
3
- import type { Plan } from "./plan.ts";
4
- declare const PlanRejected_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
5
- readonly _tag: "PlanRejected";
6
- } & Readonly<A>;
7
- export declare class PlanRejected extends PlanRejected_base<{}> {
8
- }
9
- declare const PlanReviewer_base: Context.TagClass<PlanReviewer, "PlanReviewer", {
10
- approve: <P extends Plan>(plan: P) => Effect.Effect<void, PlanRejected>;
11
- }>;
12
- export declare class PlanReviewer extends PlanReviewer_base {
13
- }
14
- export {};
15
- //# sourceMappingURL=approve.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"approve.d.ts","sourceRoot":"","sources":["../src/approve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAE1C,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;;;;AAEtC,qBAAa,YAAa,SAAQ,kBAAiC,EAAE,CAAC;CAAG;;aAK5D,CAAC,CAAC,SAAS,IAAI,EAAE,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC;;AAH3E,qBAAa,YAAa,SAAQ,iBAK/B;CAAG"}
package/lib/approve.js DELETED
@@ -1,7 +0,0 @@
1
- import * as Context from "effect/Context";
2
- import * as Data from "effect/Data";
3
- export class PlanRejected extends Data.TaggedError("PlanRejected") {
4
- }
5
- export class PlanReviewer extends Context.Tag("PlanReviewer")() {
6
- }
7
- //# sourceMappingURL=approve.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"approve.js","sourceRoot":"","sources":["../src/approve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AAIpC,MAAM,OAAO,YAAa,SAAQ,IAAI,CAAC,WAAW,CAAC,cAAc,CAAK;CAAG;AAEzE,MAAM,OAAO,YAAa,SAAQ,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,EAK1D;CAAG"}
@@ -1,8 +0,0 @@
1
- import * as Context from "effect/Context";
2
- import { Lambda as LambdaClient } from "itty-aws/lambda";
3
- declare const FunctionClient_base: Context.TagClass<FunctionClient, "AWS::Lambda::Function.Client", LambdaClient>;
4
- export declare class FunctionClient extends FunctionClient_base {
5
- }
6
- export declare const client: () => import("effect/Layer").Layer<FunctionClient, never, import("../credentials.ts").Credentials | import("../region.ts").Region>;
7
- export {};
8
- //# sourceMappingURL=function.client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"function.client.d.ts","sourceRoot":"","sources":["../../../src/aws/lambda/function.client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,iBAAiB,CAAC;;AAGzD,qBAAa,cAAe,SAAQ,mBAGjC;CAAG;AAEN,eAAO,MAAM,MAAM,oIAGY,CAAC"}
@@ -1,7 +0,0 @@
1
- import * as Context from "effect/Context";
2
- import { Lambda as LambdaClient } from "itty-aws/lambda";
3
- import { createAWSServiceClientLayer } from "../client.js";
4
- export class FunctionClient extends Context.Tag("AWS::Lambda::Function.Client")() {
5
- }
6
- export const client = createAWSServiceClientLayer(FunctionClient, LambdaClient);
7
- //# sourceMappingURL=function.client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"function.client.js","sourceRoot":"","sources":["../../../src/aws/lambda/function.client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAE3D,MAAM,OAAO,cAAe,SAAQ,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,EAG5E;CAAG;AAEN,MAAM,CAAC,MAAM,MAAM,GAAG,2BAA2B,CAG/C,cAAc,EAAE,YAAY,CAAC,CAAC"}
@@ -1,12 +0,0 @@
1
- import * as Context from "effect/Context";
2
- import * as Layer from "effect/Layer";
3
- import { SQS as SQSClient } from "itty-aws/sqs";
4
- import * as Credentials from "../credentials.ts";
5
- import * as Region from "../region.ts";
6
- declare const QueueClient_base: Context.TagClass<QueueClient, "AWS::SQS::Queue.Client", SQSClient>;
7
- export declare class QueueClient extends QueueClient_base {
8
- }
9
- export declare const client: () => Layer.Layer<QueueClient, never, Credentials.Credentials | Region.Region>;
10
- export declare const clientFromEnv: () => Layer.Layer<QueueClient, Region.EnvironmentVariableNotSet, never>;
11
- export {};
12
- //# sourceMappingURL=queue.client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"queue.client.d.ts","sourceRoot":"","sources":["../../../src/aws/sqs/queue.client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,GAAG,IAAI,SAAS,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,KAAK,WAAW,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,MAAM,MAAM,cAAc,CAAC;;AAEvC,qBAAa,WAAY,SAAQ,gBAG9B;CAAG;AAEN,eAAO,MAAM,MAAM,gFAGM,CAAC;AAE1B,eAAO,MAAM,aAAa,yEACqD,CAAC"}