alchemy-effect 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (428) hide show
  1. package/bin/alchemy-effect.js +55038 -8
  2. package/bin/alchemy-effect.js.map +1 -1
  3. package/bin/alchemy-effect.ts +266 -10
  4. package/lib/$.d.ts +5 -0
  5. package/lib/$.d.ts.map +1 -0
  6. package/lib/$.js +9 -0
  7. package/lib/$.js.map +1 -0
  8. package/lib/app.d.ts +4 -17
  9. package/lib/app.d.ts.map +1 -1
  10. package/lib/app.js +0 -20
  11. package/lib/app.js.map +1 -1
  12. package/lib/apply.d.ts +14 -74
  13. package/lib/apply.d.ts.map +1 -1
  14. package/lib/apply.js +62 -57
  15. package/lib/apply.js.map +1 -1
  16. package/lib/assert-never.d.ts +12 -0
  17. package/lib/assert-never.d.ts.map +1 -0
  18. package/lib/assert-never.js +11 -0
  19. package/lib/assert-never.js.map +1 -0
  20. package/lib/aws/account.d.ts +10 -1
  21. package/lib/aws/account.d.ts.map +1 -1
  22. package/lib/aws/account.js +18 -3
  23. package/lib/aws/account.js.map +1 -1
  24. package/lib/aws/client.d.ts.map +1 -1
  25. package/lib/aws/client.js +0 -1
  26. package/lib/aws/client.js.map +1 -1
  27. package/lib/aws/config.d.ts +15 -0
  28. package/lib/aws/config.d.ts.map +1 -0
  29. package/lib/aws/config.js +1 -0
  30. package/lib/aws/config.js.map +1 -0
  31. package/lib/aws/credentials.d.ts +10 -0
  32. package/lib/aws/credentials.d.ts.map +1 -1
  33. package/lib/aws/credentials.js +73 -47
  34. package/lib/aws/credentials.js.map +1 -1
  35. package/lib/aws/dynamodb/client.d.ts +1 -1
  36. package/lib/aws/dynamodb/client.d.ts.map +1 -1
  37. package/lib/aws/dynamodb/index.d.ts +2 -1
  38. package/lib/aws/dynamodb/index.d.ts.map +1 -1
  39. package/lib/aws/dynamodb/index.js +1 -2
  40. package/lib/aws/dynamodb/index.js.map +1 -1
  41. package/lib/aws/dynamodb/secondary-index.d.ts +5 -4
  42. package/lib/aws/dynamodb/secondary-index.d.ts.map +1 -1
  43. package/lib/aws/dynamodb/table.d.ts +23 -20
  44. package/lib/aws/dynamodb/table.d.ts.map +1 -1
  45. package/lib/aws/dynamodb/table.get-item.d.ts +8 -6
  46. package/lib/aws/dynamodb/table.get-item.d.ts.map +1 -1
  47. package/lib/aws/dynamodb/table.get-item.js +4 -2
  48. package/lib/aws/dynamodb/table.get-item.js.map +1 -1
  49. package/lib/aws/dynamodb/table.js.map +1 -1
  50. package/lib/aws/dynamodb/table.provider.d.ts +3 -4
  51. package/lib/aws/dynamodb/table.provider.d.ts.map +1 -1
  52. package/lib/aws/dynamodb/table.provider.js +17 -29
  53. package/lib/aws/dynamodb/table.provider.js.map +1 -1
  54. package/lib/aws/ec2/client.d.ts +1 -1
  55. package/lib/aws/ec2/client.d.ts.map +1 -1
  56. package/lib/aws/ec2/index.d.ts +3 -0
  57. package/lib/aws/ec2/index.d.ts.map +1 -1
  58. package/lib/aws/ec2/index.js +3 -0
  59. package/lib/aws/ec2/index.js.map +1 -1
  60. package/lib/aws/ec2/subnet.d.ts +175 -0
  61. package/lib/aws/ec2/subnet.d.ts.map +1 -0
  62. package/lib/aws/ec2/subnet.js +4 -0
  63. package/lib/aws/ec2/subnet.js.map +1 -0
  64. package/lib/aws/ec2/subnet.provider.d.ts +4 -0
  65. package/lib/aws/ec2/subnet.provider.d.ts.map +1 -0
  66. package/lib/aws/ec2/subnet.provider.js +250 -0
  67. package/lib/aws/ec2/subnet.provider.js.map +1 -0
  68. package/lib/aws/ec2/vpc.d.ts +12 -8
  69. package/lib/aws/ec2/vpc.d.ts.map +1 -1
  70. package/lib/aws/ec2/vpc.js +1 -0
  71. package/lib/aws/ec2/vpc.js.map +1 -1
  72. package/lib/aws/ec2/vpc.provider.d.ts +3 -4
  73. package/lib/aws/ec2/vpc.provider.d.ts.map +1 -1
  74. package/lib/aws/ec2/vpc.provider.js +11 -26
  75. package/lib/aws/ec2/vpc.provider.js.map +1 -1
  76. package/lib/aws/index.d.ts +16 -19
  77. package/lib/aws/index.d.ts.map +1 -1
  78. package/lib/aws/index.js +7 -10
  79. package/lib/aws/index.js.map +1 -1
  80. package/lib/aws/lambda/consume.d.ts +10 -11
  81. package/lib/aws/lambda/consume.d.ts.map +1 -1
  82. package/lib/aws/lambda/consume.js +3 -3
  83. package/lib/aws/lambda/consume.js.map +1 -1
  84. package/lib/aws/lambda/function.d.ts +7 -7
  85. package/lib/aws/lambda/function.d.ts.map +1 -1
  86. package/lib/aws/lambda/function.handler.d.ts +1 -1
  87. package/lib/aws/lambda/function.handler.d.ts.map +1 -1
  88. package/lib/aws/lambda/function.handler.js.map +1 -1
  89. package/lib/aws/lambda/function.invoke.d.ts +6 -4
  90. package/lib/aws/lambda/function.invoke.d.ts.map +1 -1
  91. package/lib/aws/lambda/function.invoke.js +3 -1
  92. package/lib/aws/lambda/function.invoke.js.map +1 -1
  93. package/lib/aws/lambda/function.js +1 -1
  94. package/lib/aws/lambda/function.js.map +1 -1
  95. package/lib/aws/lambda/function.provider.d.ts +5 -4
  96. package/lib/aws/lambda/function.provider.d.ts.map +1 -1
  97. package/lib/aws/lambda/function.provider.js +16 -14
  98. package/lib/aws/lambda/function.provider.js.map +1 -1
  99. package/lib/aws/lambda/index.d.ts +1 -0
  100. package/lib/aws/lambda/index.d.ts.map +1 -1
  101. package/lib/aws/lambda/index.js +1 -0
  102. package/lib/aws/lambda/index.js.map +1 -1
  103. package/lib/aws/lambda/serve.d.ts +2 -4
  104. package/lib/aws/lambda/serve.d.ts.map +1 -1
  105. package/lib/aws/profile.d.ts +2 -2
  106. package/lib/aws/profile.d.ts.map +1 -1
  107. package/lib/aws/profile.js +1 -1
  108. package/lib/aws/profile.js.map +1 -1
  109. package/lib/aws/region.d.ts +14 -2
  110. package/lib/aws/region.d.ts.map +1 -1
  111. package/lib/aws/region.js +26 -1
  112. package/lib/aws/region.js.map +1 -1
  113. package/lib/aws/sqs/client.d.ts +1 -1
  114. package/lib/aws/sqs/client.d.ts.map +1 -1
  115. package/lib/aws/sqs/index.d.ts +1 -0
  116. package/lib/aws/sqs/index.d.ts.map +1 -1
  117. package/lib/aws/sqs/index.js +1 -0
  118. package/lib/aws/sqs/index.js.map +1 -1
  119. package/lib/aws/sqs/queue.consume.d.ts +1 -1
  120. package/lib/aws/sqs/queue.consume.d.ts.map +1 -1
  121. package/lib/aws/sqs/queue.consume.js +0 -1
  122. package/lib/aws/sqs/queue.consume.js.map +1 -1
  123. package/lib/aws/sqs/queue.d.ts +6 -4
  124. package/lib/aws/sqs/queue.d.ts.map +1 -1
  125. package/lib/aws/sqs/queue.event-source.d.ts +8 -6
  126. package/lib/aws/sqs/queue.event-source.d.ts.map +1 -1
  127. package/lib/aws/sqs/queue.event-source.js +26 -44
  128. package/lib/aws/sqs/queue.event-source.js.map +1 -1
  129. package/lib/aws/sqs/queue.js +1 -1
  130. package/lib/aws/sqs/queue.js.map +1 -1
  131. package/lib/aws/sqs/queue.provider.d.ts +4 -4
  132. package/lib/aws/sqs/queue.provider.d.ts.map +1 -1
  133. package/lib/aws/sqs/queue.provider.js +3 -3
  134. package/lib/aws/sqs/queue.provider.js.map +1 -1
  135. package/lib/aws/sqs/queue.send-message.d.ts +7 -5
  136. package/lib/aws/sqs/queue.send-message.d.ts.map +1 -1
  137. package/lib/aws/sqs/queue.send-message.js +4 -2
  138. package/lib/aws/sqs/queue.send-message.js.map +1 -1
  139. package/lib/binding.d.ts +12 -12
  140. package/lib/binding.d.ts.map +1 -1
  141. package/lib/binding.js.map +1 -1
  142. package/lib/cli/components/ApprovePlan.d.ts +2 -2
  143. package/lib/cli/components/ApprovePlan.d.ts.map +1 -1
  144. package/lib/cli/components/ApprovePlan.js.map +1 -1
  145. package/lib/cli/components/Plan.d.ts +2 -2
  146. package/lib/cli/components/Plan.d.ts.map +1 -1
  147. package/lib/cli/components/Plan.js.map +1 -1
  148. package/lib/cli/components/PlanProgress.d.ts +8 -4
  149. package/lib/cli/components/PlanProgress.d.ts.map +1 -1
  150. package/lib/cli/components/PlanProgress.js +11 -1
  151. package/lib/cli/components/PlanProgress.js.map +1 -1
  152. package/lib/cli/index.d.ts +265 -224
  153. package/lib/cli/index.d.ts.map +1 -1
  154. package/lib/cli/index.js +57 -65
  155. package/lib/cli/index.js.map +1 -1
  156. package/lib/cli/ink-service.d.ts +4 -0
  157. package/lib/cli/ink-service.d.ts.map +1 -0
  158. package/lib/cli/ink-service.js +43 -0
  159. package/lib/cli/ink-service.js.map +1 -0
  160. package/lib/cli/service.d.ts +21 -0
  161. package/lib/cli/service.d.ts.map +1 -0
  162. package/lib/cli/service.js +5 -0
  163. package/lib/cli/service.js.map +1 -0
  164. package/lib/cloudflare/account.d.ts +10 -0
  165. package/lib/cloudflare/account.d.ts.map +1 -0
  166. package/lib/cloudflare/account.js +24 -0
  167. package/lib/cloudflare/account.js.map +1 -0
  168. package/lib/cloudflare/api.d.ts +7 -7
  169. package/lib/cloudflare/api.d.ts.map +1 -1
  170. package/lib/cloudflare/api.js +18 -17
  171. package/lib/cloudflare/api.js.map +1 -1
  172. package/lib/cloudflare/config.d.ts +9 -0
  173. package/lib/cloudflare/config.d.ts.map +1 -0
  174. package/lib/cloudflare/config.js +1 -0
  175. package/lib/cloudflare/config.js.map +1 -0
  176. package/lib/cloudflare/index.d.ts +3 -1
  177. package/lib/cloudflare/index.d.ts.map +1 -1
  178. package/lib/cloudflare/index.js +3 -0
  179. package/lib/cloudflare/index.js.map +1 -1
  180. package/lib/cloudflare/kv/namespace.binding.d.ts +5 -3
  181. package/lib/cloudflare/kv/namespace.binding.d.ts.map +1 -1
  182. package/lib/cloudflare/kv/namespace.binding.js +1 -1
  183. package/lib/cloudflare/kv/namespace.binding.js.map +1 -1
  184. package/lib/cloudflare/kv/namespace.d.ts +3 -2
  185. package/lib/cloudflare/kv/namespace.d.ts.map +1 -1
  186. package/lib/cloudflare/kv/namespace.js.map +1 -1
  187. package/lib/cloudflare/kv/namespace.provider.d.ts +3 -2
  188. package/lib/cloudflare/kv/namespace.provider.d.ts.map +1 -1
  189. package/lib/cloudflare/kv/namespace.provider.js +8 -7
  190. package/lib/cloudflare/kv/namespace.provider.js.map +1 -1
  191. package/lib/cloudflare/live.d.ts +5 -5
  192. package/lib/cloudflare/live.d.ts.map +1 -1
  193. package/lib/cloudflare/live.js +5 -8
  194. package/lib/cloudflare/live.js.map +1 -1
  195. package/lib/cloudflare/r2/bucket.binding.d.ts +5 -3
  196. package/lib/cloudflare/r2/bucket.binding.d.ts.map +1 -1
  197. package/lib/cloudflare/r2/bucket.binding.js +1 -1
  198. package/lib/cloudflare/r2/bucket.binding.js.map +1 -1
  199. package/lib/cloudflare/r2/bucket.d.ts +3 -2
  200. package/lib/cloudflare/r2/bucket.d.ts.map +1 -1
  201. package/lib/cloudflare/r2/bucket.js.map +1 -1
  202. package/lib/cloudflare/r2/bucket.provider.d.ts +3 -2
  203. package/lib/cloudflare/r2/bucket.provider.d.ts.map +1 -1
  204. package/lib/cloudflare/r2/bucket.provider.js +8 -7
  205. package/lib/cloudflare/r2/bucket.provider.js.map +1 -1
  206. package/lib/cloudflare/worker/assets.fetch.d.ts +3 -2
  207. package/lib/cloudflare/worker/assets.fetch.d.ts.map +1 -1
  208. package/lib/cloudflare/worker/assets.fetch.js +2 -1
  209. package/lib/cloudflare/worker/assets.fetch.js.map +1 -1
  210. package/lib/cloudflare/worker/assets.provider.d.ts +1 -1
  211. package/lib/cloudflare/worker/assets.provider.d.ts.map +1 -1
  212. package/lib/cloudflare/worker/index.d.ts +0 -1
  213. package/lib/cloudflare/worker/index.d.ts.map +1 -1
  214. package/lib/cloudflare/worker/worker.d.ts +5 -6
  215. package/lib/cloudflare/worker/worker.d.ts.map +1 -1
  216. package/lib/cloudflare/worker/worker.handler.d.ts +1 -1
  217. package/lib/cloudflare/worker/worker.handler.d.ts.map +1 -1
  218. package/lib/cloudflare/worker/worker.handler.js.map +1 -1
  219. package/lib/cloudflare/worker/worker.js.map +1 -1
  220. package/lib/cloudflare/worker/worker.provider.d.ts +3 -2
  221. package/lib/cloudflare/worker/worker.provider.d.ts.map +1 -1
  222. package/lib/cloudflare/worker/worker.provider.js +7 -6
  223. package/lib/cloudflare/worker/worker.provider.js.map +1 -1
  224. package/lib/cloudflare/worker/worker.serve.d.ts +7 -7
  225. package/lib/cloudflare/worker/worker.serve.d.ts.map +1 -1
  226. package/lib/cloudflare/worker/worker.serve.js.map +1 -1
  227. package/lib/data.d.ts +3 -0
  228. package/lib/data.d.ts.map +1 -0
  229. package/lib/data.js +8 -0
  230. package/lib/data.js.map +1 -0
  231. package/lib/destroy.d.ts +1 -1
  232. package/lib/destroy.d.ts.map +1 -1
  233. package/lib/destroy.js +1 -4
  234. package/lib/destroy.js.map +1 -1
  235. package/lib/diff.d.ts +16 -0
  236. package/lib/diff.d.ts.map +1 -0
  237. package/lib/diff.js +9 -0
  238. package/lib/diff.js.map +1 -0
  239. package/lib/env.d.ts +5 -0
  240. package/lib/env.d.ts.map +1 -1
  241. package/lib/env.js +15 -29
  242. package/lib/env.js.map +1 -1
  243. package/lib/exports.d.ts +9 -0
  244. package/lib/exports.d.ts.map +1 -0
  245. package/lib/exports.js +13 -0
  246. package/lib/exports.js.map +1 -0
  247. package/lib/index.d.ts +10 -2
  248. package/lib/index.d.ts.map +1 -1
  249. package/lib/index.js +10 -5
  250. package/lib/index.js.map +1 -1
  251. package/lib/input.d.ts +32 -0
  252. package/lib/input.d.ts.map +1 -0
  253. package/lib/input.js +1 -0
  254. package/lib/input.js.map +1 -0
  255. package/lib/output.d.ts +143 -0
  256. package/lib/output.d.ts.map +1 -0
  257. package/lib/output.js +269 -0
  258. package/lib/output.js.map +1 -0
  259. package/lib/plan.d.ts +47 -28
  260. package/lib/plan.d.ts.map +1 -1
  261. package/lib/plan.js +257 -151
  262. package/lib/plan.js.map +1 -1
  263. package/lib/policy.d.ts +3 -4
  264. package/lib/policy.d.ts.map +1 -1
  265. package/lib/policy.js +0 -1
  266. package/lib/policy.js.map +1 -1
  267. package/lib/provider.d.ts +14 -16
  268. package/lib/provider.d.ts.map +1 -1
  269. package/lib/ref.d.ts +14 -0
  270. package/lib/ref.d.ts.map +1 -0
  271. package/lib/ref.js +21 -0
  272. package/lib/ref.js.map +1 -0
  273. package/lib/resource.d.ts +11 -6
  274. package/lib/resource.d.ts.map +1 -1
  275. package/lib/resource.js.map +1 -1
  276. package/lib/runtime.d.ts +7 -6
  277. package/lib/runtime.d.ts.map +1 -1
  278. package/lib/runtime.js.map +1 -1
  279. package/lib/service.d.ts +9 -6
  280. package/lib/service.d.ts.map +1 -1
  281. package/lib/service.js.map +1 -1
  282. package/lib/stack.d.ts +60 -0
  283. package/lib/stack.d.ts.map +1 -0
  284. package/lib/stack.js +11 -0
  285. package/lib/stack.js.map +1 -0
  286. package/lib/stage.d.ts +39 -0
  287. package/lib/stage.d.ts.map +1 -0
  288. package/lib/stage.js +32 -0
  289. package/lib/stage.js.map +1 -0
  290. package/lib/state.d.ts +51 -10
  291. package/lib/state.d.ts.map +1 -1
  292. package/lib/state.js +30 -29
  293. package/lib/state.js.map +1 -1
  294. package/lib/test.d.ts +25 -4
  295. package/lib/test.d.ts.map +1 -1
  296. package/lib/test.js +54 -14
  297. package/lib/test.js.map +1 -1
  298. package/lib/tsconfig.test.tsbuildinfo +1 -1
  299. package/lib/type.d.ts +3 -0
  300. package/lib/type.d.ts.map +1 -1
  301. package/lib/unknown.d.ts +4 -0
  302. package/lib/unknown.d.ts.map +1 -0
  303. package/lib/unknown.js +4 -0
  304. package/lib/unknown.js.map +1 -0
  305. package/lib/user.d.ts +3 -0
  306. package/lib/user.d.ts.map +1 -0
  307. package/lib/user.js +3 -0
  308. package/lib/user.js.map +1 -0
  309. package/lib/util.d.ts +6 -0
  310. package/lib/util.d.ts.map +1 -0
  311. package/lib/util.js +9 -0
  312. package/lib/util.js.map +1 -0
  313. package/package.json +18 -12
  314. package/src/$.ts +17 -0
  315. package/src/app.ts +3 -32
  316. package/src/apply.ts +429 -441
  317. package/src/assert-never.ts +18 -0
  318. package/src/aws/account.ts +23 -3
  319. package/src/aws/client.ts +0 -1
  320. package/src/aws/config.ts +16 -0
  321. package/src/aws/credentials.ts +212 -177
  322. package/src/aws/dynamodb/index.ts +3 -3
  323. package/src/aws/dynamodb/table.get-item.ts +5 -9
  324. package/src/aws/dynamodb/table.provider.ts +35 -39
  325. package/src/aws/dynamodb/table.ts +29 -84
  326. package/src/aws/ec2/index.ts +4 -0
  327. package/src/aws/ec2/subnet.provider.ts +358 -0
  328. package/src/aws/ec2/subnet.ts +213 -0
  329. package/src/aws/ec2/vpc.provider.ts +20 -36
  330. package/src/aws/ec2/vpc.ts +19 -8
  331. package/src/aws/index.ts +46 -40
  332. package/src/aws/lambda/consume.ts +8 -7
  333. package/src/aws/lambda/function.handler.ts +1 -1
  334. package/src/aws/lambda/function.invoke.ts +6 -2
  335. package/src/aws/lambda/function.provider.ts +28 -21
  336. package/src/aws/lambda/function.ts +7 -4
  337. package/src/aws/lambda/index.ts +2 -0
  338. package/src/aws/profile.ts +1 -4
  339. package/src/aws/region.ts +42 -3
  340. package/src/aws/sqs/index.ts +2 -0
  341. package/src/aws/sqs/queue.consume.ts +1 -1
  342. package/src/aws/sqs/queue.event-source.ts +29 -55
  343. package/src/aws/sqs/queue.provider.ts +11 -4
  344. package/src/aws/sqs/queue.send-message.ts +5 -8
  345. package/src/aws/sqs/queue.ts +9 -4
  346. package/src/binding.ts +19 -19
  347. package/src/cli/components/ApprovePlan.tsx +2 -2
  348. package/src/cli/components/Plan.tsx +3 -2
  349. package/src/cli/components/PlanProgress.tsx +32 -14
  350. package/src/cli/index.ts +2 -6
  351. package/src/cli/ink-service.tsx +61 -0
  352. package/src/cli/service.ts +23 -0
  353. package/src/cloudflare/account.ts +37 -0
  354. package/src/cloudflare/api.ts +33 -29
  355. package/src/cloudflare/config.ts +7 -0
  356. package/src/cloudflare/index.ts +3 -1
  357. package/src/cloudflare/kv/namespace.binding.ts +3 -1
  358. package/src/cloudflare/kv/namespace.provider.ts +9 -8
  359. package/src/cloudflare/kv/namespace.ts +3 -2
  360. package/src/cloudflare/live.ts +11 -17
  361. package/src/cloudflare/r2/bucket.binding.ts +3 -1
  362. package/src/cloudflare/r2/bucket.provider.ts +9 -8
  363. package/src/cloudflare/r2/bucket.ts +8 -2
  364. package/src/cloudflare/worker/assets.fetch.ts +3 -1
  365. package/src/cloudflare/worker/assets.provider.ts +1 -1
  366. package/src/cloudflare/worker/index.ts +0 -2
  367. package/src/cloudflare/worker/worker.handler.ts +1 -1
  368. package/src/cloudflare/worker/worker.provider.ts +16 -13
  369. package/src/cloudflare/worker/worker.serve.ts +5 -2
  370. package/src/cloudflare/worker/worker.ts +4 -3
  371. package/src/data.ts +18 -0
  372. package/src/destroy.ts +1 -5
  373. package/src/diff.ts +30 -0
  374. package/src/env.ts +20 -32
  375. package/src/exports.ts +21 -0
  376. package/src/index.ts +10 -5
  377. package/src/input.ts +81 -0
  378. package/src/output.ts +518 -0
  379. package/src/plan.ts +380 -192
  380. package/src/policy.ts +3 -5
  381. package/src/provider.ts +25 -23
  382. package/src/ref.ts +48 -0
  383. package/src/resource.ts +20 -6
  384. package/src/runtime.ts +15 -8
  385. package/src/service.ts +11 -7
  386. package/src/stack.ts +116 -0
  387. package/src/stage.ts +85 -0
  388. package/src/state.ts +138 -60
  389. package/src/test.ts +117 -16
  390. package/src/type.ts +4 -0
  391. package/src/unknown.ts +6 -0
  392. package/src/user.ts +4 -0
  393. package/src/util.ts +21 -0
  394. package/lib/approve.d.ts +0 -15
  395. package/lib/approve.d.ts.map +0 -1
  396. package/lib/approve.js +0 -7
  397. package/lib/approve.js.map +0 -1
  398. package/lib/cli/approve.d.ts +0 -4
  399. package/lib/cli/approve.d.ts.map +0 -1
  400. package/lib/cli/approve.js +0 -18
  401. package/lib/cli/approve.js.map +0 -1
  402. package/lib/cli/clack.d.ts +0 -14
  403. package/lib/cli/clack.d.ts.map +0 -1
  404. package/lib/cli/clack.js +0 -12
  405. package/lib/cli/clack.js.map +0 -1
  406. package/lib/cli/main.d.ts +0 -2
  407. package/lib/cli/main.d.ts.map +0 -1
  408. package/lib/cli/main.js +0 -1
  409. package/lib/cli/main.js.map +0 -1
  410. package/lib/cli/plan.d.ts +0 -13
  411. package/lib/cli/plan.d.ts.map +0 -1
  412. package/lib/cli/plan.js +0 -1
  413. package/lib/cli/plan.js.map +0 -1
  414. package/lib/cli/progress.d.ts +0 -7
  415. package/lib/cli/progress.d.ts.map +0 -1
  416. package/lib/cli/progress.js +0 -30
  417. package/lib/cli/progress.js.map +0 -1
  418. package/lib/cli/spinner.d.ts +0 -2
  419. package/lib/cli/spinner.d.ts.map +0 -1
  420. package/lib/cli/spinner.js +0 -13
  421. package/lib/cli/spinner.js.map +0 -1
  422. package/src/approve.ts +0 -13
  423. package/src/cli/approve.tsx +0 -30
  424. package/src/cli/clack.ts +0 -22
  425. package/src/cli/main.ts +0 -0
  426. package/src/cli/plan.ts +0 -16
  427. package/src/cli/progress.tsx +0 -46
  428. package/src/cli/spinner.ts +0 -14
@@ -1,7 +1,6 @@
1
1
  import type * as S from "effect/Schema";
2
-
3
- import { Resource } from "alchemy-effect";
4
-
2
+ import type { Input } from "../../input.ts";
3
+ import { Resource } from "../../resource.ts";
5
4
  // required to avoid this error in consumers: "The inferred type of 'Messages' cannot be named without a reference to '../../effect-aws/node_modules/@types/aws-lambda'. This is likely not portable. A type annotation is necessary.ts(2742)"
6
5
  export type * as lambda from "aws-lambda";
7
6
 
@@ -15,7 +14,13 @@ export const Queue = Resource<{
15
14
  export interface Queue<
16
15
  ID extends string = string,
17
16
  Props extends QueueProps = QueueProps,
18
- > extends Resource<"AWS.SQS.Queue", ID, Props, QueueAttrs<Props>> {}
17
+ > extends Resource<
18
+ "AWS.SQS.Queue",
19
+ ID,
20
+ Props,
21
+ QueueAttrs<Extract<Input.Resolve<Props>, QueueProps>>,
22
+ Queue
23
+ > {}
19
24
 
20
25
  export type QueueAttrs<Props extends QueueProps> = {
21
26
  queueName: Props["queueName"] extends string ? Props["queueName"] : string;
package/src/binding.ts CHANGED
@@ -2,9 +2,9 @@ import * as Context from "effect/Context";
2
2
  import type { Effect } from "effect/Effect";
3
3
  import * as Layer from "effect/Layer";
4
4
  import type { Capability, ICapability } from "./capability.ts";
5
- import type { Diff } from "./provider.ts";
6
- import type { Resource } from "./resource.ts";
7
- import type { Runtime } from "./runtime.ts";
5
+ import type { Diff } from "./diff.ts";
6
+ import type { IResource, Resource } from "./resource.ts";
7
+ import type { IRuntime } from "./runtime.ts";
8
8
 
9
9
  export interface BindingProps {
10
10
  [key: string]: any;
@@ -13,7 +13,7 @@ export interface BindingProps {
13
13
  export const isBinding = (b: any): b is AnyBinding =>
14
14
  "runtime" in b && "capability" in b && "tag" in b && "output" in b;
15
15
 
16
- export type AnyBinding<F extends Runtime = any> = Binding<
16
+ export type AnyBinding<F extends IRuntime = any> = Binding<
17
17
  F,
18
18
  any,
19
19
  any,
@@ -23,7 +23,7 @@ export type AnyBinding<F extends Runtime = any> = Binding<
23
23
  >;
24
24
 
25
25
  export interface Binding<
26
- Run extends Runtime<any, any, any>,
26
+ Run extends IRuntime<any, any, any>,
27
27
  Cap extends Capability = Capability,
28
28
  Props = any,
29
29
  Attr extends Run["binding"] = any,
@@ -40,14 +40,14 @@ export interface Binding<
40
40
 
41
41
  /** Tag for a Service that can bind a Capability to a Runtime */
42
42
  export interface Bind<
43
- F extends Runtime,
43
+ F extends IRuntime,
44
44
  Cap extends Capability,
45
45
  Tag extends string,
46
46
  > extends Context.Tag<
47
47
  `${F["type"]}(${Cap["type"]}, ${Tag})`,
48
48
  BindingService<
49
49
  F,
50
- Extract<Extract<Cap["resource"], Resource>["parent"], Resource>,
50
+ Extract<Extract<Cap["resource"], Resource>["base"], Resource>,
51
51
  F["props"]
52
52
  >
53
53
  > {
@@ -91,12 +91,12 @@ export const Binding: {
91
91
  effect: (eff) => Layer.effect(Tag, eff),
92
92
  succeed: (service) => Layer.succeed(Tag, service),
93
93
  },
94
- } satisfies BindingDeclaration<Runtime, any>,
94
+ } satisfies BindingDeclaration<IRuntime, any>,
95
95
  );
96
96
  };
97
97
 
98
98
  export interface BindingDeclaration<
99
- Run extends Runtime,
99
+ Run extends IRuntime,
100
100
  F extends (target: any, props?: any) => AnyBinding<Run>,
101
101
  Tag extends string = ReturnType<F>["tag"],
102
102
  Cap extends Capability = ReturnType<F>["capability"],
@@ -126,8 +126,8 @@ export interface BindingDeclaration<
126
126
  }
127
127
 
128
128
  export interface BindingDiffProps<
129
- Source extends Resource = Resource,
130
- Target extends Resource = Resource,
129
+ Source extends IResource = IResource,
130
+ Target extends IResource = IResource,
131
131
  Props = any,
132
132
  Attr = any,
133
133
  > {
@@ -148,8 +148,8 @@ export interface BindingDiffProps<
148
148
  }
149
149
 
150
150
  export interface BindingAttachProps<
151
- Source extends Resource,
152
- Target extends Resource,
151
+ Source extends IResource,
152
+ Target extends IResource,
153
153
  Props,
154
154
  Attr,
155
155
  > {
@@ -168,8 +168,8 @@ export interface BindingAttachProps<
168
168
  }
169
169
 
170
170
  export interface BindingReattachProps<
171
- Source extends Resource,
172
- Target extends Resource,
171
+ Source extends IResource,
172
+ Target extends IResource,
173
173
  Props,
174
174
  Attr,
175
175
  > {
@@ -188,8 +188,8 @@ export interface BindingReattachProps<
188
188
  }
189
189
 
190
190
  export interface BindingDetachProps<
191
- Source extends Resource,
192
- Target extends Resource,
191
+ Source extends IResource,
192
+ Target extends IResource,
193
193
  Props,
194
194
  Attr,
195
195
  > {
@@ -208,8 +208,8 @@ export interface BindingDetachProps<
208
208
  }
209
209
 
210
210
  export type BindingService<
211
- Target extends Runtime = any,
212
- Source extends Resource = Resource,
211
+ Target extends IRuntime = any,
212
+ Source extends IResource = IResource,
213
213
  Props = any,
214
214
  Attr extends Target["binding"] = any,
215
215
  DiffReq = never,
@@ -1,13 +1,13 @@
1
1
  // biome-ignore lint/style/useImportType: UMD global
2
2
  import React, { useState } from "react";
3
3
 
4
- import type * as Alchemy from "alchemy-effect";
5
4
  import { Box, Text, useApp, useInput } from "ink";
5
+ import type { IPlan as AlchemyPlan } from "../../plan.ts";
6
6
 
7
7
  import { Plan } from "./Plan.tsx";
8
8
 
9
9
  export interface ApprovePlanProps {
10
- plan: Alchemy.Plan;
10
+ plan: AlchemyPlan;
11
11
  approve: (result: boolean) => void;
12
12
  }
13
13
 
@@ -1,11 +1,12 @@
1
1
  // biome-ignore lint/style/useImportType: UMD global
2
2
  import React, { useMemo } from "react";
3
3
 
4
- import type { BindNode, Capability, CRUD, Plan } from "alchemy-effect";
5
4
  import { Box, Text } from "ink";
5
+ import type { Capability } from "../../capability.ts";
6
+ import type { IPlan as AlchemyPlan, BindNode, CRUD } from "../../plan.ts";
6
7
 
7
8
  export interface PlanProps {
8
- plan: Plan;
9
+ plan: AlchemyPlan;
9
10
  }
10
11
  export function Plan({ plan }: PlanProps): React.JSX.Element {
11
12
  const items = useMemo(
@@ -1,20 +1,27 @@
1
1
  // biome-ignore lint/style/useImportType: UMD global
2
2
  import React, { useEffect, useMemo, useRef, useState } from "react";
3
3
 
4
- import type * as Alchemy from "alchemy-effect";
5
4
  import { Box, Text } from "ink";
6
- import type { ProgressEventSource } from "../progress.tsx";
7
- import { useGlobalSpinner } from "../spinner.ts";
5
+ import type {
6
+ ApplyEvent,
7
+ ApplyStatus,
8
+ StatusChangeEvent,
9
+ } from "../../event.ts";
10
+ import type { IPlan } from "../../plan.ts";
11
+
12
+ interface ProgressEventSource {
13
+ subscribe(listener: (event: ApplyEvent) => void): () => void;
14
+ }
8
15
 
9
16
  interface PlanTask
10
- extends Required<Pick<Alchemy.StatusChangeEvent, "id" | "type" | "status">> {
17
+ extends Required<Pick<StatusChangeEvent, "id" | "type" | "status">> {
11
18
  message?: string;
12
19
  updatedAt: number;
13
20
  }
14
21
 
15
- export interface PlanProgressProps {
22
+ interface PlanProgressProps {
16
23
  source: ProgressEventSource;
17
- plan: Alchemy.Plan;
24
+ plan: IPlan;
18
25
  }
19
26
 
20
27
  export function PlanProgress(props: PlanProgressProps): React.JSX.Element {
@@ -29,7 +36,7 @@ export function PlanProgress(props: PlanProgressProps): React.JSX.Element {
29
36
  ];
30
37
  for (const [id, item] of nodes) {
31
38
  const planItem = item!;
32
- const status: Alchemy.ApplyStatus =
39
+ const status: ApplyStatus =
33
40
  planItem.action === "noop" ? "success" : "pending";
34
41
  initialTasks.set(id, {
35
42
  id,
@@ -89,7 +96,7 @@ export function PlanProgress(props: PlanProgressProps): React.JSX.Element {
89
96
  ];
90
97
  for (const [id, item] of nodes) {
91
98
  const planItem = item!;
92
- const status: Alchemy.ApplyStatus =
99
+ const status: ApplyStatus =
93
100
  planItem.action === "noop" ? "success" : "pending";
94
101
  initialTasks.set(id, {
95
102
  id,
@@ -146,7 +153,7 @@ export function PlanProgress(props: PlanProgressProps): React.JSX.Element {
146
153
  );
147
154
  }
148
155
 
149
- function statusPriority(status: Alchemy.ApplyStatus): number {
156
+ function statusPriority(status: ApplyStatus): number {
150
157
  switch (status) {
151
158
  case "success":
152
159
  case "created":
@@ -166,9 +173,7 @@ function statusPriority(status: Alchemy.ApplyStatus): number {
166
173
  }
167
174
  }
168
175
 
169
- function statusColor(
170
- status: Alchemy.ApplyStatus,
171
- ): Parameters<typeof Text>[0]["color"] {
176
+ function statusColor(status: ApplyStatus): Parameters<typeof Text>[0]["color"] {
172
177
  switch (status) {
173
178
  case "pending":
174
179
  return "gray";
@@ -190,13 +195,13 @@ function statusColor(
190
195
  }
191
196
  }
192
197
 
193
- function statusIcon(status: Alchemy.ApplyStatus, spinnerChar: string): string {
198
+ function statusIcon(status: ApplyStatus, spinnerChar: string): string {
194
199
  if (isInProgress(status)) return spinnerChar;
195
200
  if (status === "fail") return "✗";
196
201
  return "✓"; // created/updated/deleted/success
197
202
  }
198
203
 
199
- function isInProgress(status: Alchemy.ApplyStatus): boolean {
204
+ function isInProgress(status: ApplyStatus): boolean {
200
205
  return (
201
206
  status === "pending" ||
202
207
  status === "creating" ||
@@ -204,3 +209,16 @@ function isInProgress(status: Alchemy.ApplyStatus): boolean {
204
209
  status === "deleting"
205
210
  );
206
211
  }
212
+
213
+ const spinnerFrames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
214
+
215
+ function useGlobalSpinner(intervalMs = 80): string {
216
+ const [index, setIndex] = useState(0);
217
+ useEffect(() => {
218
+ const timer = setInterval(() => {
219
+ setIndex((i) => (i + 1) % spinnerFrames.length);
220
+ }, intervalMs);
221
+ return () => clearInterval(timer);
222
+ }, [intervalMs]);
223
+ return spinnerFrames[index];
224
+ }
package/src/cli/index.ts CHANGED
@@ -1,6 +1,2 @@
1
- import * as Layer from "effect/Layer";
2
-
3
- import { requireApproval } from "./approve.tsx";
4
- import { reportProgress } from "./progress.tsx";
5
-
6
- export const layer = Layer.merge(requireApproval, reportProgress);
1
+ export * from "./service.ts";
2
+ export * from "./ink-service.tsx";
@@ -0,0 +1,61 @@
1
+ import React from "react";
2
+
3
+ import { type PlanStatusSession, CLI } from "./service.ts";
4
+ import * as Effect from "effect/Effect";
5
+ import * as Layer from "effect/Layer";
6
+ import type { IPlan } from "../plan.ts";
7
+ import { render } from "ink";
8
+ import { ApprovePlan } from "./components/ApprovePlan.tsx";
9
+ import { Plan } from "./components/Plan.tsx";
10
+ import { PlanProgress } from "./components/PlanProgress.tsx";
11
+ import type { ApplyEvent } from "../event.ts";
12
+
13
+ export const inkCLI = () =>
14
+ Layer.succeed(
15
+ CLI,
16
+ CLI.of({
17
+ approvePlan,
18
+ displayPlan,
19
+ startApplySession,
20
+ }),
21
+ );
22
+
23
+ const approvePlan = Effect.fn(function* <P extends IPlan>(plan: P) {
24
+ let approved = false;
25
+ const { waitUntilExit } = render(
26
+ <ApprovePlan plan={plan} approve={(a) => (approved = a)} />,
27
+ );
28
+ yield* Effect.promise(waitUntilExit);
29
+ return approved;
30
+ });
31
+
32
+ const displayPlan = <P extends IPlan>(plan: P): Effect.Effect<void> =>
33
+ Effect.sync(() => {
34
+ const { unmount } = render(<Plan plan={plan} />);
35
+ unmount();
36
+ });
37
+
38
+ const startApplySession = Effect.fn(function* <P extends IPlan>(plan: P) {
39
+ const listeners = new Set<(event: ApplyEvent) => void>();
40
+ const { unmount } = render(
41
+ <PlanProgress
42
+ plan={plan}
43
+ source={{
44
+ subscribe(listener) {
45
+ listeners.add(listener);
46
+ return () => listeners.delete(listener);
47
+ },
48
+ }}
49
+ />,
50
+ );
51
+ return {
52
+ done: Effect.fn(function* () {
53
+ yield* Effect.sleep(10); // give the react event loop time to re-render
54
+ yield* Effect.sync(() => unmount());
55
+ }),
56
+ emit: (event) =>
57
+ Effect.sync(() => {
58
+ for (const listener of listeners) listener(event);
59
+ }),
60
+ } satisfies PlanStatusSession;
61
+ });
@@ -0,0 +1,23 @@
1
+ import type { IPlan } from "../plan.ts";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Context from "effect/Context";
4
+ import type { ApplyEvent } from "../event.ts";
5
+
6
+ export interface PlanStatusSession {
7
+ emit: (event: ApplyEvent) => Effect.Effect<void>;
8
+ done: () => Effect.Effect<void>;
9
+ }
10
+
11
+ export interface ScopedPlanStatusSession extends PlanStatusSession {
12
+ note: (note: string) => Effect.Effect<void>;
13
+ }
14
+
15
+ export interface CLIService {
16
+ approvePlan: <P extends IPlan>(plan: P) => Effect.Effect<boolean>;
17
+ displayPlan: <P extends IPlan>(plan: P) => Effect.Effect<void>;
18
+ startApplySession: <P extends IPlan>(
19
+ plan: P,
20
+ ) => Effect.Effect<PlanStatusSession>;
21
+ }
22
+
23
+ export class CLI extends Context.Tag("CLIService")<CLI, CLIService>() {}
@@ -0,0 +1,37 @@
1
+ import * as Layer from "effect/Layer";
2
+ import * as Context from "effect/Context";
3
+ import * as Effect from "effect/Effect";
4
+ import * as Config from "effect/Config";
5
+ import { App } from "../app.ts";
6
+
7
+ export class Account extends Context.Tag("cloudflare/account-id")<
8
+ Account,
9
+ string
10
+ >() {}
11
+
12
+ export const fromEnv = () =>
13
+ Layer.effect(
14
+ Account,
15
+ Effect.gen(function* () {
16
+ const accountId = yield* Config.string("CLOUDFLARE_ACCOUNT_ID");
17
+ if (!accountId) {
18
+ return yield* Effect.die("CLOUDFLARE_ACCOUNT_ID is not set");
19
+ }
20
+ return accountId;
21
+ }),
22
+ );
23
+
24
+ export const fromStageConfig = () =>
25
+ Layer.effect(
26
+ Account,
27
+ Effect.gen(function* () {
28
+ const app = yield* App;
29
+ const accountId =
30
+ app.config.cloudflare?.account ??
31
+ (yield* Config.string("CLOUDFLARE_ACCOUNT_ID"));
32
+ if (!accountId) {
33
+ return yield* Effect.die("CLOUDFLARE_ACCOUNT_ID is not set");
34
+ }
35
+ return accountId;
36
+ }),
37
+ );
@@ -5,46 +5,50 @@ import {
5
5
  type RequestOptions,
6
6
  } from "cloudflare/core";
7
7
  import type { ErrorData } from "cloudflare/resources";
8
- import { Layer } from "effect";
9
- import * as Context from "effect/Context";
10
8
  import * as Data from "effect/Data";
9
+ import * as Option from "effect/Option";
11
10
  import * as Effect from "effect/Effect";
11
+ import { Config } from "effect";
12
12
 
13
- export class CloudflareAccountId extends Context.Tag("cloudflare/account-id")<
14
- CloudflareAccountId,
15
- string
16
- >() {
17
- static readonly fromEnv = Layer.effect(
18
- CloudflareAccountId,
19
- Effect.gen(function* () {
20
- const accountId = process.env.CLOUDFLARE_ACCOUNT_ID;
21
- if (!accountId) {
22
- return yield* Effect.die("CLOUDFLARE_ACCOUNT_ID is not set");
23
- }
24
- return accountId;
25
- }),
26
- );
27
- }
13
+ export const CLOUDFLARE_BASE_URL = Config.string("CLOUDFLARE_BASE_URL").pipe(
14
+ Config.option,
15
+ );
16
+ export const CLOUDFLARE_API_TOKEN = Config.string("CLOUDFLARE_API_TOKEN").pipe(
17
+ Config.option,
18
+ );
19
+ export const CLOUDFLARE_API_KEY = Config.string("CLOUDFLARE_API_KEY").pipe(
20
+ Config.option,
21
+ );
22
+ export const CLOUDFLARE_API_EMAIL = Config.string("CLOUDFLARE_API_EMAIL").pipe(
23
+ Config.option,
24
+ );
28
25
 
29
26
  export class CloudflareApi extends Effect.Service<CloudflareApi>()(
30
27
  "cloudflare/api",
31
28
  {
32
- effect: (options?: {
29
+ effect: Effect.fn(function* (options?: {
33
30
  baseUrl?: string;
34
31
  apiToken?: string;
35
32
  apiKey?: string;
36
33
  apiEmail?: string;
37
- }) =>
38
- Effect.succeed(
39
- createRecursiveProxy(
40
- new Cloudflare({
41
- baseURL: options?.baseUrl ?? import.meta.env.CLOUDFLARE_BASE_URL,
42
- apiToken: options?.apiToken ?? import.meta.env.CLOUDFLARE_API_TOKEN,
43
- apiKey: options?.apiKey ?? import.meta.env.CLOUDFLARE_API_KEY,
44
- apiEmail: options?.apiEmail ?? import.meta.env.CLOUDFLARE_API_EMAIL,
45
- }),
46
- ),
47
- ),
34
+ }) {
35
+ return createRecursiveProxy(
36
+ new Cloudflare({
37
+ baseURL:
38
+ options?.baseUrl ??
39
+ (yield* CLOUDFLARE_BASE_URL).pipe(Option.getOrUndefined),
40
+ apiToken:
41
+ options?.apiToken ??
42
+ (yield* CLOUDFLARE_API_TOKEN).pipe(Option.getOrUndefined),
43
+ apiKey:
44
+ options?.apiKey ??
45
+ (yield* CLOUDFLARE_API_KEY).pipe(Option.getOrUndefined),
46
+ apiEmail:
47
+ options?.apiEmail ??
48
+ (yield* CLOUDFLARE_API_EMAIL).pipe(Option.getOrUndefined),
49
+ }),
50
+ );
51
+ }),
48
52
  },
49
53
  ) {}
50
54
 
@@ -0,0 +1,7 @@
1
+ declare module "../stage.ts" {
2
+ interface StageConfig {
3
+ cloudflare?: {
4
+ account: string;
5
+ };
6
+ }
7
+ }
@@ -2,5 +2,7 @@ export * as KV from "./kv/index.ts";
2
2
  export * as R2 from "./r2/index.ts";
3
3
  export * as Assets from "./worker/assets.fetch.ts";
4
4
  export * as Worker from "./worker/index.ts";
5
+ export * from "./account.ts";
6
+ export * from "./live.ts";
5
7
 
6
- export type * as Alchemy from "../index.ts";
8
+ import "./config.ts";
@@ -1,4 +1,6 @@
1
- import { Binding, type Capability, type To } from "alchemy-effect";
1
+ import { Binding } from "../../binding.ts";
2
+ import type { Capability } from "../../capability.ts";
3
+ import type { To } from "../../policy.ts";
2
4
  import { Worker } from "../worker/worker.ts";
3
5
  import type { Namespace, NamespaceProps } from "./namespace.ts";
4
6
 
@@ -1,7 +1,8 @@
1
1
  import type { KV } from "cloudflare/resources";
2
2
  import * as Effect from "effect/Effect";
3
3
  import { App } from "../../app.ts";
4
- import { CloudflareAccountId, CloudflareApi } from "../api.ts";
4
+ import { Account } from "../account.ts";
5
+ import { CloudflareApi } from "../api.ts";
5
6
  import {
6
7
  Namespace,
7
8
  type NamespaceAttr,
@@ -13,10 +14,10 @@ export const namespaceProvider = () =>
13
14
  Effect.gen(function* () {
14
15
  const app = yield* App;
15
16
  const api = yield* CloudflareApi;
16
- const accountId = yield* CloudflareAccountId;
17
+ const accountId = yield* Account;
17
18
 
18
- const createTitle = (id: string, news: NamespaceProps) =>
19
- news.title ?? `${app.name}-${id}-${app.stage}`;
19
+ const createTitle = (id: string, title: string | undefined) =>
20
+ title ?? `${app.name}-${id}-${app.stage}`;
20
21
 
21
22
  const mapResult = <Props extends NamespaceProps>(
22
23
  result: KV.Namespace,
@@ -33,7 +34,7 @@ export const namespaceProvider = () =>
33
34
  if (output.accountId !== accountId) {
34
35
  return { action: "replace" };
35
36
  }
36
- const title = createTitle(id, news);
37
+ const title = createTitle(id, news.title);
37
38
  if (title !== output.title) {
38
39
  return { action: "update" };
39
40
  }
@@ -42,7 +43,7 @@ export const namespaceProvider = () =>
42
43
  return yield* api.kv.namespaces
43
44
  .create({
44
45
  account_id: accountId,
45
- title: createTitle(id, news),
46
+ title: createTitle(id, news.title),
46
47
  })
47
48
  .pipe(Effect.map(mapResult<NamespaceProps>));
48
49
  }),
@@ -50,7 +51,7 @@ export const namespaceProvider = () =>
50
51
  return yield* api.kv.namespaces
51
52
  .update(output.namespaceId, {
52
53
  account_id: accountId,
53
- title: createTitle(id, news),
54
+ title: createTitle(id, news.title),
54
55
  })
55
56
  .pipe(Effect.map(mapResult<NamespaceProps>));
56
57
  }),
@@ -72,7 +73,7 @@ export const namespaceProvider = () =>
72
73
  Effect.catchTag("NotFound", () => Effect.succeed(undefined)),
73
74
  );
74
75
  }
75
- const title = createTitle(id, olds ?? {}); // why is olds optional?
76
+ const title = createTitle(id, olds?.title); // why is olds optional? because read can be called before the resource exists (sync)
76
77
  let page = 1;
77
78
  while (true) {
78
79
  // todo: abstract pagination
@@ -18,12 +18,13 @@ export interface Namespace<
18
18
  "Cloudflare.KV.Namespace",
19
19
  ID,
20
20
  Props,
21
- NamespaceAttr<Props>
21
+ NamespaceAttr<Props>,
22
+ Namespace
22
23
  > {}
23
24
 
24
25
  export const Namespace = Resource<{
25
26
  <const ID extends string, const Props extends NamespaceProps>(
26
27
  id: ID,
27
- props: Props,
28
+ props?: Props,
28
29
  ): Namespace<ID, Props>;
29
30
  }>("Cloudflare.KV.Namespace");
@@ -1,6 +1,7 @@
1
1
  import * as Layer from "effect/Layer";
2
2
  import * as ESBuild from "../esbuild.ts";
3
- import { CloudflareAccountId, CloudflareApi } from "./api.ts";
3
+ import { CloudflareApi } from "./api.ts";
4
+ import * as Account from "./account.ts";
4
5
  import * as KV from "./kv/index.ts";
5
6
  import { namespaceProvider } from "./kv/namespace.provider.ts";
6
7
  import { bucketProvider } from "./r2/bucket.provider.ts";
@@ -8,7 +9,12 @@ import * as R2 from "./r2/index.ts";
8
9
  import { assetsProvider } from "./worker/assets.provider.ts";
9
10
  import { workerProvider } from "./worker/worker.provider.ts";
10
11
 
11
- export const providers = () =>
12
+ import "./config.ts";
13
+
14
+ export const bindings = () =>
15
+ Layer.mergeAll(KV.bindFromWorker(), R2.bindFromWorker());
16
+
17
+ export const defaultProviders = () =>
12
18
  Layer.mergeAll(
13
19
  Layer.provideMerge(
14
20
  workerProvider(),
@@ -16,23 +22,11 @@ export const providers = () =>
16
22
  ),
17
23
  namespaceProvider(),
18
24
  bucketProvider(),
19
- );
25
+ ).pipe(Layer.provideMerge(bindings()));
20
26
 
21
- export const bindings = () =>
22
- Layer.mergeAll(KV.bindFromWorker(), R2.bindFromWorker());
23
-
24
- export const defaultProviders = () =>
25
- providers().pipe(Layer.provideMerge(bindings()));
26
-
27
- export const live = () =>
27
+ export const providers = () =>
28
28
  defaultProviders().pipe(
29
29
  Layer.provideMerge(
30
- Layer.mergeAll(CloudflareAccountId.fromEnv, CloudflareApi.Default()),
30
+ Layer.mergeAll(Account.fromStageConfig(), CloudflareApi.Default()),
31
31
  ),
32
32
  );
33
-
34
- export default live;
35
-
36
- // Layer.mergeAll
37
- // Layer.provide
38
- // Layer.provideMerge
@@ -1,4 +1,6 @@
1
- import { Binding, type Capability, type To } from "alchemy-effect";
1
+ import { Binding } from "../../binding.ts";
2
+ import type { Capability } from "../../capability.ts";
3
+ import type { To } from "../../policy.ts";
2
4
  import { Worker } from "../worker/worker.ts";
3
5
  import type { Bucket } from "./bucket.ts";
4
6