alchemy-effect 0.1.0 → 0.2.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 (420) hide show
  1. package/lib/app.d.ts +7 -2
  2. package/lib/app.d.ts.map +1 -1
  3. package/lib/app.js +1 -0
  4. package/lib/app.js.map +1 -1
  5. package/lib/apply.d.ts +57 -1
  6. package/lib/apply.d.ts.map +1 -1
  7. package/lib/apply.js +141 -55
  8. package/lib/apply.js.map +1 -1
  9. package/lib/aws/account.d.ts +4 -3
  10. package/lib/aws/account.d.ts.map +1 -1
  11. package/lib/aws/account.js +2 -2
  12. package/lib/aws/account.js.map +1 -1
  13. package/lib/aws/arn.d.ts +1 -5
  14. package/lib/aws/arn.d.ts.map +1 -1
  15. package/lib/aws/client.d.ts.map +1 -1
  16. package/lib/aws/client.js +9 -1
  17. package/lib/aws/client.js.map +1 -1
  18. package/lib/aws/credentials.d.ts +1 -1
  19. package/lib/aws/credentials.d.ts.map +1 -1
  20. package/lib/aws/credentials.js.map +1 -1
  21. package/lib/aws/dynamodb/attribute-value.d.ts +20 -0
  22. package/lib/aws/dynamodb/attribute-value.d.ts.map +1 -0
  23. package/lib/aws/dynamodb/attribute-value.js +217 -0
  24. package/lib/aws/dynamodb/attribute-value.js.map +1 -0
  25. package/lib/aws/dynamodb/client.d.ts +12 -0
  26. package/lib/aws/dynamodb/client.d.ts.map +1 -0
  27. package/lib/aws/{sqs/queue.client.js → dynamodb/client.js} +6 -6
  28. package/lib/aws/dynamodb/client.js.map +1 -0
  29. package/lib/aws/dynamodb/expr.d.ts +41 -0
  30. package/lib/aws/dynamodb/expr.d.ts.map +1 -0
  31. package/lib/aws/dynamodb/expr.js +1 -0
  32. package/lib/aws/dynamodb/expr.js.map +1 -0
  33. package/lib/aws/dynamodb/index.d.ts +9 -0
  34. package/lib/aws/dynamodb/index.d.ts.map +1 -0
  35. package/lib/aws/dynamodb/index.js +10 -0
  36. package/lib/aws/dynamodb/index.js.map +1 -0
  37. package/lib/aws/dynamodb/projection.d.ts +25 -0
  38. package/lib/aws/dynamodb/projection.d.ts.map +1 -0
  39. package/lib/aws/dynamodb/projection.js +1 -0
  40. package/lib/aws/dynamodb/projection.js.map +1 -0
  41. package/lib/aws/dynamodb/secondary-index.d.ts +25 -0
  42. package/lib/aws/dynamodb/secondary-index.d.ts.map +1 -0
  43. package/lib/aws/dynamodb/secondary-index.js +4 -0
  44. package/lib/aws/dynamodb/secondary-index.js.map +1 -0
  45. package/lib/aws/dynamodb/table.d.ts +56 -0
  46. package/lib/aws/dynamodb/table.d.ts.map +1 -0
  47. package/lib/aws/dynamodb/table.get-item.d.ts +55 -0
  48. package/lib/aws/dynamodb/table.get-item.d.ts.map +1 -0
  49. package/lib/aws/dynamodb/table.get-item.js +75 -0
  50. package/lib/aws/dynamodb/table.get-item.js.map +1 -0
  51. package/lib/aws/dynamodb/table.js +4 -0
  52. package/lib/aws/dynamodb/table.js.map +1 -0
  53. package/lib/aws/dynamodb/table.provider.d.ts +8 -0
  54. package/lib/aws/dynamodb/table.provider.d.ts.map +1 -0
  55. package/lib/aws/dynamodb/table.provider.js +199 -0
  56. package/lib/aws/dynamodb/table.provider.js.map +1 -0
  57. package/lib/aws/ec2/client.d.ts +12 -0
  58. package/lib/aws/ec2/client.d.ts.map +1 -0
  59. package/lib/aws/ec2/client.js +11 -0
  60. package/lib/aws/ec2/client.js.map +1 -0
  61. package/lib/aws/ec2/index.d.ts +4 -0
  62. package/lib/aws/ec2/index.d.ts.map +1 -0
  63. package/lib/aws/ec2/index.js +4 -0
  64. package/lib/aws/ec2/index.js.map +1 -0
  65. package/lib/aws/ec2/vpc.d.ts +131 -0
  66. package/lib/aws/ec2/vpc.d.ts.map +1 -0
  67. package/lib/aws/ec2/vpc.js +3 -0
  68. package/lib/aws/ec2/vpc.js.map +1 -0
  69. package/lib/aws/ec2/vpc.provider.d.ts +7 -0
  70. package/lib/aws/ec2/vpc.provider.d.ts.map +1 -0
  71. package/lib/aws/ec2/vpc.provider.js +198 -0
  72. package/lib/aws/ec2/vpc.provider.js.map +1 -0
  73. package/lib/aws/index.d.ts +24 -14
  74. package/lib/aws/index.d.ts.map +1 -1
  75. package/lib/aws/index.js +7 -12
  76. package/lib/aws/index.js.map +1 -1
  77. package/lib/aws/lambda/client.d.ts +8 -0
  78. package/lib/aws/lambda/client.d.ts.map +1 -0
  79. package/lib/aws/lambda/client.js +7 -0
  80. package/lib/aws/lambda/client.js.map +1 -0
  81. package/lib/aws/lambda/consume.d.ts +3 -3
  82. package/lib/aws/lambda/consume.d.ts.map +1 -1
  83. package/lib/aws/lambda/consume.js.map +1 -1
  84. package/lib/aws/lambda/function.d.ts +13 -10
  85. package/lib/aws/lambda/function.d.ts.map +1 -1
  86. package/lib/aws/lambda/function.invoke.d.ts +2 -2
  87. package/lib/aws/lambda/function.invoke.d.ts.map +1 -1
  88. package/lib/aws/lambda/function.invoke.js +2 -2
  89. package/lib/aws/lambda/function.invoke.js.map +1 -1
  90. package/lib/aws/lambda/function.js +1 -1
  91. package/lib/aws/lambda/function.js.map +1 -1
  92. package/lib/aws/lambda/function.provider.d.ts +3 -3
  93. package/lib/aws/lambda/function.provider.d.ts.map +1 -1
  94. package/lib/aws/lambda/function.provider.js +145 -55
  95. package/lib/aws/lambda/function.provider.js.map +1 -1
  96. package/lib/aws/lambda/index.d.ts +1 -2
  97. package/lib/aws/lambda/index.d.ts.map +1 -1
  98. package/lib/aws/lambda/index.js +1 -1
  99. package/lib/aws/lambda/index.js.map +1 -1
  100. package/lib/aws/lambda/serve.d.ts +1 -1
  101. package/lib/aws/lambda/serve.d.ts.map +1 -1
  102. package/lib/aws/lambda/serve.js.map +1 -1
  103. package/lib/aws/region.d.ts +1 -0
  104. package/lib/aws/region.d.ts.map +1 -1
  105. package/lib/aws/region.js.map +1 -1
  106. package/lib/aws/sqs/client.d.ts +12 -0
  107. package/lib/aws/sqs/client.d.ts.map +1 -0
  108. package/lib/aws/sqs/client.js +11 -0
  109. package/lib/aws/sqs/client.js.map +1 -0
  110. package/lib/aws/sqs/index.d.ts +2 -1
  111. package/lib/aws/sqs/index.d.ts.map +1 -1
  112. package/lib/aws/sqs/index.js +2 -1
  113. package/lib/aws/sqs/index.js.map +1 -1
  114. package/lib/aws/sqs/queue.consume.d.ts +1 -10
  115. package/lib/aws/sqs/queue.consume.d.ts.map +1 -1
  116. package/lib/aws/sqs/queue.consume.js +1 -19
  117. package/lib/aws/sqs/queue.consume.js.map +1 -1
  118. package/lib/aws/sqs/queue.d.ts +2 -10
  119. package/lib/aws/sqs/queue.d.ts.map +1 -1
  120. package/lib/aws/sqs/queue.event-source.d.ts +20 -0
  121. package/lib/aws/sqs/queue.event-source.d.ts.map +1 -0
  122. package/lib/aws/sqs/queue.event-source.js +148 -0
  123. package/lib/aws/sqs/queue.event-source.js.map +1 -0
  124. package/lib/aws/sqs/queue.provider.d.ts +4 -3
  125. package/lib/aws/sqs/queue.provider.d.ts.map +1 -1
  126. package/lib/aws/sqs/queue.provider.js +4 -4
  127. package/lib/aws/sqs/queue.provider.js.map +1 -1
  128. package/lib/aws/sqs/queue.send-message.d.ts +2 -2
  129. package/lib/aws/sqs/queue.send-message.d.ts.map +1 -1
  130. package/lib/aws/sqs/queue.send-message.js +2 -2
  131. package/lib/aws/sqs/queue.send-message.js.map +1 -1
  132. package/lib/binding.d.ts +70 -22
  133. package/lib/binding.d.ts.map +1 -1
  134. package/lib/binding.js.map +1 -1
  135. package/lib/capability.d.ts +38 -0
  136. package/lib/capability.d.ts.map +1 -1
  137. package/lib/cli/components/Plan.d.ts.map +1 -1
  138. package/lib/cli/components/Plan.js +3 -1
  139. package/lib/cli/components/Plan.js.map +1 -1
  140. package/lib/cli/index.d.ts +204 -116
  141. package/lib/cli/index.d.ts.map +1 -1
  142. package/lib/cli/index.js +25707 -11055
  143. package/lib/cli/index.js.map +1 -1
  144. package/lib/cli/progress.d.ts.map +1 -1
  145. package/lib/cli/progress.js +1 -0
  146. package/lib/cli/progress.js.map +1 -1
  147. package/lib/cloudflare/api.d.ts +29 -17
  148. package/lib/cloudflare/api.d.ts.map +1 -1
  149. package/lib/cloudflare/api.js +92 -27
  150. package/lib/cloudflare/api.js.map +1 -1
  151. package/lib/cloudflare/context.d.ts +27 -0
  152. package/lib/cloudflare/context.d.ts.map +1 -0
  153. package/lib/cloudflare/context.js +24 -0
  154. package/lib/cloudflare/context.js.map +1 -0
  155. package/lib/cloudflare/index.d.ts +5 -4
  156. package/lib/cloudflare/index.d.ts.map +1 -1
  157. package/lib/cloudflare/index.js +4 -4
  158. package/lib/cloudflare/index.js.map +1 -1
  159. package/lib/cloudflare/kv/index.d.ts +4 -0
  160. package/lib/cloudflare/kv/index.d.ts.map +1 -0
  161. package/lib/cloudflare/kv/index.js +4 -0
  162. package/lib/cloudflare/kv/index.js.map +1 -0
  163. package/lib/cloudflare/kv/namespace.binding.d.ts +8 -0
  164. package/lib/cloudflare/kv/namespace.binding.d.ts.map +1 -0
  165. package/lib/cloudflare/kv/namespace.binding.js +15 -0
  166. package/lib/cloudflare/kv/namespace.binding.js.map +1 -0
  167. package/lib/cloudflare/kv/namespace.client.d.ts +11 -0
  168. package/lib/cloudflare/kv/namespace.client.d.ts.map +1 -0
  169. package/lib/cloudflare/kv/namespace.client.js +31 -0
  170. package/lib/cloudflare/kv/namespace.client.js.map +1 -0
  171. package/lib/cloudflare/kv/namespace.d.ts +23 -0
  172. package/lib/cloudflare/kv/namespace.d.ts.map +1 -0
  173. package/lib/cloudflare/kv/namespace.js +3 -0
  174. package/lib/cloudflare/kv/namespace.js.map +1 -0
  175. package/lib/cloudflare/kv/namespace.provider.d.ts +5 -0
  176. package/lib/cloudflare/kv/namespace.provider.d.ts.map +1 -0
  177. package/lib/cloudflare/kv/namespace.provider.js +80 -0
  178. package/lib/cloudflare/kv/namespace.provider.js.map +1 -0
  179. package/lib/cloudflare/live.d.ts +11 -0
  180. package/lib/cloudflare/live.d.ts.map +1 -0
  181. package/lib/cloudflare/live.js +18 -0
  182. package/lib/cloudflare/live.js.map +1 -0
  183. package/lib/cloudflare/r2/bucket.binding.d.ts +8 -0
  184. package/lib/cloudflare/r2/bucket.binding.d.ts.map +1 -0
  185. package/lib/cloudflare/r2/bucket.binding.js +18 -0
  186. package/lib/cloudflare/r2/bucket.binding.js.map +1 -0
  187. package/lib/cloudflare/r2/bucket.client.d.ts +8 -0
  188. package/lib/cloudflare/r2/bucket.client.d.ts.map +1 -0
  189. package/lib/cloudflare/r2/bucket.client.js +9 -0
  190. package/lib/cloudflare/r2/bucket.client.js.map +1 -0
  191. package/lib/cloudflare/r2/bucket.d.ts +32 -0
  192. package/lib/cloudflare/r2/bucket.d.ts.map +1 -0
  193. package/lib/cloudflare/r2/bucket.del.d.ts +4 -0
  194. package/lib/cloudflare/r2/bucket.del.d.ts.map +1 -0
  195. package/lib/cloudflare/r2/bucket.del.js +7 -0
  196. package/lib/cloudflare/r2/bucket.del.js.map +1 -0
  197. package/lib/cloudflare/r2/bucket.get.d.ts +5 -0
  198. package/lib/cloudflare/r2/bucket.get.d.ts.map +1 -0
  199. package/lib/cloudflare/r2/bucket.get.js +7 -0
  200. package/lib/cloudflare/r2/bucket.get.js.map +1 -0
  201. package/lib/cloudflare/r2/bucket.head.d.ts +4 -0
  202. package/lib/cloudflare/r2/bucket.head.d.ts.map +1 -0
  203. package/lib/cloudflare/r2/bucket.head.js +7 -0
  204. package/lib/cloudflare/r2/bucket.head.js.map +1 -0
  205. package/lib/cloudflare/r2/bucket.js +3 -0
  206. package/lib/cloudflare/r2/bucket.js.map +1 -0
  207. package/lib/cloudflare/r2/bucket.list.d.ts +5 -0
  208. package/lib/cloudflare/r2/bucket.list.d.ts.map +1 -0
  209. package/lib/cloudflare/r2/bucket.list.js +7 -0
  210. package/lib/cloudflare/r2/bucket.list.js.map +1 -0
  211. package/lib/cloudflare/r2/bucket.multipart.d.ts +19 -0
  212. package/lib/cloudflare/r2/bucket.multipart.d.ts.map +1 -0
  213. package/lib/cloudflare/r2/bucket.multipart.js +25 -0
  214. package/lib/cloudflare/r2/bucket.multipart.js.map +1 -0
  215. package/lib/cloudflare/r2/bucket.provider.d.ts +5 -0
  216. package/lib/cloudflare/r2/bucket.provider.d.ts.map +1 -0
  217. package/lib/cloudflare/r2/bucket.provider.js +66 -0
  218. package/lib/cloudflare/r2/bucket.provider.js.map +1 -0
  219. package/lib/cloudflare/r2/bucket.put.d.ts +6 -0
  220. package/lib/cloudflare/r2/bucket.put.d.ts.map +1 -0
  221. package/lib/cloudflare/r2/bucket.put.js +8 -0
  222. package/lib/cloudflare/r2/bucket.put.js.map +1 -0
  223. package/lib/cloudflare/r2/index.d.ts +10 -0
  224. package/lib/cloudflare/r2/index.d.ts.map +1 -0
  225. package/lib/cloudflare/r2/index.js +10 -0
  226. package/lib/cloudflare/r2/index.js.map +1 -0
  227. package/lib/cloudflare/stream.d.ts +10 -0
  228. package/lib/cloudflare/stream.d.ts.map +1 -0
  229. package/lib/cloudflare/stream.js +16 -0
  230. package/lib/cloudflare/stream.js.map +1 -0
  231. package/lib/cloudflare/worker/assets.fetch.d.ts +8 -0
  232. package/lib/cloudflare/worker/assets.fetch.d.ts.map +1 -0
  233. package/lib/cloudflare/worker/assets.fetch.js +11 -0
  234. package/lib/cloudflare/worker/assets.fetch.js.map +1 -0
  235. package/lib/cloudflare/worker/assets.provider.d.ts +66 -0
  236. package/lib/cloudflare/worker/assets.provider.d.ts.map +1 -0
  237. package/lib/cloudflare/worker/assets.provider.js +145 -0
  238. package/lib/cloudflare/worker/assets.provider.js.map +1 -0
  239. package/lib/cloudflare/worker/index.d.ts +6 -0
  240. package/lib/cloudflare/worker/index.d.ts.map +1 -0
  241. package/lib/cloudflare/worker/index.js +5 -0
  242. package/lib/cloudflare/worker/index.js.map +1 -0
  243. package/lib/cloudflare/worker/worker.d.ts +67 -0
  244. package/lib/cloudflare/worker/worker.d.ts.map +1 -0
  245. package/lib/cloudflare/worker/worker.handler.d.ts +11 -0
  246. package/lib/cloudflare/worker/worker.handler.d.ts.map +1 -0
  247. package/lib/cloudflare/worker/worker.handler.js +15 -0
  248. package/lib/cloudflare/worker/worker.handler.js.map +1 -0
  249. package/lib/cloudflare/worker/worker.js +4 -0
  250. package/lib/cloudflare/worker/worker.js.map +1 -0
  251. package/lib/cloudflare/worker/worker.provider.d.ts +10 -0
  252. package/lib/cloudflare/worker/worker.provider.d.ts.map +1 -0
  253. package/lib/cloudflare/worker/worker.provider.js +193 -0
  254. package/lib/cloudflare/worker/worker.provider.js.map +1 -0
  255. package/lib/cloudflare/worker/worker.serve.d.ts +39 -0
  256. package/lib/cloudflare/worker/worker.serve.d.ts.map +1 -0
  257. package/lib/cloudflare/worker/worker.serve.js +4 -0
  258. package/lib/cloudflare/worker/worker.serve.js.map +1 -0
  259. package/lib/destroy.d.ts +1 -3
  260. package/lib/destroy.d.ts.map +1 -1
  261. package/lib/destroy.js +5 -0
  262. package/lib/destroy.js.map +1 -1
  263. package/lib/dot-alchemy.d.ts +3 -2
  264. package/lib/dot-alchemy.d.ts.map +1 -1
  265. package/lib/dot-alchemy.js +3 -2
  266. package/lib/dot-alchemy.js.map +1 -1
  267. package/lib/esbuild.d.ts +28 -0
  268. package/lib/esbuild.d.ts.map +1 -0
  269. package/lib/esbuild.js +63 -0
  270. package/lib/esbuild.js.map +1 -0
  271. package/lib/index.d.ts +1 -3
  272. package/lib/index.d.ts.map +1 -1
  273. package/lib/index.js +4 -3
  274. package/lib/index.js.map +1 -1
  275. package/lib/plan.d.ts +19 -8
  276. package/lib/plan.d.ts.map +1 -1
  277. package/lib/plan.js +144 -72
  278. package/lib/plan.js.map +1 -1
  279. package/lib/policy.d.ts +19 -1
  280. package/lib/policy.d.ts.map +1 -1
  281. package/lib/policy.js +10 -1
  282. package/lib/policy.js.map +1 -1
  283. package/lib/provider.d.ts +2 -2
  284. package/lib/provider.d.ts.map +1 -1
  285. package/lib/resource.d.ts +2 -10
  286. package/lib/resource.d.ts.map +1 -1
  287. package/lib/resource.js +1 -0
  288. package/lib/resource.js.map +1 -1
  289. package/lib/runtime.d.ts +1 -1
  290. package/lib/runtime.d.ts.map +1 -1
  291. package/lib/schema.d.ts +37 -0
  292. package/lib/schema.d.ts.map +1 -0
  293. package/lib/schema.js +61 -0
  294. package/lib/schema.js.map +1 -0
  295. package/lib/sha256.d.ts +5 -0
  296. package/lib/sha256.d.ts.map +1 -0
  297. package/lib/sha256.js +16 -0
  298. package/lib/sha256.js.map +1 -0
  299. package/lib/state.d.ts +3 -2
  300. package/lib/state.d.ts.map +1 -1
  301. package/lib/state.js +3 -2
  302. package/lib/state.js.map +1 -1
  303. package/lib/tags.d.ts +17 -0
  304. package/lib/tags.d.ts.map +1 -0
  305. package/lib/tags.js +22 -0
  306. package/lib/tags.js.map +1 -0
  307. package/lib/test.d.ts +14 -0
  308. package/lib/test.d.ts.map +1 -0
  309. package/lib/test.js +28 -0
  310. package/lib/test.js.map +1 -0
  311. package/lib/tsconfig.test.tsbuildinfo +1 -0
  312. package/lib/type.d.ts +3 -0
  313. package/lib/type.d.ts.map +1 -0
  314. package/lib/type.js +3 -0
  315. package/lib/type.js.map +1 -0
  316. package/package.json +48 -3
  317. package/src/app.ts +8 -7
  318. package/src/apply.ts +251 -93
  319. package/src/aws/account.ts +6 -4
  320. package/src/aws/arn.ts +1 -7
  321. package/src/aws/client.ts +15 -1
  322. package/src/aws/credentials.ts +1 -0
  323. package/src/aws/dynamodb/attribute-value.ts +240 -0
  324. package/src/aws/{sqs/queue.client.ts → dynamodb/client.ts} +9 -9
  325. package/src/aws/dynamodb/expr.ts +90 -0
  326. package/src/aws/dynamodb/index.ts +12 -0
  327. package/src/aws/dynamodb/projection.ts +159 -0
  328. package/src/aws/dynamodb/secondary-index.ts +45 -0
  329. package/src/aws/dynamodb/table.get-item.ts +177 -0
  330. package/src/aws/dynamodb/table.provider.ts +280 -0
  331. package/src/aws/dynamodb/table.ts +156 -0
  332. package/src/aws/ec2/client.ts +20 -0
  333. package/src/aws/ec2/index.ts +3 -0
  334. package/src/aws/ec2/vpc.provider.ts +285 -0
  335. package/src/aws/ec2/vpc.ts +152 -0
  336. package/src/aws/index.ts +15 -16
  337. package/src/aws/lambda/client.ts +14 -0
  338. package/src/aws/lambda/consume.ts +0 -1
  339. package/src/aws/lambda/function.invoke.ts +2 -2
  340. package/src/aws/lambda/function.provider.ts +197 -105
  341. package/src/aws/lambda/function.ts +16 -10
  342. package/src/aws/lambda/index.ts +1 -4
  343. package/src/aws/lambda/serve.ts +1 -1
  344. package/src/aws/region.ts +3 -1
  345. package/src/aws/sqs/client.ts +20 -0
  346. package/src/aws/sqs/index.ts +2 -1
  347. package/src/aws/sqs/queue.consume.ts +1 -34
  348. package/src/aws/sqs/queue.event-source.ts +253 -0
  349. package/src/aws/sqs/queue.provider.ts +4 -4
  350. package/src/aws/sqs/queue.send-message.ts +2 -2
  351. package/src/binding.ts +121 -25
  352. package/src/capability.ts +44 -0
  353. package/src/cli/components/Plan.tsx +4 -2
  354. package/src/cli/progress.tsx +1 -0
  355. package/src/cloudflare/api.ts +141 -61
  356. package/src/cloudflare/context.ts +49 -0
  357. package/src/cloudflare/index.ts +6 -4
  358. package/src/cloudflare/kv/index.ts +3 -0
  359. package/src/cloudflare/kv/namespace.binding.ts +25 -0
  360. package/src/cloudflare/kv/namespace.client.ts +70 -0
  361. package/src/cloudflare/kv/namespace.provider.ts +99 -0
  362. package/src/cloudflare/kv/namespace.ts +29 -0
  363. package/src/cloudflare/live.ts +38 -0
  364. package/src/cloudflare/r2/bucket.binding.ts +27 -0
  365. package/src/cloudflare/r2/bucket.client.ts +22 -0
  366. package/src/cloudflare/r2/bucket.del.ts +11 -0
  367. package/src/cloudflare/r2/bucket.get.ts +13 -0
  368. package/src/cloudflare/r2/bucket.head.ts +11 -0
  369. package/src/cloudflare/r2/bucket.list.ts +12 -0
  370. package/src/cloudflare/r2/bucket.multipart.ts +55 -0
  371. package/src/cloudflare/r2/bucket.provider.ts +83 -0
  372. package/src/cloudflare/r2/bucket.put.ts +17 -0
  373. package/src/cloudflare/r2/bucket.ts +38 -0
  374. package/src/cloudflare/r2/index.ts +9 -0
  375. package/src/cloudflare/stream.ts +21 -0
  376. package/src/cloudflare/worker/assets.fetch.ts +27 -0
  377. package/src/cloudflare/worker/assets.provider.ts +249 -0
  378. package/src/cloudflare/worker/index.ts +6 -0
  379. package/src/cloudflare/worker/worker.handler.ts +39 -0
  380. package/src/cloudflare/worker/worker.provider.ts +246 -0
  381. package/src/cloudflare/worker/worker.serve.ts +19 -0
  382. package/src/cloudflare/worker/worker.ts +76 -0
  383. package/src/destroy.ts +6 -3
  384. package/src/dot-alchemy.ts +3 -2
  385. package/src/esbuild.ts +98 -0
  386. package/src/index.ts +5 -4
  387. package/src/plan.ts +233 -120
  388. package/src/policy.ts +55 -2
  389. package/src/provider.ts +2 -2
  390. package/src/resource.ts +3 -2
  391. package/src/runtime.ts +1 -1
  392. package/src/schema.ts +102 -0
  393. package/src/sha256.ts +23 -0
  394. package/src/state.ts +3 -2
  395. package/src/tags.ts +38 -0
  396. package/src/test.ts +71 -0
  397. package/src/type.ts +2 -0
  398. package/lib/aws/lambda/function.client.d.ts +0 -8
  399. package/lib/aws/lambda/function.client.d.ts.map +0 -1
  400. package/lib/aws/lambda/function.client.js +0 -7
  401. package/lib/aws/lambda/function.client.js.map +0 -1
  402. package/lib/aws/sqs/queue.client.d.ts +0 -12
  403. package/lib/aws/sqs/queue.client.d.ts.map +0 -1
  404. package/lib/aws/sqs/queue.client.js.map +0 -1
  405. package/lib/cloudflare/kv.d.ts +0 -29
  406. package/lib/cloudflare/kv.d.ts.map +0 -1
  407. package/lib/cloudflare/kv.js +0 -3
  408. package/lib/cloudflare/kv.js.map +0 -1
  409. package/lib/cloudflare/kv.provider.d.ts +0 -4
  410. package/lib/cloudflare/kv.provider.d.ts.map +0 -1
  411. package/lib/cloudflare/kv.provider.js +0 -39
  412. package/lib/cloudflare/kv.provider.js.map +0 -1
  413. package/lib/cloudflare/worker.d.ts +0 -33
  414. package/lib/cloudflare/worker.d.ts.map +0 -1
  415. package/lib/cloudflare/worker.js +0 -4
  416. package/lib/cloudflare/worker.js.map +0 -1
  417. package/src/aws/lambda/function.client.ts +0 -14
  418. package/src/cloudflare/kv.provider.ts +0 -51
  419. package/src/cloudflare/kv.ts +0 -20
  420. package/src/cloudflare/worker.ts +0 -34
@@ -1,72 +1,152 @@
1
- import * as cf from "cloudflare";
1
+ import { APIConnectionError, Cloudflare, type APIError } from "cloudflare";
2
+ import {
3
+ isRequestOptions,
4
+ type APIPromise,
5
+ type RequestOptions,
6
+ } from "cloudflare/core";
7
+ import type { ErrorData } from "cloudflare/resources";
8
+ import { Layer } from "effect";
2
9
  import * as Context from "effect/Context";
10
+ import * as Data from "effect/Data";
3
11
  import * as Effect from "effect/Effect";
4
- import * as Layer from "effect/Layer";
5
- import * as Option from "effect/Option";
6
12
 
7
- export class CloudflareApi extends Context.Tag("CloudflareApi")<
8
- CloudflareApi,
9
- cf.Cloudflare
10
- >() {}
11
-
12
- export class CloudflareAccountId extends Context.Tag("CloudflareAccountId")<
13
+ export class CloudflareAccountId extends Context.Tag("cloudflare/account-id")<
13
14
  CloudflareAccountId,
14
15
  string
15
- >() {}
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
+ }
16
28
 
17
- export class CloudflareEmail extends Context.Tag("CloudflareEmail")<
18
- CloudflareEmail,
19
- string
20
- >() {}
29
+ export class CloudflareApi extends Effect.Service<CloudflareApi>()(
30
+ "cloudflare/api",
31
+ {
32
+ effect: (options?: {
33
+ baseUrl?: string;
34
+ apiToken?: string;
35
+ apiKey?: string;
36
+ 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
+ ),
48
+ },
49
+ ) {}
21
50
 
22
- export class CloudflareApiKey extends Context.Tag("CloudflareApiKey")<
23
- CloudflareApiKey,
24
- string
25
- >() {}
51
+ export class CloudflareApiError extends Data.Error<{
52
+ _tag:
53
+ | "Connection"
54
+ | "BadRequest"
55
+ | "Authentication"
56
+ | "PermissionDenied"
57
+ | "NotFound"
58
+ | "Conflict"
59
+ | "UnprocessableEntity"
60
+ | "RateLimit"
61
+ | "InternalServerError"
62
+ | "Unknown";
63
+ message: string;
64
+ errors: ErrorData[];
65
+ cause: APIError;
66
+ }> {
67
+ static from(cause: APIError): CloudflareApiError {
68
+ const error = new CloudflareApiError({
69
+ _tag: CloudflareApiError.getTag(cause),
70
+ message: cause.message,
71
+ errors: cause.errors,
72
+ cause: cause,
73
+ });
74
+ return error;
75
+ }
26
76
 
27
- export class CloudflareApiToken extends Context.Tag("CloudflareApiToken")<
28
- CloudflareApiToken,
29
- string
30
- >() {}
77
+ private static getTag(error: APIError): CloudflareApiError["_tag"] {
78
+ if (error instanceof APIConnectionError) {
79
+ return "Connection";
80
+ }
81
+ switch (error.status) {
82
+ case 400:
83
+ return "BadRequest";
84
+ case 401:
85
+ return "Authentication";
86
+ case 403:
87
+ return "PermissionDenied";
88
+ case 404:
89
+ return "NotFound";
90
+ case 409:
91
+ return "Conflict";
92
+ case 422:
93
+ return "UnprocessableEntity";
94
+ case 429:
95
+ return "RateLimit";
96
+ case 500:
97
+ return "InternalServerError";
98
+ default:
99
+ return "Unknown";
100
+ }
101
+ }
102
+ }
31
103
 
32
- export class CloudflareBaseUrl extends Context.Tag("CloudflareBaseUrl")<
33
- CloudflareBaseUrl,
34
- string
35
- >() {}
104
+ type ToEffect<T> = {
105
+ [K in keyof T]: T[K] extends (...args: any[]) => any
106
+ ? (
107
+ ...args: Parameters<T[K]>
108
+ ) => Effect.Effect<UnwrapAPIPromise<ReturnType<T[K]>>, CloudflareApiError>
109
+ : T[K] extends Record<string, any>
110
+ ? ToEffect<T[K]>
111
+ : T[K];
112
+ };
36
113
 
37
- const tryGet = <Tag extends Context.Tag<any, any>>(
38
- tag: Tag,
39
- defaultValue: Tag["Service"] | undefined,
40
- ) =>
41
- Effect.gen(function* () {
42
- const value = yield* Effect.serviceOption(tag);
43
- return Option.getOrElse(value, () => defaultValue);
44
- });
114
+ type UnwrapAPIPromise<T> = T extends APIPromise<infer U> ? U : never;
45
115
 
46
- export const cloudflareApi = Layer.effect(
47
- CloudflareApi,
48
- Effect.gen(function* () {
49
- const email = yield* tryGet(
50
- CloudflareEmail,
51
- import.meta.env.CLOUDFLARE_EMAIL,
52
- );
53
- const apiKey = yield* tryGet(
54
- CloudflareApiKey,
55
- import.meta.env.CLOUDFLARE_API_KEY,
56
- );
57
- const apiToken = yield* tryGet(
58
- CloudflareApiToken,
59
- import.meta.env.CLOUDFLARE_API_TOKEN,
60
- );
61
- const baseURL = yield* tryGet(
62
- CloudflareBaseUrl,
63
- import.meta.env.CLOUDFLARE_BASE_URL,
64
- );
65
- return new cf.Cloudflare({
66
- apiEmail: email,
67
- apiKey: apiKey,
68
- apiToken: apiToken,
69
- baseURL: baseURL,
70
- });
71
- }),
72
- );
116
+ const createRecursiveProxy = <T extends object>(target: T): ToEffect<T> => {
117
+ return new Proxy(target as any, {
118
+ get(target, prop, receiver) {
119
+ const value = Reflect.get(target, prop, receiver);
120
+ if (typeof value === "function") {
121
+ return Effect.fnUntraced(function* (...args: any[]) {
122
+ return yield* Effect.tryPromise({
123
+ try: async (signal) => {
124
+ let modifiedArgs: any[];
125
+ if (isRequestOptions(args[args.length - 1])) {
126
+ const options = args[args.length - 1] as RequestOptions;
127
+ modifiedArgs = [
128
+ ...args.slice(0, -1),
129
+ {
130
+ ...options,
131
+ signal: options?.signal
132
+ ? AbortSignal.any([signal, options.signal])
133
+ : signal,
134
+ },
135
+ ];
136
+ } else {
137
+ modifiedArgs = [...args, { signal }];
138
+ }
139
+ const result = await value.apply(target, modifiedArgs);
140
+ return result;
141
+ },
142
+ catch: (cause) => {
143
+ const error = CloudflareApiError.from(cause as APIError);
144
+ return error;
145
+ },
146
+ });
147
+ });
148
+ }
149
+ return createRecursiveProxy(value);
150
+ },
151
+ });
152
+ };
@@ -0,0 +1,49 @@
1
+ import type { ExecutionContext } from "@cloudflare/workers-types";
2
+ import * as Context from "effect/Context";
3
+ import * as Data from "effect/Data";
4
+ import * as Effect from "effect/Effect";
5
+
6
+ export class CloudflareContext extends Context.Tag("Cloudflare.Context")<
7
+ CloudflareContext,
8
+ {
9
+ env: unknown;
10
+ ctx: ExecutionContext;
11
+ }
12
+ >() {}
13
+
14
+ export const getCloudflareEnvKey = Effect.fnUntraced(function* <T>(
15
+ key: string,
16
+ ) {
17
+ return yield* Effect.serviceOptional(CloudflareContext).pipe(
18
+ Effect.mapError(
19
+ () =>
20
+ new CloudflareContextNotFound({
21
+ message: "Cloudflare context not found",
22
+ }),
23
+ ),
24
+ Effect.flatMap((context) => {
25
+ const env = context.env as Record<string, unknown>;
26
+ if (!(key in env)) {
27
+ return new CloudflareContextKeyNotFound({
28
+ message: `${key} is not set in cloudflare context (found ${Object.keys(env).join(", ")})`,
29
+ key,
30
+ });
31
+ }
32
+ return Effect.succeed(env[key] as T);
33
+ }),
34
+ Effect.orDie,
35
+ );
36
+ });
37
+
38
+ export class CloudflareContextNotFound extends Data.TaggedError(
39
+ "Cloudflare.Context.NotFound",
40
+ )<{
41
+ message: string;
42
+ }> {}
43
+
44
+ export class CloudflareContextKeyNotFound extends Data.TaggedError(
45
+ "Cloudflare.Context.KeyNotFound",
46
+ )<{
47
+ message: string;
48
+ key: string;
49
+ }> {}
@@ -1,4 +1,6 @@
1
- export * from "./api.ts";
2
- export * from "./kv.provider.ts";
3
- export * from "./kv.ts";
4
- export * from "./worker.ts";
1
+ export * as KV from "./kv/index.ts";
2
+ export * as R2 from "./r2/index.ts";
3
+ export * as Assets from "./worker/assets.fetch.ts";
4
+ export * as Worker from "./worker/index.ts";
5
+
6
+ export type * as Alchemy from "../index.ts";
@@ -0,0 +1,3 @@
1
+ export * from "./namespace.binding.ts";
2
+ export * from "./namespace.client.ts";
3
+ export * from "./namespace.ts";
@@ -0,0 +1,25 @@
1
+ import { Binding, type Capability, type To } from "alchemy-effect";
2
+ import { Worker } from "../worker/worker.ts";
3
+ import type { Namespace, NamespaceProps } from "./namespace.ts";
4
+
5
+ export interface Bind<B = Namespace<string, NamespaceProps>>
6
+ extends Capability<"Cloudflare.KV.Namespace.Bind", B> {}
7
+
8
+ export const Bind = Binding<
9
+ <B extends Namespace<string, NamespaceProps>>(
10
+ namespace: B,
11
+ ) => Binding<Worker, Bind<To<B>>>
12
+ >(Worker, "Cloudflare.KV.Namespace.Bind");
13
+
14
+ export const bindFromWorker = () =>
15
+ Bind.provider.succeed({
16
+ attach: ({ source }) => ({
17
+ bindings: [
18
+ {
19
+ type: "kv_namespace",
20
+ name: source.id,
21
+ namespace_id: source.attr.namespaceId,
22
+ },
23
+ ],
24
+ }),
25
+ });
@@ -0,0 +1,70 @@
1
+ import type * as runtime from "@cloudflare/workers-types";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Stream from "effect/Stream";
4
+ import { declare, type To } from "../../policy.ts";
5
+ import { getCloudflareEnvKey } from "../context.ts";
6
+ import { replaceEffectStream } from "../stream.ts";
7
+ import { Bind } from "./namespace.binding.ts";
8
+ import type * as KV from "./namespace.ts";
9
+
10
+ export const get = Effect.fnUntraced(function* <KV extends KV.Namespace>(
11
+ namespace: KV,
12
+ key: string,
13
+ ) {
14
+ const client = yield* getKvNamespaceFromEnv(namespace);
15
+ return yield* Effect.promise(() => client.get(key));
16
+ });
17
+
18
+ export const getWithMetadata = Effect.fnUntraced(function* <
19
+ KV extends KV.Namespace,
20
+ Metadata = unknown,
21
+ >(
22
+ namespace: KV,
23
+ key: string,
24
+ options?: runtime.KVNamespaceGetOptions<undefined>,
25
+ ) {
26
+ const client = yield* getKvNamespaceFromEnv(namespace);
27
+ return yield* Effect.promise(() =>
28
+ client.getWithMetadata<Metadata>(key, options),
29
+ );
30
+ });
31
+
32
+ export const put = Effect.fnUntraced(function* <KV extends KV.Namespace>(
33
+ namespace: KV,
34
+ key: string,
35
+ value:
36
+ | string
37
+ | ArrayBuffer
38
+ | ArrayBufferView
39
+ | runtime.ReadableStream
40
+ | Stream.Stream<any>,
41
+ options?: runtime.KVNamespacePutOptions,
42
+ ) {
43
+ const client = yield* getKvNamespaceFromEnv(namespace);
44
+ return yield* Effect.promise(() =>
45
+ client.put(key, replaceEffectStream(value), options),
46
+ );
47
+ });
48
+
49
+ export const del = Effect.fnUntraced(function* <KV extends KV.Namespace>(
50
+ namespace: KV,
51
+ key: string,
52
+ ) {
53
+ const client = yield* getKvNamespaceFromEnv(namespace);
54
+ return yield* Effect.promise(() => client.delete(key));
55
+ });
56
+
57
+ export const list = Effect.fnUntraced(function* <
58
+ KV extends KV.Namespace,
59
+ Metadata = unknown,
60
+ >(namespace: KV, options?: runtime.KVNamespaceListOptions) {
61
+ const client = yield* getKvNamespaceFromEnv(namespace);
62
+ return yield* Effect.promise(() => client.list<Metadata>(options));
63
+ });
64
+
65
+ const getKvNamespaceFromEnv = Effect.fnUntraced(function* <
66
+ KV extends KV.Namespace,
67
+ >(namespace: KV) {
68
+ yield* declare<Bind<To<KV>>>();
69
+ return yield* getCloudflareEnvKey<runtime.KVNamespace>(namespace.id);
70
+ });
@@ -0,0 +1,99 @@
1
+ import type { KV } from "cloudflare/resources";
2
+ import * as Effect from "effect/Effect";
3
+ import { App } from "../../app.ts";
4
+ import { CloudflareAccountId, CloudflareApi } from "../api.ts";
5
+ import {
6
+ Namespace,
7
+ type NamespaceAttr,
8
+ type NamespaceProps,
9
+ } from "./namespace.ts";
10
+
11
+ export const namespaceProvider = () =>
12
+ Namespace.provider.effect(
13
+ Effect.gen(function* () {
14
+ const app = yield* App;
15
+ const api = yield* CloudflareApi;
16
+ const accountId = yield* CloudflareAccountId;
17
+
18
+ const createTitle = (id: string, news: NamespaceProps) =>
19
+ news.title ?? `${app.name}-${id}-${app.stage}`;
20
+
21
+ const mapResult = <Props extends NamespaceProps>(
22
+ result: KV.Namespace,
23
+ ): NamespaceAttr<Props> => ({
24
+ title: result.title,
25
+ namespaceId: result.id,
26
+ supportsUrlEncoding: result.supports_url_encoding,
27
+ accountId,
28
+ });
29
+
30
+ return {
31
+ diff: ({ id, news, output }) =>
32
+ Effect.sync(() => {
33
+ if (output.accountId !== accountId) {
34
+ return { action: "replace" };
35
+ }
36
+ const title = createTitle(id, news);
37
+ if (title !== output.title) {
38
+ return { action: "update" };
39
+ }
40
+ }),
41
+ create: Effect.fn(function* ({ id, news }) {
42
+ return yield* api.kv.namespaces
43
+ .create({
44
+ account_id: accountId,
45
+ title: createTitle(id, news),
46
+ })
47
+ .pipe(Effect.map(mapResult<NamespaceProps>));
48
+ }),
49
+ update: Effect.fn(function* ({ id, news, output }) {
50
+ return yield* api.kv.namespaces
51
+ .update(output.namespaceId, {
52
+ account_id: accountId,
53
+ title: createTitle(id, news),
54
+ })
55
+ .pipe(Effect.map(mapResult<NamespaceProps>));
56
+ }),
57
+ delete: Effect.fn(function* ({ output }) {
58
+ yield* api.kv.namespaces
59
+ .delete(output.namespaceId, {
60
+ account_id: output.accountId,
61
+ })
62
+ .pipe(Effect.catchTag("NotFound", () => Effect.void));
63
+ }),
64
+ read: Effect.fn(function* ({ id, olds, output }) {
65
+ if (output?.namespaceId) {
66
+ return yield* api.kv.namespaces
67
+ .get(output.namespaceId, {
68
+ account_id: output.accountId,
69
+ })
70
+ .pipe(
71
+ Effect.map(mapResult<NamespaceProps>),
72
+ Effect.catchTag("NotFound", () => Effect.succeed(undefined)),
73
+ );
74
+ }
75
+ const title = createTitle(id, olds ?? {}); // why is olds optional?
76
+ let page = 1;
77
+ while (true) {
78
+ // todo: abstract pagination
79
+ const namespaces = yield* api.kv.namespaces.list({
80
+ account_id: accountId,
81
+ page,
82
+ per_page: 100,
83
+ });
84
+ const match = namespaces.result.find(
85
+ (namespace) => namespace.title === title,
86
+ );
87
+ if (match) {
88
+ return mapResult<NamespaceProps>(match);
89
+ }
90
+ if (namespaces.nextPageInfo()) {
91
+ page++;
92
+ } else {
93
+ return undefined;
94
+ }
95
+ }
96
+ }),
97
+ };
98
+ }),
99
+ );
@@ -0,0 +1,29 @@
1
+ import { Resource } from "../../resource.ts";
2
+
3
+ export type NamespaceProps = {
4
+ title?: string;
5
+ };
6
+
7
+ export type NamespaceAttr<Props extends NamespaceProps> = {
8
+ title: Props["title"] extends string ? Props["title"] : string;
9
+ namespaceId: string;
10
+ supportsUrlEncoding?: boolean;
11
+ accountId: string;
12
+ };
13
+
14
+ export interface Namespace<
15
+ ID extends string = string,
16
+ Props extends NamespaceProps = NamespaceProps,
17
+ > extends Resource<
18
+ "Cloudflare.KV.Namespace",
19
+ ID,
20
+ Props,
21
+ NamespaceAttr<Props>
22
+ > {}
23
+
24
+ export const Namespace = Resource<{
25
+ <const ID extends string, const Props extends NamespaceProps>(
26
+ id: ID,
27
+ props: Props,
28
+ ): Namespace<ID, Props>;
29
+ }>("Cloudflare.KV.Namespace");
@@ -0,0 +1,38 @@
1
+ import * as Layer from "effect/Layer";
2
+ import * as ESBuild from "../esbuild.ts";
3
+ import { CloudflareAccountId, CloudflareApi } from "./api.ts";
4
+ import * as KV from "./kv/index.ts";
5
+ import { namespaceProvider } from "./kv/namespace.provider.ts";
6
+ import { bucketProvider } from "./r2/bucket.provider.ts";
7
+ import * as R2 from "./r2/index.ts";
8
+ import { assetsProvider } from "./worker/assets.provider.ts";
9
+ import { workerProvider } from "./worker/worker.provider.ts";
10
+
11
+ export const providers = () =>
12
+ Layer.mergeAll(
13
+ Layer.provideMerge(
14
+ workerProvider(),
15
+ Layer.mergeAll(ESBuild.layer(), assetsProvider()),
16
+ ),
17
+ namespaceProvider(),
18
+ bucketProvider(),
19
+ );
20
+
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 = () =>
28
+ defaultProviders().pipe(
29
+ Layer.provideMerge(
30
+ Layer.mergeAll(CloudflareAccountId.fromEnv, CloudflareApi.Default()),
31
+ ),
32
+ );
33
+
34
+ export default live;
35
+
36
+ // Layer.mergeAll
37
+ // Layer.provide
38
+ // Layer.provideMerge
@@ -0,0 +1,27 @@
1
+ import { Binding, type Capability, type To } from "alchemy-effect";
2
+ import { Worker } from "../worker/worker.ts";
3
+ import type { Bucket } from "./bucket.ts";
4
+
5
+ export interface Bind<B = Bucket>
6
+ extends Capability<"Cloudflare.R2.Bucket.Bind", B> {}
7
+
8
+ export const Bind = Binding<
9
+ <B extends Bucket>(bucket: B) => Binding<Worker, Bind<To<B>>>
10
+ >(Worker, "Cloudflare.R2.Bucket.Bind");
11
+
12
+ export const bindFromWorker = () =>
13
+ Bind.provider.succeed({
14
+ attach: ({ source }) => ({
15
+ bindings: [
16
+ {
17
+ type: "r2_bucket",
18
+ name: source.id,
19
+ bucket_name: source.attr.name,
20
+ jurisdiction:
21
+ source.attr.jurisdiction === "default"
22
+ ? undefined
23
+ : source.attr.jurisdiction,
24
+ },
25
+ ],
26
+ }),
27
+ });
@@ -0,0 +1,22 @@
1
+ import type * as runtime from "@cloudflare/workers-types";
2
+ import * as Effect from "effect/Effect";
3
+ import type * as Stream from "effect/Stream";
4
+ import { declare, type To } from "../../policy.ts";
5
+ import { getCloudflareEnvKey } from "../context.ts";
6
+ import { Bind } from "./bucket.binding.ts";
7
+ import type { Bucket } from "./bucket.ts";
8
+
9
+ export const getR2BucketFromEnv = Effect.fnUntraced(function* <
10
+ B extends Bucket,
11
+ >(bucket: B) {
12
+ yield* declare<Bind<To<B>>>();
13
+ return yield* getCloudflareEnvKey<runtime.R2Bucket>(bucket.id);
14
+ });
15
+
16
+ export type UploadValue =
17
+ | string
18
+ | ArrayBuffer
19
+ | ArrayBufferView
20
+ | runtime.Blob
21
+ | runtime.ReadableStream
22
+ | Stream.Stream<any>;
@@ -0,0 +1,11 @@
1
+ import * as Effect from "effect/Effect";
2
+ import { getR2BucketFromEnv } from "./bucket.client.ts";
3
+ import type { Bucket } from "./bucket.ts";
4
+
5
+ export const del = Effect.fnUntraced(function* <B extends Bucket>(
6
+ bucket: B,
7
+ keys: string | string[],
8
+ ) {
9
+ const client = yield* getR2BucketFromEnv(bucket);
10
+ return yield* Effect.promise(() => client.delete(keys));
11
+ });
@@ -0,0 +1,13 @@
1
+ import type * as runtime from "@cloudflare/workers-types";
2
+ import * as Effect from "effect/Effect";
3
+ import { getR2BucketFromEnv } from "./bucket.client.ts";
4
+ import type { Bucket } from "./bucket.ts";
5
+
6
+ export const get = Effect.fnUntraced(function* <B extends Bucket>(
7
+ bucket: B,
8
+ key: string,
9
+ options?: runtime.R2GetOptions,
10
+ ) {
11
+ const client = yield* getR2BucketFromEnv(bucket);
12
+ return yield* Effect.promise(() => client.get(key, options));
13
+ });
@@ -0,0 +1,11 @@
1
+ import * as Effect from "effect/Effect";
2
+ import { getR2BucketFromEnv } from "./bucket.client.ts";
3
+ import type { Bucket } from "./bucket.ts";
4
+
5
+ export const head = Effect.fnUntraced(function* <B extends Bucket>(
6
+ bucket: B,
7
+ key: string,
8
+ ) {
9
+ const client = yield* getR2BucketFromEnv(bucket);
10
+ return yield* Effect.promise(() => client.head(key));
11
+ });
@@ -0,0 +1,12 @@
1
+ import type * as runtime from "@cloudflare/workers-types";
2
+ import * as Effect from "effect/Effect";
3
+ import { getR2BucketFromEnv } from "./bucket.client.ts";
4
+ import type { Bucket } from "./bucket.ts";
5
+
6
+ export const list = Effect.fnUntraced(function* <B extends Bucket>(
7
+ bucket: B,
8
+ options?: runtime.R2ListOptions,
9
+ ) {
10
+ const client = yield* getR2BucketFromEnv(bucket);
11
+ return yield* Effect.promise(() => client.list(options));
12
+ });