alchemy-effect 0.0.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 (494) hide show
  1. package/README.md +179 -0
  2. package/bin/alchemy-effect.js +15 -0
  3. package/bin/alchemy-effect.js.map +1 -0
  4. package/bin/alchemy-effect.ts +10 -0
  5. package/lib/app.d.ts +7 -2
  6. package/lib/app.d.ts.map +1 -1
  7. package/lib/app.js +1 -0
  8. package/lib/app.js.map +1 -1
  9. package/lib/apply.d.ts +57 -1
  10. package/lib/apply.d.ts.map +1 -1
  11. package/lib/apply.js +141 -55
  12. package/lib/apply.js.map +1 -1
  13. package/lib/aws/account.d.ts +18 -0
  14. package/lib/aws/account.d.ts.map +1 -0
  15. package/lib/aws/account.js +18 -0
  16. package/lib/aws/account.js.map +1 -0
  17. package/lib/aws/arn.d.ts +2 -0
  18. package/lib/aws/arn.d.ts.map +1 -0
  19. package/lib/aws/arn.js +1 -0
  20. package/lib/aws/arn.js.map +1 -0
  21. package/lib/aws/assets.d.ts +8 -0
  22. package/lib/aws/assets.d.ts.map +1 -0
  23. package/lib/aws/assets.js +4 -0
  24. package/lib/aws/assets.js.map +1 -0
  25. package/lib/aws/bundle.d.ts +4 -0
  26. package/lib/aws/bundle.d.ts.map +1 -0
  27. package/lib/aws/bundle.js +4 -0
  28. package/lib/aws/bundle.js.map +1 -0
  29. package/lib/aws/client.d.ts +8 -0
  30. package/lib/aws/client.d.ts.map +1 -0
  31. package/lib/aws/client.js +28 -0
  32. package/lib/aws/client.js.map +1 -0
  33. package/lib/aws/credentials.d.ts +146 -0
  34. package/lib/aws/credentials.d.ts.map +1 -0
  35. package/lib/aws/credentials.js +170 -0
  36. package/lib/aws/credentials.js.map +1 -0
  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/dynamodb/client.js +11 -0
  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 +9 -0
  50. package/lib/aws/dynamodb/index.d.ts.map +1 -0
  51. package/lib/aws/dynamodb/index.js +10 -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 +25 -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 +56 -0
  62. package/lib/aws/dynamodb/table.d.ts.map +1 -0
  63. package/lib/aws/dynamodb/table.get-item.d.ts +55 -0
  64. package/lib/aws/dynamodb/table.get-item.d.ts.map +1 -0
  65. package/lib/aws/dynamodb/table.get-item.js +75 -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 +8 -0
  70. package/lib/aws/dynamodb/table.provider.d.ts.map +1 -0
  71. package/lib/aws/dynamodb/table.provider.js +199 -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 +4 -0
  78. package/lib/aws/ec2/index.d.ts.map +1 -0
  79. package/lib/aws/ec2/index.js +4 -0
  80. package/lib/aws/ec2/index.js.map +1 -0
  81. package/lib/aws/ec2/vpc.d.ts +131 -0
  82. package/lib/aws/ec2/vpc.d.ts.map +1 -0
  83. package/lib/aws/ec2/vpc.js +3 -0
  84. package/lib/aws/ec2/vpc.js.map +1 -0
  85. package/lib/aws/ec2/vpc.provider.d.ts +7 -0
  86. package/lib/aws/ec2/vpc.provider.d.ts.map +1 -0
  87. package/lib/aws/ec2/vpc.provider.js +198 -0
  88. package/lib/aws/ec2/vpc.provider.js.map +1 -0
  89. package/lib/aws/iam.d.ts +23 -0
  90. package/lib/aws/iam.d.ts.map +1 -0
  91. package/lib/aws/iam.js +7 -0
  92. package/lib/aws/iam.js.map +1 -0
  93. package/lib/aws/index.d.ts +32 -0
  94. package/lib/aws/index.d.ts.map +1 -0
  95. package/lib/aws/index.js +23 -0
  96. package/lib/aws/index.js.map +1 -0
  97. package/lib/aws/lambda/client.d.ts +8 -0
  98. package/lib/aws/lambda/client.d.ts.map +1 -0
  99. package/lib/aws/lambda/client.js +7 -0
  100. package/lib/aws/lambda/client.js.map +1 -0
  101. package/lib/aws/lambda/consume.d.ts +17 -0
  102. package/lib/aws/lambda/consume.d.ts.map +1 -0
  103. package/lib/aws/lambda/consume.js +30 -0
  104. package/lib/aws/lambda/consume.js.map +1 -0
  105. package/lib/aws/lambda/function.d.ts +41 -0
  106. package/lib/aws/lambda/function.d.ts.map +1 -0
  107. package/lib/aws/lambda/function.handler.d.ts +7 -0
  108. package/lib/aws/lambda/function.handler.d.ts.map +1 -0
  109. package/lib/aws/lambda/function.handler.js +8 -0
  110. package/lib/aws/lambda/function.handler.js.map +1 -0
  111. package/lib/aws/lambda/function.invoke.d.ts +10 -0
  112. package/lib/aws/lambda/function.invoke.d.ts.map +1 -0
  113. package/lib/aws/lambda/function.invoke.js +31 -0
  114. package/lib/aws/lambda/function.invoke.js.map +1 -0
  115. package/lib/aws/lambda/function.js +3 -0
  116. package/lib/aws/lambda/function.js.map +1 -0
  117. package/lib/aws/lambda/function.provider.d.ts +9 -0
  118. package/lib/aws/lambda/function.provider.d.ts.map +1 -0
  119. package/lib/aws/lambda/function.provider.js +465 -0
  120. package/lib/aws/lambda/function.provider.js.map +1 -0
  121. package/lib/aws/lambda/index.d.ts +8 -0
  122. package/lib/aws/lambda/index.d.ts.map +1 -0
  123. package/lib/aws/lambda/index.js +9 -0
  124. package/lib/aws/lambda/index.js.map +1 -0
  125. package/lib/aws/lambda/serve.d.ts +14 -0
  126. package/lib/aws/lambda/serve.d.ts.map +1 -0
  127. package/lib/aws/lambda/serve.js +7 -0
  128. package/lib/aws/lambda/serve.js.map +1 -0
  129. package/lib/aws/parse-ini.d.ts +4 -0
  130. package/lib/aws/parse-ini.d.ts.map +1 -0
  131. package/lib/aws/parse-ini.js +67 -0
  132. package/lib/aws/parse-ini.js.map +1 -0
  133. package/lib/aws/profile.d.ts +6 -0
  134. package/lib/aws/profile.d.ts.map +1 -0
  135. package/lib/aws/profile.js +4 -0
  136. package/lib/aws/profile.js.map +1 -0
  137. package/lib/aws/region.d.ts +19 -0
  138. package/lib/aws/region.d.ts.map +1 -0
  139. package/lib/aws/region.js +21 -0
  140. package/lib/aws/region.js.map +1 -0
  141. package/lib/aws/s3.d.ts +8 -0
  142. package/lib/aws/s3.d.ts.map +1 -0
  143. package/lib/aws/s3.js +7 -0
  144. package/lib/aws/s3.js.map +1 -0
  145. package/lib/aws/sqs/client.d.ts +12 -0
  146. package/lib/aws/sqs/client.d.ts.map +1 -0
  147. package/lib/aws/sqs/client.js +11 -0
  148. package/lib/aws/sqs/client.js.map +1 -0
  149. package/lib/aws/sqs/index.d.ts +7 -0
  150. package/lib/aws/sqs/index.d.ts.map +1 -0
  151. package/lib/aws/sqs/index.js +7 -0
  152. package/lib/aws/sqs/index.js.map +1 -0
  153. package/lib/aws/sqs/queue.consume.d.ts +12 -0
  154. package/lib/aws/sqs/queue.consume.d.ts.map +1 -0
  155. package/lib/aws/sqs/queue.consume.js +3 -0
  156. package/lib/aws/sqs/queue.consume.js.map +1 -0
  157. package/lib/aws/sqs/queue.d.ts +79 -0
  158. package/lib/aws/sqs/queue.d.ts.map +1 -0
  159. package/lib/aws/sqs/queue.event-source.d.ts +20 -0
  160. package/lib/aws/sqs/queue.event-source.d.ts.map +1 -0
  161. package/lib/aws/sqs/queue.event-source.js +148 -0
  162. package/lib/aws/sqs/queue.event-source.js.map +1 -0
  163. package/lib/aws/sqs/queue.js +3 -0
  164. package/lib/aws/sqs/queue.js.map +1 -0
  165. package/lib/aws/sqs/queue.provider.d.ts +7 -0
  166. package/lib/aws/sqs/queue.provider.d.ts.map +1 -0
  167. package/lib/aws/sqs/queue.provider.js +79 -0
  168. package/lib/aws/sqs/queue.provider.js.map +1 -0
  169. package/lib/aws/sqs/queue.send-message.d.ts +11 -0
  170. package/lib/aws/sqs/queue.send-message.d.ts.map +1 -0
  171. package/lib/aws/sqs/queue.send-message.js +32 -0
  172. package/lib/aws/sqs/queue.send-message.js.map +1 -0
  173. package/lib/aws/sts.d.ts +8 -0
  174. package/lib/aws/sts.d.ts.map +1 -0
  175. package/lib/aws/sts.js +7 -0
  176. package/lib/aws/sts.js.map +1 -0
  177. package/lib/aws/zip.d.ts +3 -0
  178. package/lib/aws/zip.d.ts.map +1 -0
  179. package/lib/aws/zip.js +12 -0
  180. package/lib/aws/zip.js.map +1 -0
  181. package/lib/binding.d.ts +70 -22
  182. package/lib/binding.d.ts.map +1 -1
  183. package/lib/binding.js.map +1 -1
  184. package/lib/capability.d.ts +38 -0
  185. package/lib/capability.d.ts.map +1 -1
  186. package/lib/cli/approve.d.ts +4 -0
  187. package/lib/cli/approve.d.ts.map +1 -0
  188. package/lib/cli/approve.js +18 -0
  189. package/lib/cli/approve.js.map +1 -0
  190. package/lib/cli/clack.d.ts +14 -0
  191. package/lib/cli/clack.d.ts.map +1 -0
  192. package/lib/cli/clack.js +12 -0
  193. package/lib/cli/clack.js.map +1 -0
  194. package/lib/cli/components/ApprovePlan.d.ts +8 -0
  195. package/lib/cli/components/ApprovePlan.d.ts.map +1 -0
  196. package/lib/cli/components/ApprovePlan.js +30 -0
  197. package/lib/cli/components/ApprovePlan.js.map +1 -0
  198. package/lib/cli/components/Plan.d.ts +7 -0
  199. package/lib/cli/components/Plan.d.ts.map +1 -0
  200. package/lib/cli/components/Plan.js +100 -0
  201. package/lib/cli/components/Plan.js.map +1 -0
  202. package/lib/cli/components/PlanProgress.d.ts +9 -0
  203. package/lib/cli/components/PlanProgress.d.ts.map +1 -0
  204. package/lib/cli/components/PlanProgress.js +166 -0
  205. package/lib/cli/components/PlanProgress.js.map +1 -0
  206. package/lib/cli/index.d.ts +449 -0
  207. package/lib/cli/index.d.ts.map +1 -0
  208. package/lib/cli/index.js +39912 -0
  209. package/lib/cli/index.js.map +1 -0
  210. package/lib/cli/main.d.ts +2 -0
  211. package/lib/cli/main.d.ts.map +1 -0
  212. package/lib/cli/main.js +1 -0
  213. package/lib/cli/main.js.map +1 -0
  214. package/lib/cli/plan.d.ts +13 -0
  215. package/lib/cli/plan.d.ts.map +1 -0
  216. package/lib/cli/plan.js +1 -0
  217. package/lib/cli/plan.js.map +1 -0
  218. package/lib/cli/progress.d.ts +7 -0
  219. package/lib/cli/progress.d.ts.map +1 -0
  220. package/lib/cli/progress.js +30 -0
  221. package/lib/cli/progress.js.map +1 -0
  222. package/lib/cli/spinner.d.ts +2 -0
  223. package/lib/cli/spinner.d.ts.map +1 -0
  224. package/lib/cli/spinner.js +13 -0
  225. package/lib/cli/spinner.js.map +1 -0
  226. package/lib/cloudflare/api.d.ts +36 -0
  227. package/lib/cloudflare/api.d.ts.map +1 -0
  228. package/lib/cloudflare/api.js +99 -0
  229. package/lib/cloudflare/api.js.map +1 -0
  230. package/lib/cloudflare/context.d.ts +27 -0
  231. package/lib/cloudflare/context.d.ts.map +1 -0
  232. package/lib/cloudflare/context.js +24 -0
  233. package/lib/cloudflare/context.js.map +1 -0
  234. package/lib/cloudflare/index.d.ts +6 -0
  235. package/lib/cloudflare/index.d.ts.map +1 -0
  236. package/lib/cloudflare/index.js +5 -0
  237. package/lib/cloudflare/index.js.map +1 -0
  238. package/lib/cloudflare/kv/index.d.ts +4 -0
  239. package/lib/cloudflare/kv/index.d.ts.map +1 -0
  240. package/lib/cloudflare/kv/index.js +4 -0
  241. package/lib/cloudflare/kv/index.js.map +1 -0
  242. package/lib/cloudflare/kv/namespace.binding.d.ts +8 -0
  243. package/lib/cloudflare/kv/namespace.binding.d.ts.map +1 -0
  244. package/lib/cloudflare/kv/namespace.binding.js +15 -0
  245. package/lib/cloudflare/kv/namespace.binding.js.map +1 -0
  246. package/lib/cloudflare/kv/namespace.client.d.ts +11 -0
  247. package/lib/cloudflare/kv/namespace.client.d.ts.map +1 -0
  248. package/lib/cloudflare/kv/namespace.client.js +31 -0
  249. package/lib/cloudflare/kv/namespace.client.js.map +1 -0
  250. package/lib/cloudflare/kv/namespace.d.ts +23 -0
  251. package/lib/cloudflare/kv/namespace.d.ts.map +1 -0
  252. package/lib/cloudflare/kv/namespace.js +3 -0
  253. package/lib/cloudflare/kv/namespace.js.map +1 -0
  254. package/lib/cloudflare/kv/namespace.provider.d.ts +5 -0
  255. package/lib/cloudflare/kv/namespace.provider.d.ts.map +1 -0
  256. package/lib/cloudflare/kv/namespace.provider.js +80 -0
  257. package/lib/cloudflare/kv/namespace.provider.js.map +1 -0
  258. package/lib/cloudflare/live.d.ts +11 -0
  259. package/lib/cloudflare/live.d.ts.map +1 -0
  260. package/lib/cloudflare/live.js +18 -0
  261. package/lib/cloudflare/live.js.map +1 -0
  262. package/lib/cloudflare/r2/bucket.binding.d.ts +8 -0
  263. package/lib/cloudflare/r2/bucket.binding.d.ts.map +1 -0
  264. package/lib/cloudflare/r2/bucket.binding.js +18 -0
  265. package/lib/cloudflare/r2/bucket.binding.js.map +1 -0
  266. package/lib/cloudflare/r2/bucket.client.d.ts +8 -0
  267. package/lib/cloudflare/r2/bucket.client.d.ts.map +1 -0
  268. package/lib/cloudflare/r2/bucket.client.js +9 -0
  269. package/lib/cloudflare/r2/bucket.client.js.map +1 -0
  270. package/lib/cloudflare/r2/bucket.d.ts +32 -0
  271. package/lib/cloudflare/r2/bucket.d.ts.map +1 -0
  272. package/lib/cloudflare/r2/bucket.del.d.ts +4 -0
  273. package/lib/cloudflare/r2/bucket.del.d.ts.map +1 -0
  274. package/lib/cloudflare/r2/bucket.del.js +7 -0
  275. package/lib/cloudflare/r2/bucket.del.js.map +1 -0
  276. package/lib/cloudflare/r2/bucket.get.d.ts +5 -0
  277. package/lib/cloudflare/r2/bucket.get.d.ts.map +1 -0
  278. package/lib/cloudflare/r2/bucket.get.js +7 -0
  279. package/lib/cloudflare/r2/bucket.get.js.map +1 -0
  280. package/lib/cloudflare/r2/bucket.head.d.ts +4 -0
  281. package/lib/cloudflare/r2/bucket.head.d.ts.map +1 -0
  282. package/lib/cloudflare/r2/bucket.head.js +7 -0
  283. package/lib/cloudflare/r2/bucket.head.js.map +1 -0
  284. package/lib/cloudflare/r2/bucket.js +3 -0
  285. package/lib/cloudflare/r2/bucket.js.map +1 -0
  286. package/lib/cloudflare/r2/bucket.list.d.ts +5 -0
  287. package/lib/cloudflare/r2/bucket.list.d.ts.map +1 -0
  288. package/lib/cloudflare/r2/bucket.list.js +7 -0
  289. package/lib/cloudflare/r2/bucket.list.js.map +1 -0
  290. package/lib/cloudflare/r2/bucket.multipart.d.ts +19 -0
  291. package/lib/cloudflare/r2/bucket.multipart.d.ts.map +1 -0
  292. package/lib/cloudflare/r2/bucket.multipart.js +25 -0
  293. package/lib/cloudflare/r2/bucket.multipart.js.map +1 -0
  294. package/lib/cloudflare/r2/bucket.provider.d.ts +5 -0
  295. package/lib/cloudflare/r2/bucket.provider.d.ts.map +1 -0
  296. package/lib/cloudflare/r2/bucket.provider.js +66 -0
  297. package/lib/cloudflare/r2/bucket.provider.js.map +1 -0
  298. package/lib/cloudflare/r2/bucket.put.d.ts +6 -0
  299. package/lib/cloudflare/r2/bucket.put.d.ts.map +1 -0
  300. package/lib/cloudflare/r2/bucket.put.js +8 -0
  301. package/lib/cloudflare/r2/bucket.put.js.map +1 -0
  302. package/lib/cloudflare/r2/index.d.ts +10 -0
  303. package/lib/cloudflare/r2/index.d.ts.map +1 -0
  304. package/lib/cloudflare/r2/index.js +10 -0
  305. package/lib/cloudflare/r2/index.js.map +1 -0
  306. package/lib/cloudflare/stream.d.ts +10 -0
  307. package/lib/cloudflare/stream.d.ts.map +1 -0
  308. package/lib/cloudflare/stream.js +16 -0
  309. package/lib/cloudflare/stream.js.map +1 -0
  310. package/lib/cloudflare/worker/assets.fetch.d.ts +8 -0
  311. package/lib/cloudflare/worker/assets.fetch.d.ts.map +1 -0
  312. package/lib/cloudflare/worker/assets.fetch.js +11 -0
  313. package/lib/cloudflare/worker/assets.fetch.js.map +1 -0
  314. package/lib/cloudflare/worker/assets.provider.d.ts +66 -0
  315. package/lib/cloudflare/worker/assets.provider.d.ts.map +1 -0
  316. package/lib/cloudflare/worker/assets.provider.js +145 -0
  317. package/lib/cloudflare/worker/assets.provider.js.map +1 -0
  318. package/lib/cloudflare/worker/index.d.ts +6 -0
  319. package/lib/cloudflare/worker/index.d.ts.map +1 -0
  320. package/lib/cloudflare/worker/index.js +5 -0
  321. package/lib/cloudflare/worker/index.js.map +1 -0
  322. package/lib/cloudflare/worker/worker.d.ts +67 -0
  323. package/lib/cloudflare/worker/worker.d.ts.map +1 -0
  324. package/lib/cloudflare/worker/worker.handler.d.ts +11 -0
  325. package/lib/cloudflare/worker/worker.handler.d.ts.map +1 -0
  326. package/lib/cloudflare/worker/worker.handler.js +15 -0
  327. package/lib/cloudflare/worker/worker.handler.js.map +1 -0
  328. package/lib/cloudflare/worker/worker.js +4 -0
  329. package/lib/cloudflare/worker/worker.js.map +1 -0
  330. package/lib/cloudflare/worker/worker.provider.d.ts +10 -0
  331. package/lib/cloudflare/worker/worker.provider.d.ts.map +1 -0
  332. package/lib/cloudflare/worker/worker.provider.js +193 -0
  333. package/lib/cloudflare/worker/worker.provider.js.map +1 -0
  334. package/lib/cloudflare/worker/worker.serve.d.ts +39 -0
  335. package/lib/cloudflare/worker/worker.serve.d.ts.map +1 -0
  336. package/lib/cloudflare/worker/worker.serve.js +4 -0
  337. package/lib/cloudflare/worker/worker.serve.js.map +1 -0
  338. package/lib/destroy.d.ts +1 -3
  339. package/lib/destroy.d.ts.map +1 -1
  340. package/lib/destroy.js +5 -0
  341. package/lib/destroy.js.map +1 -1
  342. package/lib/dot-alchemy.d.ts +3 -2
  343. package/lib/dot-alchemy.d.ts.map +1 -1
  344. package/lib/dot-alchemy.js +3 -2
  345. package/lib/dot-alchemy.js.map +1 -1
  346. package/lib/esbuild.d.ts +28 -0
  347. package/lib/esbuild.d.ts.map +1 -0
  348. package/lib/esbuild.js +63 -0
  349. package/lib/esbuild.js.map +1 -0
  350. package/lib/index.d.ts +1 -0
  351. package/lib/index.d.ts.map +1 -1
  352. package/lib/index.js +4 -0
  353. package/lib/index.js.map +1 -1
  354. package/lib/plan.d.ts +19 -8
  355. package/lib/plan.d.ts.map +1 -1
  356. package/lib/plan.js +144 -72
  357. package/lib/plan.js.map +1 -1
  358. package/lib/policy.d.ts +19 -1
  359. package/lib/policy.d.ts.map +1 -1
  360. package/lib/policy.js +10 -1
  361. package/lib/policy.js.map +1 -1
  362. package/lib/provider.d.ts +2 -2
  363. package/lib/provider.d.ts.map +1 -1
  364. package/lib/resource.d.ts +2 -10
  365. package/lib/resource.d.ts.map +1 -1
  366. package/lib/resource.js +1 -0
  367. package/lib/resource.js.map +1 -1
  368. package/lib/runtime.d.ts +1 -1
  369. package/lib/runtime.d.ts.map +1 -1
  370. package/lib/schema.d.ts +37 -0
  371. package/lib/schema.d.ts.map +1 -0
  372. package/lib/schema.js +61 -0
  373. package/lib/schema.js.map +1 -0
  374. package/lib/sha256.d.ts +5 -0
  375. package/lib/sha256.d.ts.map +1 -0
  376. package/lib/sha256.js +16 -0
  377. package/lib/sha256.js.map +1 -0
  378. package/lib/state.d.ts +3 -2
  379. package/lib/state.d.ts.map +1 -1
  380. package/lib/state.js +3 -2
  381. package/lib/state.js.map +1 -1
  382. package/lib/tags.d.ts +17 -0
  383. package/lib/tags.d.ts.map +1 -0
  384. package/lib/tags.js +22 -0
  385. package/lib/tags.js.map +1 -0
  386. package/lib/test.d.ts +14 -0
  387. package/lib/test.d.ts.map +1 -0
  388. package/lib/test.js +28 -0
  389. package/lib/test.js.map +1 -0
  390. package/lib/tsconfig.test.tsbuildinfo +1 -0
  391. package/lib/type.d.ts +3 -0
  392. package/lib/type.d.ts.map +1 -0
  393. package/lib/type.js +3 -0
  394. package/lib/type.js.map +1 -0
  395. package/package.json +115 -3
  396. package/src/app.ts +8 -7
  397. package/src/apply.ts +251 -93
  398. package/src/aws/account.ts +37 -0
  399. package/src/aws/arn.ts +1 -0
  400. package/src/aws/assets.ts +8 -0
  401. package/src/aws/bundle.ts +5 -0
  402. package/src/aws/client.ts +47 -0
  403. package/src/aws/credentials.ts +409 -0
  404. package/src/aws/dynamodb/attribute-value.ts +240 -0
  405. package/src/aws/dynamodb/client.ts +20 -0
  406. package/src/aws/dynamodb/expr.ts +90 -0
  407. package/src/aws/dynamodb/index.ts +12 -0
  408. package/src/aws/dynamodb/projection.ts +159 -0
  409. package/src/aws/dynamodb/secondary-index.ts +45 -0
  410. package/src/aws/dynamodb/table.get-item.ts +177 -0
  411. package/src/aws/dynamodb/table.provider.ts +280 -0
  412. package/src/aws/dynamodb/table.ts +156 -0
  413. package/src/aws/ec2/client.ts +20 -0
  414. package/src/aws/ec2/index.ts +3 -0
  415. package/src/aws/ec2/vpc.provider.ts +285 -0
  416. package/src/aws/ec2/vpc.ts +152 -0
  417. package/src/aws/iam.ts +30 -0
  418. package/src/aws/index.ts +54 -0
  419. package/src/aws/lambda/client.ts +14 -0
  420. package/src/aws/lambda/consume.ts +63 -0
  421. package/src/aws/lambda/function.handler.ts +30 -0
  422. package/src/aws/lambda/function.invoke.ts +40 -0
  423. package/src/aws/lambda/function.provider.ts +655 -0
  424. package/src/aws/lambda/function.ts +45 -0
  425. package/src/aws/lambda/index.ts +9 -0
  426. package/src/aws/lambda/serve.ts +29 -0
  427. package/src/aws/parse-ini.ts +80 -0
  428. package/src/aws/profile.ts +6 -0
  429. package/src/aws/region.ts +37 -0
  430. package/src/aws/s3.ts +10 -0
  431. package/src/aws/sqs/client.ts +20 -0
  432. package/src/aws/sqs/index.ts +6 -0
  433. package/src/aws/sqs/queue.consume.ts +13 -0
  434. package/src/aws/sqs/queue.event-source.ts +253 -0
  435. package/src/aws/sqs/queue.provider.ts +94 -0
  436. package/src/aws/sqs/queue.send-message.ts +51 -0
  437. package/src/aws/sqs/queue.ts +86 -0
  438. package/src/aws/sts.ts +13 -0
  439. package/src/aws/zip.ts +17 -0
  440. package/src/binding.ts +121 -25
  441. package/src/capability.ts +44 -0
  442. package/src/cli/approve.tsx +30 -0
  443. package/src/cli/clack.ts +22 -0
  444. package/src/cli/components/ApprovePlan.tsx +44 -0
  445. package/src/cli/components/Plan.tsx +154 -0
  446. package/src/cli/components/PlanProgress.tsx +206 -0
  447. package/src/cli/index.ts +6 -0
  448. package/src/cli/main.ts +0 -0
  449. package/src/cli/plan.ts +16 -0
  450. package/src/cli/progress.tsx +46 -0
  451. package/src/cli/spinner.ts +14 -0
  452. package/src/cloudflare/api.ts +152 -0
  453. package/src/cloudflare/context.ts +49 -0
  454. package/src/cloudflare/index.ts +6 -0
  455. package/src/cloudflare/kv/index.ts +3 -0
  456. package/src/cloudflare/kv/namespace.binding.ts +25 -0
  457. package/src/cloudflare/kv/namespace.client.ts +70 -0
  458. package/src/cloudflare/kv/namespace.provider.ts +99 -0
  459. package/src/cloudflare/kv/namespace.ts +29 -0
  460. package/src/cloudflare/live.ts +38 -0
  461. package/src/cloudflare/r2/bucket.binding.ts +27 -0
  462. package/src/cloudflare/r2/bucket.client.ts +22 -0
  463. package/src/cloudflare/r2/bucket.del.ts +11 -0
  464. package/src/cloudflare/r2/bucket.get.ts +13 -0
  465. package/src/cloudflare/r2/bucket.head.ts +11 -0
  466. package/src/cloudflare/r2/bucket.list.ts +12 -0
  467. package/src/cloudflare/r2/bucket.multipart.ts +55 -0
  468. package/src/cloudflare/r2/bucket.provider.ts +83 -0
  469. package/src/cloudflare/r2/bucket.put.ts +17 -0
  470. package/src/cloudflare/r2/bucket.ts +38 -0
  471. package/src/cloudflare/r2/index.ts +9 -0
  472. package/src/cloudflare/stream.ts +21 -0
  473. package/src/cloudflare/worker/assets.fetch.ts +27 -0
  474. package/src/cloudflare/worker/assets.provider.ts +249 -0
  475. package/src/cloudflare/worker/index.ts +6 -0
  476. package/src/cloudflare/worker/worker.handler.ts +39 -0
  477. package/src/cloudflare/worker/worker.provider.ts +246 -0
  478. package/src/cloudflare/worker/worker.serve.ts +19 -0
  479. package/src/cloudflare/worker/worker.ts +76 -0
  480. package/src/destroy.ts +6 -3
  481. package/src/dot-alchemy.ts +3 -2
  482. package/src/esbuild.ts +98 -0
  483. package/src/index.ts +5 -0
  484. package/src/plan.ts +233 -120
  485. package/src/policy.ts +55 -2
  486. package/src/provider.ts +2 -2
  487. package/src/resource.ts +3 -2
  488. package/src/runtime.ts +1 -1
  489. package/src/schema.ts +102 -0
  490. package/src/sha256.ts +23 -0
  491. package/src/state.ts +3 -2
  492. package/src/tags.ts +38 -0
  493. package/src/test.ts +71 -0
  494. package/src/type.ts +2 -0
@@ -0,0 +1,20 @@
1
+ import * as Layer from "effect/Layer";
2
+ import * as Context from "effect/Context";
3
+ import { DynamoDB } from "itty-aws/dynamodb";
4
+
5
+ import * as Credentials from "../credentials.ts";
6
+ import * as Region from "../region.ts";
7
+ import { createAWSServiceClientLayer } from "../client.ts";
8
+
9
+ export class DynamoDBClient extends Context.Tag("AWS::DynamoDB::Client")<
10
+ DynamoDBClient,
11
+ DynamoDB
12
+ >() {}
13
+
14
+ export const client = createAWSServiceClientLayer<
15
+ typeof DynamoDBClient,
16
+ DynamoDB
17
+ >(DynamoDBClient, DynamoDB);
18
+
19
+ export const clientFromEnv = () =>
20
+ Layer.provide(client(), Layer.merge(Credentials.fromEnv(), Region.fromEnv()));
@@ -0,0 +1,90 @@
1
+ export type Expr =
2
+ | ArrayIndex
3
+ | Identifier
4
+ | NumberLiteral
5
+ | OperatorExpr
6
+ | NameRef
7
+ | PropRef
8
+ | ValueRef;
9
+ //
10
+
11
+ export interface NameRef<Name extends string = string> {
12
+ kind: "name-ref";
13
+ name: Name;
14
+ }
15
+ export interface ValueRef<Name extends string = string> {
16
+ kind: "value-ref";
17
+ name: Name;
18
+ }
19
+ export interface Identifier<I extends string = string> {
20
+ kind: "identifier";
21
+ name: I;
22
+ }
23
+
24
+ export interface NumberLiteral<N extends string = string> {
25
+ kind: "index";
26
+ number: N;
27
+ }
28
+ export interface PropRef<Ex extends Expr = any, Id extends Identifier = any> {
29
+ kind: "prop-ref";
30
+ expr: Ex;
31
+ name: Id;
32
+ }
33
+ export interface ArrayIndex<
34
+ List extends Expr = any,
35
+ Number extends NumberLiteral | ValueRef = NumberLiteral | ValueRef,
36
+ > {
37
+ kind: "array-index";
38
+ list: List;
39
+ number: Number;
40
+ }
41
+
42
+ export type Operator = "and" | "or" | "=" | "<" | "<=" | ">=" | ">";
43
+ export interface OperatorExpr<
44
+ Left extends Expr = any,
45
+ Op extends Operator = Operator,
46
+ Right extends Expr = any,
47
+ > {
48
+ kind: "op";
49
+ left: Left;
50
+ op: Op;
51
+ right: Right;
52
+ }
53
+
54
+ export type LowercaseLetter =
55
+ | "a"
56
+ | "b"
57
+ | "c"
58
+ | "d"
59
+ | "e"
60
+ | "f"
61
+ | "g"
62
+ | "h"
63
+ | "i"
64
+ | "j"
65
+ | "k"
66
+ | "l"
67
+ | "m"
68
+ | "n"
69
+ | "o"
70
+ | "p"
71
+ | "q"
72
+ | "r"
73
+ | "s"
74
+ | "t"
75
+ | "u"
76
+ | "v"
77
+ | "w"
78
+ | "x"
79
+ | "y"
80
+ | "z";
81
+
82
+ export type UppercaseLetter = Uppercase<LowercaseLetter>;
83
+
84
+ export type Letter = LowercaseLetter | UppercaseLetter;
85
+
86
+ export type Digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";
87
+
88
+ export type SpecialCharacter = "_";
89
+
90
+ export type Word = Digit | Letter | SpecialCharacter;
@@ -0,0 +1,12 @@
1
+ export * from "./attribute-value.ts";
2
+ export * from "./client.ts";
3
+ export * from "./expr.ts";
4
+ export * from "./secondary-index.ts";
5
+ export * from "./table.get-item.ts";
6
+ export * from "./table.provider.ts";
7
+ export * from "./table.ts";
8
+
9
+ export type * as Alchemy from "../../index.ts";
10
+
11
+ // TODO(sam): figure out a better strategy to workaround non-portable types
12
+ // export type * as _ from "../../index.ts";
@@ -0,0 +1,159 @@
1
+ import type {
2
+ ArrayIndex,
3
+ Expr,
4
+ Identifier,
5
+ NameRef,
6
+ NumberLiteral,
7
+ PropRef,
8
+ ValueRef,
9
+ Word,
10
+ } from "./expr.ts";
11
+
12
+ export type ParseProjectionExpression<Text extends string> = Parse<
13
+ Text,
14
+ [],
15
+ undefined
16
+ >;
17
+
18
+ type AsExpr<T> = Extract<T, Expr>;
19
+
20
+ type Parse<
21
+ Text extends string,
22
+ Expressions extends Expr[],
23
+ Exp extends Expr | undefined,
24
+ > = Text extends `.${infer Rest}`
25
+ ? Exp extends Expr
26
+ ? Parse<Rest, Expressions, PropRef<Exp, Identifier<"">>>
27
+ : never
28
+ : Text extends `[:${infer Rest}`
29
+ ? Parse<Rest, Expressions, ArrayIndex<AsExpr<Exp>, ValueRef<"">>>
30
+ : Text extends `[${infer Rest}`
31
+ ? Parse<Rest, Expressions, ArrayIndex<AsExpr<Exp>, NumberLiteral<"">>>
32
+ : Text extends `]${infer Rest}`
33
+ ? Parse<Rest, Expressions, Exp>
34
+ : Text extends `]`
35
+ ? Concat<Expressions, Exp>
36
+ : Text extends `${"," | " "}${infer Rest}`
37
+ ? Parse<Rest, Concat<Expressions, Exp>, undefined>
38
+ : Text extends `#${infer Rest}`
39
+ ? Parse<Rest, Concat<Expressions, Exp>, NameRef<Rest>>
40
+ : Text extends `:${infer Rest}`
41
+ ? Parse<Rest, Concat<Expressions, Exp>, ValueRef<Rest>>
42
+ : Text extends `${Word}${string}`
43
+ ? Text extends `${infer char}${infer Rest}`
44
+ ? Parse<Rest, Expressions, Append<Exp, char>>
45
+ : never
46
+ : Text extends `${Word}${string}`
47
+ ? Text extends `${infer char}${infer Rest}`
48
+ ? Parse<Rest, Expressions, Append<Exp, char>>
49
+ : never
50
+ : Concat<Expressions, Exp>;
51
+
52
+ type Concat<
53
+ Expressions extends Expr[],
54
+ CurrentExpr extends Expr | undefined,
55
+ > = undefined extends CurrentExpr
56
+ ? Expressions
57
+ : [...Expressions, Extract<CurrentExpr, Expr>];
58
+
59
+ type Append<
60
+ Exp extends Expr | undefined,
61
+ char extends string,
62
+ > = Exp extends undefined
63
+ ? Identifier<char>
64
+ : Exp extends Identifier<infer Name>
65
+ ? Identifier<`${Name}${char}`>
66
+ : Exp extends NumberLiteral<infer Name>
67
+ ? NumberLiteral<`${Name}${char}`>
68
+ : Exp extends NameRef<infer Name>
69
+ ? NameRef<`${Name}${char}`>
70
+ : Exp extends ValueRef<infer Name>
71
+ ? ValueRef<`${Name}${char}`>
72
+ : Exp extends PropRef<infer expr, infer name>
73
+ ? PropRef<expr, Extract<Append<name, char>, Identifier>>
74
+ : Exp extends ArrayIndex<infer expr, infer idx>
75
+ ? ArrayIndex<expr, Extract<Append<idx, char>, NumberLiteral>>
76
+ : never;
77
+
78
+ export type ApplyProjection<T, Expr extends string> = Flatten<
79
+ UnionToIntersection<
80
+ ApplyProjectionExpr<T, ParseProjectionExpression<Expr>[number]>
81
+ >
82
+ >;
83
+
84
+ type ApplyProjectionExpr<T, Exp extends Expr> = T extends undefined
85
+ ? never
86
+ : Exp extends PropRef<infer expr, infer i>
87
+ ? {
88
+ [p in keyof ApplyProjectionExpr<T, expr>]: ApplyProjectionExpr<
89
+ ApplyProjectionExpr<T, expr>[p],
90
+ i
91
+ >;
92
+ }
93
+ : Exp extends ArrayIndex<infer expr, infer i>
94
+ ? {
95
+ [p in keyof ApplyProjectionExpr<T, expr>]: ApplyProjectionExpr<
96
+ ApplyProjectionExpr<T, expr>[keyof ApplyProjectionExpr<T, expr>],
97
+ i
98
+ >;
99
+ }
100
+ : Exp extends Identifier<infer I>
101
+ ? I extends keyof T
102
+ ? Pick<T, I>
103
+ : never
104
+ : Exp extends NumberLiteral<infer I>
105
+ ? ParseInt<I> extends keyof T
106
+ ? Pick<T, ParseInt<I>>
107
+ : never
108
+ : never;
109
+
110
+ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
111
+ k: infer I,
112
+ ) => void
113
+ ? I
114
+ : never;
115
+
116
+ type Flatten<T> = T extends object
117
+ ? keyof T extends number
118
+ ? FlattenArray<Extract<T, Record<number, any>>>
119
+ : {
120
+ [k in keyof T]: Flatten<T[k]>;
121
+ }
122
+ : T;
123
+
124
+ type FlattenArray<
125
+ T extends { [i in number]: any },
126
+ i extends number = 0,
127
+ > = i extends keyof T
128
+ ? [T[i], ...FlattenArray<T, Inc<i>>]
129
+ : number extends i
130
+ ? []
131
+ : FlattenArray<T, Inc<i>>;
132
+
133
+ type BuildTuple<N extends number, T extends any[] = []> = T["length"] extends N
134
+ ? T
135
+ : BuildTuple<N, [...T, any]>;
136
+
137
+ type Inc<N extends number> = Extract<[...BuildTuple<N>, any]["length"], number>;
138
+
139
+ type ParseInt<N extends string> = N extends "0"
140
+ ? 0
141
+ : N extends "1"
142
+ ? 1
143
+ : N extends "2"
144
+ ? 2
145
+ : N extends "3"
146
+ ? 3
147
+ : N extends "4"
148
+ ? 4
149
+ : N extends "5"
150
+ ? 5
151
+ : N extends "6"
152
+ ? 6
153
+ : N extends "7"
154
+ ? 7
155
+ : N extends "8"
156
+ ? 8
157
+ : N extends "9"
158
+ ? 9
159
+ : number;
@@ -0,0 +1,45 @@
1
+ import * as S from "effect/Schema";
2
+ import { Resource } from "../../resource.ts";
3
+ import type { Table } from "./table.ts";
4
+
5
+ export const SecondaryIndex = Resource<{
6
+ <
7
+ const ID extends string,
8
+ const Source extends Table,
9
+ const Attributes extends S.Struct.Fields,
10
+ const PartitionKey extends keyof Attributes,
11
+ const SortKey extends keyof Attributes | undefined = undefined,
12
+ >(
13
+ id: ID,
14
+ props: SecondaryIndexProps<Source, Attributes, PartitionKey, SortKey>,
15
+ ): SecondaryIndex<
16
+ ID,
17
+ SecondaryIndexProps<Source, Attributes, PartitionKey, SortKey>
18
+ >;
19
+ }>("AWS.DynamoDB.SecondaryIndex");
20
+
21
+ export interface SecondaryIndex<
22
+ ID extends string = string,
23
+ Props extends SecondaryIndexProps = SecondaryIndexProps,
24
+ > extends Resource<
25
+ "AWS.DynamoDB.SecondaryIndex",
26
+ ID,
27
+ Props,
28
+ SecondaryIndexAttrs<Props>
29
+ > {}
30
+
31
+ export interface SecondaryIndexProps<
32
+ Source extends Table = Table,
33
+ Attributes extends S.Struct.Fields = S.Struct.Fields,
34
+ PartitionKey extends keyof Attributes = keyof Attributes,
35
+ SortKey extends keyof Attributes | undefined = keyof Attributes | undefined,
36
+ > {
37
+ table: new () => Source;
38
+ indexName?: string;
39
+ partitionKey: PartitionKey;
40
+ sortKey?: SortKey;
41
+ }
42
+
43
+ export type SecondaryIndexAttrs<Props extends SecondaryIndexProps> = {
44
+ indexName: Props["indexName"] extends string ? Props["indexName"] : string;
45
+ };
@@ -0,0 +1,177 @@
1
+ import {
2
+ Binding,
3
+ declare,
4
+ Policy,
5
+ toEnvKey,
6
+ type Capability,
7
+ type From,
8
+ } from "alchemy-effect";
9
+ import { Effect } from "effect";
10
+ import type { ReturnConsumedCapacity } from "itty-aws/dynamodb";
11
+ import { Function } from "../lambda/index.ts";
12
+ import { fromAttributeValue } from "./attribute-value.ts";
13
+ import { DynamoDBClient } from "./client.ts";
14
+ import type { Identifier } from "./expr.ts";
15
+ import type { ParseProjectionExpression } from "./projection.ts";
16
+ import { Table } from "./table.ts";
17
+
18
+ export interface GetItemConstraint<
19
+ LeadingKeys extends Policy.AnyOf<any> = Policy.AnyOf<any>,
20
+ Attributes extends Policy.AnyOf<any> = Policy.AnyOf<any>,
21
+ ReturnConsumedCapacity extends Policy.AnyOf<any> = Policy.AnyOf<any>,
22
+ > {
23
+ leadingKeys?: LeadingKeys;
24
+ attributes?: Attributes;
25
+ returnConsumedCapacity?: ReturnConsumedCapacity;
26
+ }
27
+
28
+ export interface GetItem<
29
+ T = unknown,
30
+ Constraint extends GetItemConstraint | unknown = unknown,
31
+ > extends Capability<"AWS.DynamoDB.GetItem", T, Constraint> {
32
+ Constructor: GetItem;
33
+ Reduce: GetItem<
34
+ this["resource"],
35
+ {
36
+ [k in keyof Capability.Constraint.Simplify<
37
+ this["constraint"]
38
+ >]: Capability.Constraint.Simplify<this["constraint"]>[k];
39
+ }
40
+ >;
41
+ }
42
+
43
+ export const GetItem = Binding<
44
+ <
45
+ T extends Table,
46
+ const LeadingKeys extends Policy.AnyOf<any> = Policy.AnyOf<string>,
47
+ const Attributes extends Policy.AnyOf<any> = never,
48
+ const ReturnConsumedCapacity extends Policy.AnyOf<any> = never,
49
+ >(
50
+ table: T,
51
+ constraint?: GetItemConstraint<
52
+ LeadingKeys,
53
+ Attributes,
54
+ ReturnConsumedCapacity
55
+ >,
56
+ ) => Binding<
57
+ Function,
58
+ GetItem<
59
+ From<T>,
60
+ Policy.Constraint<{
61
+ leadingKeys: LeadingKeys;
62
+ attributes: Attributes;
63
+ returnConsumedCapacity: ReturnConsumedCapacity;
64
+ }>
65
+ >
66
+ >
67
+ >(Function, "AWS.DynamoDB.GetItem");
68
+
69
+ // see: https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazondynamodb.html
70
+ export const getItem = <
71
+ T extends Table<string, any>,
72
+ const Key extends Table.Key<T>,
73
+ const ProjectionExpression extends string = never,
74
+ const Capacity extends ReturnConsumedCapacity = never,
75
+ >({
76
+ table,
77
+ key,
78
+ projectionExpression,
79
+ returnConsumedCapacity,
80
+ }: {
81
+ table: T;
82
+ key: Key;
83
+ projectionExpression?: ProjectionExpression;
84
+ returnConsumedCapacity?: Capacity;
85
+ }) =>
86
+ Effect.gen(function* () {
87
+ type Parsed = ParseProjectionExpression<ProjectionExpression>;
88
+ type Attributes = Extract<Parsed[number], Identifier>["name"];
89
+ type LeadingKeys = Extract<Key[T["props"]["partitionKey"]], string>;
90
+ type Constraint = Policy.Constraint<{
91
+ leadingKeys: Policy.AnyOf<LeadingKeys>;
92
+ attributes: Policy.AnyOf<Attributes>;
93
+ returnConsumedCapacity: Policy.AnyOf<Capacity>;
94
+ }>;
95
+ yield* declare<
96
+ GetItem<
97
+ From<T>,
98
+ {
99
+ [k in keyof Constraint]: Constraint[k];
100
+ }
101
+ >
102
+ >();
103
+ const tableNameEnv = toEnvKey(table.id, "TABLE_NAME");
104
+ const tableName = process.env[tableNameEnv];
105
+ if (!tableName) {
106
+ return yield* Effect.die(new Error(`${tableNameEnv} is not set`));
107
+ }
108
+ const ddb = yield* DynamoDBClient;
109
+ const { Item, ...rest } = yield* ddb.getItem({
110
+ TableName: tableName,
111
+ Key: {
112
+ [table.props.partitionKey]: {
113
+ S: (key as any)[table.props.partitionKey] as string,
114
+ },
115
+ ...(table.props.sortKey
116
+ ? {
117
+ [table.props.sortKey]: {
118
+ S: (key as any)[table.props.sortKey] as string,
119
+ },
120
+ }
121
+ : {}),
122
+ },
123
+ ProjectionExpression: projectionExpression,
124
+ ReturnConsumedCapacity: returnConsumedCapacity,
125
+ });
126
+
127
+ return {
128
+ ...rest,
129
+ Item: Item
130
+ ? (Object.fromEntries(
131
+ yield* Effect.promise(() =>
132
+ Promise.all(
133
+ Object.entries(Item!).map(async ([key, value]) => [
134
+ key,
135
+ await fromAttributeValue(value),
136
+ ]),
137
+ ),
138
+ ),
139
+ ) as InstanceType<T["props"]["items"]> & Key)
140
+ : undefined,
141
+ };
142
+ });
143
+
144
+ export const getItemFromLambdaFunction = () =>
145
+ GetItem.provider.succeed({
146
+ attach: ({ source: table, props }) => ({
147
+ env: {
148
+ [toEnvKey(table.id, "TABLE_NAME")]: table.attr.tableName,
149
+ [toEnvKey(table.id, "TABLE_ARN")]: table.attr.tableArn,
150
+ },
151
+ policyStatements: [
152
+ {
153
+ Sid: "GetItem",
154
+ Effect: "Allow",
155
+ Action: ["dynamodb:GetItem"],
156
+ Resource: [table.attr.tableArn],
157
+ Condition:
158
+ props?.leadingKeys ||
159
+ props?.attributes ||
160
+ props?.returnConsumedCapacity
161
+ ? {
162
+ // https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazondynamodb.html#amazondynamodb-dynamodb_LeadingKeys
163
+
164
+ // TODO(sam): add StringLike for prefixes, templates, etc.
165
+ "ForAllValues:StringEquals": {
166
+ "dynamodb:LeadingKeys": props.leadingKeys
167
+ ?.anyOf as string[],
168
+ "dynamodb:Attributes": props.attributes?.anyOf as string[],
169
+ "dynamodb:ReturnConsumedCapacity": props
170
+ .returnConsumedCapacity?.anyOf as string[],
171
+ },
172
+ }
173
+ : undefined,
174
+ },
175
+ ],
176
+ }),
177
+ });