alchemy 2.0.0-beta.43 → 2.0.0-beta.45
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 +18 -5
- package/bin/exec.js +381 -240
- package/bin/exec.js.map +1 -1
- package/lib/AWS/Lambda/Function.d.ts +17 -0
- package/lib/AWS/Lambda/Function.d.ts.map +1 -1
- package/lib/AWS/Lambda/Function.js +61 -16
- package/lib/AWS/Lambda/Function.js.map +1 -1
- package/lib/AWS/Providers.d.ts +2 -1
- package/lib/AWS/Providers.d.ts.map +1 -1
- package/lib/AWS/Providers.js +3 -1
- package/lib/AWS/Providers.js.map +1 -1
- package/lib/Apply.js +17 -1
- package/lib/Apply.js.map +1 -1
- package/lib/Auth/AuthProvider.d.ts.map +1 -1
- package/lib/Auth/AuthProvider.js +24 -6
- package/lib/Auth/AuthProvider.js.map +1 -1
- package/lib/Auth/Credentials.d.ts.map +1 -1
- package/lib/Auth/Credentials.js +3 -3
- package/lib/Auth/Credentials.js.map +1 -1
- package/lib/Auth/Lock.js +2 -2
- package/lib/Auth/Lock.js.map +1 -1
- package/lib/Bundle/Bundle.d.ts +11 -0
- package/lib/Bundle/Bundle.d.ts.map +1 -1
- package/lib/Bundle/Bundle.js +19 -12
- package/lib/Bundle/Bundle.js.map +1 -1
- package/lib/Bundle/BundleAnalyzerPlugin.d.ts +25 -0
- package/lib/Bundle/BundleAnalyzerPlugin.d.ts.map +1 -0
- package/lib/Bundle/BundleAnalyzerPlugin.js +16 -0
- package/lib/Bundle/BundleAnalyzerPlugin.js.map +1 -0
- package/lib/Bundle/RawPlugin.d.ts +36 -0
- package/lib/Bundle/RawPlugin.d.ts.map +1 -0
- package/lib/Bundle/RawPlugin.js +80 -0
- package/lib/Bundle/RawPlugin.js.map +1 -0
- package/lib/Bundle/index.d.ts +2 -0
- package/lib/Bundle/index.d.ts.map +1 -1
- package/lib/Bundle/index.js +2 -0
- package/lib/Bundle/index.js.map +1 -1
- package/lib/Cli/commands/_shared.d.ts +13 -1
- package/lib/Cli/commands/_shared.d.ts.map +1 -1
- package/lib/Cli/commands/_shared.js +33 -2
- package/lib/Cli/commands/_shared.js.map +1 -1
- package/lib/Cli/commands/dev.d.ts +3 -2
- package/lib/Cli/commands/dev.d.ts.map +1 -1
- package/lib/Cli/commands/dev.js +19 -2
- package/lib/Cli/commands/dev.js.map +1 -1
- package/lib/Cli/commands/login.d.ts.map +1 -1
- package/lib/Cli/commands/login.js +19 -5
- package/lib/Cli/commands/login.js.map +1 -1
- package/lib/Cli/commands/profile.d.ts.map +1 -1
- package/lib/Cli/commands/profile.js +7 -27
- package/lib/Cli/commands/profile.js.map +1 -1
- package/lib/Cli/exec.d.ts.map +1 -1
- package/lib/Cli/exec.js +2 -1
- package/lib/Cli/exec.js.map +1 -1
- package/lib/Cli/main.d.ts.map +1 -1
- package/lib/Cli/main.js +0 -2
- package/lib/Cli/main.js.map +1 -1
- package/lib/Cloudflare/AiGateway/AiGateway.d.ts +0 -2
- package/lib/Cloudflare/AiGateway/AiGateway.d.ts.map +1 -1
- package/lib/Cloudflare/AiGateway/AiGateway.js +2 -4
- package/lib/Cloudflare/AiGateway/AiGateway.js.map +1 -1
- package/lib/Cloudflare/BrowserRendering/BrowserRendering.d.ts +116 -0
- package/lib/Cloudflare/BrowserRendering/BrowserRendering.d.ts.map +1 -0
- package/lib/Cloudflare/BrowserRendering/BrowserRendering.js +92 -0
- package/lib/Cloudflare/BrowserRendering/BrowserRendering.js.map +1 -0
- package/lib/Cloudflare/BrowserRendering/BrowserRenderingBinding.d.ts +55 -0
- package/lib/Cloudflare/BrowserRendering/BrowserRenderingBinding.d.ts.map +1 -0
- package/lib/Cloudflare/BrowserRendering/BrowserRenderingBinding.js +55 -0
- package/lib/Cloudflare/BrowserRendering/BrowserRenderingBinding.js.map +1 -0
- package/lib/Cloudflare/BrowserRendering/index.d.ts +3 -0
- package/lib/Cloudflare/BrowserRendering/index.d.ts.map +1 -0
- package/lib/Cloudflare/BrowserRendering/index.js +3 -0
- package/lib/Cloudflare/BrowserRendering/index.js.map +1 -0
- package/lib/Cloudflare/Container/Container.d.ts +3 -3
- package/lib/Cloudflare/Container/Container.js +3 -3
- package/lib/Cloudflare/Container/StartContainer.d.ts.map +1 -1
- package/lib/Cloudflare/Container/StartContainer.js.map +1 -1
- package/lib/Cloudflare/D1/D1Database.d.ts +1 -0
- package/lib/Cloudflare/D1/D1Database.d.ts.map +1 -1
- package/lib/Cloudflare/D1/D1Database.js +2 -1
- package/lib/Cloudflare/D1/D1Database.js.map +1 -1
- package/lib/Cloudflare/D1/D1DatabaseBinding.js +1 -1
- package/lib/Cloudflare/D1/D1DatabaseBinding.js.map +1 -1
- package/lib/Cloudflare/Fetcher.d.ts.map +1 -1
- package/lib/Cloudflare/Fetcher.js +0 -2
- package/lib/Cloudflare/Fetcher.js.map +1 -1
- package/lib/Cloudflare/Hyperdrive/Hyperdrive.d.ts +1 -0
- package/lib/Cloudflare/Hyperdrive/Hyperdrive.d.ts.map +1 -1
- package/lib/Cloudflare/Hyperdrive/Hyperdrive.js +3 -0
- package/lib/Cloudflare/Hyperdrive/Hyperdrive.js.map +1 -1
- package/lib/Cloudflare/Hyperdrive/HyperdriveBinding.d.ts +3 -2
- package/lib/Cloudflare/Hyperdrive/HyperdriveBinding.d.ts.map +1 -1
- package/lib/Cloudflare/Hyperdrive/HyperdriveBinding.js +32 -33
- package/lib/Cloudflare/Hyperdrive/HyperdriveBinding.js.map +1 -1
- package/lib/Cloudflare/KV/KVNamespace.d.ts +1 -0
- package/lib/Cloudflare/KV/KVNamespace.d.ts.map +1 -1
- package/lib/Cloudflare/KV/KVNamespace.js +2 -0
- package/lib/Cloudflare/KV/KVNamespace.js.map +1 -1
- package/lib/Cloudflare/Local.d.ts +2 -0
- package/lib/Cloudflare/Local.d.ts.map +1 -0
- package/lib/Cloudflare/Local.js +9 -0
- package/lib/Cloudflare/Local.js.map +1 -0
- package/lib/Cloudflare/Providers.d.ts +2 -1
- package/lib/Cloudflare/Providers.d.ts.map +1 -1
- package/lib/Cloudflare/Providers.js +23 -17
- package/lib/Cloudflare/Providers.js.map +1 -1
- package/lib/Cloudflare/Queue/Queue.d.ts +1 -0
- package/lib/Cloudflare/Queue/Queue.d.ts.map +1 -1
- package/lib/Cloudflare/Queue/Queue.js +1 -0
- package/lib/Cloudflare/Queue/Queue.js.map +1 -1
- package/lib/Cloudflare/Queue/QueueConsumer.d.ts +2 -1
- package/lib/Cloudflare/Queue/QueueConsumer.d.ts.map +1 -1
- package/lib/Cloudflare/Queue/QueueConsumer.js +11 -3
- package/lib/Cloudflare/Queue/QueueConsumer.js.map +1 -1
- package/lib/Cloudflare/Queue/QueueEventSource.d.ts +30 -4
- package/lib/Cloudflare/Queue/QueueEventSource.d.ts.map +1 -1
- package/lib/Cloudflare/Queue/QueueEventSource.js +22 -1
- package/lib/Cloudflare/Queue/QueueEventSource.js.map +1 -1
- package/lib/Cloudflare/R2/R2Bucket.d.ts +1 -0
- package/lib/Cloudflare/R2/R2Bucket.d.ts.map +1 -1
- package/lib/Cloudflare/R2/R2Bucket.js +18 -0
- package/lib/Cloudflare/R2/R2Bucket.js.map +1 -1
- package/lib/Cloudflare/SecretsStore/Secret.d.ts.map +1 -1
- package/lib/Cloudflare/SecretsStore/Secret.js +13 -34
- package/lib/Cloudflare/SecretsStore/Secret.js.map +1 -1
- package/lib/Cloudflare/SecretsStore/SecretBinding.d.ts +3 -2
- package/lib/Cloudflare/SecretsStore/SecretBinding.d.ts.map +1 -1
- package/lib/Cloudflare/SecretsStore/SecretBinding.js +3 -2
- package/lib/Cloudflare/SecretsStore/SecretBinding.js.map +1 -1
- package/lib/Cloudflare/StateStore/Api.d.ts +5 -13
- package/lib/Cloudflare/StateStore/Api.d.ts.map +1 -1
- package/lib/Cloudflare/StateStore/Api.js +14 -8
- package/lib/Cloudflare/StateStore/Api.js.map +1 -1
- package/lib/Cloudflare/StateStore/State.d.ts.map +1 -1
- package/lib/Cloudflare/StateStore/State.js +45 -9
- package/lib/Cloudflare/StateStore/State.js.map +1 -1
- package/lib/Cloudflare/StateStore/Store.d.ts.map +1 -1
- package/lib/Cloudflare/StateStore/Store.js +5 -2
- package/lib/Cloudflare/StateStore/Store.js.map +1 -1
- package/lib/Cloudflare/VpcService/VpcService.d.ts +2 -2
- package/lib/Cloudflare/VpcService/VpcService.d.ts.map +1 -1
- package/lib/Cloudflare/Website/StaticSite.d.ts +5 -5
- package/lib/Cloudflare/Website/StaticSite.d.ts.map +1 -1
- package/lib/Cloudflare/Website/StaticSite.js +3 -0
- package/lib/Cloudflare/Website/StaticSite.js.map +1 -1
- package/lib/Cloudflare/Website/Vite.d.ts +5 -5
- package/lib/Cloudflare/Website/Vite.d.ts.map +1 -1
- package/lib/Cloudflare/Website/Vite.js.map +1 -1
- package/lib/Cloudflare/Workers/Assets.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/Assets.js +1 -1
- package/lib/Cloudflare/Workers/Assets.js.map +1 -1
- package/lib/Cloudflare/Workers/DurableObjectBridge.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/DurableObjectBridge.js +4 -3
- package/lib/Cloudflare/Workers/DurableObjectBridge.js.map +1 -1
- package/lib/Cloudflare/Workers/DurableObjectNamespace.d.ts +183 -6
- package/lib/Cloudflare/Workers/DurableObjectNamespace.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/DurableObjectNamespace.js +279 -76
- package/lib/Cloudflare/Workers/DurableObjectNamespace.js.map +1 -1
- package/lib/Cloudflare/Workers/HttpServer.d.ts +6 -4
- package/lib/Cloudflare/Workers/HttpServer.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/HttpServer.js +20 -15
- package/lib/Cloudflare/Workers/HttpServer.js.map +1 -1
- package/lib/Cloudflare/Workers/InferEnv.d.ts +3 -2
- package/lib/Cloudflare/Workers/InferEnv.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/LocalWorkerProvider.d.ts +19 -3
- package/lib/Cloudflare/Workers/LocalWorkerProvider.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/LocalWorkerProvider.js +458 -21
- package/lib/Cloudflare/Workers/LocalWorkerProvider.js.map +1 -1
- package/lib/Cloudflare/Workers/Rpc.d.ts +16 -0
- package/lib/Cloudflare/Workers/Rpc.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/Rpc.js +22 -0
- package/lib/Cloudflare/Workers/Rpc.js.map +1 -1
- package/lib/Cloudflare/Workers/RpcDurableObjectNamespace.d.ts +285 -0
- package/lib/Cloudflare/Workers/RpcDurableObjectNamespace.d.ts.map +1 -0
- package/lib/Cloudflare/Workers/RpcDurableObjectNamespace.js +288 -0
- package/lib/Cloudflare/Workers/RpcDurableObjectNamespace.js.map +1 -0
- package/lib/Cloudflare/Workers/RpcWorker.d.ts +305 -0
- package/lib/Cloudflare/Workers/RpcWorker.d.ts.map +1 -0
- package/lib/Cloudflare/Workers/RpcWorker.js +350 -0
- package/lib/Cloudflare/Workers/RpcWorker.js.map +1 -0
- package/lib/Cloudflare/Workers/Vite.d.ts +1 -1
- package/lib/Cloudflare/Workers/Vite.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/Vite.js +2 -1
- package/lib/Cloudflare/Workers/Vite.js.map +1 -1
- package/lib/Cloudflare/Workers/Worker.d.ts +69 -37
- package/lib/Cloudflare/Workers/Worker.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/Worker.js +171 -51
- package/lib/Cloudflare/Workers/Worker.js.map +1 -1
- package/lib/Cloudflare/Workers/WorkerAsyncBindings.d.ts +1 -1
- package/lib/Cloudflare/Workers/WorkerAsyncBindings.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/WorkerAsyncBindings.js +158 -97
- package/lib/Cloudflare/Workers/WorkerAsyncBindings.js.map +1 -1
- package/lib/Cloudflare/Workers/WorkerBinding.d.ts +11 -23
- package/lib/Cloudflare/Workers/WorkerBinding.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/WorkerBinding.js +3 -0
- package/lib/Cloudflare/Workers/WorkerBinding.js.map +1 -1
- package/lib/Cloudflare/Workers/WorkerBridge.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/WorkerBridge.js +8 -7
- package/lib/Cloudflare/Workers/WorkerBridge.js.map +1 -1
- package/lib/Cloudflare/Workers/WorkerBundle.d.ts +1 -2
- package/lib/Cloudflare/Workers/WorkerBundle.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/WorkerBundle.js +7 -7
- package/lib/Cloudflare/Workers/WorkerBundle.js.map +1 -1
- package/lib/Cloudflare/Workers/WorkerRuntimeContext.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/WorkerRuntimeContext.js +9 -10
- package/lib/Cloudflare/Workers/WorkerRuntimeContext.js.map +1 -1
- package/lib/Cloudflare/Workers/Workflow.d.ts +5 -3
- package/lib/Cloudflare/Workers/Workflow.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/Workflow.js +19 -1
- package/lib/Cloudflare/Workers/Workflow.js.map +1 -1
- package/lib/Cloudflare/Workers/index.d.ts +2 -0
- package/lib/Cloudflare/Workers/index.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/index.js +2 -0
- package/lib/Cloudflare/Workers/index.js.map +1 -1
- package/lib/Cloudflare/Zaraz/ZarazConfig.d.ts +184 -0
- package/lib/Cloudflare/Zaraz/ZarazConfig.d.ts.map +1 -0
- package/lib/Cloudflare/Zaraz/ZarazConfig.js +216 -0
- package/lib/Cloudflare/Zaraz/ZarazConfig.js.map +1 -0
- package/lib/Cloudflare/Zaraz/ZarazEventTypes.d.ts +188 -0
- package/lib/Cloudflare/Zaraz/ZarazEventTypes.d.ts.map +1 -0
- package/lib/Cloudflare/Zaraz/ZarazEventTypes.js +4 -0
- package/lib/Cloudflare/Zaraz/ZarazEventTypes.js.map +1 -0
- package/lib/Cloudflare/Zaraz/index.d.ts +3 -0
- package/lib/Cloudflare/Zaraz/index.d.ts.map +1 -0
- package/lib/Cloudflare/Zaraz/index.js +2 -0
- package/lib/Cloudflare/Zaraz/index.js.map +1 -0
- package/lib/Cloudflare/index.d.ts +2 -0
- package/lib/Cloudflare/index.d.ts.map +1 -1
- package/lib/Cloudflare/index.js +2 -0
- package/lib/Cloudflare/index.js.map +1 -1
- package/lib/Dependencies.d.ts +10 -0
- package/lib/Dependencies.d.ts.map +1 -0
- package/lib/Dependencies.js +1 -0
- package/lib/Dependencies.js.map +1 -0
- package/lib/Deploy.d.ts +2 -1
- package/lib/Deploy.d.ts.map +1 -1
- package/lib/Deploy.js +2 -2
- package/lib/Deploy.js.map +1 -1
- package/lib/Diff.d.ts +11 -0
- package/lib/Diff.d.ts.map +1 -1
- package/lib/Diff.js +11 -0
- package/lib/Diff.js.map +1 -1
- package/lib/Input.d.ts +2 -1
- package/lib/Input.d.ts.map +1 -1
- package/lib/KeyPair.d.ts +77 -0
- package/lib/KeyPair.d.ts.map +1 -0
- package/lib/KeyPair.js +102 -0
- package/lib/KeyPair.js.map +1 -0
- package/lib/Local/RpcProvider.d.ts +56 -0
- package/lib/Local/RpcProvider.d.ts.map +1 -0
- package/lib/Local/RpcProvider.js +83 -0
- package/lib/Local/RpcProvider.js.map +1 -0
- package/lib/Local/RpcProviderProxy.d.ts +19 -0
- package/lib/Local/RpcProviderProxy.d.ts.map +1 -0
- package/lib/Local/RpcProviderProxy.js +48 -0
- package/lib/Local/RpcProviderProxy.js.map +1 -0
- package/lib/Local/RpcSerialization.d.ts +34 -0
- package/lib/Local/RpcSerialization.d.ts.map +1 -0
- package/lib/Local/RpcSerialization.js +120 -0
- package/lib/Local/RpcSerialization.js.map +1 -0
- package/lib/Local/RpcServer.d.ts +63 -0
- package/lib/Local/RpcServer.d.ts.map +1 -0
- package/lib/Local/RpcServer.js +72 -0
- package/lib/Local/RpcServer.js.map +1 -0
- package/lib/Local/RpcServerBun.d.ts +3 -0
- package/lib/Local/RpcServerBun.d.ts.map +1 -0
- package/lib/Local/RpcServerBun.js +47 -0
- package/lib/Local/RpcServerBun.js.map +1 -0
- package/lib/Local/RpcServerEnvironment.d.ts +20 -0
- package/lib/Local/RpcServerEnvironment.d.ts.map +1 -0
- package/lib/Local/RpcServerEnvironment.js +22 -0
- package/lib/Local/RpcServerEnvironment.js.map +1 -0
- package/lib/Local/RpcServerNode.d.ts +3 -0
- package/lib/Local/RpcServerNode.d.ts.map +1 -0
- package/lib/Local/RpcServerNode.js +43 -0
- package/lib/Local/RpcServerNode.js.map +1 -0
- package/lib/Local/RpcServerSession.d.ts +27 -0
- package/lib/Local/RpcServerSession.d.ts.map +1 -0
- package/lib/Local/RpcServerSession.js +68 -0
- package/lib/Local/RpcServerSession.js.map +1 -0
- package/lib/Local/RpcSpawner.d.ts +21 -0
- package/lib/Local/RpcSpawner.d.ts.map +1 -0
- package/lib/Local/RpcSpawner.js +132 -0
- package/lib/Local/RpcSpawner.js.map +1 -0
- package/lib/Neon/Project.d.ts.map +1 -1
- package/lib/Neon/Project.js +14 -3
- package/lib/Neon/Project.js.map +1 -1
- package/lib/Output.d.ts.map +1 -1
- package/lib/Output.js +9 -2
- package/lib/Output.js.map +1 -1
- package/lib/Phase.d.ts +2 -1
- package/lib/Phase.d.ts.map +1 -1
- package/lib/Phase.js +6 -1
- package/lib/Phase.js.map +1 -1
- package/lib/Plan.d.ts.map +1 -1
- package/lib/Plan.js +14 -3
- package/lib/Plan.js.map +1 -1
- package/lib/Platform.d.ts +8 -6
- package/lib/Platform.d.ts.map +1 -1
- package/lib/Platform.js +33 -3
- package/lib/Platform.js.map +1 -1
- package/lib/Random.d.ts.map +1 -1
- package/lib/Random.js +9 -14
- package/lib/Random.js.map +1 -1
- package/lib/RuntimeContext.d.ts +21 -1
- package/lib/RuntimeContext.d.ts.map +1 -1
- package/lib/RuntimeContext.js +12 -0
- package/lib/RuntimeContext.js.map +1 -1
- package/lib/Stack.d.ts +3 -3
- package/lib/Stack.d.ts.map +1 -1
- package/lib/Stack.js.map +1 -1
- package/lib/State/HttpStateApi.d.ts +2 -2
- package/lib/State/StateEncoding.d.ts +8 -0
- package/lib/State/StateEncoding.d.ts.map +1 -1
- package/lib/State/StateEncoding.js +55 -5
- package/lib/State/StateEncoding.js.map +1 -1
- package/lib/Test/Bun.d.ts.map +1 -1
- package/lib/Test/Bun.js +0 -2
- package/lib/Test/Bun.js.map +1 -1
- package/lib/Test/Vitest.d.ts.map +1 -1
- package/lib/Test/Vitest.js +0 -2
- package/lib/Test/Vitest.js.map +1 -1
- package/lib/Util/Duration.d.ts +14 -0
- package/lib/Util/Duration.d.ts.map +1 -0
- package/lib/Util/Duration.js +18 -0
- package/lib/Util/Duration.js.map +1 -0
- package/lib/Util/PlatformServices.d.ts +7 -0
- package/lib/Util/PlatformServices.d.ts.map +1 -1
- package/lib/Util/PlatformServices.js +22 -11
- package/lib/Util/PlatformServices.js.map +1 -1
- package/lib/Util/camel.d.ts.map +1 -1
- package/lib/Util/camel.js +2 -3
- package/lib/Util/camel.js.map +1 -1
- package/lib/Util/data.d.ts +5 -0
- package/lib/Util/data.d.ts.map +1 -1
- package/lib/Util/data.js +29 -0
- package/lib/Util/data.js.map +1 -1
- package/lib/Util/index.d.ts +0 -6
- package/lib/Util/index.d.ts.map +1 -1
- package/lib/Util/index.js +0 -6
- package/lib/Util/index.js.map +1 -1
- package/lib/Util/stable.d.ts.map +1 -1
- package/lib/Util/stable.js +3 -6
- package/lib/Util/stable.js.map +1 -1
- package/lib/Util/types.d.ts +3 -1
- package/lib/Util/types.d.ts.map +1 -1
- package/lib/Util/types.js +5 -1
- package/lib/Util/types.js.map +1 -1
- package/lib/index.d.ts +2 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -3
- package/lib/index.js.map +1 -1
- package/lib/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +22 -23
- package/src/AWS/Lambda/Function.ts +87 -34
- package/src/AWS/Providers.ts +3 -0
- package/src/Apply.ts +18 -1
- package/src/Auth/AuthProvider.ts +25 -5
- package/src/Auth/Credentials.ts +8 -7
- package/src/Auth/Lock.ts +2 -2
- package/src/Bundle/Bundle.ts +35 -13
- package/src/Bundle/BundleAnalyzerPlugin.ts +33 -0
- package/src/Bundle/RawPlugin.ts +82 -0
- package/src/Bundle/index.ts +2 -0
- package/src/Cli/commands/_shared.ts +47 -4
- package/src/Cli/commands/dev.ts +63 -37
- package/src/Cli/commands/login.ts +20 -4
- package/src/Cli/commands/profile.ts +24 -34
- package/src/Cli/exec.ts +12 -7
- package/src/Cli/main.ts +0 -3
- package/src/Cloudflare/AiGateway/AiGateway.ts +2 -6
- package/src/Cloudflare/BrowserRendering/BrowserRendering.ts +132 -0
- package/src/Cloudflare/BrowserRendering/BrowserRenderingBinding.ts +137 -0
- package/src/Cloudflare/BrowserRendering/index.ts +11 -0
- package/src/Cloudflare/Container/Container.ts +3 -3
- package/src/Cloudflare/Container/StartContainer.ts +1 -2
- package/src/Cloudflare/D1/D1Database.ts +4 -1
- package/src/Cloudflare/D1/D1DatabaseBinding.ts +1 -1
- package/src/Cloudflare/Fetcher.ts +0 -2
- package/src/Cloudflare/Hyperdrive/Hyperdrive.ts +5 -0
- package/src/Cloudflare/Hyperdrive/HyperdriveBinding.ts +41 -43
- package/src/Cloudflare/KV/KVNamespace.ts +4 -0
- package/src/Cloudflare/Local.ts +23 -0
- package/src/Cloudflare/Providers.ts +28 -16
- package/src/Cloudflare/Queue/Queue.ts +3 -0
- package/src/Cloudflare/Queue/QueueConsumer.ts +23 -8
- package/src/Cloudflare/Queue/QueueEventSource.ts +33 -5
- package/src/Cloudflare/R2/R2Bucket.ts +26 -0
- package/src/Cloudflare/SecretsStore/Secret.ts +14 -41
- package/src/Cloudflare/SecretsStore/SecretBinding.ts +11 -11
- package/src/Cloudflare/StateStore/Api.ts +15 -15
- package/src/Cloudflare/StateStore/State.ts +68 -6
- package/src/Cloudflare/StateStore/Store.ts +5 -2
- package/src/Cloudflare/VpcService/VpcService.ts +2 -2
- package/src/Cloudflare/Website/StaticSite.ts +8 -10
- package/src/Cloudflare/Website/Vite.ts +4 -7
- package/src/Cloudflare/Workers/Assets.ts +1 -1
- package/src/Cloudflare/Workers/DurableObjectBridge.ts +7 -5
- package/src/Cloudflare/Workers/DurableObjectNamespace.ts +380 -121
- package/src/Cloudflare/Workers/HttpServer.ts +31 -25
- package/src/Cloudflare/Workers/InferEnv.ts +15 -8
- package/src/Cloudflare/Workers/LocalWorkerProvider.ts +609 -22
- package/src/Cloudflare/Workers/Rpc.ts +50 -0
- package/src/Cloudflare/Workers/RpcDurableObjectNamespace.ts +502 -0
- package/src/Cloudflare/Workers/RpcWorker.ts +562 -0
- package/src/Cloudflare/Workers/Vite.ts +2 -0
- package/src/Cloudflare/Workers/Worker.ts +280 -110
- package/src/Cloudflare/Workers/WorkerAsyncBindings.ts +158 -103
- package/src/Cloudflare/Workers/WorkerBinding.ts +10 -0
- package/src/Cloudflare/Workers/WorkerBridge.ts +10 -9
- package/src/Cloudflare/Workers/WorkerBundle.ts +8 -9
- package/src/Cloudflare/Workers/WorkerRuntimeContext.ts +8 -15
- package/src/Cloudflare/Workers/Workflow.ts +22 -3
- package/src/Cloudflare/Workers/index.ts +2 -0
- package/src/Cloudflare/Zaraz/ZarazConfig.ts +403 -0
- package/src/Cloudflare/Zaraz/ZarazEventTypes.ts +257 -0
- package/src/Cloudflare/Zaraz/index.ts +25 -0
- package/src/Cloudflare/index.ts +2 -0
- package/src/Dependencies.ts +10 -0
- package/src/Deploy.ts +3 -1
- package/src/Diff.ts +13 -0
- package/src/Input.ts +2 -0
- package/src/KeyPair.ts +146 -0
- package/src/Local/RpcProvider.ts +146 -0
- package/src/Local/RpcProviderProxy.ts +86 -0
- package/src/Local/RpcSerialization.ts +225 -0
- package/src/Local/RpcServer.ts +138 -0
- package/src/Local/RpcServerBun.ts +59 -0
- package/src/Local/RpcServerEnvironment.ts +55 -0
- package/src/Local/RpcServerNode.ts +58 -0
- package/src/Local/RpcServerSession.ts +87 -0
- package/src/Local/RpcSpawner.ts +196 -0
- package/src/Neon/Project.ts +16 -3
- package/src/Output.ts +8 -2
- package/src/Phase.ts +8 -0
- package/src/Plan.ts +16 -3
- package/src/Platform.ts +74 -27
- package/src/Random.ts +22 -27
- package/src/RuntimeContext.ts +23 -1
- package/src/Stack.ts +3 -3
- package/src/State/StateEncoding.ts +58 -7
- package/src/Test/Bun.ts +0 -3
- package/src/Test/Vitest.ts +0 -3
- package/src/Util/Duration.ts +21 -0
- package/src/Util/PlatformServices.ts +41 -27
- package/src/Util/camel.ts +3 -5
- package/src/Util/data.ts +38 -0
- package/src/Util/index.ts +0 -6
- package/src/Util/stable.ts +4 -10
- package/src/Util/types.ts +9 -2
- package/src/index.ts +2 -3
- package/lib/Cloudflare/Local/Sidecar.d.ts +0 -63
- package/lib/Cloudflare/Local/Sidecar.d.ts.map +0 -1
- package/lib/Cloudflare/Local/Sidecar.js +0 -50
- package/lib/Cloudflare/Local/Sidecar.js.map +0 -1
- package/lib/Cloudflare/Local/SidecarHandlers.d.ts +0 -8
- package/lib/Cloudflare/Local/SidecarHandlers.d.ts.map +0 -1
- package/lib/Cloudflare/Local/SidecarHandlers.js +0 -381
- package/lib/Cloudflare/Local/SidecarHandlers.js.map +0 -1
- package/lib/Cloudflare/Local/SidecarServer.d.ts +0 -2
- package/lib/Cloudflare/Local/SidecarServer.d.ts.map +0 -1
- package/lib/Cloudflare/Local/SidecarServer.js +0 -34
- package/lib/Cloudflare/Local/SidecarServer.js.map +0 -1
- package/lib/Secret.d.ts +0 -50
- package/lib/Secret.d.ts.map +0 -1
- package/lib/Secret.js +0 -23
- package/lib/Secret.js.map +0 -1
- package/lib/Sidecar/Lock.d.ts +0 -23
- package/lib/Sidecar/Lock.d.ts.map +0 -1
- package/lib/Sidecar/Lock.js +0 -39
- package/lib/Sidecar/Lock.js.map +0 -1
- package/lib/Sidecar/RpcClient.d.ts +0 -15
- package/lib/Sidecar/RpcClient.d.ts.map +0 -1
- package/lib/Sidecar/RpcClient.js +0 -78
- package/lib/Sidecar/RpcClient.js.map +0 -1
- package/lib/Sidecar/RpcHandler.d.ts +0 -51
- package/lib/Sidecar/RpcHandler.d.ts.map +0 -1
- package/lib/Sidecar/RpcHandler.js +0 -87
- package/lib/Sidecar/RpcHandler.js.map +0 -1
- package/lib/Sidecar/RpcPaths.d.ts +0 -19
- package/lib/Sidecar/RpcPaths.d.ts.map +0 -1
- package/lib/Sidecar/RpcPaths.js +0 -31
- package/lib/Sidecar/RpcPaths.js.map +0 -1
- package/lib/Sidecar/RpcServer.d.ts +0 -30
- package/lib/Sidecar/RpcServer.d.ts.map +0 -1
- package/lib/Sidecar/RpcServer.js +0 -105
- package/lib/Sidecar/RpcServer.js.map +0 -1
- package/lib/Sidecar/RpcServerBun.d.ts +0 -4
- package/lib/Sidecar/RpcServerBun.d.ts.map +0 -1
- package/lib/Sidecar/RpcServerBun.js +0 -28
- package/lib/Sidecar/RpcServerBun.js.map +0 -1
- package/lib/Sidecar/RpcServerNode.d.ts +0 -4
- package/lib/Sidecar/RpcServerNode.d.ts.map +0 -1
- package/lib/Sidecar/RpcServerNode.js +0 -39
- package/lib/Sidecar/RpcServerNode.js.map +0 -1
- package/lib/Sidecar/RpcServices.d.ts +0 -6
- package/lib/Sidecar/RpcServices.d.ts.map +0 -1
- package/lib/Sidecar/RpcServices.js +0 -29
- package/lib/Sidecar/RpcServices.js.map +0 -1
- package/lib/Trait.d.ts +0 -43
- package/lib/Trait.d.ts.map +0 -1
- package/lib/Trait.js +0 -17
- package/lib/Trait.js.map +0 -1
- package/lib/Util/LocalhostDns.d.ts +0 -23
- package/lib/Util/LocalhostDns.d.ts.map +0 -1
- package/lib/Util/LocalhostDns.js +0 -46
- package/lib/Util/LocalhostDns.js.map +0 -1
- package/lib/Util/assert-never.d.ts +0 -12
- package/lib/Util/assert-never.d.ts.map +0 -1
- package/lib/Util/assert-never.js +0 -11
- package/lib/Util/assert-never.js.map +0 -1
- package/lib/Util/class.d.ts +0 -3
- package/lib/Util/class.d.ts.map +0 -1
- package/lib/Util/class.js +0 -1
- package/lib/Util/class.js.map +0 -1
- package/lib/Util/ignore.d.ts +0 -40
- package/lib/Util/ignore.d.ts.map +0 -1
- package/lib/Util/ignore.js +0 -591
- package/lib/Util/ignore.js.map +0 -1
- package/lib/Util/instance.d.ts +0 -4
- package/lib/Util/instance.d.ts.map +0 -1
- package/lib/Util/instance.js +0 -1
- package/lib/Util/instance.js.map +0 -1
- package/lib/Util/pointer.d.ts +0 -5
- package/lib/Util/pointer.d.ts.map +0 -1
- package/lib/Util/pointer.js +0 -1
- package/lib/Util/pointer.js.map +0 -1
- package/lib/Util/schema-to-type.d.ts +0 -42
- package/lib/Util/schema-to-type.d.ts.map +0 -1
- package/lib/Util/schema-to-type.js +0 -364
- package/lib/Util/schema-to-type.js.map +0 -1
- package/lib/Util/todo.d.ts +0 -3
- package/lib/Util/todo.d.ts.map +0 -1
- package/lib/Util/todo.js +0 -3
- package/lib/Util/todo.js.map +0 -1
- package/lib/Variable.d.ts +0 -29
- package/lib/Variable.d.ts.map +0 -1
- package/lib/Variable.js +0 -9
- package/lib/Variable.js.map +0 -1
- package/src/Cloudflare/Local/Sidecar.ts +0 -81
- package/src/Cloudflare/Local/SidecarHandlers.ts +0 -491
- package/src/Cloudflare/Local/SidecarServer.ts +0 -70
- package/src/Secret.ts +0 -87
- package/src/Sidecar/Lock.ts +0 -66
- package/src/Sidecar/RpcClient.ts +0 -142
- package/src/Sidecar/RpcHandler.ts +0 -205
- package/src/Sidecar/RpcPaths.ts +0 -39
- package/src/Sidecar/RpcServer.ts +0 -153
- package/src/Sidecar/RpcServerBun.ts +0 -41
- package/src/Sidecar/RpcServerNode.ts +0 -51
- package/src/Sidecar/RpcServices.ts +0 -48
- package/src/Trait.ts +0 -105
- package/src/Util/LocalhostDns.ts +0 -52
- package/src/Util/assert-never.ts +0 -18
- package/src/Util/class.ts +0 -7
- package/src/Util/ignore.ts +0 -815
- package/src/Util/instance.ts +0 -9
- package/src/Util/pointer.ts +0 -5
- package/src/Util/schema-to-type.ts +0 -456
- package/src/Util/todo.ts +0 -4
- package/src/Variable.ts +0 -44
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="@cloudflare/workers-types" />
|
|
2
2
|
|
|
3
3
|
import type * as Effect from "effect/Effect";
|
|
4
|
+
import type { Redacted } from "effect/Redacted";
|
|
4
5
|
import type * as Stream from "effect/Stream";
|
|
5
6
|
import type { Rpc } from "../../Rpc.ts";
|
|
6
7
|
import type * as Cloudflare from "../index.ts";
|
|
@@ -11,7 +12,7 @@ export type InferEnv<W> =
|
|
|
11
12
|
W extends Effect.Effect<infer A, infer _E, infer _R>
|
|
12
13
|
? InferEnv<A>
|
|
13
14
|
: W extends Worker<any>
|
|
14
|
-
? InferEnv<Exclude<W["Props"]["
|
|
15
|
+
? InferEnv<Exclude<W["Props"]["env"], undefined>>
|
|
15
16
|
: {
|
|
16
17
|
[k in keyof W]: GetBindingType<W[k]>;
|
|
17
18
|
};
|
|
@@ -41,13 +42,19 @@ export type GetBindingType<T> =
|
|
|
41
42
|
? Artifacts
|
|
42
43
|
: T extends Cloudflare.Images
|
|
43
44
|
? ImagesBinding
|
|
44
|
-
: T extends Cloudflare.
|
|
45
|
-
?
|
|
46
|
-
: T extends Cloudflare.
|
|
47
|
-
?
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
: T extends Cloudflare.BrowserRendering
|
|
46
|
+
? Fetcher
|
|
47
|
+
: T extends Cloudflare.Hyperdrive
|
|
48
|
+
? Hyperdrive
|
|
49
|
+
: T extends Cloudflare.DurableObjectNamespaceLike
|
|
50
|
+
? DurableObjectNamespace<
|
|
51
|
+
Exclude<T["Shape"], undefined>
|
|
52
|
+
>
|
|
53
|
+
: T extends Redacted<any>
|
|
54
|
+
? // redacteds are always stored as secret_text, so are always string
|
|
55
|
+
// we JSON.stringify when not a Redacted<string>
|
|
56
|
+
string
|
|
57
|
+
: T;
|
|
51
58
|
|
|
52
59
|
/**
|
|
53
60
|
* Cloudflare service-binding wire shape for an Effect-native Worker.
|
|
@@ -1,37 +1,624 @@
|
|
|
1
|
+
import {
|
|
2
|
+
layerRuntime,
|
|
3
|
+
Runtime,
|
|
4
|
+
RuntimeError,
|
|
5
|
+
type BindingHook,
|
|
6
|
+
type BindingServices,
|
|
7
|
+
type HyperdriveOrigin,
|
|
8
|
+
type Module,
|
|
9
|
+
type Assets as RuntimeAssets,
|
|
10
|
+
type DurableObjectNamespace as RuntimeDurableObjectNamespace,
|
|
11
|
+
type RuntimeServices,
|
|
12
|
+
} from "@distilled.cloud/cloudflare-runtime";
|
|
13
|
+
import {
|
|
14
|
+
Ai,
|
|
15
|
+
AnalyticsEngine,
|
|
16
|
+
Artifacts,
|
|
17
|
+
Assets,
|
|
18
|
+
Browser,
|
|
19
|
+
D1,
|
|
20
|
+
Data,
|
|
21
|
+
DispatchNamespace,
|
|
22
|
+
DurableObjectNamespace,
|
|
23
|
+
Hyperdrive,
|
|
24
|
+
Images,
|
|
25
|
+
Json,
|
|
26
|
+
KvNamespace,
|
|
27
|
+
MtlsCertificate,
|
|
28
|
+
Pipelines,
|
|
29
|
+
R2Bucket,
|
|
30
|
+
RateLimit,
|
|
31
|
+
SendEmail,
|
|
32
|
+
Service,
|
|
33
|
+
Text,
|
|
34
|
+
Vectorize,
|
|
35
|
+
VersionMetadata,
|
|
36
|
+
WasmModule,
|
|
37
|
+
WorkerLoader,
|
|
38
|
+
Workflows,
|
|
39
|
+
} from "@distilled.cloud/cloudflare-runtime/bindings";
|
|
40
|
+
import * as WorkerProxy from "@distilled.cloud/cloudflare-runtime/proxy/WorkerProxy";
|
|
41
|
+
import * as Cause from "effect/Cause";
|
|
1
42
|
import * as Effect from "effect/Effect";
|
|
2
|
-
import * as
|
|
43
|
+
import * as Equal from "effect/Equal";
|
|
44
|
+
import * as Exit from "effect/Exit";
|
|
45
|
+
import * as Fiber from "effect/Fiber";
|
|
46
|
+
import * as Hash from "effect/Hash";
|
|
47
|
+
import * as Path from "effect/Path";
|
|
48
|
+
import * as Redacted from "effect/Redacted";
|
|
49
|
+
import * as Result from "effect/Result";
|
|
50
|
+
import * as Schema from "effect/Schema";
|
|
51
|
+
import * as Scope from "effect/Scope";
|
|
52
|
+
import * as Stream from "effect/Stream";
|
|
53
|
+
import { AlchemyContext } from "../../AlchemyContext.ts";
|
|
54
|
+
import type * as Bundle from "../../Bundle/Bundle.ts";
|
|
55
|
+
import { isResolved } from "../../Diff.ts";
|
|
56
|
+
import * as RpcProvider from "../../Local/RpcProvider.ts";
|
|
57
|
+
import type { ResourceBinding } from "../../Resource.ts";
|
|
3
58
|
import { Stack } from "../../Stack.ts";
|
|
4
|
-
import {
|
|
59
|
+
import { CloudflareEnvironment } from "../CloudflareEnvironment.ts";
|
|
60
|
+
import type { WorkerAssetsConfig, WorkerProps } from "../Workers/Worker.ts";
|
|
61
|
+
import { getCompatibility } from "./Compatibility.ts";
|
|
62
|
+
import * as Vite from "./Vite.ts";
|
|
5
63
|
import { Worker } from "./Worker.ts";
|
|
64
|
+
import { getCronBindings } from "./WorkerAsyncBindings.ts";
|
|
65
|
+
import type { WorkerBinding } from "./WorkerBinding.ts";
|
|
66
|
+
import { WorkerBundle, type WorkerBundleOptions } from "./WorkerBundle.ts";
|
|
67
|
+
import { createWorkerName } from "./WorkerName.ts";
|
|
68
|
+
|
|
69
|
+
export class WorkerValidationError extends Schema.TaggedErrorClass<WorkerValidationError>()(
|
|
70
|
+
"WorkerValidationError",
|
|
71
|
+
{
|
|
72
|
+
message: Schema.String,
|
|
73
|
+
hint: Schema.optional(Schema.String),
|
|
74
|
+
value: Schema.Unknown,
|
|
75
|
+
},
|
|
76
|
+
) {}
|
|
77
|
+
|
|
78
|
+
export const localRuntimeServices = () =>
|
|
79
|
+
RpcProvider.providerServicesEffect(
|
|
80
|
+
Effect.gen(function* () {
|
|
81
|
+
const { accountId } = yield* CloudflareEnvironment;
|
|
82
|
+
const { dotAlchemy } = yield* AlchemyContext;
|
|
83
|
+
const path = yield* Path.Path;
|
|
84
|
+
return layerRuntime({
|
|
85
|
+
api: {
|
|
86
|
+
accountId,
|
|
87
|
+
},
|
|
88
|
+
storage: {
|
|
89
|
+
directory: path.join(dotAlchemy, "local"),
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
}),
|
|
93
|
+
);
|
|
6
94
|
|
|
7
95
|
export const LocalWorkerProvider = () =>
|
|
8
|
-
|
|
96
|
+
RpcProvider.effect(
|
|
9
97
|
Worker,
|
|
98
|
+
import.meta.resolve(
|
|
99
|
+
// `import.meta.resolve(<string>)` is a runtime API — TypeScript's
|
|
100
|
+
// `rewriteRelativeImportExtensions` does NOT touch the string literal, so
|
|
101
|
+
// we have to pick the right extension ourselves. `import.meta.url` reflects
|
|
102
|
+
// the actual on-disk extension of *this* file (`.ts` when loaded from
|
|
103
|
+
// `src/` under Bun or vitest, `.js` when loaded from the compiled `lib/`
|
|
104
|
+
// under Node), which is exactly the signal we need.
|
|
105
|
+
import.meta.url.endsWith(".ts") ? "../Local.ts" : "../Local.js",
|
|
106
|
+
import.meta.url,
|
|
107
|
+
),
|
|
10
108
|
Effect.gen(function* () {
|
|
109
|
+
const { accountId } = yield* CloudflareEnvironment;
|
|
110
|
+
const bundler = yield* WorkerBundle;
|
|
111
|
+
const runtime = yield* Runtime;
|
|
11
112
|
const stack = yield* Stack;
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
113
|
+
const path = yield* Path.Path;
|
|
114
|
+
const workerProxy = yield* WorkerProxy.WorkerProxy;
|
|
115
|
+
const proxyInstances = new Map<
|
|
116
|
+
string,
|
|
117
|
+
{
|
|
118
|
+
serverOptions: WorkerConfig["dev"];
|
|
119
|
+
instance: WorkerProxy.WorkerProxyInstance;
|
|
120
|
+
scope: Scope.Closeable;
|
|
121
|
+
}
|
|
122
|
+
>();
|
|
123
|
+
|
|
124
|
+
const startProxy = Effect.fn(function* (
|
|
125
|
+
id: string,
|
|
126
|
+
serverOptions: WorkerConfig["dev"],
|
|
127
|
+
) {
|
|
128
|
+
const scope = yield* Scope.fork(rootScope);
|
|
129
|
+
const instance = yield* workerProxy
|
|
130
|
+
.serve(serverOptions)
|
|
131
|
+
.pipe(Scope.provide(scope));
|
|
132
|
+
proxyInstances.set(id, { serverOptions, instance, scope });
|
|
133
|
+
return instance;
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
const stopProxy = Effect.fn(function* (id: string) {
|
|
137
|
+
const existing = proxyInstances.get(id);
|
|
138
|
+
if (existing) {
|
|
139
|
+
yield* Scope.close(existing.scope, Exit.void);
|
|
140
|
+
proxyInstances.delete(id);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
const maybeStartProxy = Effect.fn(function* (
|
|
145
|
+
id: string,
|
|
146
|
+
serverOptions: WorkerConfig["dev"],
|
|
147
|
+
) {
|
|
148
|
+
const existing = proxyInstances.get(id);
|
|
149
|
+
if (existing) {
|
|
150
|
+
if (Equal.equals(existing.serverOptions, serverOptions)) {
|
|
151
|
+
return existing.instance;
|
|
152
|
+
}
|
|
153
|
+
yield* stopProxy(id);
|
|
154
|
+
}
|
|
155
|
+
return yield* startProxy(id, serverOptions);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
const toRuntimeModules = Effect.fn(function* (
|
|
159
|
+
bundle: Bundle.BundleOutput,
|
|
160
|
+
) {
|
|
161
|
+
const modules: Module[] = [];
|
|
162
|
+
for (const file of bundle.files) {
|
|
163
|
+
const ext = path.extname(file.path);
|
|
164
|
+
const type = moduleTypeFromExtension(ext);
|
|
165
|
+
if (type === "SourceMap") continue;
|
|
166
|
+
if (type === "Data" || type === "Wasm") {
|
|
167
|
+
if (!(file.content instanceof Uint8Array)) {
|
|
168
|
+
return yield* new WorkerValidationError({
|
|
169
|
+
message: `Expected Uint8Array for ${file.path} (${type})`,
|
|
170
|
+
value: file.content,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
modules.push({
|
|
174
|
+
name: file.path,
|
|
175
|
+
type,
|
|
176
|
+
content: file.content,
|
|
177
|
+
});
|
|
178
|
+
} else {
|
|
179
|
+
if (typeof file.content !== "string") {
|
|
180
|
+
return yield* new WorkerValidationError({
|
|
181
|
+
message: `Expected string for ${file.path} (${type})`,
|
|
182
|
+
value: file.content,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
modules.push({
|
|
186
|
+
name: file.path,
|
|
187
|
+
type,
|
|
188
|
+
content: file.content,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return modules;
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
const serveScoped = Effect.fnUntraced(function* (
|
|
196
|
+
worker: WorkerConfig,
|
|
197
|
+
bundle: Bundle.BundleOutput,
|
|
198
|
+
proxy: WorkerProxy.WorkerProxyInstance,
|
|
199
|
+
) {
|
|
200
|
+
const scope = yield* Effect.scope.pipe(Effect.flatMap(Scope.fork));
|
|
201
|
+
const url = yield* runtime
|
|
202
|
+
.start({
|
|
203
|
+
name: worker.name,
|
|
204
|
+
compatibilityDate: worker.compatibility.date,
|
|
205
|
+
compatibilityFlags: worker.compatibility.flags,
|
|
206
|
+
bindings: worker.workerBindings as never,
|
|
207
|
+
hyperdrives: worker.hyperdrives,
|
|
208
|
+
durableObjectNamespaces: toRuntimeDurableObjectNamespaces(
|
|
209
|
+
worker.durableObjectNamespaces,
|
|
210
|
+
),
|
|
211
|
+
modules: yield* toRuntimeModules(bundle),
|
|
212
|
+
assets: toRuntimeAssets(worker.assets),
|
|
213
|
+
})
|
|
214
|
+
.pipe(Scope.provide(scope));
|
|
215
|
+
const previous = workerdScopes.get(worker.id);
|
|
216
|
+
if (previous) {
|
|
217
|
+
yield* Effect.forkDetach(Scope.close(previous, Exit.void));
|
|
218
|
+
}
|
|
219
|
+
workerdScopes.set(worker.id, scope);
|
|
220
|
+
yield* proxy.set(url);
|
|
221
|
+
return url;
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
const buildConfig = Effect.fn(function* ({
|
|
225
|
+
id,
|
|
226
|
+
props,
|
|
227
|
+
bindings,
|
|
228
|
+
}: {
|
|
229
|
+
id: string;
|
|
230
|
+
props: WorkerProps;
|
|
231
|
+
bindings: ResourceBinding<Worker["Binding"]>[];
|
|
232
|
+
}) {
|
|
233
|
+
const name = yield* createWorkerName(id, props.name);
|
|
234
|
+
const compatibility = getCompatibility(props);
|
|
235
|
+
const workerBindings: BindingHook<BindingServices>[] = [];
|
|
236
|
+
const durableObjectNamespaces: Record<string, string> = {};
|
|
237
|
+
const hyperdrives: Record<string, Required<HyperdriveOrigin>> = {};
|
|
238
|
+
for (const { data } of bindings) {
|
|
239
|
+
for (const binding of data.bindings ?? []) {
|
|
240
|
+
if (
|
|
241
|
+
binding.type === "durable_object_namespace" &&
|
|
242
|
+
// The `durableObjectNamespaces` property is only used to declare DOs in this worker.
|
|
243
|
+
// Otherwise, it's a cross-worker durable object binding, which cloudflare-runtime handles automatically.
|
|
244
|
+
(!binding.scriptName || binding.scriptName === name)
|
|
245
|
+
) {
|
|
246
|
+
// Reuse the existing namespace id if it was provided, otherwise generate a new one.
|
|
247
|
+
// `workerd` uses this for the object's storage path, so it must be safe to use as a file name.
|
|
248
|
+
durableObjectNamespaces[binding.className] =
|
|
249
|
+
binding.namespaceId ??
|
|
250
|
+
encodeURIComponent(`${id}-${binding.className}`);
|
|
251
|
+
}
|
|
252
|
+
workerBindings.push(yield* toRuntimeBinding(binding));
|
|
253
|
+
}
|
|
254
|
+
if (data.hyperdrives) {
|
|
255
|
+
for (const [id, origin] of Object.entries(data.hyperdrives)) {
|
|
256
|
+
hyperdrives[id] = {
|
|
257
|
+
scheme: origin.scheme,
|
|
258
|
+
host: origin.host,
|
|
259
|
+
port: origin.port,
|
|
260
|
+
user: origin.user,
|
|
261
|
+
database: origin.database,
|
|
262
|
+
password: Redacted.isRedacted(origin.password)
|
|
263
|
+
? Redacted.value(origin.password)
|
|
264
|
+
: origin.password,
|
|
265
|
+
sslmode: origin.sslmode,
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return {
|
|
271
|
+
id,
|
|
272
|
+
name,
|
|
273
|
+
compatibility,
|
|
274
|
+
workerBindings,
|
|
275
|
+
durableObjectNamespaces,
|
|
276
|
+
hyperdrives,
|
|
277
|
+
bundleOptions: {
|
|
16
278
|
id,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
279
|
+
main: props.main!,
|
|
280
|
+
compatibility,
|
|
281
|
+
entry: props.isExternal
|
|
282
|
+
? { kind: "external" }
|
|
283
|
+
: { kind: "effect", exports: (props.exports ?? {}) as any },
|
|
284
|
+
stack: { name: stack.name, stage: stack.stage },
|
|
285
|
+
extraOptions: props.build,
|
|
286
|
+
} satisfies WorkerBundleOptions,
|
|
287
|
+
assets: props.assets,
|
|
288
|
+
dev: {
|
|
289
|
+
...props.dev,
|
|
290
|
+
// This is the default. Vite and cloudflare-runtime will retry if unavailable, unless `strictPort` is true.
|
|
291
|
+
port: props.dev?.port ?? 1337,
|
|
292
|
+
},
|
|
293
|
+
};
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
type WorkerConfig = Effect.Success<ReturnType<typeof buildConfig>>;
|
|
297
|
+
|
|
298
|
+
const runServer = Effect.fnUntraced(function* (worker: WorkerConfig) {
|
|
299
|
+
let start = Date.now();
|
|
300
|
+
let status: "start" | "update" = "start";
|
|
301
|
+
const proxy = yield* maybeStartProxy(worker.id, worker.dev);
|
|
302
|
+
yield* bundler.watch(worker.bundleOptions).pipe(
|
|
303
|
+
Stream.tap((event) => {
|
|
304
|
+
if (event._tag === "Start") {
|
|
305
|
+
start = Date.now();
|
|
306
|
+
if (status === "update") {
|
|
307
|
+
return Effect.all([
|
|
308
|
+
Effect.log(`[${worker.id}] Rebuilding`),
|
|
309
|
+
// This tells the proxy to queue requests until the updated worker is ready.
|
|
310
|
+
Effect.forkChild(proxy.unset()),
|
|
311
|
+
]);
|
|
312
|
+
}
|
|
313
|
+
} else if (event._tag === "Error") {
|
|
314
|
+
return Effect.logError(
|
|
315
|
+
`[${worker.id}] Bundle error`,
|
|
316
|
+
event.error,
|
|
317
|
+
);
|
|
318
|
+
}
|
|
319
|
+
return Effect.void;
|
|
21
320
|
}),
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
321
|
+
Stream.filterMap((event) =>
|
|
322
|
+
event._tag === "Success"
|
|
323
|
+
? Result.succeed(event.output)
|
|
324
|
+
: Result.failVoid,
|
|
325
|
+
),
|
|
326
|
+
Stream.mapEffect((bundle) =>
|
|
327
|
+
serveScoped(worker, bundle, proxy).pipe(
|
|
328
|
+
Effect.exit,
|
|
329
|
+
Effect.tap((exit) => {
|
|
330
|
+
if (exit._tag === "Success") {
|
|
331
|
+
const message = Effect.log(
|
|
332
|
+
`[${worker.id}] ${status === "update" ? "Updated" : "Started"} in ${Math.round(Date.now() - start)}ms`,
|
|
333
|
+
);
|
|
334
|
+
status = "update";
|
|
335
|
+
return message;
|
|
336
|
+
} else {
|
|
337
|
+
return Effect.logError(
|
|
338
|
+
`[${worker.id}] Error`,
|
|
339
|
+
Cause.squash(exit.cause),
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
}),
|
|
343
|
+
),
|
|
344
|
+
),
|
|
345
|
+
Stream.runDrain,
|
|
346
|
+
Effect.forkScoped,
|
|
347
|
+
);
|
|
348
|
+
return proxy.url.toString();
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
const rootScope = yield* Effect.scope;
|
|
352
|
+
const workerdScopes = new Map<string, Scope.Closeable>();
|
|
353
|
+
|
|
354
|
+
const context = yield* Effect.context<RuntimeServices>();
|
|
355
|
+
const instances = new Map<
|
|
356
|
+
string,
|
|
357
|
+
{
|
|
358
|
+
hash: number;
|
|
359
|
+
fiber: Fiber.Fiber<
|
|
360
|
+
Worker["Attributes"],
|
|
361
|
+
Bundle.BundleError | WorkerValidationError | RuntimeError
|
|
362
|
+
>;
|
|
363
|
+
scope: Scope.Closeable;
|
|
364
|
+
}
|
|
365
|
+
>();
|
|
366
|
+
|
|
367
|
+
const runInstance = Effect.fn(function* (options: {
|
|
368
|
+
id: string;
|
|
369
|
+
props: WorkerProps;
|
|
370
|
+
bindings: ResourceBinding<Worker["Binding"]>[];
|
|
371
|
+
}) {
|
|
372
|
+
const { props, bindings } = options;
|
|
373
|
+
const config = yield* buildConfig(options);
|
|
374
|
+
let url: string;
|
|
375
|
+
if (props.vite) {
|
|
376
|
+
const devServer = yield* Vite.viteDev(
|
|
377
|
+
props.vite.rootDir,
|
|
378
|
+
props.env ?? {},
|
|
379
|
+
{
|
|
380
|
+
compatibilityDate: config.compatibility.date,
|
|
381
|
+
compatibilityFlags: config.compatibility.flags,
|
|
382
|
+
worker: {
|
|
383
|
+
name: config.name,
|
|
384
|
+
bindings: config.workerBindings,
|
|
385
|
+
durableObjectNamespaces: toRuntimeDurableObjectNamespaces(
|
|
386
|
+
config.durableObjectNamespaces,
|
|
387
|
+
),
|
|
388
|
+
hyperdrives: config.hyperdrives,
|
|
389
|
+
assets: toRuntimeAssets(config.assets),
|
|
390
|
+
},
|
|
391
|
+
context,
|
|
392
|
+
},
|
|
393
|
+
config.dev,
|
|
394
|
+
);
|
|
395
|
+
url = devServer.resolvedUrls!.local[0];
|
|
396
|
+
} else {
|
|
397
|
+
url = yield* runServer(config);
|
|
398
|
+
}
|
|
399
|
+
return {
|
|
400
|
+
workerId: config.name,
|
|
401
|
+
workerName: config.name,
|
|
402
|
+
logpush: undefined,
|
|
403
|
+
url,
|
|
404
|
+
tags: [],
|
|
405
|
+
durableObjectNamespaces: config.durableObjectNamespaces,
|
|
406
|
+
domains: [url],
|
|
407
|
+
crons: Array.from(
|
|
408
|
+
new Set([...getCronBindings(bindings), ...(props.crons ?? [])]),
|
|
409
|
+
),
|
|
410
|
+
accountId,
|
|
411
|
+
} satisfies Worker["Attributes"];
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
return {
|
|
415
|
+
diff: Effect.fn(function* ({ id, news, newBindings, output }) {
|
|
416
|
+
if (!isResolved(news) || !isResolved(newBindings)) return undefined;
|
|
417
|
+
const options = {
|
|
28
418
|
id,
|
|
29
419
|
props: news,
|
|
30
|
-
bindings,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
420
|
+
bindings: newBindings,
|
|
421
|
+
};
|
|
422
|
+
const hash = Hash.structure(options);
|
|
423
|
+
if (instances.get(options.id)?.hash === hash) {
|
|
424
|
+
return { action: "noop" };
|
|
425
|
+
}
|
|
426
|
+
const name = yield* createWorkerName(id, news.name);
|
|
427
|
+
return {
|
|
428
|
+
action: "update",
|
|
429
|
+
stables: output?.workerName === name ? ["workerName"] : undefined,
|
|
430
|
+
};
|
|
431
|
+
}),
|
|
432
|
+
reconcile: Effect.fn(function* ({ id, news, bindings }) {
|
|
433
|
+
const options = { id, props: news, bindings };
|
|
434
|
+
const hash = Hash.structure(options);
|
|
435
|
+
const existing = instances.get(options.id);
|
|
436
|
+
if (existing) {
|
|
437
|
+
if (existing.hash === hash) {
|
|
438
|
+
yield* Effect.log(
|
|
439
|
+
`[${options.id}] No changes, using existing instance`,
|
|
440
|
+
);
|
|
441
|
+
return yield* Fiber.join(existing.fiber);
|
|
442
|
+
}
|
|
443
|
+
yield* Effect.log(
|
|
444
|
+
`[${options.id}] Changes detected, interrupting existing instance`,
|
|
445
|
+
);
|
|
446
|
+
yield* Fiber.interrupt(existing.fiber);
|
|
447
|
+
yield* Scope.close(existing.scope, Exit.void);
|
|
448
|
+
instances.delete(options.id);
|
|
449
|
+
}
|
|
450
|
+
const scope = yield* Scope.fork(rootScope);
|
|
451
|
+
const fiber = yield* runInstance(options).pipe(
|
|
452
|
+
Effect.forkDetach,
|
|
453
|
+
Scope.provide(scope),
|
|
454
|
+
);
|
|
455
|
+
instances.set(options.id, { hash, fiber, scope });
|
|
456
|
+
return yield* Fiber.join(fiber).pipe(
|
|
457
|
+
Effect.onExit((exit) =>
|
|
458
|
+
Effect.sync(() => {
|
|
459
|
+
if (exit._tag === "Failure") {
|
|
460
|
+
instances.delete(options.id);
|
|
461
|
+
}
|
|
462
|
+
}),
|
|
463
|
+
),
|
|
464
|
+
);
|
|
465
|
+
}),
|
|
466
|
+
delete: Effect.fn(function* ({ id }) {
|
|
467
|
+
const existing = instances.get(id);
|
|
468
|
+
if (existing) {
|
|
469
|
+
yield* Fiber.interrupt(existing.fiber);
|
|
470
|
+
yield* Scope.close(existing.scope, Exit.void);
|
|
471
|
+
instances.delete(id);
|
|
472
|
+
}
|
|
473
|
+
}),
|
|
35
474
|
};
|
|
36
475
|
}),
|
|
37
476
|
);
|
|
477
|
+
|
|
478
|
+
const toRuntimeBinding = Effect.fnUntraced(function* (b: WorkerBinding) {
|
|
479
|
+
const unsupported = () =>
|
|
480
|
+
new WorkerValidationError({
|
|
481
|
+
message: `${b.type} bindings are not supported in local mode`,
|
|
482
|
+
value: b,
|
|
483
|
+
});
|
|
484
|
+
switch (b.type) {
|
|
485
|
+
case "ai":
|
|
486
|
+
return Ai.remote(b.name);
|
|
487
|
+
case "analytics_engine":
|
|
488
|
+
return AnalyticsEngine.local(b.name, b.dataset);
|
|
489
|
+
case "artifacts":
|
|
490
|
+
return Artifacts.remote(b.name, b.namespace);
|
|
491
|
+
case "assets":
|
|
492
|
+
return Assets.local(b.name);
|
|
493
|
+
case "browser":
|
|
494
|
+
return Browser.remote(b.name);
|
|
495
|
+
case "d1":
|
|
496
|
+
return D1.remote(b.name, b.databaseId);
|
|
497
|
+
case "data_blob":
|
|
498
|
+
return Data.local(b.name, Buffer.from(b.part));
|
|
499
|
+
case "dispatch_namespace":
|
|
500
|
+
return DispatchNamespace.remote({
|
|
501
|
+
binding: b.name,
|
|
502
|
+
namespace: b.namespace,
|
|
503
|
+
});
|
|
504
|
+
case "durable_object_namespace":
|
|
505
|
+
return DurableObjectNamespace.local({
|
|
506
|
+
binding: b.name,
|
|
507
|
+
className: b.className,
|
|
508
|
+
scriptName: b.scriptName,
|
|
509
|
+
});
|
|
510
|
+
case "hyperdrive":
|
|
511
|
+
return Hyperdrive.local(b.name, b.id);
|
|
512
|
+
case "images":
|
|
513
|
+
return Images.remote(b.name);
|
|
514
|
+
case "inherit":
|
|
515
|
+
return yield* unsupported();
|
|
516
|
+
case "json":
|
|
517
|
+
return Json.local(b.name, b.json);
|
|
518
|
+
case "kv_namespace":
|
|
519
|
+
return KvNamespace.remote(b.name, b.namespaceId);
|
|
520
|
+
case "mtls_certificate":
|
|
521
|
+
return MtlsCertificate.remote(b.name, b.certificateId);
|
|
522
|
+
case "pipelines":
|
|
523
|
+
return Pipelines.remote(b.name, b.pipeline);
|
|
524
|
+
case "plain_text":
|
|
525
|
+
return Text.local(b.name, b.text);
|
|
526
|
+
case "queue":
|
|
527
|
+
return yield* unsupported();
|
|
528
|
+
case "r2_bucket":
|
|
529
|
+
return R2Bucket.remote(b.name, b.bucketName, b.jurisdiction);
|
|
530
|
+
case "ratelimit":
|
|
531
|
+
return RateLimit.local({
|
|
532
|
+
binding: b.name,
|
|
533
|
+
simple: b.simple,
|
|
534
|
+
namespaceId: b.namespaceId,
|
|
535
|
+
});
|
|
536
|
+
case "secret_key":
|
|
537
|
+
return yield* unsupported();
|
|
538
|
+
case "secret_text":
|
|
539
|
+
return Text.local(b.name, b.text);
|
|
540
|
+
case "secrets_store_secret":
|
|
541
|
+
return yield* unsupported();
|
|
542
|
+
case "send_email":
|
|
543
|
+
return SendEmail.remote({
|
|
544
|
+
binding: b.name,
|
|
545
|
+
destinationAddress: b.destinationAddress,
|
|
546
|
+
allowedDestinationAddresses: b.allowedDestinationAddresses,
|
|
547
|
+
allowedSenderAddresses: b.allowedSenderAddresses,
|
|
548
|
+
});
|
|
549
|
+
case "service":
|
|
550
|
+
return Service.local({ binding: b.name, scriptName: b.service });
|
|
551
|
+
case "text_blob":
|
|
552
|
+
return Data.local(b.name, Buffer.from(b.part));
|
|
553
|
+
case "vectorize":
|
|
554
|
+
return Vectorize.remote(b.name, b.indexName);
|
|
555
|
+
case "version_metadata":
|
|
556
|
+
return VersionMetadata.local(b.name);
|
|
557
|
+
case "wasm_module":
|
|
558
|
+
return WasmModule.local(b.name, Buffer.from(b.part));
|
|
559
|
+
case "worker_loader":
|
|
560
|
+
return WorkerLoader.local(b.name);
|
|
561
|
+
case "workflow":
|
|
562
|
+
return Workflows.local({
|
|
563
|
+
binding: b.name,
|
|
564
|
+
workflowName: b.workflowName,
|
|
565
|
+
className: b.className,
|
|
566
|
+
scriptName: b.scriptName,
|
|
567
|
+
});
|
|
568
|
+
default:
|
|
569
|
+
return yield* unsupported();
|
|
570
|
+
}
|
|
571
|
+
});
|
|
572
|
+
|
|
573
|
+
const toRuntimeAssets = (
|
|
574
|
+
assets: WorkerAssetsConfig | undefined,
|
|
575
|
+
): RuntimeAssets | undefined => {
|
|
576
|
+
if (!assets) return undefined;
|
|
577
|
+
if (typeof assets === "string") {
|
|
578
|
+
return {
|
|
579
|
+
directory: assets,
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
return {
|
|
583
|
+
directory: "directory" in assets ? assets.directory : assets.path,
|
|
584
|
+
headers: assets.config?.headers,
|
|
585
|
+
redirects: assets.config?.redirects,
|
|
586
|
+
htmlHandling: assets.config?.htmlHandling,
|
|
587
|
+
notFoundHandling: assets.config?.notFoundHandling,
|
|
588
|
+
runWorkerFirst: assets.config?.runWorkerFirst,
|
|
589
|
+
serveDirectly: assets.config?.serveDirectly,
|
|
590
|
+
};
|
|
591
|
+
};
|
|
592
|
+
|
|
593
|
+
const toRuntimeDurableObjectNamespaces = (
|
|
594
|
+
namespaces: Record<string, string>,
|
|
595
|
+
): RuntimeDurableObjectNamespace[] => {
|
|
596
|
+
return Object.entries(namespaces).map(([className, namespaceId]) => ({
|
|
597
|
+
className,
|
|
598
|
+
uniqueKey: namespaceId,
|
|
599
|
+
sql: true,
|
|
600
|
+
}));
|
|
601
|
+
};
|
|
602
|
+
|
|
603
|
+
const moduleTypeFromExtension = (ext: string): Module["type"] | "SourceMap" => {
|
|
604
|
+
switch (ext) {
|
|
605
|
+
case ".wasm":
|
|
606
|
+
return "Wasm";
|
|
607
|
+
case ".txt":
|
|
608
|
+
case ".html":
|
|
609
|
+
case ".sql":
|
|
610
|
+
case ".custom":
|
|
611
|
+
return "Text";
|
|
612
|
+
case ".bin":
|
|
613
|
+
return "Data";
|
|
614
|
+
case ".mjs":
|
|
615
|
+
case ".js":
|
|
616
|
+
return "ESModule";
|
|
617
|
+
case ".cjs":
|
|
618
|
+
return "CommonJsModule";
|
|
619
|
+
case ".map":
|
|
620
|
+
return "SourceMap";
|
|
621
|
+
default:
|
|
622
|
+
return "Text";
|
|
623
|
+
}
|
|
624
|
+
};
|