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.
- package/bin/alchemy.js +9477 -9290
- package/bin/alchemy.js.map +1 -1
- package/bin/alchemy.ts +6 -2
- package/bin/cli.js +61 -0
- package/bin/commands/deploy.ts +6 -4
- package/bin/commands/login.ts +1 -1
- package/bin/commands/logs.ts +1 -1
- package/bin/commands/state.ts +233 -0
- package/bin/commands/tail.ts +1 -1
- package/lib/AWS/AutoScaling/LaunchTemplate.d.ts +1 -1
- package/lib/AWS/EC2/Instance.d.ts +1 -1
- package/lib/AWS/EC2/hosted.d.ts +2 -2
- package/lib/AWS/ECS/Task.d.ts +4 -4
- package/lib/AWS/ECS/Task.d.ts.map +1 -1
- package/lib/AWS/ECS/Task.js +2 -2
- package/lib/AWS/ECS/Task.js.map +1 -1
- package/lib/AWS/Environment.d.ts +2 -2
- package/lib/AWS/Lambda/BucketEventSource.d.ts +1 -1
- package/lib/AWS/Lambda/BucketEventSource.d.ts.map +1 -1
- package/lib/AWS/Lambda/EventBridgeEventSource.d.ts +1 -1
- package/lib/AWS/Lambda/EventBridgeEventSource.d.ts.map +1 -1
- package/lib/AWS/Lambda/Function.d.ts +2 -2
- package/lib/AWS/Lambda/Function.d.ts.map +1 -1
- package/lib/AWS/Lambda/Function.js +1 -2
- package/lib/AWS/Lambda/Function.js.map +1 -1
- package/lib/AWS/Lambda/QueueEventSource.d.ts +1 -1
- package/lib/AWS/Lambda/QueueEventSource.d.ts.map +1 -1
- package/lib/AWS/Lambda/StreamEventSource.d.ts +1 -1
- package/lib/AWS/Lambda/StreamEventSource.d.ts.map +1 -1
- package/lib/AWS/Lambda/TableEventSource.d.ts +1 -1
- package/lib/AWS/Lambda/TableEventSource.d.ts.map +1 -1
- package/lib/AWS/Lambda/TopicEventSource.d.ts +1 -1
- package/lib/AWS/Lambda/TopicEventSource.d.ts.map +1 -1
- package/lib/AWS/SQS/QueueSink.d.ts.map +1 -1
- package/lib/AWS/SQS/QueueSink.js +1 -2
- package/lib/AWS/SQS/QueueSink.js.map +1 -1
- package/lib/Agent/coding/bash.d.ts +2 -6
- package/lib/Agent/coding/bash.d.ts.map +1 -1
- package/lib/Agent/coding/bash.js +2 -3
- package/lib/Agent/coding/bash.js.map +1 -1
- package/lib/Agent/coding/edit.d.ts +1 -1
- package/lib/Agent/coding/glob.d.ts +2 -4
- package/lib/Agent/coding/glob.d.ts.map +1 -1
- package/lib/Agent/coding/glob.js +1 -2
- package/lib/Agent/coding/glob.js.map +1 -1
- package/lib/Agent/coding/grep.d.ts +2 -4
- package/lib/Agent/coding/grep.d.ts.map +1 -1
- package/lib/Agent/coding/grep.js +1 -2
- package/lib/Agent/coding/grep.js.map +1 -1
- package/lib/Agent/coding/read.d.ts +1 -1
- package/lib/Agent/coding/write.d.ts +1 -1
- package/lib/Agent/lsp/client.d.ts +2 -2
- package/lib/Agent/util/ripgrep.d.ts +2 -2
- package/lib/AlchemyContext.d.ts +13 -0
- package/lib/AlchemyContext.d.ts.map +1 -0
- package/lib/AlchemyContext.js +18 -0
- package/lib/AlchemyContext.js.map +1 -0
- package/lib/Auth/AuthProvider.js +1 -1
- package/lib/Auth/AuthProvider.js.map +1 -1
- package/lib/Auth/Profile.d.ts +1 -1
- package/lib/Auth/index.d.ts +3 -1
- package/lib/Auth/index.d.ts.map +1 -1
- package/lib/Auth/index.js +3 -0
- package/lib/Auth/index.js.map +1 -1
- package/lib/Build/Command.d.ts +1 -1
- package/lib/Build/Memo.d.ts +1 -1
- package/lib/Bundle/Docker.d.ts +3 -3
- package/lib/Bundle/TempRoot.d.ts +3 -3
- package/lib/Cli/LoggingCli.d.ts +4 -0
- package/lib/Cli/LoggingCli.d.ts.map +1 -0
- package/lib/{Test/TestCli.js → Cli/LoggingCli.js} +3 -3
- package/lib/Cli/LoggingCli.js.map +1 -0
- package/lib/Cli/index.d.ts +0 -1
- package/lib/Cli/index.d.ts.map +1 -1
- package/lib/Cli/index.js +4 -1
- package/lib/Cli/index.js.map +1 -1
- package/lib/Cloudflare/ApiToken/AccountApiToken.d.ts +58 -0
- package/lib/Cloudflare/ApiToken/AccountApiToken.d.ts.map +1 -0
- package/lib/Cloudflare/ApiToken/AccountApiToken.js +137 -0
- package/lib/Cloudflare/ApiToken/AccountApiToken.js.map +1 -0
- package/lib/Cloudflare/ApiToken/Common.d.ts +91 -0
- package/lib/Cloudflare/ApiToken/Common.d.ts.map +1 -0
- package/lib/Cloudflare/ApiToken/Common.js +61 -0
- package/lib/Cloudflare/ApiToken/Common.js.map +1 -0
- package/lib/Cloudflare/ApiToken/PermissionGroups.d.ts +1549 -0
- package/lib/Cloudflare/ApiToken/PermissionGroups.d.ts.map +1 -0
- package/lib/Cloudflare/ApiToken/PermissionGroups.js +1856 -0
- package/lib/Cloudflare/ApiToken/PermissionGroups.js.map +1 -0
- package/lib/Cloudflare/ApiToken/UserApiToken.d.ts +49 -0
- package/lib/Cloudflare/ApiToken/UserApiToken.d.ts.map +1 -0
- package/lib/Cloudflare/ApiToken/UserApiToken.js +113 -0
- package/lib/Cloudflare/ApiToken/UserApiToken.js.map +1 -0
- package/lib/Cloudflare/ApiToken/index.d.ts +5 -0
- package/lib/Cloudflare/ApiToken/index.d.ts.map +1 -0
- package/lib/Cloudflare/ApiToken/index.js +5 -0
- package/lib/Cloudflare/ApiToken/index.js.map +1 -0
- package/lib/Cloudflare/Auth/AuthProvider.js +2 -2
- package/lib/Cloudflare/Auth/AuthProvider.js.map +1 -1
- package/lib/Cloudflare/CloudflareEnvironment.d.ts +1 -1
- package/lib/Cloudflare/Container/ContainerApplication.d.ts +2 -2
- package/lib/Cloudflare/Container/ContainerApplication.d.ts.map +1 -1
- package/lib/Cloudflare/Container/ContainerApplication.js +7 -2
- package/lib/Cloudflare/Container/ContainerApplication.js.map +1 -1
- package/lib/Cloudflare/EdgeSession.d.ts +53 -0
- package/lib/Cloudflare/EdgeSession.d.ts.map +1 -0
- package/lib/Cloudflare/EdgeSession.js +78 -0
- package/lib/Cloudflare/EdgeSession.js.map +1 -0
- package/lib/Cloudflare/Providers.d.ts +1 -1
- package/lib/Cloudflare/Providers.d.ts.map +1 -1
- package/lib/Cloudflare/Providers.js +4 -1
- package/lib/Cloudflare/Providers.js.map +1 -1
- package/lib/Cloudflare/StateStore/Api.d.ts +61 -0
- package/lib/Cloudflare/StateStore/Api.d.ts.map +1 -0
- package/lib/Cloudflare/StateStore/Api.js +103 -0
- package/lib/Cloudflare/StateStore/Api.js.map +1 -0
- package/lib/Cloudflare/StateStore/State.d.ts +39 -0
- package/lib/Cloudflare/StateStore/State.d.ts.map +1 -0
- package/lib/Cloudflare/StateStore/State.js +217 -0
- package/lib/Cloudflare/StateStore/State.js.map +1 -0
- package/lib/Cloudflare/StateStore/Store.d.ts +82 -0
- package/lib/Cloudflare/StateStore/Store.d.ts.map +1 -0
- package/lib/Cloudflare/StateStore/Store.js +191 -0
- package/lib/Cloudflare/StateStore/Store.js.map +1 -0
- package/lib/Cloudflare/StateStore/Token.d.ts +43 -0
- package/lib/Cloudflare/StateStore/Token.d.ts.map +1 -0
- package/lib/Cloudflare/StateStore/Token.js +61 -0
- package/lib/Cloudflare/StateStore/Token.js.map +1 -0
- package/lib/Cloudflare/StateStore/index.d.ts +2 -0
- package/lib/Cloudflare/StateStore/index.d.ts.map +1 -0
- package/lib/Cloudflare/StateStore/index.js +2 -0
- package/lib/Cloudflare/StateStore/index.js.map +1 -0
- package/lib/Cloudflare/Workers/Assets.d.ts +2 -2
- package/lib/Cloudflare/Workers/DurableObjectNamespace.d.ts +2 -2
- package/lib/Cloudflare/Workers/DurableObjectNamespace.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/DurableObjectNamespace.js +0 -1
- package/lib/Cloudflare/Workers/DurableObjectNamespace.js.map +1 -1
- package/lib/Cloudflare/Workers/HttpServer.d.ts +1 -1
- package/lib/Cloudflare/Workers/HttpServer.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/HttpServer.js.map +1 -1
- package/lib/Cloudflare/Workers/Worker.d.ts +5 -5
- package/lib/Cloudflare/Workers/Worker.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/Worker.js +0 -1
- package/lib/Cloudflare/Workers/Worker.js.map +1 -1
- package/lib/Cloudflare/index.d.ts +4 -1
- package/lib/Cloudflare/index.d.ts.map +1 -1
- package/lib/Cloudflare/index.js +4 -1
- package/lib/Cloudflare/index.js.map +1 -1
- package/lib/Deploy.d.ts +10 -0
- package/lib/Deploy.d.ts.map +1 -0
- package/lib/Deploy.js +12 -0
- package/lib/Deploy.js.map +1 -0
- package/lib/Destroy.d.ts +8 -3
- package/lib/Destroy.d.ts.map +1 -1
- package/lib/Destroy.js +8 -8
- package/lib/Destroy.js.map +1 -1
- package/lib/GitHub/Providers.d.ts +3 -0
- package/lib/GitHub/Providers.d.ts.map +1 -0
- package/lib/GitHub/Providers.js +5 -0
- package/lib/GitHub/Providers.js.map +1 -0
- package/lib/GitHub/index.d.ts +1 -0
- package/lib/GitHub/index.d.ts.map +1 -1
- package/lib/GitHub/index.js +1 -0
- package/lib/GitHub/index.js.map +1 -1
- package/lib/Http.d.ts +1 -1
- package/lib/Http.d.ts.map +1 -1
- package/lib/Http.js +7 -3
- package/lib/Http.js.map +1 -1
- package/lib/Kubernetes/client.d.ts +10 -10
- package/lib/Output.d.ts.map +1 -1
- package/lib/Output.js +4 -0
- package/lib/Output.js.map +1 -1
- package/lib/Plan.d.ts.map +1 -1
- package/lib/Plan.js +4 -0
- package/lib/Plan.js.map +1 -1
- package/lib/Platform.d.ts +2 -2
- package/lib/Platform.d.ts.map +1 -1
- package/lib/Platform.js.map +1 -1
- package/lib/Provider.d.ts.map +1 -1
- package/lib/Provider.js +0 -1
- package/lib/Provider.js.map +1 -1
- package/lib/Stack.d.ts +24 -12
- package/lib/Stack.d.ts.map +1 -1
- package/lib/Stack.js +47 -10
- package/lib/Stack.js.map +1 -1
- package/lib/State/HttpStateApi.d.ts +96 -0
- package/lib/State/HttpStateApi.d.ts.map +1 -0
- package/lib/State/HttpStateApi.js +96 -0
- package/lib/State/HttpStateApi.js.map +1 -0
- package/lib/State/HttpStateStore.d.ts +10 -0
- package/lib/State/HttpStateStore.d.ts.map +1 -0
- package/lib/State/HttpStateStore.js +102 -0
- package/lib/State/HttpStateStore.js.map +1 -0
- package/lib/State/InMemoryState.d.ts +2 -30
- package/lib/State/InMemoryState.d.ts.map +1 -1
- package/lib/State/InMemoryState.js +23 -18
- package/lib/State/InMemoryState.js.map +1 -1
- package/lib/State/LocalState.d.ts +4 -2
- package/lib/State/LocalState.d.ts.map +1 -1
- package/lib/State/LocalState.js +9 -41
- package/lib/State/LocalState.js.map +1 -1
- package/lib/State/State.d.ts +11 -4
- package/lib/State/State.d.ts.map +1 -1
- package/lib/State/State.js +1 -1
- package/lib/State/State.js.map +1 -1
- package/lib/State/StateEncoding.d.ts +31 -0
- package/lib/State/StateEncoding.d.ts.map +1 -0
- package/lib/State/StateEncoding.js +82 -0
- package/lib/State/StateEncoding.js.map +1 -0
- package/lib/State/Sync.d.ts +23 -0
- package/lib/State/Sync.d.ts.map +1 -0
- package/lib/State/Sync.js +49 -0
- package/lib/State/Sync.js.map +1 -0
- package/lib/State/index.d.ts +4 -0
- package/lib/State/index.d.ts.map +1 -1
- package/lib/State/index.js +4 -0
- package/lib/State/index.js.map +1 -1
- package/lib/Test/Bun.d.ts +13 -17
- package/lib/Test/Bun.d.ts.map +1 -1
- package/lib/Test/Bun.js +17 -36
- package/lib/Test/Bun.js.map +1 -1
- package/lib/Test/TestState.d.ts +1 -2
- package/lib/Test/TestState.d.ts.map +1 -1
- package/lib/Test/TestState.js +5 -9
- package/lib/Test/TestState.js.map +1 -1
- package/lib/Test/Vitest.d.ts +3 -2
- package/lib/Test/Vitest.d.ts.map +1 -1
- package/lib/Test/Vitest.js +20 -11
- package/lib/Test/Vitest.js.map +1 -1
- package/lib/Test/index.d.ts +0 -1
- package/lib/Test/index.d.ts.map +1 -1
- package/lib/Test/index.js +0 -1
- package/lib/Test/index.js.map +1 -1
- package/lib/Util/FileLogger.d.ts +2 -2
- package/lib/Util/FileLogger.d.ts.map +1 -1
- package/lib/Util/FileLogger.js +2 -2
- package/lib/Util/FileLogger.js.map +1 -1
- package/lib/cli/index.d.ts +10 -5
- package/lib/cli/index.d.ts.map +1 -1
- package/lib/cli/index.js +2 -43045
- package/lib/cli/index.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/package.json +30 -15
- package/src/AWS/ECS/Task.ts +4 -4
- package/src/AWS/Lambda/Function.ts +2 -3
- package/src/AWS/SQS/QueueSink.ts +1 -2
- package/src/Agent/coding/bash.ts +2 -3
- package/src/Agent/coding/glob.ts +1 -2
- package/src/Agent/coding/grep.ts +1 -2
- package/src/AlchemyContext.ts +27 -0
- package/src/Auth/AuthProvider.ts +1 -1
- package/src/Auth/index.ts +3 -1
- package/src/{Test/TestCli.ts → Cli/LoggingCli.ts} +2 -2
- package/src/Cli/index.ts +4 -1
- package/src/Cloudflare/ApiToken/AccountApiToken.ts +197 -0
- package/src/Cloudflare/ApiToken/Common.ts +148 -0
- package/src/Cloudflare/ApiToken/PermissionGroups.ts +1910 -0
- package/src/Cloudflare/ApiToken/UserApiToken.ts +168 -0
- package/src/Cloudflare/ApiToken/index.ts +4 -0
- package/src/Cloudflare/Auth/AuthProvider.ts +2 -2
- package/src/Cloudflare/Container/ContainerApplication.ts +8 -2
- package/src/Cloudflare/EdgeSession.ts +144 -0
- package/src/Cloudflare/Providers.ts +5 -0
- package/src/Cloudflare/StateStore/Api.ts +159 -0
- package/src/Cloudflare/StateStore/State.ts +318 -0
- package/src/Cloudflare/StateStore/Store.ts +290 -0
- package/src/Cloudflare/StateStore/Token.ts +68 -0
- package/src/Cloudflare/StateStore/index.ts +1 -0
- package/src/Cloudflare/Workers/DurableObjectNamespace.ts +1 -6
- package/src/Cloudflare/Workers/HttpServer.ts +1 -1
- package/src/Cloudflare/Workers/Worker.ts +7 -7
- package/src/Cloudflare/index.ts +4 -1
- package/src/Deploy.ts +25 -0
- package/src/Destroy.ts +25 -13
- package/src/GitHub/Providers.ts +6 -0
- package/src/GitHub/index.ts +1 -0
- package/src/Http.ts +31 -16
- package/src/Output.ts +3 -2
- package/src/Plan.ts +3 -0
- package/src/Platform.ts +8 -2
- package/src/Provider.ts +0 -2
- package/src/Stack.ts +146 -45
- package/src/State/HttpStateApi.ts +155 -0
- package/src/State/HttpStateStore.ts +156 -0
- package/src/State/InMemoryState.ts +15 -17
- package/src/State/LocalState.ts +13 -45
- package/src/State/State.ts +13 -4
- package/src/State/StateEncoding.ts +83 -0
- package/src/State/Sync.ts +89 -0
- package/src/State/index.ts +4 -0
- package/src/Test/Bun.ts +31 -89
- package/src/Test/TestState.ts +6 -8
- package/src/Test/Vitest.ts +32 -19
- package/src/Test/index.ts +0 -1
- package/src/Util/FileLogger.ts +2 -2
- package/src/index.ts +2 -1
- package/lib/Config.d.ts +0 -20
- package/lib/Config.d.ts.map +0 -1
- package/lib/Config.js +0 -22
- package/lib/Config.js.map +0 -1
- package/lib/Observability.d.ts +0 -2
- package/lib/Observability.d.ts.map +0 -1
- package/lib/Observability.js +0 -1
- package/lib/Observability.js.map +0 -1
- package/lib/Test/TestCli.d.ts +0 -4
- package/lib/Test/TestCli.d.ts.map +0 -1
- package/lib/Test/TestCli.js.map +0 -1
- package/src/Config.ts +0 -31
- package/src/Observability.ts +0 -0
|
@@ -14,7 +14,7 @@ import { isWorkerEvent, type WorkerServices } from "./Worker.ts";
|
|
|
14
14
|
export type HttpEffect = Http.HttpEffect<WorkerServices>;
|
|
15
15
|
|
|
16
16
|
export const workersHttpHandler = <Req = never>(
|
|
17
|
-
handler: Http.HttpEffect<Req
|
|
17
|
+
handler: Http.HttpEffect<Req> | Effect.Effect<Http.HttpEffect<Req>>,
|
|
18
18
|
) => {
|
|
19
19
|
const safeHandler = Http.safeHttpEffect(handler);
|
|
20
20
|
return (event: any) => {
|
|
@@ -48,11 +48,11 @@ import { Stack } from "../../Stack.ts";
|
|
|
48
48
|
import { CloudflareEnvironment } from "../CloudflareEnvironment.ts";
|
|
49
49
|
import { D1Database } from "../D1/D1Database.ts";
|
|
50
50
|
import { fromCloudflareFetcher } from "../Fetcher.ts";
|
|
51
|
+
import type { KVNamespace } from "../KV/KVNamespace.ts";
|
|
51
52
|
import { CloudflareLogs } from "../Logs.ts";
|
|
52
53
|
import type { Providers } from "../Providers.ts";
|
|
53
|
-
import type { R2Bucket } from "../R2/R2Bucket.ts";
|
|
54
|
-
import type { KVNamespace } from "../KV/KVNamespace.ts";
|
|
55
54
|
import type { Queue as CloudflareQueue } from "../Queue/Queue.ts";
|
|
55
|
+
import type { R2Bucket } from "../R2/R2Bucket.ts";
|
|
56
56
|
import {
|
|
57
57
|
isAssets,
|
|
58
58
|
readAssets,
|
|
@@ -173,9 +173,9 @@ export interface WorkerExecutionContext extends Serverless.FunctionContext {
|
|
|
173
173
|
export(name: string, value: any): Effect.Effect<void>;
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
export type WorkerServices = Worker |
|
|
176
|
+
export type WorkerServices = Worker | Request;
|
|
177
177
|
|
|
178
|
-
export type WorkerShape = Main<WorkerServices>;
|
|
178
|
+
export type WorkerShape = Main<WorkerServices | WorkerEnvironment>;
|
|
179
179
|
|
|
180
180
|
export type WorkerBindingResource =
|
|
181
181
|
| Assets
|
|
@@ -764,8 +764,9 @@ export const Worker: Platform<
|
|
|
764
764
|
);
|
|
765
765
|
return key;
|
|
766
766
|
}),
|
|
767
|
-
serve: <Req = never>(
|
|
768
|
-
|
|
767
|
+
serve: <Req = never>(
|
|
768
|
+
handler: HttpEffect<Req> | Effect.Effect<HttpEffect<Req>>,
|
|
769
|
+
) => ctx.listen(workersHttpHandler(handler)),
|
|
769
770
|
listen: ((
|
|
770
771
|
handler:
|
|
771
772
|
| Serverless.FunctionListener
|
|
@@ -1280,7 +1281,6 @@ const stack = Layer.succeed(
|
|
|
1280
1281
|
|
|
1281
1282
|
const exportsEffect = tag.asEffect().pipe(
|
|
1282
1283
|
Effect.flatMap(func => func.ExecutionContext.exports),
|
|
1283
|
-
Effect.map(exports => exports),
|
|
1284
1284
|
Effect.provide(
|
|
1285
1285
|
layer.pipe(
|
|
1286
1286
|
Layer.provideMerge(stack),
|
package/src/Cloudflare/index.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
export * from "./ApiToken/index.ts";
|
|
1
2
|
export * from "./CloudflareEnvironment.ts";
|
|
2
3
|
export * from "./Container/index.ts";
|
|
3
4
|
export * from "./D1/index.ts";
|
|
5
|
+
export * from "./EdgeSession.ts";
|
|
4
6
|
export * from "./KV/index.ts";
|
|
5
|
-
export * from "./Queue/index.ts";
|
|
6
7
|
export * from "./Providers.ts";
|
|
8
|
+
export * from "./Queue/index.ts";
|
|
7
9
|
export * from "./R2/index.ts";
|
|
8
10
|
export * from "./SecretsStore/index.ts";
|
|
11
|
+
export * from "./StateStore/index.ts";
|
|
9
12
|
export * from "./Website/index.ts";
|
|
10
13
|
export * from "./Workers/index.ts";
|
package/src/Deploy.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import { AlchemyContext } from "./AlchemyContext.ts";
|
|
3
|
+
import * as Apply from "./Apply.ts";
|
|
4
|
+
import type { Input } from "./Input.ts";
|
|
5
|
+
import * as Plan from "./Plan.ts";
|
|
6
|
+
import { evalStack, type CompiledStack, type StackEffect } from "./Stack.ts";
|
|
7
|
+
import { Stage } from "./Stage.ts";
|
|
8
|
+
|
|
9
|
+
export const deploy = <A>({
|
|
10
|
+
stack,
|
|
11
|
+
stage,
|
|
12
|
+
}: {
|
|
13
|
+
stack: StackEffect<CompiledStack<A>, Stage | AlchemyContext>;
|
|
14
|
+
stage: string;
|
|
15
|
+
}) =>
|
|
16
|
+
evalStack(
|
|
17
|
+
stack,
|
|
18
|
+
(stack) =>
|
|
19
|
+
Effect.gen(function* () {
|
|
20
|
+
const plan = yield* Plan.make(stack);
|
|
21
|
+
const output = yield* Apply.apply(plan);
|
|
22
|
+
return output as Input.Resolve<A>;
|
|
23
|
+
}),
|
|
24
|
+
{ stage },
|
|
25
|
+
);
|
package/src/Destroy.ts
CHANGED
|
@@ -1,16 +1,28 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import type { AlchemyContext } from "./AlchemyContext.ts";
|
|
3
|
+
import * as Apply from "./Apply.ts";
|
|
4
4
|
import * as Plan from "./Plan.ts";
|
|
5
|
-
import {
|
|
5
|
+
import type { CompiledStack, StackEffect } from "./Stack.ts";
|
|
6
|
+
import { evalStack } from "./Stack.ts";
|
|
7
|
+
import type { Stage } from "./Stage.ts";
|
|
6
8
|
|
|
7
|
-
export const destroy = (
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
export const destroy = ({
|
|
10
|
+
stack,
|
|
11
|
+
stage,
|
|
12
|
+
}: {
|
|
13
|
+
stack: StackEffect<CompiledStack, Stage | AlchemyContext>;
|
|
14
|
+
stage: string;
|
|
15
|
+
}) =>
|
|
16
|
+
evalStack(
|
|
17
|
+
stack,
|
|
18
|
+
(stack) =>
|
|
19
|
+
Plan.make({
|
|
20
|
+
...stack,
|
|
21
|
+
// zero these out (destroy will treat all as orphans)
|
|
22
|
+
// TODO(sam): probably better to have Plan.destroy and Plan.update
|
|
23
|
+
resources: {},
|
|
24
|
+
bindings: {},
|
|
25
|
+
output: {},
|
|
26
|
+
}).pipe(Effect.flatMap(Apply.apply)),
|
|
27
|
+
{ stage },
|
|
16
28
|
);
|
package/src/GitHub/index.ts
CHANGED
package/src/Http.ts
CHANGED
|
@@ -25,7 +25,6 @@ export const serve = <Req = never>(
|
|
|
25
25
|
) =>
|
|
26
26
|
Effect.serviceOption(HttpServer).pipe(
|
|
27
27
|
Effect.map(Option.getOrUndefined),
|
|
28
|
-
Effect.tap((http) => Effect.logInfo("http", http)),
|
|
29
28
|
Effect.flatMap((http) => (http ? http.serve(handler) : Effect.void)),
|
|
30
29
|
);
|
|
31
30
|
|
|
@@ -45,22 +44,38 @@ export class HttpServer extends Context.Service<
|
|
|
45
44
|
}
|
|
46
45
|
>()("HttpServer") {}
|
|
47
46
|
|
|
48
|
-
export const safeHttpEffect = <Req = never>(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
export const safeHttpEffect = <Req = never>(
|
|
48
|
+
handler: HttpEffect<Req> | Effect.Effect<HttpEffect<Req>>,
|
|
49
|
+
): Effect.Effect<
|
|
50
|
+
HttpServerResponse.HttpServerResponse,
|
|
51
|
+
never,
|
|
52
|
+
Req | HttpServerRequest | Scope
|
|
53
|
+
> =>
|
|
54
|
+
Effect.catchCause(
|
|
55
|
+
handler.pipe(
|
|
56
|
+
// @ts-expect-error
|
|
57
|
+
Effect.flatMap((response) =>
|
|
58
|
+
HttpServerResponse.isHttpServerResponse(response)
|
|
59
|
+
? Effect.succeed(response)
|
|
60
|
+
: response,
|
|
61
|
+
),
|
|
62
|
+
) as any as HttpEffect<Req>,
|
|
63
|
+
(cause) => {
|
|
64
|
+
const message = Option.match(Cause.findErrorOption(cause), {
|
|
65
|
+
onNone: () => "Internal Server Error",
|
|
66
|
+
onSome: (error) => error.message ?? "Internal Server Error",
|
|
67
|
+
});
|
|
54
68
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
69
|
+
return Effect.map(
|
|
70
|
+
Effect.all([Effect.logError(message), Effect.logError(cause)]),
|
|
71
|
+
() =>
|
|
72
|
+
HttpServerResponse.text(message, {
|
|
73
|
+
status: 500,
|
|
74
|
+
statusText: message,
|
|
75
|
+
}),
|
|
76
|
+
);
|
|
77
|
+
},
|
|
78
|
+
);
|
|
64
79
|
|
|
65
80
|
export const resolvePort = (options: { port?: number } | undefined) =>
|
|
66
81
|
options?.port !== undefined
|
package/src/Output.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { Yieldable } from "effect/Effect";
|
|
|
3
3
|
import * as Effect from "effect/Effect";
|
|
4
4
|
import { pipe } from "effect/Function";
|
|
5
5
|
import type { Pipeable } from "effect/Pipeable";
|
|
6
|
+
import * as Redacted from "effect/Redacted";
|
|
6
7
|
import { SingleShotGen } from "effect/Utils";
|
|
7
8
|
import { ExecutionContext } from "./ExecutionContext.ts";
|
|
8
9
|
import { getRefMetadata, isRef, ref as stageRef, type Ref } from "./Ref.ts";
|
|
@@ -208,8 +209,6 @@ export const map: {
|
|
|
208
209
|
new ApplyExpr(output as Expr<A, Req>, args[0]) as any
|
|
209
210
|
: new ApplyExpr(args[0] as any, args[1])) as any;
|
|
210
211
|
|
|
211
|
-
type _ = Parameters<typeof map>;
|
|
212
|
-
|
|
213
212
|
//Output.ApplyExpr<any, any, ResourceLike, any>
|
|
214
213
|
export const isApplyExpr = <In = any, Out = any, Req = any>(
|
|
215
214
|
node: Output<Out, Req>,
|
|
@@ -470,6 +469,8 @@ export const evaluate: <A, Req = never>(
|
|
|
470
469
|
}
|
|
471
470
|
if (Array.isArray(expr)) {
|
|
472
471
|
return yield* Effect.all(expr.map((item) => evaluate(item, upstream)));
|
|
472
|
+
} else if (Redacted.isRedacted(expr)) {
|
|
473
|
+
return expr;
|
|
473
474
|
} else if (typeof expr === "object" && expr !== null) {
|
|
474
475
|
return Object.fromEntries(
|
|
475
476
|
yield* Effect.all(
|
package/src/Plan.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as Data from "effect/Data";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
3
|
import * as Option from "effect/Option";
|
|
4
|
+
import * as Redacted from "effect/Redacted";
|
|
4
5
|
import { asEffect } from ".//Util/types.ts";
|
|
5
6
|
import {
|
|
6
7
|
Artifacts,
|
|
@@ -271,6 +272,8 @@ export const make = <A>(
|
|
|
271
272
|
return input;
|
|
272
273
|
} else if (Output.isExpr(input)) {
|
|
273
274
|
return yield* resolveOutput(input);
|
|
275
|
+
} else if (Redacted.isRedacted(input)) {
|
|
276
|
+
return input;
|
|
274
277
|
} else if (Array.isArray(input)) {
|
|
275
278
|
return yield* Effect.all(input.map(resolveInput), {
|
|
276
279
|
concurrency: "unbounded",
|
package/src/Platform.ts
CHANGED
|
@@ -28,8 +28,14 @@ export interface PlatformProps {
|
|
|
28
28
|
isExternal?: boolean;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
export type Main<
|
|
32
|
-
fetch:
|
|
31
|
+
export type Main<InitServices = never> = void | {
|
|
32
|
+
fetch:
|
|
33
|
+
| HttpEffect<InitServices | PlatformServices>
|
|
34
|
+
| Effect.Effect<
|
|
35
|
+
HttpEffect<InitServices | PlatformServices>,
|
|
36
|
+
never,
|
|
37
|
+
InitServices | PlatformServices
|
|
38
|
+
>;
|
|
33
39
|
};
|
|
34
40
|
|
|
35
41
|
export type Rpc<Shape> = {
|
package/src/Provider.ts
CHANGED
package/src/Stack.ts
CHANGED
|
@@ -1,20 +1,29 @@
|
|
|
1
|
+
import { ConfigProvider } from "effect/ConfigProvider";
|
|
1
2
|
import * as Context from "effect/Context";
|
|
2
3
|
import * as Effect from "effect/Effect";
|
|
3
4
|
import { FileSystem } from "effect/FileSystem";
|
|
4
5
|
import * as Layer from "effect/Layer";
|
|
6
|
+
import * as Logger from "effect/Logger";
|
|
5
7
|
import * as Option from "effect/Option";
|
|
6
8
|
import { Path } from "effect/Path";
|
|
7
9
|
import type { Scope } from "effect/Scope";
|
|
10
|
+
import * as FetchHttpClient from "effect/unstable/http/FetchHttpClient";
|
|
8
11
|
import type { HttpClient } from "effect/unstable/http/HttpClient";
|
|
9
12
|
import type { ChildProcessSpawner } from "effect/unstable/process/ChildProcessSpawner";
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
13
|
+
import { AlchemyContext, AlchemyContextLive } from "./AlchemyContext.ts";
|
|
14
|
+
import { provideFreshArtifactStore } from "./Artifacts.ts";
|
|
15
|
+
import { AuthProviders } from "./Auth/AuthProvider.ts";
|
|
16
|
+
import { Cli } from "./Cli/Cli.ts";
|
|
12
17
|
import type { Input, InputProps } from "./Input.ts";
|
|
13
18
|
import * as Output from "./Output.ts";
|
|
14
19
|
import { ref } from "./Ref.ts";
|
|
15
20
|
import type { ResourceBinding, ResourceLike } from "./Resource.ts";
|
|
16
21
|
import { Stage } from "./Stage.ts";
|
|
22
|
+
import type { State } from "./State/State.ts";
|
|
23
|
+
import { loadConfigProvider } from "./Util/ConfigProvider.ts";
|
|
17
24
|
import { taggedFunction } from "./Util/effect.ts";
|
|
25
|
+
import { fileLogger } from "./Util/FileLogger.ts";
|
|
26
|
+
import { PlatformServices } from "./Util/PlatformServices.ts";
|
|
18
27
|
|
|
19
28
|
export type StackServices =
|
|
20
29
|
| Stack
|
|
@@ -22,16 +31,35 @@ export type StackServices =
|
|
|
22
31
|
| Scope
|
|
23
32
|
| FileSystem
|
|
24
33
|
| Path
|
|
25
|
-
|
|
|
34
|
+
| AlchemyContext
|
|
26
35
|
| HttpClient
|
|
27
36
|
| ChildProcessSpawner
|
|
28
|
-
| AuthProviders
|
|
37
|
+
| AuthProviders
|
|
38
|
+
| Cli;
|
|
39
|
+
|
|
40
|
+
export type StackEffect<A, Err = never, Req = never> = Effect.Effect<
|
|
41
|
+
A,
|
|
42
|
+
Err,
|
|
43
|
+
| PlatformServices
|
|
44
|
+
| HttpClient
|
|
45
|
+
| Scope
|
|
46
|
+
| AuthProviders
|
|
47
|
+
| AlchemyContext
|
|
48
|
+
| Cli
|
|
49
|
+
| State
|
|
50
|
+
| Req
|
|
51
|
+
>;
|
|
29
52
|
|
|
30
53
|
export type Stack = Context.ServiceClass.Shape<
|
|
31
54
|
"Stack",
|
|
32
55
|
Omit<StackSpec, "output">
|
|
33
56
|
>;
|
|
34
57
|
|
|
58
|
+
export interface StackProps<Req> {
|
|
59
|
+
providers: Layer.Layer<NoInfer<Req>, never, StackServices>;
|
|
60
|
+
state: Layer.Layer<State, never, StackServices>;
|
|
61
|
+
}
|
|
62
|
+
|
|
35
63
|
export const Stack: Context.ServiceClass<
|
|
36
64
|
Stack,
|
|
37
65
|
"Stack",
|
|
@@ -50,9 +78,7 @@ export const Stack: Context.ServiceClass<
|
|
|
50
78
|
<Self>(): {
|
|
51
79
|
<A, Req>(
|
|
52
80
|
stackName: string,
|
|
53
|
-
options:
|
|
54
|
-
providers: Layer.Layer<NoInfer<Req>, never, StackServices>;
|
|
55
|
-
},
|
|
81
|
+
options: StackProps<NoInfer<Req>>,
|
|
56
82
|
eff: Effect.Effect<A, never, Req>,
|
|
57
83
|
): Effect.Effect<Self> & {
|
|
58
84
|
new (_: never): A extends object ? A : {};
|
|
@@ -75,9 +101,7 @@ export const Stack: Context.ServiceClass<
|
|
|
75
101
|
};
|
|
76
102
|
<A, Req>(
|
|
77
103
|
stackName: string,
|
|
78
|
-
options:
|
|
79
|
-
providers: Layer.Layer<NoInfer<Req>, never, StackServices>;
|
|
80
|
-
},
|
|
104
|
+
options: StackProps<NoInfer<Req>>,
|
|
81
105
|
eff: Effect.Effect<A, never, Req | StackServices>,
|
|
82
106
|
): Effect.Effect<CompiledStack<A>>;
|
|
83
107
|
} = Object.assign(
|
|
@@ -87,23 +111,29 @@ export const Stack: Context.ServiceClass<
|
|
|
87
111
|
stackName: string,
|
|
88
112
|
options: {
|
|
89
113
|
providers: Layer.Layer<NoInfer<Req>, never, StackServices>;
|
|
114
|
+
state: Layer.Layer<State, never, StackServices>;
|
|
90
115
|
},
|
|
91
116
|
eff: Effect.Effect<A, never, Req>,
|
|
92
117
|
) =>
|
|
93
|
-
eff.pipe(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
{
|
|
98
|
-
get: (_, stage: string) =>
|
|
99
|
-
ref({
|
|
100
|
-
stack: stackName,
|
|
101
|
-
stage,
|
|
102
|
-
id: stackName,
|
|
103
|
-
}),
|
|
104
|
-
},
|
|
105
|
-
),
|
|
118
|
+
eff.pipe(
|
|
119
|
+
make({
|
|
120
|
+
name: stackName,
|
|
121
|
+
...options,
|
|
106
122
|
}),
|
|
123
|
+
(eff) =>
|
|
124
|
+
Object.assign(eff, {
|
|
125
|
+
stage: new Proxy(
|
|
126
|
+
{},
|
|
127
|
+
{
|
|
128
|
+
get: (_, stage: string) =>
|
|
129
|
+
ref({
|
|
130
|
+
stack: stackName,
|
|
131
|
+
stage,
|
|
132
|
+
id: stackName,
|
|
133
|
+
}),
|
|
134
|
+
},
|
|
135
|
+
),
|
|
136
|
+
}),
|
|
107
137
|
),
|
|
108
138
|
),
|
|
109
139
|
) as any;
|
|
@@ -130,35 +160,64 @@ export interface CompiledStack<
|
|
|
130
160
|
|
|
131
161
|
export const StackName = Stack.use((stack) => Effect.succeed(stack.name));
|
|
132
162
|
|
|
163
|
+
export interface MakeStackProps<ROut = never> {
|
|
164
|
+
name: string;
|
|
165
|
+
providers: Layer.Layer<ROut, never, StackServices>;
|
|
166
|
+
state: Layer.Layer<State, never, StackServices>;
|
|
167
|
+
/** @internal */
|
|
168
|
+
stack?: StackSpec;
|
|
169
|
+
}
|
|
170
|
+
|
|
133
171
|
export const make =
|
|
134
|
-
<ROut = never>(
|
|
135
|
-
name: string,
|
|
136
|
-
providers: Layer.Layer<ROut, never, StackServices>,
|
|
137
|
-
/** @internal */
|
|
138
|
-
stack?: StackSpec,
|
|
139
|
-
) =>
|
|
172
|
+
<ROut = never>(options: MakeStackProps<ROut>) =>
|
|
140
173
|
<A, Err = never, Req extends ROut | StackServices = never>(
|
|
141
174
|
effect: Effect.Effect<A, Err, Req>,
|
|
142
175
|
) =>
|
|
143
176
|
Effect.scope.pipe(
|
|
144
177
|
Effect.flatMap((scope) => {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
178
|
+
if (options.state == null) {
|
|
179
|
+
return Effect.die(
|
|
180
|
+
new Error(
|
|
181
|
+
`Stack "${options.name}" is missing a state store. ` +
|
|
182
|
+
`Add a \`state\` layer to the stack options, e.g.:\n` +
|
|
183
|
+
` Alchemy.Stack("${options.name}", {\n` +
|
|
184
|
+
` providers: Cloudflare.providers(),\n` +
|
|
185
|
+
` state: Cloudflare.state(), // <-- required\n` +
|
|
186
|
+
` }, ...)\n` +
|
|
187
|
+
`See https://alchemy.run/concepts/state-store for available state stores.`,
|
|
188
|
+
),
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
if (options.providers == null) {
|
|
192
|
+
return Effect.die(
|
|
193
|
+
new Error(
|
|
194
|
+
`Stack "${options.name}" is missing a providers layer. ` +
|
|
195
|
+
`Add a \`providers\` layer to the stack options, e.g.:\n` +
|
|
196
|
+
` Alchemy.Stack("${options.name}", {\n` +
|
|
197
|
+
` providers: Cloudflare.providers(), // <-- required\n` +
|
|
198
|
+
` state: Cloudflare.state(),\n` +
|
|
199
|
+
` }, ...)`,
|
|
200
|
+
),
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
return options.providers.pipe(
|
|
204
|
+
Layer.provideMerge(options.state),
|
|
205
|
+
Layer.provideMerge(
|
|
206
|
+
Layer.effect(
|
|
207
|
+
Stack,
|
|
208
|
+
Stage.asEffect().pipe(
|
|
209
|
+
Effect.map(
|
|
210
|
+
(stage) =>
|
|
211
|
+
options.stack ?? {
|
|
212
|
+
name: options.name,
|
|
213
|
+
stage,
|
|
214
|
+
resources: {},
|
|
215
|
+
bindings: {},
|
|
216
|
+
},
|
|
217
|
+
),
|
|
218
|
+
),
|
|
156
219
|
),
|
|
157
|
-
Effect.tap(Effect.logInfo),
|
|
158
220
|
),
|
|
159
|
-
);
|
|
160
|
-
return providers.pipe(
|
|
161
|
-
Layer.provideMerge(stackLayer),
|
|
162
221
|
Layer.buildWithScope(scope),
|
|
163
222
|
);
|
|
164
223
|
}),
|
|
@@ -175,7 +234,7 @@ export const make =
|
|
|
175
234
|
> => ({
|
|
176
235
|
...stack,
|
|
177
236
|
output,
|
|
178
|
-
services,
|
|
237
|
+
services: Context.merge(services, context),
|
|
179
238
|
}),
|
|
180
239
|
),
|
|
181
240
|
Effect.provideContext(context),
|
|
@@ -186,3 +245,45 @@ export const make =
|
|
|
186
245
|
export const CurrentStack = Effect.serviceOption(Stack)
|
|
187
246
|
.asEffect()
|
|
188
247
|
.pipe(Effect.map(Option.getOrUndefined));
|
|
248
|
+
|
|
249
|
+
const platform = Layer.mergeAll(
|
|
250
|
+
PlatformServices,
|
|
251
|
+
FetchHttpClient.layer,
|
|
252
|
+
Logger.layer([fileLogger("out")]),
|
|
253
|
+
);
|
|
254
|
+
// override alchemy state store, CLI/reporting, state, and Config
|
|
255
|
+
const alchemy = Layer.mergeAll(
|
|
256
|
+
// CLI.inkCLI(),
|
|
257
|
+
// optional
|
|
258
|
+
AlchemyContextLive,
|
|
259
|
+
);
|
|
260
|
+
|
|
261
|
+
export const evalStack = <A, B, Err, Req>(
|
|
262
|
+
effect: StackEffect<CompiledStack<A>, Stage | AlchemyContext>,
|
|
263
|
+
fn: (stack: CompiledStack<A>) => Effect.Effect<B, Err, Req>,
|
|
264
|
+
options: {
|
|
265
|
+
stage: string;
|
|
266
|
+
},
|
|
267
|
+
) =>
|
|
268
|
+
Effect.gen(function* () {
|
|
269
|
+
const stack = yield* effect;
|
|
270
|
+
const configProvider = yield* loadConfigProvider(Option.none());
|
|
271
|
+
|
|
272
|
+
return yield* fn(stack).pipe(
|
|
273
|
+
provideFreshArtifactStore,
|
|
274
|
+
Effect.provide(stack.services),
|
|
275
|
+
Effect.provide(Layer.succeed(ConfigProvider, configProvider)),
|
|
276
|
+
);
|
|
277
|
+
}).pipe(
|
|
278
|
+
Effect.provide(
|
|
279
|
+
Layer.effect(
|
|
280
|
+
AuthProviders,
|
|
281
|
+
Effect.serviceOption(AuthProviders).pipe(
|
|
282
|
+
Effect.map(Option.getOrElse(() => ({}))),
|
|
283
|
+
),
|
|
284
|
+
),
|
|
285
|
+
),
|
|
286
|
+
Effect.provide(Layer.succeed(Stage, options.stage)),
|
|
287
|
+
Effect.provide(Layer.provideMerge(alchemy, platform)),
|
|
288
|
+
Effect.scoped,
|
|
289
|
+
);
|