alchemy 2.0.0-beta.13 → 2.0.0-beta.15

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 (311) hide show
  1. package/bin/alchemy.js +9477 -9290
  2. package/bin/alchemy.js.map +1 -1
  3. package/bin/alchemy.ts +6 -2
  4. package/bin/cli.js +61 -0
  5. package/bin/commands/deploy.ts +6 -4
  6. package/bin/commands/login.ts +1 -1
  7. package/bin/commands/logs.ts +1 -1
  8. package/bin/commands/state.ts +233 -0
  9. package/bin/commands/tail.ts +1 -1
  10. package/lib/AWS/AutoScaling/LaunchTemplate.d.ts +1 -1
  11. package/lib/AWS/EC2/Instance.d.ts +1 -1
  12. package/lib/AWS/EC2/hosted.d.ts +2 -2
  13. package/lib/AWS/ECS/Task.d.ts +4 -4
  14. package/lib/AWS/ECS/Task.d.ts.map +1 -1
  15. package/lib/AWS/ECS/Task.js +2 -2
  16. package/lib/AWS/ECS/Task.js.map +1 -1
  17. package/lib/AWS/Environment.d.ts +2 -2
  18. package/lib/AWS/Lambda/BucketEventSource.d.ts +1 -1
  19. package/lib/AWS/Lambda/BucketEventSource.d.ts.map +1 -1
  20. package/lib/AWS/Lambda/EventBridgeEventSource.d.ts +1 -1
  21. package/lib/AWS/Lambda/EventBridgeEventSource.d.ts.map +1 -1
  22. package/lib/AWS/Lambda/Function.d.ts +2 -2
  23. package/lib/AWS/Lambda/Function.d.ts.map +1 -1
  24. package/lib/AWS/Lambda/Function.js +1 -2
  25. package/lib/AWS/Lambda/Function.js.map +1 -1
  26. package/lib/AWS/Lambda/QueueEventSource.d.ts +1 -1
  27. package/lib/AWS/Lambda/QueueEventSource.d.ts.map +1 -1
  28. package/lib/AWS/Lambda/StreamEventSource.d.ts +1 -1
  29. package/lib/AWS/Lambda/StreamEventSource.d.ts.map +1 -1
  30. package/lib/AWS/Lambda/TableEventSource.d.ts +1 -1
  31. package/lib/AWS/Lambda/TableEventSource.d.ts.map +1 -1
  32. package/lib/AWS/Lambda/TopicEventSource.d.ts +1 -1
  33. package/lib/AWS/Lambda/TopicEventSource.d.ts.map +1 -1
  34. package/lib/AWS/SQS/QueueSink.d.ts.map +1 -1
  35. package/lib/AWS/SQS/QueueSink.js +1 -2
  36. package/lib/AWS/SQS/QueueSink.js.map +1 -1
  37. package/lib/Agent/coding/bash.d.ts +2 -6
  38. package/lib/Agent/coding/bash.d.ts.map +1 -1
  39. package/lib/Agent/coding/bash.js +2 -3
  40. package/lib/Agent/coding/bash.js.map +1 -1
  41. package/lib/Agent/coding/edit.d.ts +1 -1
  42. package/lib/Agent/coding/glob.d.ts +2 -4
  43. package/lib/Agent/coding/glob.d.ts.map +1 -1
  44. package/lib/Agent/coding/glob.js +1 -2
  45. package/lib/Agent/coding/glob.js.map +1 -1
  46. package/lib/Agent/coding/grep.d.ts +2 -4
  47. package/lib/Agent/coding/grep.d.ts.map +1 -1
  48. package/lib/Agent/coding/grep.js +1 -2
  49. package/lib/Agent/coding/grep.js.map +1 -1
  50. package/lib/Agent/coding/read.d.ts +1 -1
  51. package/lib/Agent/coding/write.d.ts +1 -1
  52. package/lib/Agent/lsp/client.d.ts +2 -2
  53. package/lib/Agent/util/ripgrep.d.ts +2 -2
  54. package/lib/AlchemyContext.d.ts +13 -0
  55. package/lib/AlchemyContext.d.ts.map +1 -0
  56. package/lib/AlchemyContext.js +18 -0
  57. package/lib/AlchemyContext.js.map +1 -0
  58. package/lib/Auth/AuthProvider.js +1 -1
  59. package/lib/Auth/AuthProvider.js.map +1 -1
  60. package/lib/Auth/Profile.d.ts +1 -1
  61. package/lib/Auth/index.d.ts +3 -1
  62. package/lib/Auth/index.d.ts.map +1 -1
  63. package/lib/Auth/index.js +3 -0
  64. package/lib/Auth/index.js.map +1 -1
  65. package/lib/Build/Command.d.ts +1 -1
  66. package/lib/Build/Memo.d.ts +1 -1
  67. package/lib/Bundle/Docker.d.ts +3 -3
  68. package/lib/Bundle/TempRoot.d.ts +3 -3
  69. package/lib/Cli/LoggingCli.d.ts +4 -0
  70. package/lib/Cli/LoggingCli.d.ts.map +1 -0
  71. package/lib/{Test/TestCli.js → Cli/LoggingCli.js} +3 -3
  72. package/lib/Cli/LoggingCli.js.map +1 -0
  73. package/lib/Cli/index.d.ts +0 -1
  74. package/lib/Cli/index.d.ts.map +1 -1
  75. package/lib/Cli/index.js +4 -1
  76. package/lib/Cli/index.js.map +1 -1
  77. package/lib/Cloudflare/ApiToken/AccountApiToken.d.ts +58 -0
  78. package/lib/Cloudflare/ApiToken/AccountApiToken.d.ts.map +1 -0
  79. package/lib/Cloudflare/ApiToken/AccountApiToken.js +137 -0
  80. package/lib/Cloudflare/ApiToken/AccountApiToken.js.map +1 -0
  81. package/lib/Cloudflare/ApiToken/Common.d.ts +91 -0
  82. package/lib/Cloudflare/ApiToken/Common.d.ts.map +1 -0
  83. package/lib/Cloudflare/ApiToken/Common.js +61 -0
  84. package/lib/Cloudflare/ApiToken/Common.js.map +1 -0
  85. package/lib/Cloudflare/ApiToken/PermissionGroups.d.ts +1549 -0
  86. package/lib/Cloudflare/ApiToken/PermissionGroups.d.ts.map +1 -0
  87. package/lib/Cloudflare/ApiToken/PermissionGroups.js +1856 -0
  88. package/lib/Cloudflare/ApiToken/PermissionGroups.js.map +1 -0
  89. package/lib/Cloudflare/ApiToken/UserApiToken.d.ts +49 -0
  90. package/lib/Cloudflare/ApiToken/UserApiToken.d.ts.map +1 -0
  91. package/lib/Cloudflare/ApiToken/UserApiToken.js +113 -0
  92. package/lib/Cloudflare/ApiToken/UserApiToken.js.map +1 -0
  93. package/lib/Cloudflare/ApiToken/index.d.ts +5 -0
  94. package/lib/Cloudflare/ApiToken/index.d.ts.map +1 -0
  95. package/lib/Cloudflare/ApiToken/index.js +5 -0
  96. package/lib/Cloudflare/ApiToken/index.js.map +1 -0
  97. package/lib/Cloudflare/Auth/AuthProvider.js +2 -2
  98. package/lib/Cloudflare/Auth/AuthProvider.js.map +1 -1
  99. package/lib/Cloudflare/CloudflareEnvironment.d.ts +1 -1
  100. package/lib/Cloudflare/Container/ContainerApplication.d.ts +2 -2
  101. package/lib/Cloudflare/Container/ContainerApplication.d.ts.map +1 -1
  102. package/lib/Cloudflare/Container/ContainerApplication.js +7 -2
  103. package/lib/Cloudflare/Container/ContainerApplication.js.map +1 -1
  104. package/lib/Cloudflare/EdgeSession.d.ts +53 -0
  105. package/lib/Cloudflare/EdgeSession.d.ts.map +1 -0
  106. package/lib/Cloudflare/EdgeSession.js +78 -0
  107. package/lib/Cloudflare/EdgeSession.js.map +1 -0
  108. package/lib/Cloudflare/Providers.d.ts +1 -1
  109. package/lib/Cloudflare/Providers.d.ts.map +1 -1
  110. package/lib/Cloudflare/Providers.js +4 -1
  111. package/lib/Cloudflare/Providers.js.map +1 -1
  112. package/lib/Cloudflare/StateStore/Api.d.ts +61 -0
  113. package/lib/Cloudflare/StateStore/Api.d.ts.map +1 -0
  114. package/lib/Cloudflare/StateStore/Api.js +103 -0
  115. package/lib/Cloudflare/StateStore/Api.js.map +1 -0
  116. package/lib/Cloudflare/StateStore/State.d.ts +39 -0
  117. package/lib/Cloudflare/StateStore/State.d.ts.map +1 -0
  118. package/lib/Cloudflare/StateStore/State.js +217 -0
  119. package/lib/Cloudflare/StateStore/State.js.map +1 -0
  120. package/lib/Cloudflare/StateStore/Store.d.ts +82 -0
  121. package/lib/Cloudflare/StateStore/Store.d.ts.map +1 -0
  122. package/lib/Cloudflare/StateStore/Store.js +191 -0
  123. package/lib/Cloudflare/StateStore/Store.js.map +1 -0
  124. package/lib/Cloudflare/StateStore/Token.d.ts +43 -0
  125. package/lib/Cloudflare/StateStore/Token.d.ts.map +1 -0
  126. package/lib/Cloudflare/StateStore/Token.js +61 -0
  127. package/lib/Cloudflare/StateStore/Token.js.map +1 -0
  128. package/lib/Cloudflare/StateStore/index.d.ts +2 -0
  129. package/lib/Cloudflare/StateStore/index.d.ts.map +1 -0
  130. package/lib/Cloudflare/StateStore/index.js +2 -0
  131. package/lib/Cloudflare/StateStore/index.js.map +1 -0
  132. package/lib/Cloudflare/Workers/Assets.d.ts +2 -2
  133. package/lib/Cloudflare/Workers/DurableObjectNamespace.d.ts +2 -2
  134. package/lib/Cloudflare/Workers/DurableObjectNamespace.d.ts.map +1 -1
  135. package/lib/Cloudflare/Workers/DurableObjectNamespace.js +0 -1
  136. package/lib/Cloudflare/Workers/DurableObjectNamespace.js.map +1 -1
  137. package/lib/Cloudflare/Workers/HttpServer.d.ts +1 -1
  138. package/lib/Cloudflare/Workers/HttpServer.d.ts.map +1 -1
  139. package/lib/Cloudflare/Workers/HttpServer.js.map +1 -1
  140. package/lib/Cloudflare/Workers/Worker.d.ts +5 -5
  141. package/lib/Cloudflare/Workers/Worker.d.ts.map +1 -1
  142. package/lib/Cloudflare/Workers/Worker.js +0 -1
  143. package/lib/Cloudflare/Workers/Worker.js.map +1 -1
  144. package/lib/Cloudflare/index.d.ts +4 -1
  145. package/lib/Cloudflare/index.d.ts.map +1 -1
  146. package/lib/Cloudflare/index.js +4 -1
  147. package/lib/Cloudflare/index.js.map +1 -1
  148. package/lib/Deploy.d.ts +10 -0
  149. package/lib/Deploy.d.ts.map +1 -0
  150. package/lib/Deploy.js +12 -0
  151. package/lib/Deploy.js.map +1 -0
  152. package/lib/Destroy.d.ts +8 -3
  153. package/lib/Destroy.d.ts.map +1 -1
  154. package/lib/Destroy.js +8 -8
  155. package/lib/Destroy.js.map +1 -1
  156. package/lib/GitHub/Providers.d.ts +3 -0
  157. package/lib/GitHub/Providers.d.ts.map +1 -0
  158. package/lib/GitHub/Providers.js +5 -0
  159. package/lib/GitHub/Providers.js.map +1 -0
  160. package/lib/GitHub/index.d.ts +1 -0
  161. package/lib/GitHub/index.d.ts.map +1 -1
  162. package/lib/GitHub/index.js +1 -0
  163. package/lib/GitHub/index.js.map +1 -1
  164. package/lib/Http.d.ts +1 -1
  165. package/lib/Http.d.ts.map +1 -1
  166. package/lib/Http.js +7 -3
  167. package/lib/Http.js.map +1 -1
  168. package/lib/Kubernetes/client.d.ts +10 -10
  169. package/lib/Output.d.ts.map +1 -1
  170. package/lib/Output.js +4 -0
  171. package/lib/Output.js.map +1 -1
  172. package/lib/Plan.d.ts.map +1 -1
  173. package/lib/Plan.js +4 -0
  174. package/lib/Plan.js.map +1 -1
  175. package/lib/Platform.d.ts +2 -2
  176. package/lib/Platform.d.ts.map +1 -1
  177. package/lib/Platform.js.map +1 -1
  178. package/lib/Provider.d.ts.map +1 -1
  179. package/lib/Provider.js +0 -1
  180. package/lib/Provider.js.map +1 -1
  181. package/lib/Stack.d.ts +24 -12
  182. package/lib/Stack.d.ts.map +1 -1
  183. package/lib/Stack.js +47 -10
  184. package/lib/Stack.js.map +1 -1
  185. package/lib/State/HttpStateApi.d.ts +96 -0
  186. package/lib/State/HttpStateApi.d.ts.map +1 -0
  187. package/lib/State/HttpStateApi.js +96 -0
  188. package/lib/State/HttpStateApi.js.map +1 -0
  189. package/lib/State/HttpStateStore.d.ts +10 -0
  190. package/lib/State/HttpStateStore.d.ts.map +1 -0
  191. package/lib/State/HttpStateStore.js +102 -0
  192. package/lib/State/HttpStateStore.js.map +1 -0
  193. package/lib/State/InMemoryState.d.ts +2 -30
  194. package/lib/State/InMemoryState.d.ts.map +1 -1
  195. package/lib/State/InMemoryState.js +23 -18
  196. package/lib/State/InMemoryState.js.map +1 -1
  197. package/lib/State/LocalState.d.ts +4 -2
  198. package/lib/State/LocalState.d.ts.map +1 -1
  199. package/lib/State/LocalState.js +9 -41
  200. package/lib/State/LocalState.js.map +1 -1
  201. package/lib/State/State.d.ts +11 -4
  202. package/lib/State/State.d.ts.map +1 -1
  203. package/lib/State/State.js +1 -1
  204. package/lib/State/State.js.map +1 -1
  205. package/lib/State/StateEncoding.d.ts +31 -0
  206. package/lib/State/StateEncoding.d.ts.map +1 -0
  207. package/lib/State/StateEncoding.js +82 -0
  208. package/lib/State/StateEncoding.js.map +1 -0
  209. package/lib/State/Sync.d.ts +23 -0
  210. package/lib/State/Sync.d.ts.map +1 -0
  211. package/lib/State/Sync.js +49 -0
  212. package/lib/State/Sync.js.map +1 -0
  213. package/lib/State/index.d.ts +4 -0
  214. package/lib/State/index.d.ts.map +1 -1
  215. package/lib/State/index.js +4 -0
  216. package/lib/State/index.js.map +1 -1
  217. package/lib/Test/Bun.d.ts +13 -17
  218. package/lib/Test/Bun.d.ts.map +1 -1
  219. package/lib/Test/Bun.js +17 -36
  220. package/lib/Test/Bun.js.map +1 -1
  221. package/lib/Test/TestState.d.ts +1 -2
  222. package/lib/Test/TestState.d.ts.map +1 -1
  223. package/lib/Test/TestState.js +5 -9
  224. package/lib/Test/TestState.js.map +1 -1
  225. package/lib/Test/Vitest.d.ts +3 -2
  226. package/lib/Test/Vitest.d.ts.map +1 -1
  227. package/lib/Test/Vitest.js +20 -11
  228. package/lib/Test/Vitest.js.map +1 -1
  229. package/lib/Test/index.d.ts +0 -1
  230. package/lib/Test/index.d.ts.map +1 -1
  231. package/lib/Test/index.js +0 -1
  232. package/lib/Test/index.js.map +1 -1
  233. package/lib/Util/FileLogger.d.ts +2 -2
  234. package/lib/Util/FileLogger.d.ts.map +1 -1
  235. package/lib/Util/FileLogger.js +2 -2
  236. package/lib/Util/FileLogger.js.map +1 -1
  237. package/lib/cli/index.d.ts +10 -5
  238. package/lib/cli/index.d.ts.map +1 -1
  239. package/lib/cli/index.js +2 -43045
  240. package/lib/cli/index.js.map +1 -1
  241. package/lib/index.d.ts +2 -1
  242. package/lib/index.d.ts.map +1 -1
  243. package/lib/index.js +2 -1
  244. package/lib/index.js.map +1 -1
  245. package/package.json +30 -15
  246. package/src/AWS/ECS/Task.ts +4 -4
  247. package/src/AWS/Lambda/Function.ts +2 -3
  248. package/src/AWS/SQS/QueueSink.ts +1 -2
  249. package/src/Agent/coding/bash.ts +2 -3
  250. package/src/Agent/coding/glob.ts +1 -2
  251. package/src/Agent/coding/grep.ts +1 -2
  252. package/src/AlchemyContext.ts +27 -0
  253. package/src/Auth/AuthProvider.ts +1 -1
  254. package/src/Auth/index.ts +3 -1
  255. package/src/{Test/TestCli.ts → Cli/LoggingCli.ts} +2 -2
  256. package/src/Cli/index.ts +4 -1
  257. package/src/Cloudflare/ApiToken/AccountApiToken.ts +197 -0
  258. package/src/Cloudflare/ApiToken/Common.ts +148 -0
  259. package/src/Cloudflare/ApiToken/PermissionGroups.ts +1910 -0
  260. package/src/Cloudflare/ApiToken/UserApiToken.ts +168 -0
  261. package/src/Cloudflare/ApiToken/index.ts +4 -0
  262. package/src/Cloudflare/Auth/AuthProvider.ts +2 -2
  263. package/src/Cloudflare/Container/ContainerApplication.ts +8 -2
  264. package/src/Cloudflare/EdgeSession.ts +144 -0
  265. package/src/Cloudflare/Providers.ts +5 -0
  266. package/src/Cloudflare/StateStore/Api.ts +159 -0
  267. package/src/Cloudflare/StateStore/State.ts +318 -0
  268. package/src/Cloudflare/StateStore/Store.ts +290 -0
  269. package/src/Cloudflare/StateStore/Token.ts +68 -0
  270. package/src/Cloudflare/StateStore/index.ts +1 -0
  271. package/src/Cloudflare/Workers/DurableObjectNamespace.ts +1 -6
  272. package/src/Cloudflare/Workers/HttpServer.ts +1 -1
  273. package/src/Cloudflare/Workers/Worker.ts +7 -7
  274. package/src/Cloudflare/index.ts +4 -1
  275. package/src/Deploy.ts +25 -0
  276. package/src/Destroy.ts +25 -13
  277. package/src/GitHub/Providers.ts +6 -0
  278. package/src/GitHub/index.ts +1 -0
  279. package/src/Http.ts +31 -16
  280. package/src/Output.ts +3 -2
  281. package/src/Plan.ts +3 -0
  282. package/src/Platform.ts +8 -2
  283. package/src/Provider.ts +0 -2
  284. package/src/Stack.ts +146 -45
  285. package/src/State/HttpStateApi.ts +155 -0
  286. package/src/State/HttpStateStore.ts +156 -0
  287. package/src/State/InMemoryState.ts +15 -17
  288. package/src/State/LocalState.ts +13 -45
  289. package/src/State/State.ts +13 -4
  290. package/src/State/StateEncoding.ts +83 -0
  291. package/src/State/Sync.ts +89 -0
  292. package/src/State/index.ts +4 -0
  293. package/src/Test/Bun.ts +31 -89
  294. package/src/Test/TestState.ts +6 -8
  295. package/src/Test/Vitest.ts +32 -19
  296. package/src/Test/index.ts +0 -1
  297. package/src/Util/FileLogger.ts +2 -2
  298. package/src/index.ts +2 -1
  299. package/lib/Config.d.ts +0 -20
  300. package/lib/Config.d.ts.map +0 -1
  301. package/lib/Config.js +0 -22
  302. package/lib/Config.js.map +0 -1
  303. package/lib/Observability.d.ts +0 -2
  304. package/lib/Observability.d.ts.map +0 -1
  305. package/lib/Observability.js +0 -1
  306. package/lib/Observability.js.map +0 -1
  307. package/lib/Test/TestCli.d.ts +0 -4
  308. package/lib/Test/TestCli.d.ts.map +0 -1
  309. package/lib/Test/TestCli.js.map +0 -1
  310. package/src/Config.ts +0 -31
  311. package/src/Observability.ts +0 -0
package/src/Test/Bun.ts CHANGED
@@ -1,44 +1,37 @@
1
- import { BunServices } from "@effect/platform-bun";
2
1
  import bun from "bun:test";
3
2
  import { ConfigProvider } from "effect/ConfigProvider";
4
3
  import * as Effect from "effect/Effect";
5
4
  import * as Layer from "effect/Layer";
6
5
  import * as Logger from "effect/Logger";
7
6
  import * as Option from "effect/Option";
8
- import type { Scope } from "effect/Scope";
9
7
  import * as FetchHttpClient from "effect/unstable/http/FetchHttpClient";
10
- import type { HttpClient } from "effect/unstable/http/HttpClient";
11
8
  import type { HookOptions } from "node:test";
12
- import * as Apply from "../Apply.ts";
9
+ import { AlchemyContext, AlchemyContextLive } from "../AlchemyContext.ts";
13
10
  import { provideFreshArtifactStore } from "../Artifacts.ts";
14
11
  import { AuthProviders } from "../Auth/AuthProvider.ts";
15
- import { DotAlchemy, dotAlchemy } from "../Config.ts";
16
- import type { Input } from "../Input.ts";
17
- import * as Plan from "../Plan.ts";
18
- import { type CompiledStack, type StackServices } from "../Stack.ts";
19
- import { Stage } from "../Stage.ts";
12
+ import { inkCLI } from "../Cli/InkCLI.tsx";
13
+ import { deploy as _deploy } from "../Deploy.ts";
14
+ import { destroy as _destroy } from "../Destroy.ts";
15
+ import {
16
+ type CompiledStack,
17
+ type StackEffect,
18
+ type StackServices,
19
+ } from "../Stack.ts";
20
20
  import * as State from "../State/index.ts";
21
21
  import { loadConfigProvider } from "../Util/ConfigProvider.ts";
22
- import { TestCli } from "./TestCli.ts";
22
+ import { PlatformServices } from "../Util/PlatformServices.ts";
23
23
 
24
24
  export type ProvidedServices = StackServices;
25
25
 
26
- type TestEffect<A, Req = never> = Effect.Effect<
27
- A,
28
- any,
29
- BunServices.BunServices | HttpClient | Scope | Req
30
- >;
26
+ type TestEffect<A, Req = never> = StackEffect<A, any, Req>;
31
27
 
32
- const platform = Layer.mergeAll(BunServices.layer, FetchHttpClient.layer);
28
+ const platform = Layer.mergeAll(PlatformServices, FetchHttpClient.layer);
33
29
 
34
- // override alchemy state store, CLI/reporting and dotAlchemy
30
+ // override alchemy state store, CLI/reporting, state, and dotAlchemy
35
31
  const alchemy = Layer.mergeAll(
36
- // TODO(sam): support overriding these
37
- State.LocalState,
38
- // CLI.inkCLI(),
39
- // optional
32
+ inkCLI(),
40
33
  Logger.layer([Logger.consolePretty()]),
41
- dotAlchemy,
34
+ AlchemyContextLive,
42
35
  );
43
36
 
44
37
  const run = <A>(effect: TestEffect<A>) =>
@@ -51,6 +44,7 @@ const run = <A>(effect: TestEffect<A>) =>
51
44
  );
52
45
  }).pipe(
53
46
  Effect.provideService(AuthProviders, {}),
47
+ Effect.provide(State.localState()),
54
48
  Effect.provide(Layer.provideMerge(alchemy, platform)),
55
49
  Effect.scoped,
56
50
  Effect.runPromise,
@@ -106,10 +100,7 @@ export namespace test {
106
100
 
107
101
  export const describe = bun.describe;
108
102
 
109
- export function beforeAll<A>(
110
- eff: Effect.Effect<A, any>,
111
- options?: HookOptions,
112
- ) {
103
+ export function beforeAll<A>(eff: TestEffect<A>, options?: HookOptions) {
113
104
  let a: A;
114
105
  bun.beforeAll(
115
106
  () => run(eff).then((v) => (a = v)),
@@ -120,21 +111,17 @@ export function beforeAll<A>(
120
111
  return Effect.sync(() => a);
121
112
  }
122
113
 
123
- export function beforeEach(
124
- eff: Effect.Effect<void, any>,
125
- options?: HookOptions,
126
- ) {
114
+ export function beforeEach(eff: TestEffect<void>, options?: HookOptions) {
127
115
  bun.beforeEach(() => run(eff), options);
128
116
  }
129
117
 
130
- export function afterAll(eff: Effect.Effect<any, any>, options?: HookOptions) {
118
+ export function afterAll(eff: TestEffect<any>, options?: HookOptions) {
131
119
  bun.afterAll(() => run(eff), options);
132
120
  }
133
121
 
134
122
  export namespace afterAll {
135
123
  export const skipIf =
136
- (predicate: boolean) =>
137
- (test: Effect.Effect<void, any>, options?: HookOptions) => {
124
+ (predicate: boolean) => (test: TestEffect<void>, options?: HookOptions) => {
138
125
  if (predicate) {
139
126
  } else {
140
127
  bun.afterAll(
@@ -147,75 +134,30 @@ export namespace afterAll {
147
134
  };
148
135
  }
149
136
 
150
- export function afterEach(
151
- eff: Effect.Effect<void, any>,
152
- options?: HookOptions,
153
- ) {
137
+ export function afterEach(eff: TestEffect<void>, options?: HookOptions) {
154
138
  bun.afterEach(() => run(eff), options);
155
139
  }
156
140
 
157
141
  export const deploy = <A>(
158
- effect: TestEffect<CompiledStack<A>, Stage | DotAlchemy>,
142
+ stack: TestEffect<CompiledStack<A>, AlchemyContext>,
159
143
  options?: {
160
144
  /** @default test */
161
145
  stage?: string;
162
146
  },
163
147
  ) =>
164
- exec(
165
- effect,
166
- (stack) =>
167
- Effect.gen(function* () {
168
- const plan = yield* Plan.make(stack);
169
- const output = yield* Apply.apply(plan);
170
- return output as Input.Resolve<A>;
171
- }),
172
- options,
173
- );
148
+ _deploy({
149
+ stack: stack,
150
+ stage: options?.stage ?? "test",
151
+ });
174
152
 
175
153
  export const destroy = (
176
- effect: TestEffect<CompiledStack, Stage | DotAlchemy>,
154
+ stack: TestEffect<CompiledStack, AlchemyContext>,
177
155
  options?: {
178
156
  /** @default test */
179
157
  stage?: string;
180
158
  },
181
159
  ) =>
182
- exec(
183
- effect,
184
- (stack) =>
185
- Effect.gen(function* () {
186
- const plan = yield* Plan.make({
187
- ...stack,
188
- // zero these out (destroy will treat all as orphans)
189
- // TODO(sam): probably better to have Plan.destroy and Plan.update
190
- resources: {},
191
- bindings: {},
192
- output: {},
193
- });
194
- yield* Apply.apply(plan);
195
- }),
196
- options,
197
- );
198
-
199
- const exec = <A, B>(
200
- effect: TestEffect<CompiledStack<A>, Stage | DotAlchemy>,
201
- fn: (stack: CompiledStack<A>) => Effect.Effect<B, any, any>,
202
- options?: {
203
- stage?: string;
204
- },
205
- ) =>
206
- Effect.gen(function* () {
207
- const stack = yield* effect;
208
- const configProvider = yield* loadConfigProvider(Option.none());
209
-
210
- return yield* fn(stack).pipe(
211
- provideFreshArtifactStore,
212
- Effect.provide(stack.services),
213
- Effect.provide(Layer.succeed(ConfigProvider, configProvider)),
214
- );
215
- }).pipe(
216
- Effect.provideService(AuthProviders, {}),
217
- Effect.provide(Layer.succeed(Stage, options?.stage ?? "test")),
218
- Effect.provide(TestCli),
219
- Effect.provide(Layer.provideMerge(alchemy, platform)),
220
- Effect.scoped,
221
- );
160
+ _destroy({
161
+ stack,
162
+ stage: options?.stage ?? "test",
163
+ });
@@ -1,19 +1,17 @@
1
- import * as Effect from "effect/Effect";
2
1
  import * as Layer from "effect/Layer";
3
2
  import { Stack } from "../Stack.ts";
4
- import { Stage } from "../Stage.ts";
5
3
  import * as State from "../State/index.ts";
6
4
 
7
5
  export const state = (resources: Record<string, State.ResourceState> = {}) =>
8
6
  Layer.effect(
9
7
  State.State,
10
- Effect.gen(function* () {
11
- return State.InMemoryService({
12
- [(yield* Stack).name]: {
13
- [yield* Stage]: resources,
8
+ Stack.useSync((stack) =>
9
+ State.InMemoryService({
10
+ [stack.name]: {
11
+ [stack.stage]: resources,
14
12
  },
15
- });
16
- }),
13
+ }),
14
+ ),
17
15
  );
18
16
 
19
17
  export const defaultState = (
@@ -22,6 +22,7 @@ import * as AWS from "../AWS/index.ts";
22
22
  import * as Cloudflare from "../Cloudflare/index.ts";
23
23
 
24
24
  import type { ChildProcessSpawner } from "effect/unstable/process/ChildProcessSpawner";
25
+ import { AlchemyContext, AlchemyContextLive } from "../AlchemyContext.ts";
25
26
  import { apply } from "../Apply.ts";
26
27
  import { Artifacts, provideFreshArtifactStore } from "../Artifacts.ts";
27
28
  import { AuthProviders } from "../Auth/AuthProvider.ts";
@@ -30,12 +31,12 @@ import * as AWSEnvironment from "../AWS/Environment.ts";
30
31
  import * as AWSRegion from "../AWS/Region.ts";
31
32
  import type { Command } from "../Build/Command.ts";
32
33
  import type { Cli } from "../Cli/index.ts";
34
+ import { LoggingCli } from "../Cli/LoggingCli.ts";
33
35
  import {
34
36
  buildNamespaceTree,
35
37
  flattenTree,
36
38
  type DerivedAction,
37
39
  } from "../Cli/NamespaceTree.ts";
38
- import { DotAlchemy, dotAlchemy } from "../Config.ts";
39
40
  import { ExecutionContext } from "../ExecutionContext.ts";
40
41
  import type { Input } from "../Input.ts";
41
42
  import type { Output } from "../Output.ts";
@@ -47,7 +48,6 @@ import * as Stack from "../Stack.ts";
47
48
  import * as Stage from "../Stage.ts";
48
49
  import * as State from "../State/index.ts";
49
50
  import { PlatformServices } from "../Util/PlatformServices.ts";
50
- import { TestCli } from "./TestCli.ts";
51
51
 
52
52
  export const expectEmptyObject = () =>
53
53
  expect.toSatisfy(
@@ -70,7 +70,7 @@ type Provided =
70
70
  | Stack.Stack
71
71
  | State.State
72
72
  | Stage.Stage
73
- | DotAlchemy
73
+ | AlchemyContext
74
74
  | HttpClient.HttpClient
75
75
  | FileSystem.FileSystem
76
76
  | Path.Path
@@ -101,7 +101,7 @@ const platform = Layer.mergeAll(
101
101
 
102
102
  const awsEnvironment = Layer.unwrap(
103
103
  Effect.gen(function* () {
104
- const profileName = yield* Config.string("AWS_PROFILE").pipe(
104
+ const _profileName = yield* Config.string("AWS_PROFILE").pipe(
105
105
  Config.withDefault("default"),
106
106
  );
107
107
  const LOCAL = yield* Config.boolean("LOCAL").pipe(
@@ -176,8 +176,8 @@ const runWithContext = <A, Err>(
176
176
  );
177
177
 
178
178
  const alchemy = Layer.provideMerge(
179
- Layer.mergeAll(options.state ?? State.LocalState, TestCli),
180
- Layer.mergeAll(stack, dotAlchemy),
179
+ Layer.mergeAll(options.state ?? State.localState(), LoggingCli),
180
+ Layer.mergeAll(stack, AlchemyContextLive),
181
181
  );
182
182
 
183
183
  const context = {
@@ -357,23 +357,26 @@ export namespace test {
357
357
  export const deploy = <A, Err = never, Req = any>(
358
358
  effect: Effect.Effect<A, Err, Req>,
359
359
  ): Effect.Effect<Input.Resolve<A>, Err, Req | Stack.Stack> =>
360
- Stack.Stack.use((stack) => {
361
- return provideFreshArtifactStore(
362
- effect.pipe(
363
- // Effect.tap(Effect.logInfo),
364
- // @ts-expect-error
365
- Stack.make(stack.name, Layer.effectContext(Effect.context<never>()), {
360
+ Stack.Stack.use((stack) =>
361
+ effect.pipe(
362
+ // @ts-expect-error - test harness reuses ambient runtime context
363
+ Stack.make({
364
+ name: stack.name,
365
+ providers: Layer.effectContext(Effect.context<never>()),
366
+ state: State.localState(),
367
+ stack: {
366
368
  ...stack,
367
369
  resources: {},
368
370
  bindings: {},
369
371
  output: {},
370
- }),
371
- Effect.flatMap(Plan.make),
372
- Effect.tap((plan) => Effect.logInfo(formatPlan(plan))),
373
- Effect.flatMap(apply),
374
- ),
375
- );
376
- });
372
+ },
373
+ }),
374
+ Effect.flatMap(Plan.make),
375
+ Effect.tap((plan) => Effect.logInfo(formatPlan(plan))),
376
+ Effect.flatMap(apply),
377
+ provideFreshArtifactStore,
378
+ ),
379
+ );
377
380
  }
378
381
 
379
382
  type AnyAction = Plan.CRUD["action"] | Plan.BindingAction | DerivedAction;
@@ -528,3 +531,13 @@ export function afterAll<A, E, R extends Provided = never>(
528
531
  options?.timeout,
529
532
  );
530
533
  }
534
+ export const destroy = () =>
535
+ Stack.Stack.use((stack) =>
536
+ Plan.make({
537
+ name: stack.name,
538
+ stage: stack.stage,
539
+ resources: {},
540
+ bindings: {},
541
+ output: {},
542
+ }).pipe(Effect.flatMap(apply), provideFreshArtifactStore),
543
+ );
package/src/Test/index.ts CHANGED
@@ -1,3 +1,2 @@
1
- export * from "./TestCli.ts";
2
1
  export * from "./TestState.ts";
3
2
  export * from "./Vitest.ts";
@@ -2,12 +2,12 @@ import * as Effect from "effect/Effect";
2
2
  import * as FileSystem from "effect/FileSystem";
3
3
  import * as Logger from "effect/Logger";
4
4
  import { Path } from "effect/Path";
5
- import { DotAlchemy } from "../Config.ts";
5
+ import { AlchemyContext } from "../AlchemyContext.ts";
6
6
 
7
7
  export const fileLogger = Effect.fnUntraced(function* (
8
8
  ...segments: ReadonlyArray<string>
9
9
  ) {
10
- const dotAlchemy = yield* DotAlchemy;
10
+ const { dotAlchemy } = yield* AlchemyContext;
11
11
  const fs = yield* FileSystem.FileSystem;
12
12
  const path = yield* Path;
13
13
  const logFile = path.join(dotAlchemy, "log", ...segments);
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * as AdoptPolicy from "./AdoptPolicy.ts";
2
+ export * from "./AlchemyContext.ts";
2
3
  export * from "./Apply.ts";
3
4
  export {
4
5
  Service as BindingService,
@@ -8,7 +9,6 @@ export {
8
9
  type PolicyLike,
9
10
  type PolicyShape,
10
11
  } from "./Binding.ts";
11
- export * from "./Config.ts";
12
12
  export * from "./Destroy.ts";
13
13
  export * from "./Diff.ts";
14
14
  export * from "./Input.ts";
@@ -27,6 +27,7 @@ export * as Server from "./Server/index.ts";
27
27
  export * as Serverless from "./Serverless/index.ts";
28
28
  export { Stack } from "./Stack.ts";
29
29
  export * from "./Stage.ts";
30
+ export { inMemoryState, localState } from "./State/index.ts";
30
31
  export * from "./Trait.ts";
31
32
 
32
33
  export * as Construct from "./Construct.ts";
package/lib/Config.d.ts DELETED
@@ -1,20 +0,0 @@
1
- import * as Context from "effect/Context";
2
- import * as FileSystem from "effect/FileSystem";
3
- import * as Layer from "effect/Layer";
4
- import * as Path from "effect/Path";
5
- export type cwd = typeof cwd;
6
- /**
7
- * Placeholder for referencing the current working directory in module-scoped code.
8
- *
9
- * Will be replaced lazily with the actual current working directory (as provided by Effect context).
10
- */
11
- export declare const cwd: {
12
- readonly type: "cwd";
13
- };
14
- export declare const isCwd: (x: any) => x is cwd;
15
- declare const DotAlchemy_base: Context.ServiceClass<DotAlchemy, ".alchemy", string>;
16
- export declare class DotAlchemy extends DotAlchemy_base {
17
- }
18
- export declare const dotAlchemy: Layer.Layer<DotAlchemy, import("effect/PlatformError").PlatformError, FileSystem.FileSystem | Path.Path>;
19
- export {};
20
- //# sourceMappingURL=Config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Config.d.ts","sourceRoot":"","sources":["../src/Config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAE1C,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AAEpC,MAAM,MAAM,GAAG,GAAG,OAAO,GAAG,CAAC;AAE7B;;;;GAIG;AACH,eAAO,MAAM,GAAG;;CAA2B,CAAC;AAE5C,eAAO,MAAM,KAAK,GAAI,GAAG,GAAG,KAAG,CAAC,IAAI,GAAwB,CAAC;;AAE7D,qBAAa,UAAW,SAAQ,eAE/B;CAAG;AAEJ,eAAO,MAAM,UAAU,0GAStB,CAAC"}
package/lib/Config.js DELETED
@@ -1,22 +0,0 @@
1
- import * as Context from "effect/Context";
2
- import * as Effect from "effect/Effect";
3
- import * as FileSystem from "effect/FileSystem";
4
- import * as Layer from "effect/Layer";
5
- import * as Path from "effect/Path";
6
- /**
7
- * Placeholder for referencing the current working directory in module-scoped code.
8
- *
9
- * Will be replaced lazily with the actual current working directory (as provided by Effect context).
10
- */
11
- export const cwd = { type: "cwd" };
12
- export const isCwd = (x) => x?.type === "cwd";
13
- export class DotAlchemy extends Context.Service()(".alchemy") {
14
- }
15
- export const dotAlchemy = Layer.effect(DotAlchemy, Effect.gen(function* () {
16
- const fs = yield* FileSystem.FileSystem;
17
- const path = yield* Path.Path;
18
- const dir = path.join(process.cwd(), ".alchemy");
19
- yield* fs.makeDirectory(dir, { recursive: true });
20
- return dir;
21
- }));
22
- //# sourceMappingURL=Config.js.map
package/lib/Config.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"Config.js","sourceRoot":"","sources":["../src/Config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AAIpC;;;;GAIG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE,IAAI,EAAE,KAAK,EAAW,CAAC;AAE5C,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,CAAM,EAAY,EAAE,CAAC,CAAC,EAAE,IAAI,KAAK,KAAK,CAAC;AAE7D,MAAM,OAAO,UAAW,SAAQ,OAAO,CAAC,OAAO,EAAsB,CACnE,UAAU,CACX;CAAG;AAEJ,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CACpC,UAAU,EACV,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC;IACxC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;IAC9B,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,CAAC;IACjD,KAAK,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAClD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC,CACH,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=Observability.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Observability.d.ts","sourceRoot":"","sources":["../src/Observability.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=Observability.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Observability.js","sourceRoot":"","sources":["../src/Observability.ts"],"names":[],"mappings":""}
@@ -1,4 +0,0 @@
1
- import * as Layer from "effect/Layer";
2
- import { Cli } from "../Cli/Cli.ts";
3
- export declare const TestCli: Layer.Layer<Cli, never, never>;
4
- //# sourceMappingURL=TestCli.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TestCli.d.ts","sourceRoot":"","sources":["../../src/Test/TestCli.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,eAAO,MAAM,OAAO,gCAgBnB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"TestCli.js","sourceRoot":"","sources":["../../src/Test/TestCli.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAClC,GAAG,EACH,GAAG,CAAC,EAAE,CAAC;IACL,WAAW,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;IACvC,WAAW,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI;IAC9B,iBAAiB,EAAE,GAAG,EAAE,CACtB,MAAM,CAAC,OAAO,CAAC;QACb,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI;QACvB,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CACd,MAAM,CAAC,GAAG,CACR,KAAK,CAAC,IAAI,KAAK,eAAe;YAC5B,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,EAAE,IAAI,KAAK,CAAC,IAAI,GAAG;YAC9C,CAAC,CAAC,GAAG,KAAK,CAAC,EAAE,KAAK,KAAK,CAAC,OAAO,EAAE,CACpC;KACJ,CAAC;CACL,CAAC,CACH,CAAC"}
package/src/Config.ts DELETED
@@ -1,31 +0,0 @@
1
- import * as Context from "effect/Context";
2
- import * as Effect from "effect/Effect";
3
- import * as FileSystem from "effect/FileSystem";
4
- import * as Layer from "effect/Layer";
5
- import * as Path from "effect/Path";
6
-
7
- export type cwd = typeof cwd;
8
-
9
- /**
10
- * Placeholder for referencing the current working directory in module-scoped code.
11
- *
12
- * Will be replaced lazily with the actual current working directory (as provided by Effect context).
13
- */
14
- export const cwd = { type: "cwd" } as const;
15
-
16
- export const isCwd = (x: any): x is cwd => x?.type === "cwd";
17
-
18
- export class DotAlchemy extends Context.Service<DotAlchemy, string>()(
19
- ".alchemy",
20
- ) {}
21
-
22
- export const dotAlchemy = Layer.effect(
23
- DotAlchemy,
24
- Effect.gen(function* () {
25
- const fs = yield* FileSystem.FileSystem;
26
- const path = yield* Path.Path;
27
- const dir = path.join(process.cwd(), ".alchemy");
28
- yield* fs.makeDirectory(dir, { recursive: true });
29
- return dir;
30
- }),
31
- );
File without changes