alchemy 2.0.0-beta.44 → 2.0.0-beta.46
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/exec.js +67 -8
- 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/AlchemyContext.d.ts +0 -1
- package/lib/AlchemyContext.d.ts.map +1 -1
- package/lib/AlchemyContext.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/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/cloudflare.d.ts.map +1 -1
- package/lib/Cli/commands/cloudflare.js +5 -1
- package/lib/Cli/commands/cloudflare.js.map +1 -1
- package/lib/Cli/commands/dev.d.ts.map +1 -1
- package/lib/Cli/commands/dev.js +10 -1
- 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/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.js +1 -1
- package/lib/Cloudflare/Local.js.map +1 -1
- package/lib/Cloudflare/Providers.d.ts +2 -1
- package/lib/Cloudflare/Providers.d.ts.map +1 -1
- package/lib/Cloudflare/Providers.js +25 -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 +10 -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 +11 -65
- package/lib/Cloudflare/StateStore/State.d.ts.map +1 -1
- package/lib/Cloudflare/StateStore/State.js +320 -343
- 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 +21 -31
- package/lib/Cloudflare/StateStore/Store.js.map +1 -1
- package/lib/Cloudflare/Vectorize/VectorizeIndex.d.ts +114 -0
- package/lib/Cloudflare/Vectorize/VectorizeIndex.d.ts.map +1 -0
- package/lib/Cloudflare/Vectorize/VectorizeIndex.js +157 -0
- package/lib/Cloudflare/Vectorize/VectorizeIndex.js.map +1 -0
- package/lib/Cloudflare/Vectorize/VectorizeIndexBinding.d.ts +38 -0
- package/lib/Cloudflare/Vectorize/VectorizeIndexBinding.d.ts.map +1 -0
- package/lib/Cloudflare/Vectorize/VectorizeIndexBinding.js +44 -0
- package/lib/Cloudflare/Vectorize/VectorizeIndexBinding.js.map +1 -0
- package/lib/Cloudflare/Vectorize/VectorizeMetadataIndex.d.ts +72 -0
- package/lib/Cloudflare/Vectorize/VectorizeMetadataIndex.d.ts.map +1 -0
- package/lib/Cloudflare/Vectorize/VectorizeMetadataIndex.js +131 -0
- package/lib/Cloudflare/Vectorize/VectorizeMetadataIndex.js.map +1 -0
- package/lib/Cloudflare/Vectorize/index.d.ts +4 -0
- package/lib/Cloudflare/Vectorize/index.d.ts.map +1 -0
- package/lib/Cloudflare/Vectorize/index.js +4 -0
- package/lib/Cloudflare/Vectorize/index.js.map +1 -0
- 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 -2
- 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 +4 -7
- package/lib/Cloudflare/Workers/LocalWorkerProvider.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/LocalWorkerProvider.js +111 -66
- 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 -24
- package/lib/Cloudflare/Workers/Worker.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/Worker.js +168 -47
- 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 +166 -97
- package/lib/Cloudflare/Workers/WorkerAsyncBindings.js.map +1 -1
- package/lib/Cloudflare/Workers/WorkerBinding.d.ts +12 -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 +5 -2
- package/lib/Cloudflare/Workers/WorkerBridge.js.map +1 -1
- package/lib/Cloudflare/Workers/WorkerBundle.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/WorkerBundle.js +4 -1
- 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/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 +3 -1
- package/lib/Local/RpcProvider.d.ts.map +1 -1
- package/lib/Local/RpcProvider.js +28 -2
- package/lib/Local/RpcProvider.js.map +1 -1
- package/lib/Local/RpcServerEnvironment.js +1 -1
- package/lib/Local/RpcServerEnvironment.js.map +1 -1
- 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/HttpStateStore.d.ts +4 -0
- package/lib/State/HttpStateStore.d.ts.map +1 -1
- package/lib/State/HttpStateStore.js +13 -0
- package/lib/State/HttpStateStore.js.map +1 -1
- 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/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/poll.d.ts +30 -0
- package/lib/Util/poll.d.ts.map +1 -0
- package/lib/Util/poll.js +26 -0
- package/lib/Util/poll.js.map +1 -0
- 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 +20 -19
- package/src/AWS/Lambda/Function.ts +87 -34
- package/src/AWS/Providers.ts +3 -0
- package/src/AlchemyContext.ts +0 -1
- package/src/Apply.ts +18 -1
- package/src/Auth/AuthProvider.ts +25 -5
- package/src/Auth/Credentials.ts +8 -7
- package/src/Cli/commands/_shared.ts +47 -4
- package/src/Cli/commands/cloudflare.ts +5 -3
- package/src/Cli/commands/dev.ts +13 -1
- package/src/Cli/commands/login.ts +20 -4
- package/src/Cli/commands/profile.ts +24 -34
- 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 +1 -1
- package/src/Cloudflare/Providers.ts +32 -16
- package/src/Cloudflare/Queue/Queue.ts +3 -0
- package/src/Cloudflare/Queue/QueueConsumer.ts +21 -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 +468 -468
- package/src/Cloudflare/StateStore/Store.ts +27 -37
- package/src/Cloudflare/Vectorize/VectorizeIndex.ts +261 -0
- package/src/Cloudflare/Vectorize/VectorizeIndexBinding.ts +103 -0
- package/src/Cloudflare/Vectorize/VectorizeMetadataIndex.ts +208 -0
- package/src/Cloudflare/Vectorize/index.ts +3 -0
- 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 -4
- 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 +139 -78
- 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 +274 -93
- package/src/Cloudflare/Workers/WorkerAsyncBindings.ts +165 -103
- package/src/Cloudflare/Workers/WorkerBinding.ts +12 -0
- package/src/Cloudflare/Workers/WorkerBridge.ts +7 -4
- package/src/Cloudflare/Workers/WorkerBundle.ts +4 -1
- 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/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 +45 -1
- package/src/Local/RpcServerEnvironment.ts +1 -1
- 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/HttpStateStore.ts +28 -0
- 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/index.ts +0 -6
- package/src/Util/poll.ts +47 -0
- package/src/Util/types.ts +9 -2
- package/src/index.ts +2 -3
- 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/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/Secret.ts +0 -87
- 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,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
layerLocalProxy,
|
|
3
2
|
layerRuntime,
|
|
4
3
|
Runtime,
|
|
5
4
|
RuntimeError,
|
|
@@ -13,30 +12,38 @@ import {
|
|
|
13
12
|
} from "@distilled.cloud/cloudflare-runtime";
|
|
14
13
|
import {
|
|
15
14
|
Ai,
|
|
15
|
+
AnalyticsEngine,
|
|
16
16
|
Artifacts,
|
|
17
17
|
Assets,
|
|
18
18
|
Browser,
|
|
19
19
|
D1,
|
|
20
20
|
Data,
|
|
21
|
+
DispatchNamespace,
|
|
21
22
|
DurableObjectNamespace,
|
|
22
23
|
Hyperdrive,
|
|
23
24
|
Images,
|
|
24
25
|
Json,
|
|
25
26
|
KvNamespace,
|
|
27
|
+
MtlsCertificate,
|
|
28
|
+
Pipelines,
|
|
26
29
|
R2Bucket,
|
|
30
|
+
RateLimit,
|
|
31
|
+
SendEmail,
|
|
27
32
|
Service,
|
|
28
33
|
Text,
|
|
34
|
+
Vectorize,
|
|
29
35
|
VersionMetadata,
|
|
30
36
|
WasmModule,
|
|
31
37
|
WorkerLoader,
|
|
38
|
+
Workflows,
|
|
32
39
|
} from "@distilled.cloud/cloudflare-runtime/bindings";
|
|
33
|
-
import * as
|
|
40
|
+
import * as WorkerProxy from "@distilled.cloud/cloudflare-runtime/proxy/WorkerProxy";
|
|
34
41
|
import * as Cause from "effect/Cause";
|
|
35
42
|
import * as Effect from "effect/Effect";
|
|
43
|
+
import * as Equal from "effect/Equal";
|
|
36
44
|
import * as Exit from "effect/Exit";
|
|
37
45
|
import * as Fiber from "effect/Fiber";
|
|
38
46
|
import * as Hash from "effect/Hash";
|
|
39
|
-
import * as Layer from "effect/Layer";
|
|
40
47
|
import * as Path from "effect/Path";
|
|
41
48
|
import * as Redacted from "effect/Redacted";
|
|
42
49
|
import * as Result from "effect/Result";
|
|
@@ -45,11 +52,10 @@ import * as Scope from "effect/Scope";
|
|
|
45
52
|
import * as Stream from "effect/Stream";
|
|
46
53
|
import { AlchemyContext } from "../../AlchemyContext.ts";
|
|
47
54
|
import type * as Bundle from "../../Bundle/Bundle.ts";
|
|
48
|
-
import {
|
|
55
|
+
import { isResolved } from "../../Diff.ts";
|
|
49
56
|
import * as RpcProvider from "../../Local/RpcProvider.ts";
|
|
50
57
|
import type { ResourceBinding } from "../../Resource.ts";
|
|
51
58
|
import { Stack } from "../../Stack.ts";
|
|
52
|
-
import { Stage } from "../../Stage.ts";
|
|
53
59
|
import { CloudflareEnvironment } from "../CloudflareEnvironment.ts";
|
|
54
60
|
import type { WorkerAssetsConfig, WorkerProps } from "../Workers/Worker.ts";
|
|
55
61
|
import { getCompatibility } from "./Compatibility.ts";
|
|
@@ -69,23 +75,20 @@ export class WorkerValidationError extends Schema.TaggedErrorClass<WorkerValidat
|
|
|
69
75
|
},
|
|
70
76
|
) {}
|
|
71
77
|
|
|
72
|
-
export const localRuntimeServices = (
|
|
78
|
+
export const localRuntimeServices = () =>
|
|
73
79
|
RpcProvider.providerServicesEffect(
|
|
74
80
|
Effect.gen(function* () {
|
|
75
81
|
const { accountId } = yield* CloudflareEnvironment;
|
|
76
82
|
const { dotAlchemy } = yield* AlchemyContext;
|
|
77
83
|
const path = yield* Path.Path;
|
|
78
|
-
return
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}),
|
|
87
|
-
layerLocalProxy(options.port ?? 0),
|
|
88
|
-
);
|
|
84
|
+
return layerRuntime({
|
|
85
|
+
api: {
|
|
86
|
+
accountId,
|
|
87
|
+
},
|
|
88
|
+
storage: {
|
|
89
|
+
directory: path.join(dotAlchemy, "local"),
|
|
90
|
+
},
|
|
91
|
+
});
|
|
89
92
|
}),
|
|
90
93
|
);
|
|
91
94
|
|
|
@@ -108,7 +111,49 @@ export const LocalWorkerProvider = () =>
|
|
|
108
111
|
const runtime = yield* Runtime;
|
|
109
112
|
const stack = yield* Stack;
|
|
110
113
|
const path = yield* Path.Path;
|
|
111
|
-
const
|
|
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
|
+
});
|
|
112
157
|
|
|
113
158
|
const toRuntimeModules = Effect.fn(function* (
|
|
114
159
|
bundle: Bundle.BundleOutput,
|
|
@@ -150,9 +195,10 @@ export const LocalWorkerProvider = () =>
|
|
|
150
195
|
const serveScoped = Effect.fnUntraced(function* (
|
|
151
196
|
worker: WorkerConfig,
|
|
152
197
|
bundle: Bundle.BundleOutput,
|
|
198
|
+
proxy: WorkerProxy.WorkerProxyInstance,
|
|
153
199
|
) {
|
|
154
200
|
const scope = yield* Effect.scope.pipe(Effect.flatMap(Scope.fork));
|
|
155
|
-
const
|
|
201
|
+
const url = yield* runtime
|
|
156
202
|
.start({
|
|
157
203
|
name: worker.name,
|
|
158
204
|
compatibilityDate: worker.compatibility.date,
|
|
@@ -171,26 +217,20 @@ export const LocalWorkerProvider = () =>
|
|
|
171
217
|
yield* Effect.forkDetach(Scope.close(previous, Exit.void));
|
|
172
218
|
}
|
|
173
219
|
workerdScopes.set(worker.id, scope);
|
|
174
|
-
yield*
|
|
175
|
-
return
|
|
220
|
+
yield* proxy.set(url);
|
|
221
|
+
return url;
|
|
176
222
|
});
|
|
177
223
|
|
|
178
224
|
const buildConfig = Effect.fn(function* ({
|
|
179
225
|
id,
|
|
180
226
|
props,
|
|
181
227
|
bindings,
|
|
182
|
-
instanceId,
|
|
183
228
|
}: {
|
|
184
229
|
id: string;
|
|
185
230
|
props: WorkerProps;
|
|
186
231
|
bindings: ResourceBinding<Worker["Binding"]>[];
|
|
187
|
-
instanceId: string;
|
|
188
232
|
}) {
|
|
189
|
-
const name = yield* createWorkerName(id, props.name)
|
|
190
|
-
Effect.provideService(Stack, stack),
|
|
191
|
-
Effect.provideService(Stage, stack.stage),
|
|
192
|
-
Effect.provideService(InstanceId, instanceId),
|
|
193
|
-
);
|
|
233
|
+
const name = yield* createWorkerName(id, props.name);
|
|
194
234
|
const compatibility = getCompatibility(props);
|
|
195
235
|
const workerBindings: BindingHook<BindingServices>[] = [];
|
|
196
236
|
const durableObjectNamespaces: Record<string, string> = {};
|
|
@@ -227,16 +267,6 @@ export const LocalWorkerProvider = () =>
|
|
|
227
267
|
}
|
|
228
268
|
}
|
|
229
269
|
}
|
|
230
|
-
for (const [key, value] of Object.entries(props.env ?? {})) {
|
|
231
|
-
if (value === undefined) continue;
|
|
232
|
-
if (Redacted.isRedacted(value)) {
|
|
233
|
-
workerBindings.push(Text.binding(key, Redacted.value(value)));
|
|
234
|
-
} else if (typeof value === "string") {
|
|
235
|
-
workerBindings.push(Text.binding(key, value));
|
|
236
|
-
} else {
|
|
237
|
-
workerBindings.push(Json.binding(key, value));
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
270
|
return {
|
|
241
271
|
id,
|
|
242
272
|
name,
|
|
@@ -246,7 +276,7 @@ export const LocalWorkerProvider = () =>
|
|
|
246
276
|
hyperdrives,
|
|
247
277
|
bundleOptions: {
|
|
248
278
|
id,
|
|
249
|
-
main: props.main
|
|
279
|
+
main: props.main!,
|
|
250
280
|
compatibility,
|
|
251
281
|
entry: props.isExternal
|
|
252
282
|
? { kind: "external" }
|
|
@@ -255,6 +285,11 @@ export const LocalWorkerProvider = () =>
|
|
|
255
285
|
extraOptions: props.build,
|
|
256
286
|
} satisfies WorkerBundleOptions,
|
|
257
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
|
+
},
|
|
258
293
|
};
|
|
259
294
|
});
|
|
260
295
|
|
|
@@ -263,12 +298,17 @@ export const LocalWorkerProvider = () =>
|
|
|
263
298
|
const runServer = Effect.fnUntraced(function* (worker: WorkerConfig) {
|
|
264
299
|
let start = Date.now();
|
|
265
300
|
let status: "start" | "update" = "start";
|
|
301
|
+
const proxy = yield* maybeStartProxy(worker.id, worker.dev);
|
|
266
302
|
yield* bundler.watch(worker.bundleOptions).pipe(
|
|
267
303
|
Stream.tap((event) => {
|
|
268
304
|
if (event._tag === "Start") {
|
|
269
305
|
start = Date.now();
|
|
270
306
|
if (status === "update") {
|
|
271
|
-
return Effect.
|
|
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
|
+
]);
|
|
272
312
|
}
|
|
273
313
|
} else if (event._tag === "Error") {
|
|
274
314
|
return Effect.logError(
|
|
@@ -284,7 +324,7 @@ export const LocalWorkerProvider = () =>
|
|
|
284
324
|
: Result.failVoid,
|
|
285
325
|
),
|
|
286
326
|
Stream.mapEffect((bundle) =>
|
|
287
|
-
serveScoped(worker, bundle).pipe(
|
|
327
|
+
serveScoped(worker, bundle, proxy).pipe(
|
|
288
328
|
Effect.exit,
|
|
289
329
|
Effect.tap((exit) => {
|
|
290
330
|
if (exit._tag === "Success") {
|
|
@@ -305,6 +345,7 @@ export const LocalWorkerProvider = () =>
|
|
|
305
345
|
Stream.runDrain,
|
|
306
346
|
Effect.forkScoped,
|
|
307
347
|
);
|
|
348
|
+
return proxy.url.toString();
|
|
308
349
|
});
|
|
309
350
|
|
|
310
351
|
const rootScope = yield* Effect.scope;
|
|
@@ -327,11 +368,10 @@ export const LocalWorkerProvider = () =>
|
|
|
327
368
|
id: string;
|
|
328
369
|
props: WorkerProps;
|
|
329
370
|
bindings: ResourceBinding<Worker["Binding"]>[];
|
|
330
|
-
instanceId: string;
|
|
331
371
|
}) {
|
|
332
|
-
const {
|
|
372
|
+
const { props, bindings } = options;
|
|
333
373
|
const config = yield* buildConfig(options);
|
|
334
|
-
|
|
374
|
+
let url: string;
|
|
335
375
|
if (props.vite) {
|
|
336
376
|
const devServer = yield* Vite.viteDev(
|
|
337
377
|
props.vite.rootDir,
|
|
@@ -350,11 +390,11 @@ export const LocalWorkerProvider = () =>
|
|
|
350
390
|
},
|
|
351
391
|
context,
|
|
352
392
|
},
|
|
393
|
+
config.dev,
|
|
353
394
|
);
|
|
354
|
-
|
|
355
|
-
yield* localProxy.setLocalAddress(id, localAddress);
|
|
395
|
+
url = devServer.resolvedUrls!.local[0];
|
|
356
396
|
} else {
|
|
357
|
-
yield* runServer(config);
|
|
397
|
+
url = yield* runServer(config);
|
|
358
398
|
}
|
|
359
399
|
return {
|
|
360
400
|
workerId: config.name,
|
|
@@ -363,7 +403,7 @@ export const LocalWorkerProvider = () =>
|
|
|
363
403
|
url,
|
|
364
404
|
tags: [],
|
|
365
405
|
durableObjectNamespaces: config.durableObjectNamespaces,
|
|
366
|
-
domains: [],
|
|
406
|
+
domains: [url],
|
|
367
407
|
crons: Array.from(
|
|
368
408
|
new Set([...getCronBindings(bindings), ...(props.crons ?? [])]),
|
|
369
409
|
),
|
|
@@ -372,21 +412,25 @@ export const LocalWorkerProvider = () =>
|
|
|
372
412
|
});
|
|
373
413
|
|
|
374
414
|
return {
|
|
375
|
-
diff: Effect.fn(function* ({ id, news, newBindings,
|
|
415
|
+
diff: Effect.fn(function* ({ id, news, newBindings, output }) {
|
|
416
|
+
if (!isResolved(news) || !isResolved(newBindings)) return undefined;
|
|
376
417
|
const options = {
|
|
377
418
|
id,
|
|
378
419
|
props: news,
|
|
379
420
|
bindings: newBindings,
|
|
380
|
-
instanceId,
|
|
381
421
|
};
|
|
382
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);
|
|
383
427
|
return {
|
|
384
|
-
action:
|
|
385
|
-
|
|
428
|
+
action: "update",
|
|
429
|
+
stables: output?.workerName === name ? ["workerName"] : undefined,
|
|
386
430
|
};
|
|
387
431
|
}),
|
|
388
|
-
reconcile: Effect.fn(function* ({ id, news, bindings
|
|
389
|
-
const options = { id, props: news, bindings
|
|
432
|
+
reconcile: Effect.fn(function* ({ id, news, bindings }) {
|
|
433
|
+
const options = { id, props: news, bindings };
|
|
390
434
|
const hash = Hash.structure(options);
|
|
391
435
|
const existing = instances.get(options.id);
|
|
392
436
|
if (existing) {
|
|
@@ -441,69 +485,86 @@ const toRuntimeBinding = Effect.fnUntraced(function* (b: WorkerBinding) {
|
|
|
441
485
|
case "ai":
|
|
442
486
|
return Ai.remote(b.name);
|
|
443
487
|
case "analytics_engine":
|
|
444
|
-
return
|
|
488
|
+
return AnalyticsEngine.local(b.name, b.dataset);
|
|
445
489
|
case "artifacts":
|
|
446
|
-
return Artifacts.
|
|
490
|
+
return Artifacts.remote(b.name, b.namespace);
|
|
447
491
|
case "assets":
|
|
448
|
-
return Assets.
|
|
492
|
+
return Assets.local(b.name);
|
|
449
493
|
case "browser":
|
|
450
|
-
return Browser.
|
|
494
|
+
return Browser.remote(b.name);
|
|
451
495
|
case "d1":
|
|
452
|
-
return D1.remote(b.name, b.
|
|
496
|
+
return D1.remote(b.name, b.databaseId);
|
|
453
497
|
case "data_blob":
|
|
454
|
-
return Data.
|
|
498
|
+
return Data.local(b.name, Buffer.from(b.part));
|
|
455
499
|
case "dispatch_namespace":
|
|
456
|
-
return
|
|
500
|
+
return DispatchNamespace.remote({
|
|
501
|
+
binding: b.name,
|
|
502
|
+
namespace: b.namespace,
|
|
503
|
+
});
|
|
457
504
|
case "durable_object_namespace":
|
|
458
505
|
return DurableObjectNamespace.local({
|
|
459
|
-
|
|
460
|
-
className: b.className
|
|
506
|
+
binding: b.name,
|
|
507
|
+
className: b.className,
|
|
461
508
|
scriptName: b.scriptName,
|
|
462
509
|
});
|
|
463
510
|
case "hyperdrive":
|
|
464
|
-
return Hyperdrive.
|
|
511
|
+
return Hyperdrive.local(b.name, b.id);
|
|
465
512
|
case "images":
|
|
466
513
|
return Images.remote(b.name);
|
|
467
514
|
case "inherit":
|
|
468
515
|
return yield* unsupported();
|
|
469
516
|
case "json":
|
|
470
|
-
return Json.
|
|
517
|
+
return Json.local(b.name, b.json);
|
|
471
518
|
case "kv_namespace":
|
|
472
519
|
return KvNamespace.remote(b.name, b.namespaceId);
|
|
473
520
|
case "mtls_certificate":
|
|
474
|
-
return
|
|
521
|
+
return MtlsCertificate.remote(b.name, b.certificateId);
|
|
475
522
|
case "pipelines":
|
|
476
|
-
return
|
|
523
|
+
return Pipelines.remote(b.name, b.pipeline);
|
|
477
524
|
case "plain_text":
|
|
478
|
-
return Text.
|
|
525
|
+
return Text.local(b.name, b.text);
|
|
479
526
|
case "queue":
|
|
480
527
|
return yield* unsupported();
|
|
481
528
|
case "r2_bucket":
|
|
482
529
|
return R2Bucket.remote(b.name, b.bucketName, b.jurisdiction);
|
|
483
530
|
case "ratelimit":
|
|
484
|
-
return
|
|
531
|
+
return RateLimit.local({
|
|
532
|
+
binding: b.name,
|
|
533
|
+
simple: b.simple,
|
|
534
|
+
namespaceId: b.namespaceId,
|
|
535
|
+
});
|
|
485
536
|
case "secret_key":
|
|
486
537
|
return yield* unsupported();
|
|
487
538
|
case "secret_text":
|
|
488
|
-
return Text.
|
|
539
|
+
return Text.local(b.name, b.text);
|
|
489
540
|
case "secrets_store_secret":
|
|
490
541
|
return yield* unsupported();
|
|
491
542
|
case "send_email":
|
|
492
|
-
return
|
|
543
|
+
return SendEmail.remote({
|
|
544
|
+
binding: b.name,
|
|
545
|
+
destinationAddress: b.destinationAddress,
|
|
546
|
+
allowedDestinationAddresses: b.allowedDestinationAddresses,
|
|
547
|
+
allowedSenderAddresses: b.allowedSenderAddresses,
|
|
548
|
+
});
|
|
493
549
|
case "service":
|
|
494
|
-
return Service.local({
|
|
550
|
+
return Service.local({ binding: b.name, scriptName: b.service });
|
|
495
551
|
case "text_blob":
|
|
496
|
-
return Data.
|
|
552
|
+
return Data.local(b.name, Buffer.from(b.part));
|
|
497
553
|
case "vectorize":
|
|
498
|
-
return
|
|
554
|
+
return Vectorize.remote(b.name, b.indexName);
|
|
499
555
|
case "version_metadata":
|
|
500
|
-
return VersionMetadata.
|
|
556
|
+
return VersionMetadata.local(b.name);
|
|
501
557
|
case "wasm_module":
|
|
502
|
-
return WasmModule.
|
|
558
|
+
return WasmModule.local(b.name, Buffer.from(b.part));
|
|
503
559
|
case "worker_loader":
|
|
504
|
-
return WorkerLoader.
|
|
560
|
+
return WorkerLoader.local(b.name);
|
|
505
561
|
case "workflow":
|
|
506
|
-
return
|
|
562
|
+
return Workflows.local({
|
|
563
|
+
binding: b.name,
|
|
564
|
+
workflowName: b.workflowName,
|
|
565
|
+
className: b.className,
|
|
566
|
+
scriptName: b.scriptName,
|
|
567
|
+
});
|
|
507
568
|
default:
|
|
508
569
|
return yield* unsupported();
|
|
509
570
|
}
|
|
@@ -3,9 +3,18 @@ import type * as cf from "@cloudflare/workers-types";
|
|
|
3
3
|
import * as Cause from "effect/Cause";
|
|
4
4
|
import * as Data from "effect/Data";
|
|
5
5
|
import * as Effect from "effect/Effect";
|
|
6
|
+
import * as Layer from "effect/Layer";
|
|
6
7
|
import * as Option from "effect/Option";
|
|
7
8
|
import * as Sink from "effect/Sink";
|
|
8
9
|
import * as Stream from "effect/Stream";
|
|
10
|
+
import * as HttpClient from "effect/unstable/http/HttpClient";
|
|
11
|
+
import {
|
|
12
|
+
RpcClient,
|
|
13
|
+
RpcSerialization,
|
|
14
|
+
type Rpc,
|
|
15
|
+
type RpcGroup,
|
|
16
|
+
} from "effect/unstable/rpc";
|
|
17
|
+
import type * as RpcClientError from "effect/unstable/rpc/RpcClientError";
|
|
9
18
|
import * as Socket from "effect/unstable/socket/Socket";
|
|
10
19
|
import { isYieldableEffect } from "../../Util/effect.ts";
|
|
11
20
|
import { fromCloudflareFetcher } from "../Fetcher.ts";
|
|
@@ -291,3 +300,44 @@ const appendStreamErrors = (s: Stream.Stream<string, unknown>) =>
|
|
|
291
300
|
Stream.succeed(encodeStreamErrorMarker(cause)),
|
|
292
301
|
),
|
|
293
302
|
);
|
|
303
|
+
|
|
304
|
+
export const bindEffectRpc = <Rpcs extends Rpc.Any>(
|
|
305
|
+
namespace: { readonly getByName: (id: string) => { readonly fetch: any } },
|
|
306
|
+
group: RpcGroup.RpcGroup<Rpcs>,
|
|
307
|
+
options?: {
|
|
308
|
+
/**
|
|
309
|
+
* Override the rpc serialization layer. Defaults to NDJSON, which
|
|
310
|
+
* is required when any rpc in the group is a streaming rpc.
|
|
311
|
+
*/
|
|
312
|
+
readonly serialization?: Layer.Layer<RpcSerialization.RpcSerialization>;
|
|
313
|
+
},
|
|
314
|
+
): {
|
|
315
|
+
readonly getByName: (
|
|
316
|
+
id: string,
|
|
317
|
+
) => Effect.Effect<
|
|
318
|
+
RpcClient.RpcClient<Rpcs, RpcClientError.RpcClientError>,
|
|
319
|
+
never,
|
|
320
|
+
Rpc.MiddlewareClient<Rpcs>
|
|
321
|
+
>;
|
|
322
|
+
} => {
|
|
323
|
+
const serialization = options?.serialization ?? RpcSerialization.layerNdjson;
|
|
324
|
+
|
|
325
|
+
return {
|
|
326
|
+
// Wrap the cached `RpcClient` Effect in a chainable Proxy so callers
|
|
327
|
+
// can `yield* counter.getByName(id).method(args)` directly. The proxy
|
|
328
|
+
// records the `.method(args)` ops and replays them against the
|
|
329
|
+
// resolved client when the chain is yielded.
|
|
330
|
+
getByName: Effect.fnUntraced(function* (id: string) {
|
|
331
|
+
const httpClient = HttpClient.layerMergedContext(
|
|
332
|
+
Effect.sync(() => {
|
|
333
|
+
const stub = namespace.getByName(id);
|
|
334
|
+
return HttpClient.make((request) => stub.fetch(request));
|
|
335
|
+
}),
|
|
336
|
+
);
|
|
337
|
+
const protocol = RpcClient.layerProtocolHttp({
|
|
338
|
+
url: "http://alchemy-rpc/",
|
|
339
|
+
}).pipe(Layer.provide(serialization), Layer.provide(httpClient));
|
|
340
|
+
return yield* RpcClient.make(group).pipe(Effect.provide(protocol));
|
|
341
|
+
}) as any,
|
|
342
|
+
};
|
|
343
|
+
};
|