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,14 +1,18 @@
|
|
|
1
1
|
import type * as cf from "@cloudflare/workers-types";
|
|
2
2
|
import * as Context from "effect/Context";
|
|
3
3
|
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Layer from "effect/Layer";
|
|
4
5
|
import type { HttpServerError } from "effect/unstable/http/HttpServerError";
|
|
5
6
|
import * as HttpServerRequest from "effect/unstable/http/HttpServerRequest";
|
|
6
7
|
import * as HttpServerResponse from "effect/unstable/http/HttpServerResponse";
|
|
8
|
+
import type { Dependencies } from "../../Dependencies.ts";
|
|
7
9
|
import type { HttpEffect } from "../../Http.ts";
|
|
10
|
+
import type { Input } from "../../Input.ts";
|
|
8
11
|
import * as Output from "../../Output.ts";
|
|
9
12
|
import { ALCHEMY_PHASE } from "../../Phase.ts";
|
|
10
13
|
import type { PlatformServices } from "../../Platform.ts";
|
|
11
14
|
import { effectClass, taggedFunction } from "../../Util/effect.ts";
|
|
15
|
+
import { asEffect } from "../../Util/types.ts";
|
|
12
16
|
import { DurableObjectState } from "./DurableObjectState.ts";
|
|
13
17
|
import { makeRpcStub } from "./Rpc.ts";
|
|
14
18
|
import { type DurableWebSocket } from "./WebSocket.ts";
|
|
@@ -50,6 +54,8 @@ export interface DurableObjectNamespaceLike<Shape = any> {
|
|
|
50
54
|
/** @internal phantom */
|
|
51
55
|
className?: string;
|
|
52
56
|
/** @internal phantom */
|
|
57
|
+
scriptName?: Input<string>;
|
|
58
|
+
/** @internal phantom */
|
|
53
59
|
Shape?: Shape;
|
|
54
60
|
}
|
|
55
61
|
|
|
@@ -98,10 +104,16 @@ export type DurableObjectServices =
|
|
|
98
104
|
|
|
99
105
|
export interface DurableObjectNamespaceProps {
|
|
100
106
|
/**
|
|
107
|
+
* Name of the exported `DurableObject` class.
|
|
108
|
+
*
|
|
101
109
|
* @default name
|
|
102
110
|
*/
|
|
103
|
-
className
|
|
104
|
-
|
|
111
|
+
className?: string;
|
|
112
|
+
/**
|
|
113
|
+
* Worker script that hosts the Durable Object class. Omit this when the
|
|
114
|
+
* namespace is hosted by the Worker that declares the binding.
|
|
115
|
+
*/
|
|
116
|
+
scriptName?: Input<string> | undefined;
|
|
105
117
|
// environment?: string | undefined;
|
|
106
118
|
// sqlite?: boolean | undefined;
|
|
107
119
|
// namespaceId?: string | undefined;
|
|
@@ -112,6 +124,35 @@ export interface DurableObjectNamespaceClass extends Effect.Effect<
|
|
|
112
124
|
never,
|
|
113
125
|
DurableObjectNamespace
|
|
114
126
|
> {
|
|
127
|
+
<Self, Shape>(): {
|
|
128
|
+
<Name extends string>(
|
|
129
|
+
name: Name,
|
|
130
|
+
): Effect.Effect<DurableObjectNamespace<Self>, never, Worker | Self> & {
|
|
131
|
+
new (_: never): Shape & {
|
|
132
|
+
/** @internal */
|
|
133
|
+
"~alchemy/name": Name;
|
|
134
|
+
};
|
|
135
|
+
from(
|
|
136
|
+
scriptName: Input<string>,
|
|
137
|
+
): Effect.Effect<DurableObjectNamespace<Self>, never, Worker>;
|
|
138
|
+
from<Req = never>(
|
|
139
|
+
worker:
|
|
140
|
+
| Dependencies<Self>
|
|
141
|
+
| Effect.Effect<Dependencies<Self>, never, Req>,
|
|
142
|
+
): Effect.Effect<DurableObjectNamespace<Self>, never, Worker | Req>;
|
|
143
|
+
make<InitReq = never>(
|
|
144
|
+
impl: Effect.Effect<
|
|
145
|
+
Effect.Effect<Shape, never, DurableObjectServices>,
|
|
146
|
+
never,
|
|
147
|
+
InitReq
|
|
148
|
+
>,
|
|
149
|
+
): Layer.Layer<
|
|
150
|
+
Self,
|
|
151
|
+
never,
|
|
152
|
+
Worker | Exclude<InitReq, DurableObjectServices>
|
|
153
|
+
>;
|
|
154
|
+
};
|
|
155
|
+
};
|
|
115
156
|
<Self>(): {
|
|
116
157
|
<Shape, InitReq = never>(
|
|
117
158
|
name: string,
|
|
@@ -234,7 +275,7 @@ export class DurableObjectNamespaceScope extends Context.Service<
|
|
|
234
275
|
* @example Modular Durable Object (class + .make() in one file)
|
|
235
276
|
* ```typescript
|
|
236
277
|
* // src/Counter.ts
|
|
237
|
-
* export
|
|
278
|
+
* export class Counter extends Cloudflare.DurableObjectNamespace<Counter>()(
|
|
238
279
|
* "Counter",
|
|
239
280
|
* ) {}
|
|
240
281
|
*
|
|
@@ -279,6 +320,115 @@ export class DurableObjectNamespaceScope extends Context.Service<
|
|
|
279
320
|
* };
|
|
280
321
|
* ```
|
|
281
322
|
*
|
|
323
|
+
* @section Cross-Worker Binding
|
|
324
|
+
* A Durable Object is _hosted_ by exactly one Worker, but any
|
|
325
|
+
* number of other Workers can bind to the same DO. This is how
|
|
326
|
+
* you share state across Workers: one Worker hosts the DO, every
|
|
327
|
+
* other Worker addresses it by `scriptName` and gets a typed stub.
|
|
328
|
+
*
|
|
329
|
+
* To make this type-safe, the **host Worker** must declare the DO
|
|
330
|
+
* as part of its public contract via the third type argument to
|
|
331
|
+
* `Cloudflare.Worker<Self, Bindings, Deps>()`. `Deps` is the set
|
|
332
|
+
* of DO classes (or other Workers) the script exposes for other
|
|
333
|
+
* scripts to bind to.
|
|
334
|
+
*
|
|
335
|
+
* @example Host Worker declares the DO in its contract
|
|
336
|
+
* ```typescript
|
|
337
|
+
* // workerA.ts — hosts Counter
|
|
338
|
+
* import { Counter, CounterLive } from "./object.ts";
|
|
339
|
+
*
|
|
340
|
+
* // ^^^^^^^ declared as part of WorkerA's public contract
|
|
341
|
+
* export class WorkerA extends Cloudflare.Worker<WorkerA, {}, Counter>()(
|
|
342
|
+
* "WorkerA",
|
|
343
|
+
* { main: import.meta.filename },
|
|
344
|
+
* ) {}
|
|
345
|
+
*
|
|
346
|
+
* // WorkerA's Layer also provides the DO's Live implementation.
|
|
347
|
+
* export default WorkerA.make(
|
|
348
|
+
* Effect.gen(function* () {
|
|
349
|
+
* const counter = yield* Counter;
|
|
350
|
+
* return { fetch: Effect.gen(function* () { ... }) };
|
|
351
|
+
* }).pipe(Effect.provide(CounterLive)),
|
|
352
|
+
* );
|
|
353
|
+
* ```
|
|
354
|
+
*
|
|
355
|
+
* @example Consumer Worker binds the DO via `Counter.from(WorkerA)`
|
|
356
|
+
* ```typescript
|
|
357
|
+
* // workerB.ts — binds to the same Counter, hosted by WorkerA
|
|
358
|
+
* import { Counter } from "./object.ts";
|
|
359
|
+
* import { WorkerA } from "./workerA.ts";
|
|
360
|
+
*
|
|
361
|
+
* export default class WorkerB extends Cloudflare.Worker<WorkerB>()(
|
|
362
|
+
* "WorkerB",
|
|
363
|
+
* { main: import.meta.filename },
|
|
364
|
+
* Effect.gen(function* () {
|
|
365
|
+
* // ^^^^^^^^^^^^ scriptName-bound stub of WorkerA's Counter
|
|
366
|
+
* const counter = yield* Counter.from(WorkerA);
|
|
367
|
+
* return {
|
|
368
|
+
* fetch: Effect.gen(function* () {
|
|
369
|
+
* const value = yield* counter.getByName("shared").get();
|
|
370
|
+
* return HttpServerResponse.text(String(value));
|
|
371
|
+
* }),
|
|
372
|
+
* };
|
|
373
|
+
* }),
|
|
374
|
+
* ) {}
|
|
375
|
+
* ```
|
|
376
|
+
*
|
|
377
|
+
* :::tip
|
|
378
|
+
* The `, Counter` in `Worker<WorkerA, {}, Counter>` is what makes
|
|
379
|
+
* `Counter.from(WorkerA)` type-check. You can still bind across
|
|
380
|
+
* scripts without it (the runtime works either way), but consumers
|
|
381
|
+
* will get a TypeScript error because `WorkerA` doesn't declare
|
|
382
|
+
* `Counter` as part of its public contract.
|
|
383
|
+
* :::
|
|
384
|
+
*
|
|
385
|
+
* Only the host Worker's Stack provides `CounterLive` — the
|
|
386
|
+
* consumer Worker just imports the `Counter` class as a typed
|
|
387
|
+
* identifier. Rolldown tree-shakes `CounterLive` (and its
|
|
388
|
+
* dependencies) out of WorkerB's bundle.
|
|
389
|
+
*
|
|
390
|
+
* @section Using `.from(Self)` Inside the Host
|
|
391
|
+
* Inside the host Worker, `yield* Counter` and
|
|
392
|
+
* `yield* Counter.from(Self)` resolve to the same local namespace.
|
|
393
|
+
* The `.from(Self)` form is preferred — especially in code that
|
|
394
|
+
* may be extracted into a reusable Layer — because it makes the
|
|
395
|
+
* scriptName explicit and lets the same Layer shape work whether
|
|
396
|
+
* the consumer is the host or another script.
|
|
397
|
+
*
|
|
398
|
+
* @example `Counter.from(WorkerA)` inside WorkerA itself
|
|
399
|
+
* ```typescript
|
|
400
|
+
* // workerA.ts — host uses `.from(Self)` instead of bare `yield* Counter`
|
|
401
|
+
* export default WorkerA.make(
|
|
402
|
+
* Effect.gen(function* () {
|
|
403
|
+
* const counter = yield* Counter.from(WorkerA); // same as `yield* Counter`
|
|
404
|
+
* return { fetch: Effect.gen(function* () { ... }) };
|
|
405
|
+
* }).pipe(Effect.provide(CounterLive)),
|
|
406
|
+
* );
|
|
407
|
+
* ```
|
|
408
|
+
*
|
|
409
|
+
* A Worker can also host its **own isolated** namespace this way.
|
|
410
|
+
* If a second host Worker declares `Counter` in its contract and
|
|
411
|
+
* provides `CounterLive`, the DO instances under that script are
|
|
412
|
+
* separate from the original host's — same class, two namespaces.
|
|
413
|
+
*
|
|
414
|
+
* @example Two hosts, two isolated namespaces
|
|
415
|
+
* ```typescript
|
|
416
|
+
* // workerC.ts — another host of Counter, isolated from WorkerA
|
|
417
|
+
* export class WorkerC extends Cloudflare.Worker<WorkerC, {}, Counter>()(
|
|
418
|
+
* "WorkerC",
|
|
419
|
+
* { main: import.meta.filename },
|
|
420
|
+
* ) {}
|
|
421
|
+
*
|
|
422
|
+
* export default WorkerC.make(
|
|
423
|
+
* Effect.gen(function* () {
|
|
424
|
+
* // .from(WorkerC) binds to WorkerC's own Counter namespace —
|
|
425
|
+
* // writes here are NOT visible from WorkerA's Counter.
|
|
426
|
+
* const counter = yield* Counter.from(WorkerC);
|
|
427
|
+
* return { fetch: Effect.gen(function* () { ... }) };
|
|
428
|
+
* }).pipe(Effect.provide(CounterLive)),
|
|
429
|
+
* );
|
|
430
|
+
* ```
|
|
431
|
+
*
|
|
282
432
|
* @section RPC Methods
|
|
283
433
|
* Any function you return from the inner Effect becomes an RPC method
|
|
284
434
|
* that Workers can call through a stub. Methods must return an `Effect`.
|
|
@@ -495,7 +645,8 @@ export class DurableObjectNamespaceScope extends Context.Service<
|
|
|
495
645
|
* runtime), declare Durable Objects in the `bindings` prop of the
|
|
496
646
|
* Worker resource. Pass a `DurableObjectNamespace` reference with a
|
|
497
647
|
* `className` matching the exported `DurableObject` subclass in your
|
|
498
|
-
* worker source file.
|
|
648
|
+
* worker source file. If `className` is omitted, it defaults to the
|
|
649
|
+
* namespace name. Use `Cloudflare.InferEnv` to get a fully typed
|
|
499
650
|
* `env` object that includes the namespace.
|
|
500
651
|
*
|
|
501
652
|
* @example Declaring a DO binding in the stack
|
|
@@ -508,9 +659,7 @@ export class DurableObjectNamespaceScope extends Context.Service<
|
|
|
508
659
|
* export const Worker = Cloudflare.Worker("Worker", {
|
|
509
660
|
* main: "./src/worker.ts",
|
|
510
661
|
* bindings: {
|
|
511
|
-
* Counter: Cloudflare.DurableObjectNamespace<Counter>("Counter",
|
|
512
|
-
* className: "Counter",
|
|
513
|
-
* }),
|
|
662
|
+
* Counter: Cloudflare.DurableObjectNamespace<Counter>("Counter"),
|
|
514
663
|
* },
|
|
515
664
|
* });
|
|
516
665
|
* ```
|
|
@@ -536,128 +685,238 @@ export class DurableObjectNamespaceScope extends Context.Service<
|
|
|
536
685
|
* }
|
|
537
686
|
* }
|
|
538
687
|
* ```
|
|
688
|
+
*
|
|
689
|
+
* @section Cross-Script Binding in an Async Worker
|
|
690
|
+
* Async Workers can also bind to a Durable Object hosted by another
|
|
691
|
+
* Worker script. The host Worker declares and exports the DO class. The
|
|
692
|
+
* consumer Worker declares a `DurableObjectNamespace` with `scriptName`
|
|
693
|
+
* set to the host Worker's script name.
|
|
694
|
+
*
|
|
695
|
+
* Cross-script async bindings are references only: the consumer uploads
|
|
696
|
+
* the binding metadata, but Alchemy does not drive class migrations for
|
|
697
|
+
* the foreign class. Deploy the host first so Cloudflare can verify that
|
|
698
|
+
* the target script exports the requested class.
|
|
699
|
+
*
|
|
700
|
+
* @example Host Worker owns the Durable Object class
|
|
701
|
+
* ```typescript
|
|
702
|
+
* const host = yield* Cloudflare.Worker("Host", {
|
|
703
|
+
* main: "./src/host.ts",
|
|
704
|
+
* bindings: {
|
|
705
|
+
* Counter: Cloudflare.DurableObjectNamespace<Counter>("Counter"),
|
|
706
|
+
* },
|
|
707
|
+
* });
|
|
708
|
+
* ```
|
|
709
|
+
*
|
|
710
|
+
* @example Consumer Worker binds to the host script
|
|
711
|
+
* ```typescript
|
|
712
|
+
* const consumer = yield* Cloudflare.Worker("Consumer", {
|
|
713
|
+
* main: "./src/consumer.ts",
|
|
714
|
+
* bindings: {
|
|
715
|
+
* Counter: Cloudflare.DurableObjectNamespace<Counter>("Counter", {
|
|
716
|
+
* scriptName: host.workerName,
|
|
717
|
+
* }),
|
|
718
|
+
* },
|
|
719
|
+
* });
|
|
720
|
+
* ```
|
|
721
|
+
*
|
|
722
|
+
* @example Binding to a different exported class name
|
|
723
|
+
* ```typescript
|
|
724
|
+
* const consumer = yield* Cloudflare.Worker("Consumer", {
|
|
725
|
+
* main: "./src/consumer.ts",
|
|
726
|
+
* bindings: {
|
|
727
|
+
* Counter: Cloudflare.DurableObjectNamespace<Counter>("Counter", {
|
|
728
|
+
* className: "CounterV2",
|
|
729
|
+
* scriptName: host.workerName,
|
|
730
|
+
* }),
|
|
731
|
+
* },
|
|
732
|
+
* });
|
|
733
|
+
* ```
|
|
539
734
|
*/
|
|
540
735
|
export const DurableObjectNamespace: DurableObjectNamespaceClass =
|
|
541
|
-
taggedFunction(
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
yield* worker.bind`${namespace}`({
|
|
576
|
-
// TODO(sam): automate class migrations, probably in the provider
|
|
577
|
-
bindings: [
|
|
578
|
-
{
|
|
579
|
-
type: "durable_object_namespace",
|
|
580
|
-
name: namespace,
|
|
581
|
-
className: namespace,
|
|
582
|
-
// scriptName:
|
|
583
|
-
// binding.scriptName === props.workerName
|
|
584
|
-
// ? undefined
|
|
585
|
-
// : binding.scriptName,
|
|
586
|
-
// environment: binding.environment,
|
|
587
|
-
// namespaceId: binding.namespaceId,
|
|
588
|
-
},
|
|
589
|
-
],
|
|
590
|
-
});
|
|
591
|
-
|
|
592
|
-
const binding = yield* Effect.all([
|
|
593
|
-
WorkerEnvironment,
|
|
594
|
-
ALCHEMY_PHASE,
|
|
595
|
-
]).pipe(
|
|
596
|
-
Effect.flatMap(([env, phase]) => {
|
|
597
|
-
if (env === undefined || phase === "plan") {
|
|
598
|
-
// should be fine to return undefined here (it is only undefined at plantime)
|
|
599
|
-
return Effect.succeed(undefined);
|
|
600
|
-
}
|
|
601
|
-
const ns = env[namespace];
|
|
602
|
-
if (!ns) {
|
|
603
|
-
return Effect.die(
|
|
604
|
-
new Error(
|
|
605
|
-
`DurableObjectNamespace '${namespace}' not found`,
|
|
606
|
-
),
|
|
607
|
-
);
|
|
608
|
-
} else if (typeof ns.getByName === "function") {
|
|
609
|
-
return Effect.succeed(ns);
|
|
610
|
-
} else {
|
|
611
|
-
return Effect.die(
|
|
612
|
-
new Error(
|
|
613
|
-
`DurableObjectNamespace '${namespace}' is not a DurableObjectNamespace`,
|
|
614
|
-
),
|
|
615
|
-
);
|
|
616
|
-
}
|
|
617
|
-
}),
|
|
618
|
-
);
|
|
736
|
+
taggedFunction(
|
|
737
|
+
DurableObjectNamespaceScope,
|
|
738
|
+
function (
|
|
739
|
+
...args:
|
|
740
|
+
| []
|
|
741
|
+
| [
|
|
742
|
+
name: string,
|
|
743
|
+
props?: DurableObjectNamespaceProps,
|
|
744
|
+
// phantom argument
|
|
745
|
+
isClassForm?: true,
|
|
746
|
+
]
|
|
747
|
+
| [
|
|
748
|
+
name: string,
|
|
749
|
+
impl: Effect.Effect<
|
|
750
|
+
Effect.Effect<
|
|
751
|
+
DurableObjectNamespace<any>,
|
|
752
|
+
never,
|
|
753
|
+
DurableObjectState
|
|
754
|
+
>
|
|
755
|
+
>,
|
|
756
|
+
// phantom argument
|
|
757
|
+
isClassForm?: true,
|
|
758
|
+
]
|
|
759
|
+
) {
|
|
760
|
+
if (args.length === 0) {
|
|
761
|
+
return (name: string, propsOrImpl?: any) =>
|
|
762
|
+
// @ts-expect-error
|
|
763
|
+
DurableObjectNamespace(name, propsOrImpl, true);
|
|
764
|
+
}
|
|
765
|
+
const namespace = args[0];
|
|
766
|
+
const isClassForm = args[2] === true;
|
|
767
|
+
const propsOrImpl = args[1];
|
|
768
|
+
const tag = Context.Service(namespace);
|
|
619
769
|
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
durableObjectNamespaces?.[namespace],
|
|
624
|
-
),
|
|
625
|
-
);
|
|
770
|
+
const binding = (scriptName?: Input<string>) =>
|
|
771
|
+
Effect.gen(function* () {
|
|
772
|
+
const worker = yield* Worker;
|
|
626
773
|
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
774
|
+
yield* worker.bind`${namespace}`({
|
|
775
|
+
// TODO(sam): automate class migrations, probably in the provider
|
|
776
|
+
bindings: [
|
|
777
|
+
{
|
|
778
|
+
type: "durable_object_namespace",
|
|
630
779
|
name: namespace,
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
// idFromString: (id: string) => use((ns) => ns.idFromString(id)),
|
|
637
|
-
// get: (
|
|
638
|
-
// id: cf.DurableObjectId,
|
|
639
|
-
// options?: cf.DurableObjectNamespaceGetDurableObjectOptions,
|
|
640
|
-
// ) => use((ns) => makeRpcStub(ns.get(id, options))),
|
|
641
|
-
// jurisdiction: (jurisdiction: cf.DurableObjectJurisdiction) =>
|
|
642
|
-
// use((ns) => ns.jurisdiction(jurisdiction) as any),
|
|
643
|
-
};
|
|
780
|
+
className: namespace,
|
|
781
|
+
scriptName,
|
|
782
|
+
},
|
|
783
|
+
],
|
|
784
|
+
});
|
|
644
785
|
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
786
|
+
const binding = yield* Effect.all([
|
|
787
|
+
WorkerEnvironment,
|
|
788
|
+
ALCHEMY_PHASE,
|
|
789
|
+
]).pipe(
|
|
790
|
+
Effect.flatMap(([env, phase]) => {
|
|
791
|
+
if (env === undefined || phase === "plan") {
|
|
792
|
+
// should be fine to return undefined here (it is only undefined at plantime)
|
|
793
|
+
return Effect.succeed(undefined);
|
|
794
|
+
}
|
|
795
|
+
const ns = env[namespace];
|
|
796
|
+
if (!ns) {
|
|
797
|
+
return Effect.die(
|
|
798
|
+
new Error(`DurableObjectNamespace '${namespace}' not found`),
|
|
799
|
+
);
|
|
800
|
+
} else if (typeof ns.getByName === "function") {
|
|
801
|
+
return Effect.succeed(ns);
|
|
802
|
+
} else {
|
|
803
|
+
return Effect.die(
|
|
804
|
+
new Error(
|
|
805
|
+
`DurableObjectNamespace '${namespace}' is not a DurableObjectNamespace`,
|
|
652
806
|
),
|
|
653
|
-
)
|
|
654
|
-
|
|
655
|
-
services: yield* Effect.context<Effect.Services<typeof impl>>(),
|
|
656
|
-
} satisfies DurableObjectExport);
|
|
657
|
-
|
|
658
|
-
return self;
|
|
807
|
+
);
|
|
808
|
+
}
|
|
659
809
|
}),
|
|
660
|
-
)
|
|
810
|
+
);
|
|
811
|
+
|
|
812
|
+
return {
|
|
813
|
+
Type: TypeId,
|
|
814
|
+
LogicalId: namespace,
|
|
815
|
+
name: namespace,
|
|
816
|
+
namespaceId: worker.durableObjectNamespaces.pipe(
|
|
817
|
+
Output.map(
|
|
818
|
+
(durableObjectNamespaces) =>
|
|
819
|
+
durableObjectNamespaces?.[namespace],
|
|
820
|
+
),
|
|
821
|
+
),
|
|
822
|
+
getByName: (name: string) => makeRpcStub(binding.getByName(name)),
|
|
823
|
+
// newUniqueId: () => use((ns) => ns.newUniqueId()),
|
|
824
|
+
// idFromName: (name: string) => use((ns) => ns.idFromName(name)),
|
|
825
|
+
// idFromString: (id: string) => use((ns) => ns.idFromString(id)),
|
|
826
|
+
// get: (
|
|
827
|
+
// id: cf.DurableObjectId,
|
|
828
|
+
// options?: cf.DurableObjectNamespaceGetDurableObjectOptions,
|
|
829
|
+
// ) => use((ns) => makeRpcStub(ns.get(id, options))),
|
|
830
|
+
// jurisdiction: (jurisdiction: cf.DurableObjectJurisdiction) =>
|
|
831
|
+
// use((ns) => ns.jurisdiction(jurisdiction) as any),
|
|
832
|
+
};
|
|
833
|
+
});
|
|
834
|
+
|
|
835
|
+
const make = Effect.fnUntraced(function* (
|
|
836
|
+
impl: Effect.Effect<
|
|
837
|
+
Effect.Effect<DurableObjectShape, never, DurableObjectState>
|
|
838
|
+
>,
|
|
839
|
+
) {
|
|
840
|
+
// Register the local DO binding (no `scriptName`) and obtain the
|
|
841
|
+
// namespace handle. We provide this same handle as
|
|
842
|
+
// `DurableObjectNamespaceScope` to the user's constructor effect
|
|
843
|
+
// and also return it so a `Layer.effect(tag, make(impl))` Layer
|
|
844
|
+
// resolves the tag to a concrete namespace value.
|
|
845
|
+
const self = yield* binding();
|
|
846
|
+
yield* (yield* Worker).export(namespace, {
|
|
847
|
+
kind: "durableObject",
|
|
848
|
+
// initialize the object's constructor (apply infra dependencies)
|
|
849
|
+
constructor: yield* impl.pipe(
|
|
850
|
+
Effect.provideService(DurableObjectNamespaceScope, self as any),
|
|
851
|
+
),
|
|
852
|
+
// grab the object's infra dependencies so we can apply them when calling the instance's methods
|
|
853
|
+
services: yield* Effect.context<Effect.Services<typeof impl>>(),
|
|
854
|
+
} satisfies DurableObjectExport);
|
|
855
|
+
return self;
|
|
856
|
+
});
|
|
857
|
+
|
|
858
|
+
if (!isClassForm && !Effect.isEffect(args[1])) {
|
|
859
|
+
// this is an in-line, async only DO (no implementation, props only)
|
|
860
|
+
return {
|
|
861
|
+
kind: TypeId,
|
|
862
|
+
name: namespace,
|
|
863
|
+
className:
|
|
864
|
+
(args[1] as DurableObjectNamespaceProps)?.className || namespace,
|
|
865
|
+
scriptName: (args[1] as DurableObjectNamespaceProps)?.scriptName,
|
|
866
|
+
};
|
|
867
|
+
} else if (Effect.isEffect(propsOrImpl)) {
|
|
868
|
+
// inline Effect DO
|
|
869
|
+
return effectClass(
|
|
870
|
+
Effect.tap(binding(), () => make(propsOrImpl as any)),
|
|
871
|
+
);
|
|
872
|
+
} else {
|
|
873
|
+
// Tagged Effect DO. Yielding the class resolves the `tag`, which
|
|
874
|
+
// forces the `CounterLive` Layer (built by `Counter.make(impl)`) to
|
|
875
|
+
// run so `worker.export(namespace, …)` is invoked — without this,
|
|
876
|
+
// the class would never be registered with the Worker's exports
|
|
877
|
+
// map and the deployed bundle would have no DO class for
|
|
878
|
+
// Cloudflare to instantiate.
|
|
879
|
+
return class extends effectClass(
|
|
880
|
+
tag as Effect.Effect<any, never, any>,
|
|
881
|
+
) {
|
|
882
|
+
static make = <Req = never>(
|
|
883
|
+
impl: Effect.Effect<
|
|
884
|
+
Effect.Effect<DurableObjectShape, never, DurableObjectState | Req>
|
|
885
|
+
>,
|
|
886
|
+
) => Layer.effect(tag, make(impl as any));
|
|
887
|
+
|
|
888
|
+
static from = (
|
|
889
|
+
worker: string | Worker | Effect.Effect<Worker, any, any>,
|
|
890
|
+
) => {
|
|
891
|
+
// Resolve `worker` to an Effect that yields the actual Worker
|
|
892
|
+
// instance (or a plain string scriptName).
|
|
893
|
+
//
|
|
894
|
+
// A class produced by `Cloudflare.Worker<T>()(...)` exposes
|
|
895
|
+
// `asEffect()` returning the Self tag — yielding that tag
|
|
896
|
+
// resolves to the live Worker instance whose `workerName`
|
|
897
|
+
// is a `PropExpr`, which is what we need so the engine can:
|
|
898
|
+
// 1) Track WorkerB → WorkerA as a binding-level upstream
|
|
899
|
+
// dependency (so WorkerA reconciles first).
|
|
900
|
+
// 2) Persist `scriptName` as a real value (not `undefined`)
|
|
901
|
+
// on the cross-script binding so the migration code in
|
|
902
|
+
// Worker.ts can detect it and skip emitting class
|
|
903
|
+
// migrations for the foreign class.
|
|
904
|
+
// Plain Effects and string literals are passed through as-is.
|
|
905
|
+
const resolved: Effect.Effect<Worker | string, any, any> =
|
|
906
|
+
typeof worker === "string"
|
|
907
|
+
? Effect.succeed(worker)
|
|
908
|
+
: asEffect(worker);
|
|
909
|
+
|
|
910
|
+
return resolved.pipe(
|
|
911
|
+
Effect.flatMap((w) =>
|
|
912
|
+
binding(typeof w === "string" ? w : w.workerName),
|
|
913
|
+
),
|
|
914
|
+
);
|
|
915
|
+
};
|
|
916
|
+
};
|
|
917
|
+
}
|
|
918
|
+
},
|
|
919
|
+
) as any;
|
|
661
920
|
|
|
662
921
|
export type DurableObjectStub<Shape> = {
|
|
663
922
|
// TODO(sam): do we need to transform? hopefully not
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type * as cf from "@cloudflare/workers-types";
|
|
2
|
-
import * as
|
|
2
|
+
import * as Deferred from "effect/Deferred";
|
|
3
3
|
import * as Effect from "effect/Effect";
|
|
4
4
|
import * as Layer from "effect/Layer";
|
|
5
5
|
import * as Option from "effect/Option";
|
|
6
|
-
import
|
|
6
|
+
import * as Scope from "effect/Scope";
|
|
7
|
+
import * as EffectHttp from "effect/unstable/http/HttpEffect";
|
|
7
8
|
import * as HttpServerRequest from "effect/unstable/http/HttpServerRequest";
|
|
8
9
|
import * as HttpServerResponse from "effect/unstable/http/HttpServerResponse";
|
|
9
10
|
import * as Http from "../../Http.ts";
|
|
@@ -24,11 +25,7 @@ export const makeRequestHandler =
|
|
|
24
25
|
export const makeRequestEffect = <Req = never>(
|
|
25
26
|
webRequest: cf.Request,
|
|
26
27
|
handler: Http.HttpEffect<Req> | Effect.Effect<Http.HttpEffect<Req>>,
|
|
27
|
-
)
|
|
28
|
-
Response,
|
|
29
|
-
never,
|
|
30
|
-
Exclude<Req, HttpServerRequest.HttpServerRequest | Scope>
|
|
31
|
-
> => {
|
|
28
|
+
) => {
|
|
32
29
|
const safeHandler = Http.safeHttpEffect(handler);
|
|
33
30
|
return Effect.gen(function* () {
|
|
34
31
|
const request = HttpServerRequest.fromWeb(
|
|
@@ -46,28 +43,37 @@ export const makeRequestEffect = <Req = never>(
|
|
|
46
43
|
}),
|
|
47
44
|
});
|
|
48
45
|
|
|
49
|
-
|
|
46
|
+
return yield* toHandledWebResponse(safeHandler).pipe(
|
|
50
47
|
Effect.provide([
|
|
51
48
|
Layer.succeed(HttpServerRequest.HttpServerRequest, request),
|
|
52
49
|
Layer.succeed(Request, webRequest as any),
|
|
53
50
|
]),
|
|
54
|
-
Effect.catchCause((cause) => {
|
|
55
|
-
const message = Option.match(Cause.findErrorOption(cause), {
|
|
56
|
-
onNone: () => "Internal Server Error",
|
|
57
|
-
onSome: (error: any) =>
|
|
58
|
-
error instanceof Error && error.message
|
|
59
|
-
? error.message
|
|
60
|
-
: "Internal Server Error",
|
|
61
|
-
});
|
|
62
|
-
return Effect.succeed(
|
|
63
|
-
HttpServerResponse.text(message, {
|
|
64
|
-
status: 500,
|
|
65
|
-
statusText: message,
|
|
66
|
-
}),
|
|
67
|
-
);
|
|
68
|
-
}),
|
|
69
51
|
);
|
|
70
|
-
|
|
71
|
-
return HttpServerResponse.toWeb(response);
|
|
72
52
|
}) as any;
|
|
73
53
|
};
|
|
54
|
+
|
|
55
|
+
const toHandledWebResponse = <Req>(
|
|
56
|
+
handler: Effect.Effect<HttpServerResponse.HttpServerResponse, never, Req>,
|
|
57
|
+
) =>
|
|
58
|
+
Effect.gen(function* () {
|
|
59
|
+
// `toHandled` exposes the final response through this callback, not its
|
|
60
|
+
// return value. Keep the assignment isolated here so callers get Response.
|
|
61
|
+
const context = yield* Effect.context();
|
|
62
|
+
const webResponse = yield* Deferred.make<Response>();
|
|
63
|
+
|
|
64
|
+
yield* EffectHttp.toHandled(handler, (request, response) =>
|
|
65
|
+
Deferred.succeed(
|
|
66
|
+
webResponse,
|
|
67
|
+
// Conversion to web response with options matches `EffectHttp.toWebHandler`'s callback.
|
|
68
|
+
HttpServerResponse.toWeb(EffectHttp.scopeTransferToStream(response), {
|
|
69
|
+
withoutBody: request.method === "HEAD",
|
|
70
|
+
context,
|
|
71
|
+
}),
|
|
72
|
+
),
|
|
73
|
+
);
|
|
74
|
+
return yield* Deferred.await(webResponse);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const scopeEjected = Symbol.for("effect/http/HttpEffect/scopeEjected");
|
|
78
|
+
|
|
79
|
+
export const isScopeEjected = (scope: Scope.Scope) => scopeEjected in scope;
|