alchemy 2.0.0-beta.34 → 2.0.0-beta.35
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/cli.js +8 -7
- package/bin/exec.js +226 -52
- package/bin/exec.js.map +1 -1
- package/lib/AWS/AuthProvider.d.ts +7 -6
- package/lib/AWS/AuthProvider.d.ts.map +1 -1
- package/lib/AWS/AuthProvider.js +143 -134
- package/lib/AWS/AuthProvider.js.map +1 -1
- package/lib/AWS/Bootstrap.d.ts +2 -2
- package/lib/AWS/Bootstrap.d.ts.map +1 -1
- package/lib/AWS/EC2/hosted.d.ts +1 -1
- package/lib/AWS/Environment.d.ts +25 -3
- package/lib/AWS/Environment.d.ts.map +1 -1
- package/lib/AWS/Environment.js +47 -3
- package/lib/AWS/Environment.js.map +1 -1
- package/lib/AWS/IAM/OpenIDConnectProvider.d.ts +14 -6
- package/lib/AWS/IAM/OpenIDConnectProvider.d.ts.map +1 -1
- package/lib/AWS/IAM/OpenIDConnectProvider.js +6 -3
- package/lib/AWS/IAM/OpenIDConnectProvider.js.map +1 -1
- package/lib/AWS/IAM/Policy.d.ts +1 -1
- package/lib/AWS/IAM/Policy.d.ts.map +1 -1
- package/lib/AWS/IAM/Policy.js.map +1 -1
- 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/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/Providers.d.ts +1 -1
- package/lib/AWS/Providers.d.ts.map +1 -1
- package/lib/AWS/Providers.js +2 -1
- package/lib/AWS/Providers.js.map +1 -1
- package/lib/Auth/Credentials.d.ts +21 -6
- package/lib/Auth/Credentials.d.ts.map +1 -1
- package/lib/Auth/Credentials.js +30 -31
- package/lib/Auth/Credentials.js.map +1 -1
- package/lib/Auth/Profile.d.ts +31 -34
- package/lib/Auth/Profile.d.ts.map +1 -1
- package/lib/Auth/Profile.js +46 -31
- package/lib/Auth/Profile.js.map +1 -1
- package/lib/Axiom/AuthProvider.d.ts +2 -1
- package/lib/Axiom/AuthProvider.d.ts.map +1 -1
- package/lib/Axiom/AuthProvider.js +149 -143
- package/lib/Axiom/AuthProvider.js.map +1 -1
- package/lib/Axiom/Credentials.d.ts +2 -1
- package/lib/Axiom/Credentials.d.ts.map +1 -1
- package/lib/Axiom/Credentials.js +4 -4
- package/lib/Axiom/Credentials.js.map +1 -1
- package/lib/Axiom/Providers.d.ts +1 -1
- package/lib/Axiom/Providers.d.ts.map +1 -1
- package/lib/Axiom/Providers.js +3 -1
- package/lib/Axiom/Providers.js.map +1 -1
- package/lib/Cli/LoggingCli.d.ts.map +1 -1
- package/lib/Cli/LoggingCli.js +105 -7
- package/lib/Cli/LoggingCli.js.map +1 -1
- package/lib/Cli/checkVersion.d.ts +13 -0
- package/lib/Cli/checkVersion.d.ts.map +1 -0
- package/lib/Cli/checkVersion.js +47 -0
- package/lib/Cli/checkVersion.js.map +1 -0
- package/lib/Cli/commands/_shared.d.ts +2 -2
- package/lib/Cli/commands/_shared.d.ts.map +1 -1
- package/lib/Cli/commands/_shared.js +3 -3
- package/lib/Cli/commands/_shared.js.map +1 -1
- package/lib/Cli/commands/aws.d.ts +6 -0
- package/lib/Cli/commands/aws.d.ts.map +1 -0
- package/lib/Cli/commands/aws.js +63 -0
- package/lib/Cli/commands/aws.js.map +1 -0
- package/lib/Cli/commands/cloudflare.d.ts +17 -0
- package/lib/Cli/commands/cloudflare.d.ts.map +1 -0
- package/lib/Cli/commands/cloudflare.js +111 -0
- package/lib/Cli/commands/cloudflare.js.map +1 -0
- package/lib/Cli/commands/deploy.d.ts +6 -5
- package/lib/Cli/commands/deploy.d.ts.map +1 -1
- package/lib/Cli/commands/deploy.js +10 -10
- package/lib/Cli/commands/deploy.js.map +1 -1
- package/lib/Cli/commands/dev.d.ts.map +1 -1
- package/lib/Cli/commands/dev.js +16 -16
- package/lib/Cli/commands/dev.js.map +1 -1
- package/lib/Cli/commands/login.d.ts +2 -1
- package/lib/Cli/commands/login.d.ts.map +1 -1
- package/lib/Cli/commands/login.js +9 -8
- package/lib/Cli/commands/login.js.map +1 -1
- package/lib/Cli/commands/logs.d.ts +1 -1
- package/lib/Cli/commands/logs.d.ts.map +1 -1
- package/lib/Cli/commands/logs.js +7 -7
- package/lib/Cli/commands/logs.js.map +1 -1
- package/lib/Cli/commands/profile.d.ts +3 -1
- package/lib/Cli/commands/profile.d.ts.map +1 -1
- package/lib/Cli/commands/profile.js +14 -11
- package/lib/Cli/commands/profile.js.map +1 -1
- package/lib/Cli/commands/state.d.ts +1 -1
- package/lib/Cli/commands/state.d.ts.map +1 -1
- package/lib/Cli/commands/state.js +8 -8
- package/lib/Cli/commands/state.js.map +1 -1
- package/lib/Cli/commands/tail.d.ts +1 -1
- package/lib/Cli/commands/tail.d.ts.map +1 -1
- package/lib/Cli/commands/tail.js +7 -7
- package/lib/Cli/commands/tail.js.map +1 -1
- package/lib/Cli/exec.d.ts.map +1 -1
- package/lib/Cli/exec.js +5 -3
- package/lib/Cli/exec.js.map +1 -1
- package/lib/Cli/main.d.ts.map +1 -1
- package/lib/Cli/main.js +17 -5
- package/lib/Cli/main.js.map +1 -1
- package/lib/Cli/selectCli.d.ts +12 -0
- package/lib/Cli/selectCli.d.ts.map +1 -0
- package/lib/Cli/selectCli.js +32 -0
- package/lib/Cli/selectCli.js.map +1 -0
- package/lib/Cloudflare/Auth/AuthProvider.d.ts +2 -1
- package/lib/Cloudflare/Auth/AuthProvider.d.ts.map +1 -1
- package/lib/Cloudflare/Auth/AuthProvider.js +235 -214
- package/lib/Cloudflare/Auth/AuthProvider.js.map +1 -1
- package/lib/Cloudflare/CloudflareEnvironment.d.ts +2 -1
- package/lib/Cloudflare/CloudflareEnvironment.d.ts.map +1 -1
- package/lib/Cloudflare/CloudflareEnvironment.js +3 -2
- package/lib/Cloudflare/CloudflareEnvironment.js.map +1 -1
- package/lib/Cloudflare/Credentials.d.ts +2 -1
- package/lib/Cloudflare/Credentials.d.ts.map +1 -1
- package/lib/Cloudflare/Credentials.js +4 -4
- package/lib/Cloudflare/Credentials.js.map +1 -1
- package/lib/Cloudflare/D1/D1Clone.d.ts +2 -1
- package/lib/Cloudflare/D1/D1Clone.d.ts.map +1 -1
- package/lib/Cloudflare/D1/D1Database.d.ts +2 -1
- package/lib/Cloudflare/D1/D1Database.d.ts.map +1 -1
- package/lib/Cloudflare/D1/D1Import.d.ts +3 -1
- package/lib/Cloudflare/D1/D1Import.d.ts.map +1 -1
- package/lib/Cloudflare/Local/Sidecar.d.ts +11 -4
- package/lib/Cloudflare/Local/Sidecar.d.ts.map +1 -1
- package/lib/Cloudflare/Local/Sidecar.js +8 -6
- package/lib/Cloudflare/Local/Sidecar.js.map +1 -1
- package/lib/Cloudflare/Local/SidecarHandlers.d.ts.map +1 -1
- package/lib/Cloudflare/Local/SidecarHandlers.js +1 -5
- package/lib/Cloudflare/Local/SidecarHandlers.js.map +1 -1
- package/lib/Cloudflare/Local/SidecarServer.js +5 -2
- package/lib/Cloudflare/Local/SidecarServer.js.map +1 -1
- package/lib/Cloudflare/Logs.d.ts +5 -0
- package/lib/Cloudflare/Logs.d.ts.map +1 -1
- package/lib/Cloudflare/Logs.js +70 -1
- package/lib/Cloudflare/Logs.js.map +1 -1
- 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/Queue/Queue.d.ts +1 -1
- package/lib/Cloudflare/Queue/Queue.js +1 -1
- package/lib/Cloudflare/Queue/QueueConsumer.d.ts +6 -2
- package/lib/Cloudflare/Queue/QueueConsumer.d.ts.map +1 -1
- package/lib/Cloudflare/Queue/QueueConsumer.js +194 -53
- package/lib/Cloudflare/Queue/QueueConsumer.js.map +1 -1
- package/lib/Cloudflare/Queue/QueueEventSource.d.ts +106 -0
- package/lib/Cloudflare/Queue/QueueEventSource.d.ts.map +1 -0
- package/lib/Cloudflare/Queue/QueueEventSource.js +145 -0
- package/lib/Cloudflare/Queue/QueueEventSource.js.map +1 -0
- package/lib/Cloudflare/Queue/index.d.ts +1 -0
- package/lib/Cloudflare/Queue/index.d.ts.map +1 -1
- package/lib/Cloudflare/Queue/index.js +1 -0
- package/lib/Cloudflare/Queue/index.js.map +1 -1
- package/lib/Cloudflare/R2/R2Bucket.d.ts +94 -0
- package/lib/Cloudflare/R2/R2Bucket.d.ts.map +1 -1
- package/lib/Cloudflare/R2/R2Bucket.js +186 -2
- package/lib/Cloudflare/R2/R2Bucket.js.map +1 -1
- package/lib/Cloudflare/StateStore/State.d.ts +4 -3
- package/lib/Cloudflare/StateStore/State.d.ts.map +1 -1
- package/lib/Cloudflare/StateStore/State.js +16 -8
- package/lib/Cloudflare/StateStore/State.js.map +1 -1
- package/lib/Cloudflare/VpcService/VpcServiceRef.d.ts +1 -1
- package/lib/Cloudflare/VpcService/VpcServiceRef.d.ts.map +1 -1
- package/lib/Cloudflare/Website/StaticSite.d.ts.map +1 -1
- package/lib/Cloudflare/Website/StaticSite.js +10 -1
- package/lib/Cloudflare/Website/StaticSite.js.map +1 -1
- package/lib/Cloudflare/Workers/Assets.d.ts +1 -1
- package/lib/Cloudflare/Workers/Assets.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/LocalWorkerProvider.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/LocalWorkerProvider.js +11 -1
- package/lib/Cloudflare/Workers/LocalWorkerProvider.js.map +1 -1
- package/lib/Cloudflare/Workers/Worker.d.ts +9 -7
- package/lib/Cloudflare/Workers/Worker.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/Worker.js +62 -142
- package/lib/Cloudflare/Workers/Worker.js.map +1 -1
- package/lib/Cloudflare/Workers/WorkerBundle.d.ts +2 -0
- package/lib/Cloudflare/Workers/WorkerBundle.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/WorkerBundle.js +21 -7
- package/lib/Cloudflare/Workers/WorkerBundle.js.map +1 -1
- package/lib/Cloudflare/Zone.d.ts +14 -0
- package/lib/Cloudflare/Zone.d.ts.map +1 -0
- package/lib/Cloudflare/Zone.js +44 -0
- package/lib/Cloudflare/Zone.js.map +1 -0
- package/lib/Drizzle/Schema.d.ts.map +1 -1
- package/lib/Drizzle/Schema.js +20 -5
- package/lib/Drizzle/Schema.js.map +1 -1
- package/lib/GitHub/AuthProvider.d.ts +3 -1
- package/lib/GitHub/AuthProvider.d.ts.map +1 -1
- package/lib/GitHub/AuthProvider.js +114 -108
- package/lib/GitHub/AuthProvider.js.map +1 -1
- package/lib/GitHub/Credentials.d.ts +2 -1
- package/lib/GitHub/Credentials.d.ts.map +1 -1
- package/lib/GitHub/Credentials.js +4 -4
- package/lib/GitHub/Credentials.js.map +1 -1
- package/lib/GitHub/Providers.d.ts +1 -1
- package/lib/GitHub/Providers.d.ts.map +1 -1
- package/lib/GitHub/Providers.js +3 -1
- package/lib/GitHub/Providers.js.map +1 -1
- package/lib/GitHub/Secrets.d.ts.map +1 -1
- package/lib/GitHub/Secrets.js +14 -1
- package/lib/GitHub/Secrets.js.map +1 -1
- package/lib/GitHub/Variables.d.ts +40 -0
- package/lib/GitHub/Variables.d.ts.map +1 -0
- package/lib/GitHub/Variables.js +28 -0
- package/lib/GitHub/Variables.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/Neon/AuthProvider.d.ts +3 -1
- package/lib/Neon/AuthProvider.d.ts.map +1 -1
- package/lib/Neon/AuthProvider.js +87 -80
- package/lib/Neon/AuthProvider.js.map +1 -1
- package/lib/Neon/Credentials.d.ts +2 -1
- package/lib/Neon/Credentials.d.ts.map +1 -1
- package/lib/Neon/Credentials.js +4 -4
- package/lib/Neon/Credentials.js.map +1 -1
- package/lib/Neon/NeonEnvironment.d.ts +2 -1
- package/lib/Neon/NeonEnvironment.d.ts.map +1 -1
- package/lib/Neon/NeonEnvironment.js +3 -2
- package/lib/Neon/NeonEnvironment.js.map +1 -1
- package/lib/Neon/Project.d.ts +16 -0
- package/lib/Neon/Project.d.ts.map +1 -1
- package/lib/Neon/Project.js +25 -0
- package/lib/Neon/Project.js.map +1 -1
- package/lib/Neon/Providers.d.ts +1 -1
- package/lib/Neon/Providers.d.ts.map +1 -1
- package/lib/Neon/Providers.js +3 -1
- package/lib/Neon/Providers.js.map +1 -1
- package/lib/Neon/api.d.ts +1 -0
- package/lib/Neon/api.d.ts.map +1 -1
- package/lib/Neon/api.js +1 -0
- package/lib/Neon/api.js.map +1 -1
- package/lib/Sidecar/RpcClient.d.ts.map +1 -1
- package/lib/Sidecar/RpcClient.js +8 -5
- package/lib/Sidecar/RpcClient.js.map +1 -1
- package/lib/Sidecar/RpcPaths.d.ts +5 -0
- package/lib/Sidecar/RpcPaths.d.ts.map +1 -1
- package/lib/Sidecar/RpcPaths.js +10 -1
- package/lib/Sidecar/RpcPaths.js.map +1 -1
- package/lib/Sidecar/RpcServer.d.ts +24 -4
- package/lib/Sidecar/RpcServer.d.ts.map +1 -1
- package/lib/Sidecar/RpcServer.js +70 -15
- package/lib/Sidecar/RpcServer.js.map +1 -1
- package/lib/Sidecar/RpcServerBun.d.ts +4 -0
- package/lib/Sidecar/RpcServerBun.d.ts.map +1 -0
- package/lib/Sidecar/RpcServerBun.js +28 -0
- package/lib/Sidecar/RpcServerBun.js.map +1 -0
- package/lib/Sidecar/RpcServerNode.d.ts +4 -0
- package/lib/Sidecar/RpcServerNode.d.ts.map +1 -0
- package/lib/Sidecar/RpcServerNode.js +39 -0
- package/lib/Sidecar/RpcServerNode.js.map +1 -0
- package/lib/Sidecar/RpcServices.d.ts +6 -0
- package/lib/Sidecar/RpcServices.d.ts.map +1 -0
- package/lib/Sidecar/RpcServices.js +29 -0
- package/lib/Sidecar/RpcServices.js.map +1 -0
- package/lib/Stack.d.ts +5 -3
- package/lib/Stack.d.ts.map +1 -1
- package/lib/Stack.js +3 -1
- package/lib/Stack.js.map +1 -1
- package/lib/Test/Core.d.ts.map +1 -1
- package/lib/Test/Core.js +5 -4
- package/lib/Test/Core.js.map +1 -1
- package/lib/Util/PlatformServices.js +1 -1
- package/lib/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +15 -12
- package/src/AWS/AuthProvider.ts +269 -259
- package/src/AWS/Environment.ts +57 -3
- package/src/AWS/IAM/OpenIDConnectProvider.ts +19 -8
- package/src/AWS/IAM/Policy.ts +1 -1
- package/src/AWS/Providers.ts +2 -0
- package/src/Auth/Credentials.ts +82 -46
- package/src/Auth/Profile.ts +123 -69
- package/src/Axiom/AuthProvider.ts +263 -255
- package/src/Axiom/Credentials.ts +3 -4
- package/src/Axiom/Providers.ts +4 -0
- package/src/Cli/LoggingCli.ts +127 -11
- package/src/Cli/checkVersion.ts +57 -0
- package/src/Cli/commands/_shared.ts +4 -4
- package/src/Cli/commands/aws.ts +127 -0
- package/src/Cli/commands/cloudflare.ts +222 -0
- package/src/Cli/commands/deploy.ts +11 -10
- package/src/Cli/commands/dev.ts +28 -33
- package/src/Cli/commands/login.ts +9 -12
- package/src/Cli/commands/logs.ts +8 -8
- package/src/Cli/commands/profile.ts +14 -16
- package/src/Cli/commands/state.ts +8 -8
- package/src/Cli/commands/tail.ts +8 -8
- package/src/Cli/exec.ts +7 -3
- package/src/Cli/main.ts +20 -5
- package/src/Cli/selectCli.ts +33 -0
- package/src/Cloudflare/Auth/AuthProvider.ts +445 -430
- package/src/Cloudflare/CloudflareEnvironment.ts +3 -2
- package/src/Cloudflare/Credentials.ts +3 -4
- package/src/Cloudflare/Local/Sidecar.ts +13 -10
- package/src/Cloudflare/Local/SidecarHandlers.ts +8 -13
- package/src/Cloudflare/Local/SidecarServer.ts +6 -1
- package/src/Cloudflare/Logs.ts +115 -1
- package/src/Cloudflare/Providers.ts +6 -0
- package/src/Cloudflare/Queue/Queue.ts +1 -1
- package/src/Cloudflare/Queue/QueueConsumer.ts +262 -60
- package/src/Cloudflare/Queue/QueueEventSource.ts +234 -0
- package/src/Cloudflare/Queue/index.ts +1 -0
- package/src/Cloudflare/R2/R2Bucket.ts +337 -2
- package/src/Cloudflare/StateStore/State.ts +25 -16
- package/src/Cloudflare/Website/StaticSite.ts +11 -1
- package/src/Cloudflare/Workers/LocalWorkerProvider.ts +9 -1
- package/src/Cloudflare/Workers/Worker.ts +83 -203
- package/src/Cloudflare/Workers/WorkerBundle.ts +38 -12
- package/src/Cloudflare/Zone.ts +88 -0
- package/src/Drizzle/Schema.ts +21 -5
- package/src/GitHub/AuthProvider.ts +221 -217
- package/src/GitHub/Credentials.ts +3 -4
- package/src/GitHub/Providers.ts +4 -0
- package/src/GitHub/Secrets.ts +25 -1
- package/src/GitHub/Variables.ts +54 -0
- package/src/GitHub/index.ts +1 -0
- package/src/Neon/AuthProvider.ts +160 -154
- package/src/Neon/Credentials.ts +3 -4
- package/src/Neon/NeonEnvironment.ts +3 -2
- package/src/Neon/Project.ts +42 -0
- package/src/Neon/Providers.ts +4 -0
- package/src/Neon/api.ts +2 -0
- package/src/Sidecar/RpcClient.ts +8 -7
- package/src/Sidecar/RpcPaths.ts +11 -1
- package/src/Sidecar/RpcServer.ts +97 -24
- package/src/Sidecar/RpcServerBun.ts +41 -0
- package/src/Sidecar/RpcServerNode.ts +51 -0
- package/src/Sidecar/RpcServices.ts +48 -0
- package/src/Stack.ts +8 -0
- package/src/Test/Core.ts +10 -4
- package/src/Util/PlatformServices.ts +1 -1
- package/lib/Cli/commands/bootstrap.d.ts +0 -20
- package/lib/Cli/commands/bootstrap.d.ts.map +0 -1
- package/lib/Cli/commands/bootstrap.js +0 -107
- package/lib/Cli/commands/bootstrap.js.map +0 -1
- package/lib/Sidecar/RpcTransport.d.ts +0 -22
- package/lib/Sidecar/RpcTransport.d.ts.map +0 -1
- package/lib/Sidecar/RpcTransport.js +0 -81
- package/lib/Sidecar/RpcTransport.js.map +0 -1
- package/lib/Test/TestCli.d.ts +0 -19
- package/lib/Test/TestCli.d.ts.map +0 -1
- package/lib/Test/TestCli.js +0 -175
- package/lib/Test/TestCli.js.map +0 -1
- package/src/Cli/commands/bootstrap.ts +0 -216
- package/src/Sidecar/RpcTransport.ts +0 -85
- package/src/Test/TestCli.ts +0 -221
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type * as cf from "@cloudflare/workers-types";
|
|
2
|
-
import cloudflareRolldown from "@distilled.cloud/cloudflare-rolldown-plugin";
|
|
3
2
|
import cloudflareVite from "@distilled.cloud/cloudflare-vite-plugin";
|
|
4
3
|
import * as workers from "@distilled.cloud/cloudflare/workers";
|
|
5
4
|
import * as zones from "@distilled.cloud/cloudflare/zones";
|
|
6
|
-
import type * as Cause from "effect/Cause";
|
|
7
5
|
import * as Context from "effect/Context";
|
|
8
6
|
import * as Data from "effect/Data";
|
|
9
7
|
import * as Effect from "effect/Effect";
|
|
@@ -12,39 +10,30 @@ import * as FileSystem from "effect/FileSystem";
|
|
|
12
10
|
import * as Layer from "effect/Layer";
|
|
13
11
|
import * as Option from "effect/Option";
|
|
14
12
|
import * as Path from "effect/Path";
|
|
15
|
-
import * as Queue from "effect/Queue";
|
|
16
13
|
import * as Redacted from "effect/Redacted";
|
|
17
14
|
import * as Schedule from "effect/Schedule";
|
|
18
15
|
import * as Scope from "effect/Scope";
|
|
19
|
-
import * as Stream from "effect/Stream";
|
|
20
|
-
import * as Socket from "effect/unstable/socket/Socket";
|
|
21
16
|
import { createRequire } from "node:module";
|
|
22
17
|
import path from "node:path";
|
|
23
18
|
import { pathToFileURL } from "node:url";
|
|
24
|
-
import type * as rolldown from "rolldown";
|
|
25
|
-
import Sonda from "sonda/rolldown";
|
|
26
19
|
import type * as vite from "vite";
|
|
27
20
|
import { Unowned } from "../../AdoptPolicy.ts";
|
|
28
21
|
import { AlchemyContext } from "../../AlchemyContext.ts";
|
|
29
|
-
import * as Artifacts from "../../Artifacts.ts";
|
|
30
22
|
import * as Binding from "../../Binding.ts";
|
|
31
23
|
import { hashDirectory, type MemoOptions } from "../../Build/Memo.ts";
|
|
32
24
|
import * as Bundle from "../../Bundle/Bundle.ts";
|
|
33
|
-
import { findCwdForBundle } from "../../Bundle/TempRoot.ts";
|
|
34
25
|
import type { ScopedPlanStatusSession } from "../../Cli/Cli.ts";
|
|
35
26
|
import { isResolved } from "../../Diff.ts";
|
|
36
27
|
import { ExecutionContext } from "../../ExecutionContext.ts";
|
|
37
28
|
import type { HttpEffect } from "../../Http.ts";
|
|
38
29
|
import type { InputProps } from "../../Input.ts";
|
|
39
30
|
import * as Output from "../../Output.ts";
|
|
40
|
-
import { createPhysicalName } from "../../PhysicalName.ts";
|
|
41
31
|
import {
|
|
42
32
|
Platform,
|
|
43
33
|
type Main,
|
|
44
34
|
type PlatformProps,
|
|
45
35
|
type Rpc,
|
|
46
36
|
} from "../../Platform.ts";
|
|
47
|
-
import type { LogLine } from "../../Provider.ts";
|
|
48
37
|
import * as Provider from "../../Provider.ts";
|
|
49
38
|
import { Resource, type ResourceBinding } from "../../Resource.ts";
|
|
50
39
|
import * as Serverless from "../../Serverless/index.ts";
|
|
@@ -72,6 +61,7 @@ import {
|
|
|
72
61
|
type AssetsConfig,
|
|
73
62
|
type AssetsProps,
|
|
74
63
|
} from "./Assets.ts";
|
|
64
|
+
import { getCompatibility } from "./Compatibility.ts";
|
|
75
65
|
import {
|
|
76
66
|
isDurableObjectExport,
|
|
77
67
|
isDurableObjectNamespaceLike,
|
|
@@ -81,7 +71,8 @@ import { workersHttpHandler } from "./HttpServer.ts";
|
|
|
81
71
|
import { LocalWorkerProvider } from "./LocalWorkerProvider.ts";
|
|
82
72
|
import { Request } from "./Request.ts";
|
|
83
73
|
import { makeRpcStub } from "./Rpc.ts";
|
|
84
|
-
import {
|
|
74
|
+
import { WorkerBundle } from "./WorkerBundle.ts";
|
|
75
|
+
import { createWorkerName } from "./WorkerName.ts";
|
|
85
76
|
|
|
86
77
|
const WorkerTypeId = "Cloudflare.Worker";
|
|
87
78
|
type WorkerTypeId = typeof WorkerTypeId;
|
|
@@ -269,7 +260,16 @@ export interface WorkerProps<
|
|
|
269
260
|
};
|
|
270
261
|
limits?: WorkerLimits;
|
|
271
262
|
placement?: WorkerPlacement;
|
|
272
|
-
env?: Record<
|
|
263
|
+
env?: Record<
|
|
264
|
+
string,
|
|
265
|
+
| string
|
|
266
|
+
| number
|
|
267
|
+
| boolean
|
|
268
|
+
| null
|
|
269
|
+
| readonly unknown[]
|
|
270
|
+
| { readonly [key: string]: unknown }
|
|
271
|
+
| Redacted.Redacted<string>
|
|
272
|
+
>;
|
|
273
273
|
exports?: string[];
|
|
274
274
|
bindings?: Bindings;
|
|
275
275
|
/**
|
|
@@ -411,7 +411,7 @@ export type Worker<Bindings extends WorkerBindings = any> = Resource<
|
|
|
411
411
|
* ```typescript
|
|
412
412
|
* export default class MyWorker extends Cloudflare.Worker<MyWorker>()(
|
|
413
413
|
* "MyWorker",
|
|
414
|
-
* { main: import.meta.
|
|
414
|
+
* { main: import.meta.filename },
|
|
415
415
|
* Effect.gen(function* () {
|
|
416
416
|
* // init: bind resources
|
|
417
417
|
* const kv = yield* Cloudflare.KVNamespace.bind(MyKV);
|
|
@@ -446,7 +446,7 @@ export type Worker<Bindings extends WorkerBindings = any> = Resource<
|
|
|
446
446
|
* // src/WorkerB.ts
|
|
447
447
|
* export default class WorkerB extends Cloudflare.Worker<WorkerB>()(
|
|
448
448
|
* "WorkerB",
|
|
449
|
-
* { main: import.meta.
|
|
449
|
+
* { main: import.meta.filename },
|
|
450
450
|
* ) {}
|
|
451
451
|
*
|
|
452
452
|
* export default WorkerB.make(
|
|
@@ -473,7 +473,7 @@ export type Worker<Bindings extends WorkerBindings = any> = Resource<
|
|
|
473
473
|
*
|
|
474
474
|
* export default class WorkerA extends Cloudflare.Worker<WorkerA>()(
|
|
475
475
|
* "WorkerA",
|
|
476
|
-
* { main: import.meta.
|
|
476
|
+
* { main: import.meta.filename },
|
|
477
477
|
* Effect.gen(function* () {
|
|
478
478
|
* const b = yield* Cloudflare.Worker.bind(WorkerB);
|
|
479
479
|
* return {
|
|
@@ -492,7 +492,7 @@ export type Worker<Bindings extends WorkerBindings = any> = Resource<
|
|
|
492
492
|
* @example Enabling Node.js compatibility
|
|
493
493
|
* ```typescript
|
|
494
494
|
* {
|
|
495
|
-
* main: import.meta.
|
|
495
|
+
* main: import.meta.filename,
|
|
496
496
|
* compatibility: {
|
|
497
497
|
* flags: ["nodejs_compat"],
|
|
498
498
|
* date: "2026-03-17",
|
|
@@ -503,7 +503,7 @@ export type Worker<Bindings extends WorkerBindings = any> = Resource<
|
|
|
503
503
|
* @example Serving static assets
|
|
504
504
|
* ```typescript
|
|
505
505
|
* {
|
|
506
|
-
* main: import.meta.
|
|
506
|
+
* main: import.meta.filename,
|
|
507
507
|
* assets: "./public",
|
|
508
508
|
* }
|
|
509
509
|
* ```
|
|
@@ -521,7 +521,7 @@ export type Worker<Bindings extends WorkerBindings = any> = Resource<
|
|
|
521
521
|
* @example Enabling logs and traces
|
|
522
522
|
* ```typescript
|
|
523
523
|
* {
|
|
524
|
-
* main: import.meta.
|
|
524
|
+
* main: import.meta.filename,
|
|
525
525
|
* observability: {
|
|
526
526
|
* enabled: true,
|
|
527
527
|
* headSamplingRate: 1,
|
|
@@ -1064,12 +1064,11 @@ export const LiveWorkerProvider = () =>
|
|
|
1064
1064
|
|
|
1065
1065
|
const { accountId } = yield* CloudflareEnvironment;
|
|
1066
1066
|
const virtualEntryPlugin = yield* Bundle.virtualEntryPlugin;
|
|
1067
|
+
const bundler = yield* WorkerBundle;
|
|
1067
1068
|
const stack = yield* Stack;
|
|
1068
1069
|
|
|
1069
1070
|
const createScriptSubdomain = yield* workers.createScriptSubdomain;
|
|
1070
|
-
const createScriptTail = yield* workers.createScriptTail;
|
|
1071
1071
|
const deleteScript = yield* workers.deleteScript;
|
|
1072
|
-
const deleteScriptTail = yield* workers.deleteScriptTail;
|
|
1073
1072
|
const getScriptSubdomain = yield* workers.getScriptSubdomain;
|
|
1074
1073
|
const getScriptSettings = yield* workers.getScriptScriptAndVersionSetting;
|
|
1075
1074
|
const getSubdomain = yield* workers.getSubdomain;
|
|
@@ -1079,12 +1078,6 @@ export const LiveWorkerProvider = () =>
|
|
|
1079
1078
|
const deleteDomain = yield* workers.deleteDomain;
|
|
1080
1079
|
const listZones = yield* zones.listZones;
|
|
1081
1080
|
const telemetry = yield* CloudflareLogs;
|
|
1082
|
-
// TODO(sam): figure out why the later one from workerd breaks
|
|
1083
|
-
const defaultCompatibilityDate = "2026-03-17";
|
|
1084
|
-
// const defaultCompatibilityDate = yield* Effect.promise(() =>
|
|
1085
|
-
// // @ts-expect-error no types for workerd
|
|
1086
|
-
// import("workerd").then((m) => m.compatibilityDate as string),
|
|
1087
|
-
// );
|
|
1088
1081
|
|
|
1089
1082
|
const getAccountSubdomain = (accountId: string) =>
|
|
1090
1083
|
getSubdomain({
|
|
@@ -1105,14 +1098,6 @@ export const LiveWorkerProvider = () =>
|
|
|
1105
1098
|
previewsEnabled: enabled ? true : undefined,
|
|
1106
1099
|
});
|
|
1107
1100
|
|
|
1108
|
-
const createWorkerName = (id: string, name: string | undefined) =>
|
|
1109
|
-
name
|
|
1110
|
-
? Effect.succeed(name)
|
|
1111
|
-
: createPhysicalName({
|
|
1112
|
-
id,
|
|
1113
|
-
maxLength: 54,
|
|
1114
|
-
}).pipe(Effect.map((name) => name.toLowerCase()));
|
|
1115
|
-
|
|
1116
1101
|
// Convert non-ASCII hostnames (emoji, IDN, etc.) to punycode so the
|
|
1117
1102
|
// Cloudflare API receives the form it stores domains in. `new URL(...)`
|
|
1118
1103
|
// does IDNA via WHATWG URL parsing — `📦.alchemy.run` → `xn--5z8h.alchemy.run`.
|
|
@@ -1262,12 +1247,24 @@ export const LiveWorkerProvider = () =>
|
|
|
1262
1247
|
}
|
|
1263
1248
|
|
|
1264
1249
|
const zoneId = yield* inferZoneIdForHostname(hostname, zoneCache);
|
|
1250
|
+
// Same eventual-consistency window as `setWorkerSubdomain`:
|
|
1251
|
+
// PUT /accounts/.../workers/domains right after `putScript`
|
|
1252
|
+
// can return `WorkerNotFound` until Cloudflare's script
|
|
1253
|
+
// registry has propagated. Retry on that specific tag.
|
|
1265
1254
|
const res = yield* putDomain({
|
|
1266
1255
|
accountId,
|
|
1267
1256
|
hostname,
|
|
1268
1257
|
service: scriptName,
|
|
1269
1258
|
zoneId,
|
|
1270
|
-
})
|
|
1259
|
+
}).pipe(
|
|
1260
|
+
Effect.retry({
|
|
1261
|
+
while: (error: { _tag?: string }) =>
|
|
1262
|
+
error?._tag === "WorkerNotFound",
|
|
1263
|
+
schedule: Schedule.exponential(200).pipe(
|
|
1264
|
+
Schedule.both(Schedule.recurs(15)),
|
|
1265
|
+
),
|
|
1266
|
+
}),
|
|
1267
|
+
);
|
|
1271
1268
|
return {
|
|
1272
1269
|
hostname,
|
|
1273
1270
|
id: res.id ?? "",
|
|
@@ -1383,67 +1380,27 @@ export const LiveWorkerProvider = () =>
|
|
|
1383
1380
|
);
|
|
1384
1381
|
});
|
|
1385
1382
|
|
|
1386
|
-
const getCompatibility = (props: WorkerProps) => ({
|
|
1387
|
-
compatibilityDate:
|
|
1388
|
-
props.compatibility?.date ?? defaultCompatibilityDate,
|
|
1389
|
-
compatibilityFlags: props.compatibility?.flags
|
|
1390
|
-
? [
|
|
1391
|
-
...props.compatibility.flags,
|
|
1392
|
-
...(props.isExternal ? [] : ["nodejs_compat"]),
|
|
1393
|
-
].filter((value, index, self) => self.indexOf(value) === index)
|
|
1394
|
-
: props.isExternal
|
|
1395
|
-
? []
|
|
1396
|
-
: ["nodejs_compat"],
|
|
1397
|
-
});
|
|
1398
|
-
|
|
1399
1383
|
const prepareBundle = (id: string, props: WorkerProps) =>
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
cloudflareRolldown({ compatibilityDate, compatibilityFlags }),
|
|
1412
|
-
plugins,
|
|
1413
|
-
...(props.build?.metafile ? [Sonda({ open: false })] : []),
|
|
1414
|
-
],
|
|
1415
|
-
checks: {
|
|
1416
|
-
// Suppress unresolved import warnings for unrelated AWS packages
|
|
1417
|
-
unresolvedImport: false,
|
|
1418
|
-
},
|
|
1419
|
-
},
|
|
1420
|
-
{
|
|
1421
|
-
format: "esm",
|
|
1422
|
-
sourcemap: "hidden",
|
|
1423
|
-
minify: true,
|
|
1424
|
-
keepNames: true,
|
|
1425
|
-
dir: `.alchemy/bundles/${id}`,
|
|
1384
|
+
bundler.build({
|
|
1385
|
+
id,
|
|
1386
|
+
main: props.main,
|
|
1387
|
+
compatibility: getCompatibility(props),
|
|
1388
|
+
entry: props.isExternal
|
|
1389
|
+
? {
|
|
1390
|
+
kind: "external",
|
|
1391
|
+
}
|
|
1392
|
+
: {
|
|
1393
|
+
kind: "effect",
|
|
1394
|
+
exports: (props.exports ?? {}) as any,
|
|
1426
1395
|
},
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
if (props.isExternal) {
|
|
1431
|
-
const bundle = yield* buildBundle();
|
|
1432
|
-
return bundle;
|
|
1433
|
-
}
|
|
1434
|
-
|
|
1435
|
-
const script = makeEffectVirtualEntry((props.exports ?? {}) as any, {
|
|
1436
|
-
name: stack.name,
|
|
1437
|
-
stage: stack.stage,
|
|
1438
|
-
});
|
|
1439
|
-
return yield* buildBundle(virtualEntryPlugin(script));
|
|
1440
|
-
}).pipe(Artifacts.cached("build"));
|
|
1396
|
+
stack: { name: stack.name, stage: stack.stage },
|
|
1397
|
+
userOptions: props.build,
|
|
1398
|
+
});
|
|
1441
1399
|
|
|
1442
1400
|
const viteBuild = Effect.fnUntraced(function* (props: WorkerProps) {
|
|
1443
1401
|
let assetsDirectory: string | undefined;
|
|
1444
1402
|
let serverBundle: vite.Rolldown.OutputBundle | undefined;
|
|
1445
|
-
const
|
|
1446
|
-
getCompatibility(props);
|
|
1403
|
+
const compatibility = getCompatibility(props);
|
|
1447
1404
|
|
|
1448
1405
|
yield* Effect.promise(async () => {
|
|
1449
1406
|
const vite = await loadVite(props.vite?.rootDir);
|
|
@@ -1462,13 +1419,10 @@ export const LiveWorkerProvider = () =>
|
|
|
1462
1419
|
},
|
|
1463
1420
|
},
|
|
1464
1421
|
},
|
|
1465
|
-
builder: {
|
|
1466
|
-
sharedConfigBuild: true,
|
|
1467
|
-
},
|
|
1468
1422
|
plugins: [
|
|
1469
1423
|
cloudflareVite({
|
|
1470
|
-
compatibilityDate,
|
|
1471
|
-
compatibilityFlags,
|
|
1424
|
+
compatibilityDate: compatibility.date,
|
|
1425
|
+
compatibilityFlags: compatibility.flags,
|
|
1472
1426
|
}),
|
|
1473
1427
|
{
|
|
1474
1428
|
name: "output:ssr",
|
|
@@ -1698,18 +1652,24 @@ export const LiveWorkerProvider = () =>
|
|
|
1698
1652
|
// Add environment variables as metadata bindings
|
|
1699
1653
|
if (news.env) {
|
|
1700
1654
|
for (const [key, value] of Object.entries(news.env)) {
|
|
1701
|
-
if (value
|
|
1655
|
+
if (value === undefined) continue;
|
|
1702
1656
|
if (Redacted.isRedacted(value)) {
|
|
1703
1657
|
metadataBindings.push({
|
|
1704
1658
|
type: "secret_text",
|
|
1705
1659
|
name: key,
|
|
1706
1660
|
text: Redacted.value(value),
|
|
1707
1661
|
});
|
|
1708
|
-
} else {
|
|
1662
|
+
} else if (typeof value === "string") {
|
|
1709
1663
|
metadataBindings.push({
|
|
1710
1664
|
type: "plain_text",
|
|
1711
1665
|
name: key,
|
|
1712
|
-
text:
|
|
1666
|
+
text: value,
|
|
1667
|
+
});
|
|
1668
|
+
} else {
|
|
1669
|
+
metadataBindings.push({
|
|
1670
|
+
type: "json",
|
|
1671
|
+
name: key,
|
|
1672
|
+
json: value,
|
|
1713
1673
|
});
|
|
1714
1674
|
}
|
|
1715
1675
|
}
|
|
@@ -1862,11 +1822,13 @@ export const LiveWorkerProvider = () =>
|
|
|
1862
1822
|
}),
|
|
1863
1823
|
);
|
|
1864
1824
|
|
|
1865
|
-
const
|
|
1825
|
+
const compatibility = getCompatibility(news);
|
|
1826
|
+
const metadata: workers.PutScriptRequest["metadata"] = {
|
|
1866
1827
|
assets: metadataAssets,
|
|
1867
1828
|
bindings: metadataBindings,
|
|
1868
1829
|
bodyPart: undefined,
|
|
1869
|
-
|
|
1830
|
+
compatibilityDate: compatibility.date,
|
|
1831
|
+
compatibilityFlags: compatibility.flags,
|
|
1870
1832
|
containers:
|
|
1871
1833
|
metadataContainers.length > 0 ? metadataContainers : undefined,
|
|
1872
1834
|
keepAssets,
|
|
@@ -1949,7 +1911,21 @@ export const LiveWorkerProvider = () =>
|
|
|
1949
1911
|
yield* session.note(
|
|
1950
1912
|
`${desiredSubdomainEnabled ? "Enabling" : "Disabling"} workers.dev subdomain...`,
|
|
1951
1913
|
);
|
|
1952
|
-
|
|
1914
|
+
// Cloudflare's script registry is eventually consistent — for the
|
|
1915
|
+
// first few hundred ms after `putScript` returns, POST /subdomain
|
|
1916
|
+
// can still get back `WorkerNotFound` (a generic "unknown error"
|
|
1917
|
+
// body). Bigger uploads race harder. Retry the subdomain toggle on
|
|
1918
|
+
// that specific tag with a short exponential backoff; same pattern
|
|
1919
|
+
// we use elsewhere in this provider for DO-namespace propagation.
|
|
1920
|
+
yield* setWorkerSubdomain(name, desiredSubdomainEnabled).pipe(
|
|
1921
|
+
Effect.retry({
|
|
1922
|
+
while: (error: { _tag?: string }) =>
|
|
1923
|
+
error?._tag === "WorkerNotFound",
|
|
1924
|
+
schedule: Schedule.exponential(200).pipe(
|
|
1925
|
+
Schedule.both(Schedule.recurs(15)),
|
|
1926
|
+
),
|
|
1927
|
+
}),
|
|
1928
|
+
);
|
|
1953
1929
|
}
|
|
1954
1930
|
const desiredDomains = normalizeDomains(news.domain);
|
|
1955
1931
|
const previousDomains = output?.domains ?? [];
|
|
@@ -2328,80 +2304,11 @@ export const LiveWorkerProvider = () =>
|
|
|
2328
2304
|
scriptName: output.workerName,
|
|
2329
2305
|
}).pipe(Effect.catchTag("WorkerNotFound", () => Effect.void));
|
|
2330
2306
|
}),
|
|
2331
|
-
tail: ({ output }) =>
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
body: { filters: [] },
|
|
2337
|
-
});
|
|
2338
|
-
|
|
2339
|
-
const socket = yield* Socket.makeWebSocket(url, {
|
|
2340
|
-
protocols: ["trace-v1"],
|
|
2341
|
-
});
|
|
2342
|
-
|
|
2343
|
-
const queue = yield* Queue.make<LogLine, Cause.Done>();
|
|
2344
|
-
|
|
2345
|
-
yield* socket
|
|
2346
|
-
.runRaw((raw) => {
|
|
2347
|
-
const text =
|
|
2348
|
-
typeof raw === "string" ? raw : new TextDecoder().decode(raw);
|
|
2349
|
-
const data: TailEventMessage = JSON.parse(text);
|
|
2350
|
-
const eventTs = new Date(data.eventTimestamp ?? Date.now());
|
|
2351
|
-
|
|
2352
|
-
if (data.event && "request" in data.event) {
|
|
2353
|
-
const reqEvent = data.event;
|
|
2354
|
-
const pathname = (() => {
|
|
2355
|
-
try {
|
|
2356
|
-
return new URL(reqEvent.request.url).pathname;
|
|
2357
|
-
} catch {
|
|
2358
|
-
return reqEvent.request.url;
|
|
2359
|
-
}
|
|
2360
|
-
})();
|
|
2361
|
-
const status = reqEvent.response?.status ?? 500;
|
|
2362
|
-
Queue.offerUnsafe(queue, {
|
|
2363
|
-
timestamp: eventTs,
|
|
2364
|
-
message: `${reqEvent.request.method} ${pathname} > ${status} (cpu: ${Math.round(data.cpuTime)}ms, wall: ${Math.round(data.wallTime)}ms)`,
|
|
2365
|
-
});
|
|
2366
|
-
}
|
|
2367
|
-
|
|
2368
|
-
for (const log of data.logs) {
|
|
2369
|
-
const msg = log.message.join(" ");
|
|
2370
|
-
Queue.offerUnsafe(queue, {
|
|
2371
|
-
timestamp: new Date(log.timestamp),
|
|
2372
|
-
message: log.level === "log" ? msg : `${log.level}: ${msg}`,
|
|
2373
|
-
});
|
|
2374
|
-
}
|
|
2375
|
-
|
|
2376
|
-
for (const exception of data.exceptions) {
|
|
2377
|
-
Queue.offerUnsafe(queue, {
|
|
2378
|
-
timestamp: new Date(exception.timestamp),
|
|
2379
|
-
message: `${exception.name} ${exception.message}\n${exception.stack}`,
|
|
2380
|
-
});
|
|
2381
|
-
}
|
|
2382
|
-
})
|
|
2383
|
-
.pipe(
|
|
2384
|
-
Effect.ensuring(
|
|
2385
|
-
Effect.all([
|
|
2386
|
-
deleteScriptTail({
|
|
2387
|
-
scriptName: output.workerName,
|
|
2388
|
-
id: tailId,
|
|
2389
|
-
accountId: output.accountId,
|
|
2390
|
-
}).pipe(Effect.ignore),
|
|
2391
|
-
Queue.end(queue),
|
|
2392
|
-
]),
|
|
2393
|
-
),
|
|
2394
|
-
Effect.ignore,
|
|
2395
|
-
Effect.forkChild(),
|
|
2396
|
-
);
|
|
2397
|
-
|
|
2398
|
-
return Stream.fromQueue(queue);
|
|
2399
|
-
});
|
|
2400
|
-
|
|
2401
|
-
return Stream.unwrap(runTailSession).pipe(
|
|
2402
|
-
Stream.repeat(Schedule.spaced("1 second")),
|
|
2403
|
-
);
|
|
2404
|
-
},
|
|
2307
|
+
tail: ({ output }) =>
|
|
2308
|
+
telemetry.tailScript({
|
|
2309
|
+
accountId: output.accountId,
|
|
2310
|
+
scriptName: output.workerName,
|
|
2311
|
+
}),
|
|
2405
2312
|
logs: ({ output, options }) =>
|
|
2406
2313
|
telemetry.queryLogs({
|
|
2407
2314
|
accountId: output.accountId,
|
|
@@ -2419,33 +2326,6 @@ export const LiveWorkerProvider = () =>
|
|
|
2419
2326
|
}),
|
|
2420
2327
|
);
|
|
2421
2328
|
|
|
2422
|
-
interface TailEventMessage {
|
|
2423
|
-
eventTimestamp?: number;
|
|
2424
|
-
wallTime: number;
|
|
2425
|
-
cpuTime: number;
|
|
2426
|
-
truncated: boolean;
|
|
2427
|
-
outcome: string;
|
|
2428
|
-
scriptName: string;
|
|
2429
|
-
exceptions: {
|
|
2430
|
-
name: string;
|
|
2431
|
-
message: string;
|
|
2432
|
-
stack: string;
|
|
2433
|
-
timestamp: string;
|
|
2434
|
-
}[];
|
|
2435
|
-
logs: {
|
|
2436
|
-
message: string[];
|
|
2437
|
-
level: string;
|
|
2438
|
-
timestamp: string;
|
|
2439
|
-
}[];
|
|
2440
|
-
event:
|
|
2441
|
-
| {
|
|
2442
|
-
request: { method: string; url: string };
|
|
2443
|
-
response?: { status: number };
|
|
2444
|
-
}
|
|
2445
|
-
| null
|
|
2446
|
-
| undefined;
|
|
2447
|
-
}
|
|
2448
|
-
|
|
2449
2329
|
const contentTypeFromExtension = (extension: string) => {
|
|
2450
2330
|
switch (extension) {
|
|
2451
2331
|
case ".wasm":
|
|
@@ -4,7 +4,9 @@ import * as FileSystem from "effect/FileSystem";
|
|
|
4
4
|
import { flow } from "effect/Function";
|
|
5
5
|
import type * as Path from "effect/Path";
|
|
6
6
|
import * as Stream from "effect/Stream";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
7
8
|
import type * as rolldown from "rolldown";
|
|
9
|
+
import Sonda from "sonda/rolldown";
|
|
8
10
|
import * as Artifacts from "../../Artifacts.ts";
|
|
9
11
|
import * as Bundle from "../../Bundle/Bundle.ts";
|
|
10
12
|
import { findCwdForBundle } from "../../Bundle/TempRoot.ts";
|
|
@@ -13,6 +15,7 @@ import {
|
|
|
13
15
|
isDurableObjectExport,
|
|
14
16
|
type DurableObjectExport,
|
|
15
17
|
} from "./DurableObjectNamespace.ts";
|
|
18
|
+
import type { WorkerProps } from "./Worker.ts";
|
|
16
19
|
import { isWorkflowExport, type WorkflowExport } from "./Workflow.ts";
|
|
17
20
|
|
|
18
21
|
export interface WorkerBundleOptions {
|
|
@@ -31,6 +34,7 @@ export interface WorkerBundleOptions {
|
|
|
31
34
|
exports: Record<string, DurableObjectExport | WorkflowExport>;
|
|
32
35
|
};
|
|
33
36
|
stack: { name: string; stage: string };
|
|
37
|
+
userOptions: WorkerProps["build"] | undefined;
|
|
34
38
|
}
|
|
35
39
|
|
|
36
40
|
export const WorkerBundle = Effect.gen(function* () {
|
|
@@ -41,15 +45,7 @@ export const WorkerBundle = Effect.gen(function* () {
|
|
|
41
45
|
const makeOptions = Effect.fnUntraced(function* (
|
|
42
46
|
options: WorkerBundleOptions,
|
|
43
47
|
) {
|
|
44
|
-
const realMain = yield*
|
|
45
|
-
Effect.mapError(
|
|
46
|
-
(cause) =>
|
|
47
|
-
new Bundle.BundleError({
|
|
48
|
-
message: `Failed to find real path for bundle: ${options.main}`,
|
|
49
|
-
cause,
|
|
50
|
-
}),
|
|
51
|
-
),
|
|
52
|
-
);
|
|
48
|
+
const realMain = yield* sanitizeMain(options.main);
|
|
53
49
|
const inputOptions: rolldown.InputOptions = {
|
|
54
50
|
input: realMain,
|
|
55
51
|
cwd: yield* findCwdForBundle(realMain).pipe(
|
|
@@ -72,6 +68,7 @@ export const WorkerBundle = Effect.gen(function* () {
|
|
|
72
68
|
makeEffectVirtualEntry(options.entry.exports, options.stack),
|
|
73
69
|
)
|
|
74
70
|
: undefined,
|
|
71
|
+
...(options.userOptions?.metafile ? [Sonda({ open: false })] : []),
|
|
75
72
|
],
|
|
76
73
|
checks: {
|
|
77
74
|
// Suppress unresolved import warnings for unrelated AWS packages
|
|
@@ -85,14 +82,39 @@ export const WorkerBundle = Effect.gen(function* () {
|
|
|
85
82
|
keepNames: true,
|
|
86
83
|
dir: `.alchemy/bundles/${options.id}`,
|
|
87
84
|
};
|
|
88
|
-
|
|
85
|
+
const extraOptions: Bundle.BundleExtraOptions = {
|
|
86
|
+
pure: options.userOptions?.pure,
|
|
87
|
+
};
|
|
88
|
+
return { inputOptions, outputOptions, extraOptions };
|
|
89
89
|
});
|
|
90
90
|
|
|
91
|
+
const sanitizeMain = (main: string) =>
|
|
92
|
+
Effect.sync(() => {
|
|
93
|
+
try {
|
|
94
|
+
return fileURLToPath(main);
|
|
95
|
+
} catch {
|
|
96
|
+
return main;
|
|
97
|
+
}
|
|
98
|
+
}).pipe(
|
|
99
|
+
Effect.flatMap((path) => fs.realPath(path)),
|
|
100
|
+
Effect.mapError(
|
|
101
|
+
(cause) =>
|
|
102
|
+
new Bundle.BundleError({
|
|
103
|
+
message: `Failed to find real path for bundle: ${main}`,
|
|
104
|
+
cause,
|
|
105
|
+
}),
|
|
106
|
+
),
|
|
107
|
+
);
|
|
108
|
+
|
|
91
109
|
return {
|
|
92
110
|
build: flow(
|
|
93
111
|
makeOptions,
|
|
94
112
|
Effect.flatMap((resolved) =>
|
|
95
|
-
Bundle.build(
|
|
113
|
+
Bundle.build(
|
|
114
|
+
resolved.inputOptions,
|
|
115
|
+
resolved.outputOptions,
|
|
116
|
+
resolved.extraOptions,
|
|
117
|
+
),
|
|
96
118
|
),
|
|
97
119
|
Artifacts.cached("build"),
|
|
98
120
|
),
|
|
@@ -100,7 +122,11 @@ export const WorkerBundle = Effect.gen(function* () {
|
|
|
100
122
|
makeOptions,
|
|
101
123
|
Stream.fromEffect,
|
|
102
124
|
Stream.flatMap((resolved) =>
|
|
103
|
-
Bundle.watch(
|
|
125
|
+
Bundle.watch(
|
|
126
|
+
resolved.inputOptions,
|
|
127
|
+
resolved.outputOptions,
|
|
128
|
+
resolved.extraOptions,
|
|
129
|
+
),
|
|
104
130
|
),
|
|
105
131
|
),
|
|
106
132
|
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Credentials,
|
|
3
|
+
formatHeaders,
|
|
4
|
+
} from "@distilled.cloud/cloudflare/Credentials";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
|
|
7
|
+
export type ZoneReference = string | { zoneId: string; name?: string };
|
|
8
|
+
|
|
9
|
+
export const isZoneId = (zone: string): boolean => /^[a-f0-9]{32}$/i.test(zone);
|
|
10
|
+
|
|
11
|
+
export const matchesZoneHostname = (
|
|
12
|
+
zoneName: string,
|
|
13
|
+
hostname: string,
|
|
14
|
+
): boolean => hostname === zoneName || hostname.endsWith(`.${zoneName}`);
|
|
15
|
+
|
|
16
|
+
export const resolveZoneId = ({
|
|
17
|
+
accountId,
|
|
18
|
+
zone,
|
|
19
|
+
hostname,
|
|
20
|
+
}: {
|
|
21
|
+
accountId: string;
|
|
22
|
+
zone: ZoneReference | undefined;
|
|
23
|
+
hostname: string;
|
|
24
|
+
}) =>
|
|
25
|
+
Effect.gen(function* () {
|
|
26
|
+
if (typeof zone === "object") return zone.zoneId;
|
|
27
|
+
if (typeof zone === "string" && isZoneId(zone)) return zone;
|
|
28
|
+
|
|
29
|
+
const lookup = zone ?? hostname;
|
|
30
|
+
for (const candidate of zoneNameCandidates(lookup)) {
|
|
31
|
+
const match = yield* findZoneByName({ accountId, name: candidate });
|
|
32
|
+
if (match) return match.id;
|
|
33
|
+
}
|
|
34
|
+
return yield* Effect.fail(
|
|
35
|
+
new Error(`Cloudflare zone not found for ${lookup}`),
|
|
36
|
+
);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
type ZoneListResponse = {
|
|
40
|
+
success: boolean;
|
|
41
|
+
errors?: { message?: string }[];
|
|
42
|
+
result?: { id: string; name: string; account: { id?: string | null } }[];
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const findZoneByName = ({
|
|
46
|
+
accountId,
|
|
47
|
+
name,
|
|
48
|
+
}: {
|
|
49
|
+
accountId: string;
|
|
50
|
+
name: string;
|
|
51
|
+
}) =>
|
|
52
|
+
Effect.gen(function* () {
|
|
53
|
+
const credentialsEffect = yield* Credentials;
|
|
54
|
+
const credentials = yield* credentialsEffect;
|
|
55
|
+
const url = new URL(`${credentials.apiBaseUrl}/zones`);
|
|
56
|
+
url.searchParams.set("account.id", accountId);
|
|
57
|
+
url.searchParams.set("name", name);
|
|
58
|
+
url.searchParams.set("per_page", "1");
|
|
59
|
+
|
|
60
|
+
const json = yield* Effect.tryPromise({
|
|
61
|
+
try: async () => {
|
|
62
|
+
const response = await fetch(url, {
|
|
63
|
+
headers: formatHeaders(credentials),
|
|
64
|
+
});
|
|
65
|
+
return (await response.json()) as ZoneListResponse;
|
|
66
|
+
},
|
|
67
|
+
catch: (cause) => new Error(`Failed to list Cloudflare zones`, { cause }),
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
if (!json.success) {
|
|
71
|
+
return yield* Effect.fail(
|
|
72
|
+
new Error(
|
|
73
|
+
json.errors?.map((error) => error.message).join(", ") ??
|
|
74
|
+
`Failed to list Cloudflare zones`,
|
|
75
|
+
),
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return json.result?.find(
|
|
80
|
+
(candidate) =>
|
|
81
|
+
candidate.name === name && candidate.account.id === accountId,
|
|
82
|
+
);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const zoneNameCandidates = (hostname: string): string[] => {
|
|
86
|
+
const parts = hostname.split(".");
|
|
87
|
+
return parts.slice(0, -1).map((_, index) => parts.slice(index).join("."));
|
|
88
|
+
};
|