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
package/bin/exec.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as ConfigProvider from "effect/ConfigProvider";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
3
|
import * as Layer from "effect/Layer";
|
|
4
|
-
import * as
|
|
4
|
+
import * as Schema from "effect/Schema";
|
|
5
5
|
import * as FetchHttpClient from "effect/unstable/http/FetchHttpClient";
|
|
6
6
|
import * as EffectContext from "effect/Context";
|
|
7
7
|
import * as FileSystem from "effect/FileSystem";
|
|
@@ -11,20 +11,29 @@ import * as Redacted from "effect/Redacted";
|
|
|
11
11
|
import path from "pathe";
|
|
12
12
|
import * as Config from "effect/Config";
|
|
13
13
|
import os from "node:os";
|
|
14
|
-
import
|
|
14
|
+
import { newWebSocketRpcSession } from "capnweb";
|
|
15
|
+
import * as Cache from "effect/Cache";
|
|
16
|
+
import * as HttpBody from "effect/unstable/http/HttpBody";
|
|
17
|
+
import * as HttpClient from "effect/unstable/http/HttpClient";
|
|
15
18
|
import * as Logger from "effect/Logger";
|
|
16
19
|
import * as Option from "effect/Option";
|
|
17
|
-
import
|
|
18
|
-
import * as Flag from "effect/unstable/cli/Flag";
|
|
19
|
-
import * as Data from "effect/Data";
|
|
20
|
-
import * as Cause from "effect/Cause";
|
|
20
|
+
import "effect/Scope";
|
|
21
21
|
import * as Deferred from "effect/Deferred";
|
|
22
|
-
import
|
|
22
|
+
import * as Semaphore from "effect/Semaphore";
|
|
23
|
+
import * as Data from "effect/Data";
|
|
24
|
+
import * as Duration from "effect/Duration";
|
|
25
|
+
import { flow, pipe } from "effect/Function";
|
|
23
26
|
import { SingleShotGen } from "effect/Utils";
|
|
24
27
|
import { pipeArguments } from "effect/Pipeable";
|
|
25
|
-
import "effect/
|
|
26
|
-
import
|
|
28
|
+
import "effect/Predicate";
|
|
29
|
+
import "effect/Record";
|
|
30
|
+
import * as Cause from "effect/Cause";
|
|
27
31
|
import * as Exit from "effect/Exit";
|
|
32
|
+
import * as Stream from "effect/Stream";
|
|
33
|
+
import * as NodeUtil from "node:util";
|
|
34
|
+
import * as Console from "effect/Console";
|
|
35
|
+
import * as Command from "effect/unstable/cli/Command";
|
|
36
|
+
import * as Flag from "effect/unstable/cli/Flag";
|
|
28
37
|
import * as Metric from "effect/Metric";
|
|
29
38
|
import { createHash } from "node:crypto";
|
|
30
39
|
import * as Argument from "effect/unstable/cli/Argument";
|
|
@@ -134,7 +143,9 @@ const CredentialsStoreLive = Layer.effect(CredentialsStore, Effect.gen(function*
|
|
|
134
143
|
}));
|
|
135
144
|
const write = (profile$1, provider, credentials) => {
|
|
136
145
|
const filePath = credentialsFilePath(profile$1, provider);
|
|
137
|
-
return fs.makeDirectory(path.dirname(filePath), { recursive: true }).pipe(Effect.flatMap(() =>
|
|
146
|
+
return fs.makeDirectory(path.dirname(filePath), { recursive: true }).pipe(Effect.flatMap(() => {
|
|
147
|
+
return fs.writeFileString(filePath, JSON.stringify(credentials, null, 2));
|
|
148
|
+
}));
|
|
138
149
|
};
|
|
139
150
|
const remove_ = (profile$1, provider) => fs.remove(credentialsFilePath(profile$1, provider)).pipe(Effect.catch(() => Effect.void));
|
|
140
151
|
const deleteProfile = (profile$1) => fs.remove(profileCredentialsDirPath(profile$1), { recursive: true }).pipe(Effect.catch(() => Effect.void));
|
|
@@ -146,125 +157,6 @@ const CredentialsStoreLive = Layer.effect(CredentialsStore, Effect.gen(function*
|
|
|
146
157
|
};
|
|
147
158
|
}));
|
|
148
159
|
|
|
149
|
-
//#endregion
|
|
150
|
-
//#region lib/Util/PlatformServices.js
|
|
151
|
-
const isBun = typeof Bun !== "undefined";
|
|
152
|
-
const PlatformServices = Effect.promise(async () => {
|
|
153
|
-
if (isBun) {
|
|
154
|
-
const [BunServices, BunSocket] = await Promise.all([import("@effect/platform-bun/BunServices"), import("@effect/platform-bun/BunSocket")]);
|
|
155
|
-
return Layer.merge(BunServices.layer, BunSocket.layerWebSocketConstructor);
|
|
156
|
-
} else {
|
|
157
|
-
const [NodeServices, NodeSocket] = await Promise.all([import("@effect/platform-node/NodeServices"), import("@effect/platform-node/NodeSocket")]);
|
|
158
|
-
return Layer.merge(NodeServices.layer, NodeSocket.layerWebSocketConstructor);
|
|
159
|
-
}
|
|
160
|
-
}).pipe(Layer.unwrap);
|
|
161
|
-
const runMain = (effect, options) => {
|
|
162
|
-
if (isBun) import("@effect/platform-bun/BunRuntime").then((BunRuntime) => BunRuntime.runMain(effect, options));
|
|
163
|
-
else import("@effect/platform-node/NodeRuntime").then((NodeRuntime) => NodeRuntime.runMain(effect, options));
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
//#endregion
|
|
167
|
-
//#region lib/AdoptPolicy.js
|
|
168
|
-
/**
|
|
169
|
-
* AdoptPolicy controls whether the engine should "adopt" pre-existing cloud
|
|
170
|
-
* resources that conflict with this stack instead of failing.
|
|
171
|
-
*
|
|
172
|
-
* The engine always calls a provider's `read` lifecycle operation when there
|
|
173
|
-
* is no prior state and `read` is implemented. The provider's job is to
|
|
174
|
-
* report two things:
|
|
175
|
-
*
|
|
176
|
-
* 1. Whether the resource exists (returns attributes vs. `undefined`).
|
|
177
|
-
* 2. Whether *we* own it (plain attributes vs. {@link Unowned}-branded).
|
|
178
|
-
*
|
|
179
|
-
* The engine then routes:
|
|
180
|
-
*
|
|
181
|
-
* | `read` outcome | `adopt: false` | `adopt: true` |
|
|
182
|
-
* | ------------------- | -------------- | ----------------- |
|
|
183
|
-
* | undefined | create | create |
|
|
184
|
-
* | owned (plain attrs) | silent adopt | silent adopt |
|
|
185
|
-
* | {@link Unowned} | fail | takeover (adopt) |
|
|
186
|
-
*
|
|
187
|
-
* "Owned" means a provider has affirmatively determined the resource was
|
|
188
|
-
* created by this stack/stage/logical-id (typically by inspecting tags or
|
|
189
|
-
* naming conventions). Resources without ownership semantics simply always
|
|
190
|
-
* return plain attrs — they are treated as owned by default, so silent
|
|
191
|
-
* adoption is the norm and `--adopt` is unnecessary.
|
|
192
|
-
*
|
|
193
|
-
* The policy can be overridden per-effect via {@link adopt} — most commonly
|
|
194
|
-
* applied at the resource or stack scope.
|
|
195
|
-
*/
|
|
196
|
-
var AdoptPolicy = class extends EffectContext.Service()("AdoptPolicy") {};
|
|
197
|
-
/**
|
|
198
|
-
* Engine-raised failure produced when `read` reports an existing resource
|
|
199
|
-
* marked as {@link Unowned} and `adopt` is `false`. Surface this to the user
|
|
200
|
-
* to indicate they should either re-tag the cloud resource, pick a different
|
|
201
|
-
* physical name, or re-run with `--adopt` (or `adopt(true)`) to force a
|
|
202
|
-
* takeover.
|
|
203
|
-
*/
|
|
204
|
-
var OwnedBySomeoneElse = class extends Data.TaggedError("OwnedBySomeoneElse") {};
|
|
205
|
-
/**
|
|
206
|
-
* Private symbol used to brand attribute objects returned by `read` as
|
|
207
|
-
* "exists in cloud, but not owned by this stack/stage/logical-id".
|
|
208
|
-
*
|
|
209
|
-
* Deliberately *not* registered via `Symbol.for` — the brand is an
|
|
210
|
-
* engine-internal routing hint and must not be observable or
|
|
211
|
-
* forgeable from outside this module. The engine strips it before any
|
|
212
|
-
* state persistence (see {@link stripUnowned}) so it never leaks into
|
|
213
|
-
* the state store, JSON serialization, or downstream `Output`s.
|
|
214
|
-
*/
|
|
215
|
-
const UnownedTag = Symbol("alchemy/Unowned");
|
|
216
|
-
/**
|
|
217
|
-
* Brand a `read` return value as belonging to a different owner.
|
|
218
|
-
*
|
|
219
|
-
* Use this in a provider's `read` implementation when the resource exists in
|
|
220
|
-
* the cloud but a positive ownership check (e.g. tag inspection) shows it
|
|
221
|
-
* was *not* created by this stack/stage/logical-id:
|
|
222
|
-
*
|
|
223
|
-
* ```ts
|
|
224
|
-
* read: Effect.fnUntraced(function* ({ id, output, olds }) {
|
|
225
|
-
* const settings = yield* getScriptSettings({ ... }).pipe(
|
|
226
|
-
* Effect.catchTag("WorkerNotFound", () => Effect.succeed(undefined)),
|
|
227
|
-
* );
|
|
228
|
-
* if (!settings) return undefined;
|
|
229
|
-
*
|
|
230
|
-
* const attrs = { workerName, ...buildAttrs(settings) };
|
|
231
|
-
* return hasAlchemyWorkerTags(id, settings.tags) ? attrs : Unowned(attrs);
|
|
232
|
-
* }),
|
|
233
|
-
* ```
|
|
234
|
-
*
|
|
235
|
-
* The returned value is structurally still `T` — there is no wrapper to
|
|
236
|
-
* unwrap. The brand is a non-enumerable symbol that the engine inspects
|
|
237
|
-
* during planning to decide whether to take over (`adopt: true`) or fail
|
|
238
|
-
* loudly (`adopt: false`).
|
|
239
|
-
*
|
|
240
|
-
* Resources without ownership semantics should simply return plain attrs —
|
|
241
|
-
* the engine treats them as owned and silent adoption is the default.
|
|
242
|
-
*/
|
|
243
|
-
const Unowned = Object.assign((attrs) => {
|
|
244
|
-
const cloned = { ...attrs };
|
|
245
|
-
Object.defineProperty(cloned, UnownedTag, {
|
|
246
|
-
value: true,
|
|
247
|
-
enumerable: false,
|
|
248
|
-
writable: false,
|
|
249
|
-
configurable: false
|
|
250
|
-
});
|
|
251
|
-
return cloned;
|
|
252
|
-
}, { is: (value) => typeof value === "object" && value !== null && value[UnownedTag] === true });
|
|
253
|
-
/**
|
|
254
|
-
* Strip the {@link Unowned} brand from an attributes object before persisting
|
|
255
|
-
* it — state should not carry per-deploy ownership-routing metadata.
|
|
256
|
-
*
|
|
257
|
-
* The brand is intentionally non-enumerable, so a plain spread already
|
|
258
|
-
* drops it; the additional `delete` is defense-in-depth in case a future
|
|
259
|
-
* change makes the descriptor enumerable. Always returns a fresh object
|
|
260
|
-
* (never mutates the input).
|
|
261
|
-
*/
|
|
262
|
-
const stripUnowned = (attrs) => {
|
|
263
|
-
const out = { ...attrs };
|
|
264
|
-
if (UnownedTag in out) delete out[UnownedTag];
|
|
265
|
-
return out;
|
|
266
|
-
};
|
|
267
|
-
|
|
268
160
|
//#endregion
|
|
269
161
|
//#region lib/Artifacts.js
|
|
270
162
|
/**
|
|
@@ -325,6 +217,11 @@ const makeScopedArtifacts = (store, fqn) => {
|
|
|
325
217
|
*/
|
|
326
218
|
const ensureArtifactStore = (effect) => Effect.serviceOption(ArtifactStore).pipe(Effect.map(Option.getOrUndefined), Effect.flatMap((existing) => effect.pipe(Effect.provideService(ArtifactStore, existing ?? createArtifactStore()))));
|
|
327
219
|
|
|
220
|
+
//#endregion
|
|
221
|
+
//#region lib/Auth/AuthProvider.js
|
|
222
|
+
const interactiveMutex = Semaphore.makeUnsafe(1);
|
|
223
|
+
var AuthProviders = class extends EffectContext.Service()("AuthProviders") {};
|
|
224
|
+
|
|
328
225
|
//#endregion
|
|
329
226
|
//#region lib/Cli/Cli.js
|
|
330
227
|
var Cli = class extends EffectContext.Service()("CLI") {};
|
|
@@ -415,97 +312,6 @@ const tryFindProviderByType = Effect.fnUntraced(function* (resourceType) {
|
|
|
415
312
|
return Option.none();
|
|
416
313
|
});
|
|
417
314
|
|
|
418
|
-
//#endregion
|
|
419
|
-
//#region lib/Auth/AuthProvider.js
|
|
420
|
-
var AuthProviders = class extends EffectContext.Service()("AuthProviders") {};
|
|
421
|
-
|
|
422
|
-
//#endregion
|
|
423
|
-
//#region lib/Stage.js
|
|
424
|
-
var Stage = class extends EffectContext.Service()("Stage") {};
|
|
425
|
-
|
|
426
|
-
//#endregion
|
|
427
|
-
//#region lib/Util/ConfigProvider.js
|
|
428
|
-
const loadConfigProvider = (envFile$1) => {
|
|
429
|
-
if (Option.isSome(envFile$1)) return ConfigProvider.fromDotEnv({ path: envFile$1.value }).pipe(Effect.map((dotEnv) => ConfigProvider.orElse(dotEnv, ConfigProvider.fromEnv())));
|
|
430
|
-
return Effect.gen(function* () {
|
|
431
|
-
if (!(yield* (yield* FileSystem.FileSystem).exists(".env"))) return ConfigProvider.fromEnv();
|
|
432
|
-
return ConfigProvider.orElse(yield* ConfigProvider.fromDotEnv({ path: ".env" }), ConfigProvider.fromEnv());
|
|
433
|
-
});
|
|
434
|
-
};
|
|
435
|
-
|
|
436
|
-
//#endregion
|
|
437
|
-
//#region lib/Util/effect.js
|
|
438
|
-
const effectClass = ((impl) => impl === void 0 ? (innerImpl) => effectClass(innerImpl) : Object.assign(class {
|
|
439
|
-
static asEffect() {
|
|
440
|
-
return impl;
|
|
441
|
-
}
|
|
442
|
-
static [Symbol.iterator]() {
|
|
443
|
-
return new SingleShotGen(this.asEffect());
|
|
444
|
-
}
|
|
445
|
-
static pipe(...fns) {
|
|
446
|
-
return pipeArguments(this, fns);
|
|
447
|
-
}
|
|
448
|
-
}, impl));
|
|
449
|
-
const taggedFunction = (tag$1, fn) => {
|
|
450
|
-
const overrides = {
|
|
451
|
-
asEffect: () => tag$1,
|
|
452
|
-
[Symbol.iterator]: () => tag$1[Symbol.iterator](),
|
|
453
|
-
pipe: (...fns) => pipeArguments(tag$1, fns),
|
|
454
|
-
toString: () => `${tag$1.toString()}.${fn.name}`
|
|
455
|
-
};
|
|
456
|
-
return new Proxy(fn, {
|
|
457
|
-
get: (target, prop, receiver) => Reflect.has(overrides, prop) ? Reflect.get(overrides, prop, receiver) : Reflect.has(target, prop) ? Reflect.get(target, prop, receiver) : Reflect.get(tag$1, prop, tag$1),
|
|
458
|
-
has: (target, prop) => Reflect.has(overrides, prop) || Reflect.has(target, prop) || Reflect.has(tag$1, prop)
|
|
459
|
-
});
|
|
460
|
-
};
|
|
461
|
-
|
|
462
|
-
//#endregion
|
|
463
|
-
//#region lib/Util/FileLogger.js
|
|
464
|
-
const fileLogger = Effect.fnUntraced(function* (...segments) {
|
|
465
|
-
const { dotAlchemy } = yield* AlchemyContext;
|
|
466
|
-
const fs = yield* FileSystem.FileSystem;
|
|
467
|
-
const path$1 = yield* Path;
|
|
468
|
-
const logFile = path$1.join(dotAlchemy, "log", ...segments);
|
|
469
|
-
yield* fs.makeDirectory(path$1.dirname(logFile), { recursive: true });
|
|
470
|
-
return yield* Logger.formatLogFmt.pipe(Logger.toFile(logFile, { flag: "a" }));
|
|
471
|
-
});
|
|
472
|
-
|
|
473
|
-
//#endregion
|
|
474
|
-
//#region lib/Stack.js
|
|
475
|
-
const Stack = Object.assign(taggedFunction(EffectContext.Service()("Stack"), (stackName, options, eff) => {
|
|
476
|
-
if (!stackName) return (stackName$1) => Object.assign(stackRef(stackName$1).pipe(effectClass), {
|
|
477
|
-
stage: createStageProxy(stackName$1),
|
|
478
|
-
make: (options$1, eff$1) => Stack(stackName$1, options$1, eff$1)
|
|
479
|
-
});
|
|
480
|
-
return eff.pipe(make$1({
|
|
481
|
-
name: stackName,
|
|
482
|
-
...options
|
|
483
|
-
}), (eff$1) => Object.assign(eff$1, { stage: createStageProxy(stackName) }));
|
|
484
|
-
}));
|
|
485
|
-
const createStageProxy = (stackName) => new Proxy({}, { get: (_, stage$1) => stackRef(stackName, { stage: stage$1 }) });
|
|
486
|
-
const StackName = Stack.use((stack) => Effect.succeed(stack.name));
|
|
487
|
-
const make$1 = (options) => (effect) => Effect.scope.pipe(Effect.flatMap((scope) => {
|
|
488
|
-
if (options.state == null) return Effect.die(/* @__PURE__ */ new Error(`Stack "${options.name}" is missing a state store. Add a \`state\` layer to the stack options, e.g.:\n Alchemy.Stack("${options.name}", {\n providers: Cloudflare.providers(),\n state: Cloudflare.state(), // <-- required\n }, ...)\nSee https://v2.alchemy.run/concepts/state-store for available state stores.`));
|
|
489
|
-
if (options.providers == null) return Effect.die(/* @__PURE__ */ new Error(`Stack "${options.name}" is missing a providers layer. Add a \`providers\` layer to the stack options, e.g.:\n Alchemy.Stack("${options.name}", {\n providers: Cloudflare.providers(), // <-- required\n state: Cloudflare.state(),\n }, ...)`));
|
|
490
|
-
return options.providers.pipe(Layer.provideMerge(options.state), Layer.provideMerge(Layer.effect(Stack, Stage.pipe(Effect.map((stage$1) => options.stack ?? {
|
|
491
|
-
name: options.name,
|
|
492
|
-
stage: stage$1,
|
|
493
|
-
resources: {},
|
|
494
|
-
bindings: {},
|
|
495
|
-
actions: {}
|
|
496
|
-
})))), Layer.buildWithScope(scope));
|
|
497
|
-
}), Effect.flatMap((context) => Effect.all([
|
|
498
|
-
effect,
|
|
499
|
-
Stack,
|
|
500
|
-
Effect.context()
|
|
501
|
-
]).pipe(Effect.map(([output, stack, services$1]) => ({
|
|
502
|
-
...stack,
|
|
503
|
-
output,
|
|
504
|
-
services: EffectContext.merge(services$1, context)
|
|
505
|
-
})), Effect.provideContext(context))));
|
|
506
|
-
const CurrentStack = Effect.serviceOption(Stack).pipe(Effect.map(Option.getOrUndefined));
|
|
507
|
-
const platform = Layer.mergeAll(PlatformServices, FetchHttpClient.layer, Logger.layer([fileLogger("out")], { mergeWithExisting: true }), Layer.provide(ProfileLive, PlatformServices), Layer.provide(CredentialsStoreLive, PlatformServices));
|
|
508
|
-
|
|
509
315
|
//#endregion
|
|
510
316
|
//#region lib/Resource.js
|
|
511
317
|
const isResource = (value) => {
|
|
@@ -515,6 +321,18 @@ const isResource = (value) => {
|
|
|
515
321
|
//#endregion
|
|
516
322
|
//#region lib/RuntimeContext.js
|
|
517
323
|
/**
|
|
324
|
+
* Canonicalize a logical key into a key that is safe to use as the name of an
|
|
325
|
+
* environment variable / binding (`[a-zA-Z][a-zA-Z0-9_]*`).
|
|
326
|
+
*
|
|
327
|
+
* `RuntimeContext.set`/`get` are dumb key/value stores: they read and write the
|
|
328
|
+
* key **verbatim**. It is the *caller's* responsibility to hand them a
|
|
329
|
+
* canonical key, since the caller is the one that knows the logical key may
|
|
330
|
+
* contain `.`/`-` (e.g. a dotted config name from `Platform`, or an
|
|
331
|
+
* `Output.toString()` like `"QueueSinkQueue.queueUrl"`). Callers run the key
|
|
332
|
+
* through this before calling `set`/`get` so both sides agree.
|
|
333
|
+
*/
|
|
334
|
+
const sanitizeKey = (key) => key.replaceAll(/[^a-zA-Z0-9]/g, "_");
|
|
335
|
+
/**
|
|
518
336
|
* Context of the runtime environment.
|
|
519
337
|
*
|
|
520
338
|
* E.g. the context of a running Worker, Task, Process, Function
|
|
@@ -522,6 +340,10 @@ const isResource = (value) => {
|
|
|
522
340
|
var RuntimeContext = class extends EffectContext.Service()("RuntimeContext") {};
|
|
523
341
|
const CurrentRuntimeContext = Effect.serviceOption(RuntimeContext).pipe(Effect.map(Option.getOrUndefined));
|
|
524
342
|
|
|
343
|
+
//#endregion
|
|
344
|
+
//#region lib/Stage.js
|
|
345
|
+
var Stage = class extends EffectContext.Service()("Stage") {};
|
|
346
|
+
|
|
525
347
|
//#endregion
|
|
526
348
|
//#region lib/State/State.js
|
|
527
349
|
const isActionState = (s) => !!s && s.kind === "action";
|
|
@@ -556,7 +378,8 @@ var BaseExpr = class {
|
|
|
556
378
|
return this.bind(this.toString());
|
|
557
379
|
}
|
|
558
380
|
bind(id) {
|
|
559
|
-
|
|
381
|
+
const key = sanitizeKey(id);
|
|
382
|
+
return RuntimeContext.pipe(Effect.flatMap((ctx) => Effect.map(ctx.set(key, this), (k) => ctx.get(k))));
|
|
560
383
|
}
|
|
561
384
|
pipe(...fns) {
|
|
562
385
|
return pipe(this, ...fns);
|
|
@@ -805,6 +628,7 @@ const evaluate = (expr, upstream$1) => Effect.gen(function* () {
|
|
|
805
628
|
}
|
|
806
629
|
if (Array.isArray(expr)) return yield* Effect.all(expr.map((item) => evaluate(item, upstream$1)));
|
|
807
630
|
else if (Redacted.isRedacted(expr)) return expr;
|
|
631
|
+
else if (Duration.isDuration(expr)) return expr;
|
|
808
632
|
else if (typeof expr === "object" && expr !== null) return Object.fromEntries(yield* Effect.all(Object.entries(expr).map(([key, value]) => evaluate(value, upstream$1).pipe(Effect.map((value$1) => [key, value$1])))));
|
|
809
633
|
return expr;
|
|
810
634
|
});
|
|
@@ -839,6 +663,282 @@ const toObject = (acc, v) => ({
|
|
|
839
663
|
...v
|
|
840
664
|
});
|
|
841
665
|
|
|
666
|
+
//#endregion
|
|
667
|
+
//#region lib/Util/ConfigProvider.js
|
|
668
|
+
const loadConfigProvider = (envFile$1) => {
|
|
669
|
+
if (Option.isSome(envFile$1)) return ConfigProvider.fromDotEnv({ path: envFile$1.value }).pipe(Effect.map((dotEnv) => ConfigProvider.orElse(dotEnv, ConfigProvider.fromEnv())));
|
|
670
|
+
return Effect.gen(function* () {
|
|
671
|
+
if (!(yield* (yield* FileSystem.FileSystem).exists(".env"))) return ConfigProvider.fromEnv();
|
|
672
|
+
return ConfigProvider.orElse(yield* ConfigProvider.fromDotEnv({ path: ".env" }), ConfigProvider.fromEnv());
|
|
673
|
+
});
|
|
674
|
+
};
|
|
675
|
+
|
|
676
|
+
//#endregion
|
|
677
|
+
//#region lib/Util/effect.js
|
|
678
|
+
const effectClass = ((impl) => impl === void 0 ? (innerImpl) => effectClass(innerImpl) : Object.assign(class {
|
|
679
|
+
static asEffect() {
|
|
680
|
+
return impl;
|
|
681
|
+
}
|
|
682
|
+
static [Symbol.iterator]() {
|
|
683
|
+
return new SingleShotGen(this.asEffect());
|
|
684
|
+
}
|
|
685
|
+
static pipe(...fns) {
|
|
686
|
+
return pipeArguments(this, fns);
|
|
687
|
+
}
|
|
688
|
+
}, impl));
|
|
689
|
+
const taggedFunction = (tag$1, fn) => {
|
|
690
|
+
const overrides = {
|
|
691
|
+
asEffect: () => tag$1,
|
|
692
|
+
[Symbol.iterator]: () => tag$1[Symbol.iterator](),
|
|
693
|
+
pipe: (...fns) => pipeArguments(tag$1, fns),
|
|
694
|
+
toString: () => `${tag$1.toString()}.${fn.name}`
|
|
695
|
+
};
|
|
696
|
+
return new Proxy(fn, {
|
|
697
|
+
get: (target, prop, receiver) => Reflect.has(overrides, prop) ? Reflect.get(overrides, prop, receiver) : Reflect.has(target, prop) ? Reflect.get(target, prop, receiver) : Reflect.get(tag$1, prop, tag$1),
|
|
698
|
+
has: (target, prop) => Reflect.has(overrides, prop) || Reflect.has(target, prop) || Reflect.has(tag$1, prop)
|
|
699
|
+
});
|
|
700
|
+
};
|
|
701
|
+
|
|
702
|
+
//#endregion
|
|
703
|
+
//#region lib/Util/FileLogger.js
|
|
704
|
+
const fileLogger = Effect.fnUntraced(function* (...segments) {
|
|
705
|
+
const { dotAlchemy } = yield* AlchemyContext;
|
|
706
|
+
const fs = yield* FileSystem.FileSystem;
|
|
707
|
+
const path$1 = yield* Path;
|
|
708
|
+
const logFile = path$1.join(dotAlchemy, "log", ...segments);
|
|
709
|
+
yield* fs.makeDirectory(path$1.dirname(logFile), { recursive: true });
|
|
710
|
+
return yield* Logger.formatLogFmt.pipe(Logger.toFile(logFile, { flag: "a" }));
|
|
711
|
+
});
|
|
712
|
+
|
|
713
|
+
//#endregion
|
|
714
|
+
//#region lib/Util/PlatformServices.js
|
|
715
|
+
const isBun = typeof Bun !== "undefined";
|
|
716
|
+
/**
|
|
717
|
+
* Constructs a layer with different implementations for Bun and Node.
|
|
718
|
+
*/
|
|
719
|
+
const platformLayer = (constructors) => Layer.unwrap(Effect.promise(async () => {
|
|
720
|
+
if (isBun) return await constructors.bun();
|
|
721
|
+
else return await constructors.node();
|
|
722
|
+
}));
|
|
723
|
+
const PlatformServices = platformLayer({
|
|
724
|
+
bun: async () => {
|
|
725
|
+
const [BunServices, BunSocket] = await Promise.all([import("@effect/platform-bun/BunServices"), import("@effect/platform-bun/BunSocket")]);
|
|
726
|
+
return Layer.merge(BunServices.layer, BunSocket.layerWebSocketConstructor);
|
|
727
|
+
},
|
|
728
|
+
node: async () => {
|
|
729
|
+
const [NodeServices, NodeSocket] = await Promise.all([import("@effect/platform-node/NodeServices"), import("@effect/platform-node/NodeSocket")]);
|
|
730
|
+
return Layer.merge(NodeServices.layer, NodeSocket.layerWebSocketConstructor);
|
|
731
|
+
}
|
|
732
|
+
});
|
|
733
|
+
const runMain = (effect, options) => {
|
|
734
|
+
if (isBun) import("@effect/platform-bun/BunRuntime").then((BunRuntime) => BunRuntime.runMain(effect, options));
|
|
735
|
+
else import("@effect/platform-node/NodeRuntime").then((NodeRuntime) => NodeRuntime.runMain(effect, options));
|
|
736
|
+
};
|
|
737
|
+
|
|
738
|
+
//#endregion
|
|
739
|
+
//#region lib/Stack.js
|
|
740
|
+
const Stack = Object.assign(taggedFunction(EffectContext.Service()("Stack"), (stackName, options, eff) => {
|
|
741
|
+
if (!stackName) return (stackName$1) => Object.assign(stackRef(stackName$1).pipe(effectClass), {
|
|
742
|
+
stage: createStageProxy(stackName$1),
|
|
743
|
+
make: (options$1, eff$1) => Stack(stackName$1, options$1, eff$1)
|
|
744
|
+
});
|
|
745
|
+
return eff.pipe(make$2({
|
|
746
|
+
name: stackName,
|
|
747
|
+
...options
|
|
748
|
+
}), (eff$1) => Object.assign(eff$1, { stage: createStageProxy(stackName) }));
|
|
749
|
+
}));
|
|
750
|
+
const createStageProxy = (stackName) => new Proxy({}, { get: (_, stage$1) => stackRef(stackName, { stage: stage$1 }) });
|
|
751
|
+
const StackName = Stack.use((stack) => Effect.succeed(stack.name));
|
|
752
|
+
const make$2 = (options) => (effect) => Effect.scope.pipe(Effect.flatMap((scope) => {
|
|
753
|
+
if (options.state == null) return Effect.die(/* @__PURE__ */ new Error(`Stack "${options.name}" is missing a state store. Add a \`state\` layer to the stack options, e.g.:\n Alchemy.Stack("${options.name}", {\n providers: Cloudflare.providers(),\n state: Cloudflare.state(), // <-- required\n }, ...)\nSee https://v2.alchemy.run/concepts/state-store for available state stores.`));
|
|
754
|
+
if (options.providers == null) return Effect.die(/* @__PURE__ */ new Error(`Stack "${options.name}" is missing a providers layer. Add a \`providers\` layer to the stack options, e.g.:\n Alchemy.Stack("${options.name}", {\n providers: Cloudflare.providers(), // <-- required\n state: Cloudflare.state(),\n }, ...)`));
|
|
755
|
+
return options.providers.pipe(Layer.provideMerge(options.state), Layer.provideMerge(Layer.effect(Stack, Stage.pipe(Effect.map((stage$1) => options.stack ?? {
|
|
756
|
+
name: options.name,
|
|
757
|
+
stage: stage$1,
|
|
758
|
+
resources: {},
|
|
759
|
+
bindings: {},
|
|
760
|
+
actions: {}
|
|
761
|
+
})))), Layer.buildWithScope(scope));
|
|
762
|
+
}), Effect.flatMap((context) => Effect.all([
|
|
763
|
+
effect,
|
|
764
|
+
Stack,
|
|
765
|
+
Effect.context()
|
|
766
|
+
]).pipe(Effect.map(([output, stack, services$1]) => ({
|
|
767
|
+
...stack,
|
|
768
|
+
output,
|
|
769
|
+
services: EffectContext.merge(services$1, context)
|
|
770
|
+
})), Effect.provideContext(context))));
|
|
771
|
+
const CurrentStack = Effect.serviceOption(Stack).pipe(Effect.map(Option.getOrUndefined));
|
|
772
|
+
const platform = Layer.mergeAll(PlatformServices, FetchHttpClient.layer, Logger.layer([fileLogger("out")], { mergeWithExisting: true }), Layer.provide(ProfileLive, PlatformServices), Layer.provide(CredentialsStoreLive, PlatformServices));
|
|
773
|
+
|
|
774
|
+
//#endregion
|
|
775
|
+
//#region lib/Local/RpcSerialization.js
|
|
776
|
+
const unwrapRpcHandlers = (handlers, streamKeys) => {
|
|
777
|
+
return Object.fromEntries(Object.entries(handlers).map(([key, value]) => [key, typeof value === "function" ? streamKeys?.includes(key) ? unwrapRpcStreamHandler(value) : unwrapRpcEffectHandler(value) : typeof value === "object" && value !== null ? unwrapRpcHandlers(value) : value]));
|
|
778
|
+
};
|
|
779
|
+
const serializeError = Schema.encodeSync(Schema.Defect);
|
|
780
|
+
const unwrapRpcEffectHandler = (handler) => flow((...args) => serializeRpcArgs(args), (args) => Effect.promise(() => handler(args)), Effect.flatMap((exit) => {
|
|
781
|
+
if (exit._tag === "Success") return Exit.succeed(exit.value);
|
|
782
|
+
return Exit.failCause(Cause.fromReasons(exit.cause.map((reason) => {
|
|
783
|
+
switch (reason._tag) {
|
|
784
|
+
case "Fail": return Cause.makeFailReason(reason.error);
|
|
785
|
+
case "Die": return Cause.makeDieReason(reason.defect);
|
|
786
|
+
case "Interrupt": return Cause.makeInterruptReason(reason.fiberId);
|
|
787
|
+
}
|
|
788
|
+
})));
|
|
789
|
+
}));
|
|
790
|
+
const unwrapRpcStreamHandler = (handler) => flow((...args) => serializeRpcArgs(args), (args) => handler(args), (stream) => Stream.fromReadableStream({
|
|
791
|
+
evaluate: () => stream,
|
|
792
|
+
onError: (error) => error
|
|
793
|
+
}));
|
|
794
|
+
const serializeRpcArgs = (value) => {
|
|
795
|
+
if (Redacted.isRedacted(value)) return {
|
|
796
|
+
_tag: "Redacted",
|
|
797
|
+
value: Redacted.value(value)
|
|
798
|
+
};
|
|
799
|
+
if (isOutput(value)) return {
|
|
800
|
+
_tag: "Output",
|
|
801
|
+
description: NodeUtil.inspect(value)
|
|
802
|
+
};
|
|
803
|
+
if (typeof value === "function") return null;
|
|
804
|
+
if (Array.isArray(value)) return value.map(serializeRpcArgs);
|
|
805
|
+
if (value && typeof value === "object" && !("toJSON" in value)) return Object.fromEntries(Object.entries(value).map(([key, child]) => [key, serializeRpcArgs(child)]));
|
|
806
|
+
return value;
|
|
807
|
+
};
|
|
808
|
+
|
|
809
|
+
//#endregion
|
|
810
|
+
//#region lib/Local/RpcProviderProxy.js
|
|
811
|
+
var RpcProviderProxy = class extends EffectContext.Service()("alchemy/Local/RpcProviderProxy") {};
|
|
812
|
+
const SPAWNER_URL_ENV_KEY = "ALCHEMY_RPC_SPAWNER_URL";
|
|
813
|
+
const make$1 = Effect.fnUntraced(function* (spawnerUrl) {
|
|
814
|
+
const client = yield* HttpClient.HttpClient;
|
|
815
|
+
const getSession = Effect.fnUntraced(function* (serverEntryUrl) {
|
|
816
|
+
const alchemyContext = yield* AlchemyContext;
|
|
817
|
+
const stack = yield* Stack;
|
|
818
|
+
const payload = {
|
|
819
|
+
serverEntryUrl,
|
|
820
|
+
alchemyContext,
|
|
821
|
+
stack: {
|
|
822
|
+
name: stack.name,
|
|
823
|
+
stage: stack.stage
|
|
824
|
+
}
|
|
825
|
+
};
|
|
826
|
+
return newWebSocketRpcSession(yield* (yield* client.post(spawnerUrl, { body: yield* HttpBody.json(payload) })).text);
|
|
827
|
+
}, (effect, serverEntryUrl) => Effect.catch(effect, (error) => Effect.die(new Error(`Failed to create provider RPC session for "${serverEntryUrl}"`, { cause: error }))));
|
|
828
|
+
const cache = yield* Cache.make({
|
|
829
|
+
lookup: getSession,
|
|
830
|
+
capacity: Infinity,
|
|
831
|
+
requireServicesAt: "lookup"
|
|
832
|
+
});
|
|
833
|
+
return RpcProviderProxy.of({ get: Effect.fnUntraced(function* (mainUrl, providerName) {
|
|
834
|
+
const session = yield* cache.lookup(mainUrl);
|
|
835
|
+
return unwrapRpcHandlers(yield* Effect.promise(() => session.getProvider(providerName)), ["tail"]);
|
|
836
|
+
}) });
|
|
837
|
+
});
|
|
838
|
+
const fromEnv = () => Layer.effect(RpcProviderProxy, Config.string(SPAWNER_URL_ENV_KEY).pipe(Effect.flatMap(make$1)));
|
|
839
|
+
|
|
840
|
+
//#endregion
|
|
841
|
+
//#region lib/AdoptPolicy.js
|
|
842
|
+
/**
|
|
843
|
+
* AdoptPolicy controls whether the engine should "adopt" pre-existing cloud
|
|
844
|
+
* resources that conflict with this stack instead of failing.
|
|
845
|
+
*
|
|
846
|
+
* The engine always calls a provider's `read` lifecycle operation when there
|
|
847
|
+
* is no prior state and `read` is implemented. The provider's job is to
|
|
848
|
+
* report two things:
|
|
849
|
+
*
|
|
850
|
+
* 1. Whether the resource exists (returns attributes vs. `undefined`).
|
|
851
|
+
* 2. Whether *we* own it (plain attributes vs. {@link Unowned}-branded).
|
|
852
|
+
*
|
|
853
|
+
* The engine then routes:
|
|
854
|
+
*
|
|
855
|
+
* | `read` outcome | `adopt: false` | `adopt: true` |
|
|
856
|
+
* | ------------------- | -------------- | ----------------- |
|
|
857
|
+
* | undefined | create | create |
|
|
858
|
+
* | owned (plain attrs) | silent adopt | silent adopt |
|
|
859
|
+
* | {@link Unowned} | fail | takeover (adopt) |
|
|
860
|
+
*
|
|
861
|
+
* "Owned" means a provider has affirmatively determined the resource was
|
|
862
|
+
* created by this stack/stage/logical-id (typically by inspecting tags or
|
|
863
|
+
* naming conventions). Resources without ownership semantics simply always
|
|
864
|
+
* return plain attrs — they are treated as owned by default, so silent
|
|
865
|
+
* adoption is the norm and `--adopt` is unnecessary.
|
|
866
|
+
*
|
|
867
|
+
* The policy can be overridden per-effect via {@link adopt} — most commonly
|
|
868
|
+
* applied at the resource or stack scope.
|
|
869
|
+
*/
|
|
870
|
+
var AdoptPolicy = class extends EffectContext.Service()("AdoptPolicy") {};
|
|
871
|
+
/**
|
|
872
|
+
* Engine-raised failure produced when `read` reports an existing resource
|
|
873
|
+
* marked as {@link Unowned} and `adopt` is `false`. Surface this to the user
|
|
874
|
+
* to indicate they should either re-tag the cloud resource, pick a different
|
|
875
|
+
* physical name, or re-run with `--adopt` (or `adopt(true)`) to force a
|
|
876
|
+
* takeover.
|
|
877
|
+
*/
|
|
878
|
+
var OwnedBySomeoneElse = class extends Data.TaggedError("OwnedBySomeoneElse") {};
|
|
879
|
+
/**
|
|
880
|
+
* Private symbol used to brand attribute objects returned by `read` as
|
|
881
|
+
* "exists in cloud, but not owned by this stack/stage/logical-id".
|
|
882
|
+
*
|
|
883
|
+
* Deliberately *not* registered via `Symbol.for` — the brand is an
|
|
884
|
+
* engine-internal routing hint and must not be observable or
|
|
885
|
+
* forgeable from outside this module. The engine strips it before any
|
|
886
|
+
* state persistence (see {@link stripUnowned}) so it never leaks into
|
|
887
|
+
* the state store, JSON serialization, or downstream `Output`s.
|
|
888
|
+
*/
|
|
889
|
+
const UnownedTag = Symbol("alchemy/Unowned");
|
|
890
|
+
/**
|
|
891
|
+
* Brand a `read` return value as belonging to a different owner.
|
|
892
|
+
*
|
|
893
|
+
* Use this in a provider's `read` implementation when the resource exists in
|
|
894
|
+
* the cloud but a positive ownership check (e.g. tag inspection) shows it
|
|
895
|
+
* was *not* created by this stack/stage/logical-id:
|
|
896
|
+
*
|
|
897
|
+
* ```ts
|
|
898
|
+
* read: Effect.fnUntraced(function* ({ id, output, olds }) {
|
|
899
|
+
* const settings = yield* getScriptSettings({ ... }).pipe(
|
|
900
|
+
* Effect.catchTag("WorkerNotFound", () => Effect.succeed(undefined)),
|
|
901
|
+
* );
|
|
902
|
+
* if (!settings) return undefined;
|
|
903
|
+
*
|
|
904
|
+
* const attrs = { workerName, ...buildAttrs(settings) };
|
|
905
|
+
* return hasAlchemyWorkerTags(id, settings.tags) ? attrs : Unowned(attrs);
|
|
906
|
+
* }),
|
|
907
|
+
* ```
|
|
908
|
+
*
|
|
909
|
+
* The returned value is structurally still `T` — there is no wrapper to
|
|
910
|
+
* unwrap. The brand is a non-enumerable symbol that the engine inspects
|
|
911
|
+
* during planning to decide whether to take over (`adopt: true`) or fail
|
|
912
|
+
* loudly (`adopt: false`).
|
|
913
|
+
*
|
|
914
|
+
* Resources without ownership semantics should simply return plain attrs —
|
|
915
|
+
* the engine treats them as owned and silent adoption is the default.
|
|
916
|
+
*/
|
|
917
|
+
const Unowned = Object.assign((attrs) => {
|
|
918
|
+
const cloned = { ...attrs };
|
|
919
|
+
Object.defineProperty(cloned, UnownedTag, {
|
|
920
|
+
value: true,
|
|
921
|
+
enumerable: false,
|
|
922
|
+
writable: false,
|
|
923
|
+
configurable: false
|
|
924
|
+
});
|
|
925
|
+
return cloned;
|
|
926
|
+
}, { is: (value) => typeof value === "object" && value !== null && value[UnownedTag] === true });
|
|
927
|
+
/**
|
|
928
|
+
* Strip the {@link Unowned} brand from an attributes object before persisting
|
|
929
|
+
* it — state should not carry per-deploy ownership-routing metadata.
|
|
930
|
+
*
|
|
931
|
+
* The brand is intentionally non-enumerable, so a plain spread already
|
|
932
|
+
* drops it; the additional `delete` is defense-in-depth in case a future
|
|
933
|
+
* change makes the descriptor enumerable. Always returns a fresh object
|
|
934
|
+
* (never mutates the input).
|
|
935
|
+
*/
|
|
936
|
+
const stripUnowned = (attrs) => {
|
|
937
|
+
const out = { ...attrs };
|
|
938
|
+
if (UnownedTag in out) delete out[UnownedTag];
|
|
939
|
+
return out;
|
|
940
|
+
};
|
|
941
|
+
|
|
842
942
|
//#endregion
|
|
843
943
|
//#region lib/Diff.js
|
|
844
944
|
const isResolved = (value) => !_hasUnresolved(value);
|
|
@@ -856,6 +956,17 @@ const canonicalize = (value, stripNullish) => {
|
|
|
856
956
|
if (value && typeof value === "object") return Object.fromEntries(Object.entries(value).filter(([, nested]) => !stripNullish || nested != null).sort(([a], [b]) => a.localeCompare(b)).map(([key, nested]) => [key, canonicalize(nested, stripNullish)]));
|
|
857
957
|
return value;
|
|
858
958
|
};
|
|
959
|
+
/**
|
|
960
|
+
* Collapse bindings that share the same `sid`, keeping the last occurrence.
|
|
961
|
+
*
|
|
962
|
+
* The same binding can be recorded more than once on a target resource — e.g.
|
|
963
|
+
* a KV namespace bound to both a Worker and a Workflow ends up pushed twice to
|
|
964
|
+
* `stack.bindings[fqn]`. `diffBindings` already collapses these implicitly via
|
|
965
|
+
* its `Map` keyed by `sid`, so the `reconcile` path never observes duplicates.
|
|
966
|
+
* Use this helper to give a provider's `diff` handler the same de-duplicated
|
|
967
|
+
* binding set, keeping plan-time hashing consistent with deploy-time.
|
|
968
|
+
*/
|
|
969
|
+
const dedupeBindings = (bindings) => Array.from(new Map(bindings.map((b) => [b.sid, b])).values());
|
|
859
970
|
const diffBindings = (oldBindings, newBindings) => {
|
|
860
971
|
const oldMap = new Map(oldBindings.map((b) => [b.sid, b]));
|
|
861
972
|
const newMap = new Map(newBindings.map((b) => [b.sid, b]));
|
|
@@ -888,7 +999,7 @@ const generateInstanceId = () => Effect.sync(() => {
|
|
|
888
999
|
|
|
889
1000
|
//#endregion
|
|
890
1001
|
//#region lib/Util/types.js
|
|
891
|
-
const asEffect = (effect) => Effect.isEffect(effect) ? effect : Effect.succeed(effect);
|
|
1002
|
+
const asEffect = (effect) => typeof effect?.asEffect === "function" ? effect.asEffect() : Effect.isEffect(effect) ? effect : Effect.succeed(effect);
|
|
892
1003
|
|
|
893
1004
|
//#endregion
|
|
894
1005
|
//#region lib/Telemetry/Metrics.js
|
|
@@ -1096,7 +1207,7 @@ const make = (stack, options = {}) => Effect.gen(function* () {
|
|
|
1096
1207
|
if (!oldState || oldState.status === "creating") return resourceExpr;
|
|
1097
1208
|
const oldProps = oldState.status === "updating" ? oldState.old.props : oldState.props;
|
|
1098
1209
|
const oldBindings = oldState.bindings ?? [];
|
|
1099
|
-
const newBindings = stack.bindings[resource.FQN] ?? [];
|
|
1210
|
+
const newBindings = dedupeBindings(stack.bindings[resource.FQN] ?? []);
|
|
1100
1211
|
const diff = yield* provider.diff ? provider.diff({
|
|
1101
1212
|
id: resource.LogicalId,
|
|
1102
1213
|
olds: oldProps,
|
|
@@ -1120,6 +1231,7 @@ const make = (stack, options = {}) => Effect.gen(function* () {
|
|
|
1120
1231
|
if (!input) return input;
|
|
1121
1232
|
else if (isExpr(input)) return yield* resolveOutput(input);
|
|
1122
1233
|
else if (Redacted.isRedacted(input)) return input;
|
|
1234
|
+
else if (Duration.isDuration(input)) return input;
|
|
1123
1235
|
else if (Array.isArray(input)) return yield* Effect.all(input.map(resolveInput), { concurrency: "unbounded" });
|
|
1124
1236
|
else if (isResource(input)) return yield* resolveInput(yield* resolveOutput(of(input)));
|
|
1125
1237
|
else if (typeof input === "object") return Object.fromEntries(yield* Effect.all(Object.entries(input).map(([key, value]) => resolveInput(value).pipe(Effect.map((value$1) => [key, value$1]))), { concurrency: "unbounded" }));
|
|
@@ -1212,7 +1324,7 @@ const make = (stack, options = {}) => Effect.gen(function* () {
|
|
|
1212
1324
|
const fqn = resource.FQN;
|
|
1213
1325
|
const news = yield* resolveInput(resource.Props);
|
|
1214
1326
|
const downstream = newDownstreamDependencies[fqn] ?? [];
|
|
1215
|
-
const newBindings = yield* resolveInput(stack.bindings[fqn] ?? []);
|
|
1327
|
+
const newBindings = dedupeBindings(yield* resolveInput(stack.bindings[fqn] ?? []));
|
|
1216
1328
|
const persisted = yield* state.get({
|
|
1217
1329
|
stack: stackName,
|
|
1218
1330
|
stage: stage$1,
|
|
@@ -1621,7 +1733,7 @@ const executePlan = Effect.fnUntraced(function* (plan, tracker, terminalStatuses
|
|
|
1621
1733
|
const ready = Object.fromEntries(yield* Effect.all(Object.keys(allNodes).map((fqn) => Effect.map(Deferred.make(), (d) => [fqn, d]))));
|
|
1622
1734
|
const readyStable = Object.fromEntries(yield* Effect.all(Object.keys(allNodes).map((fqn) => Effect.map(Deferred.make(), (d) => [fqn, d]))));
|
|
1623
1735
|
const getOutputs = () => Object.fromEntries(Object.entries(tracker).map(([fqn, t]) => [fqn, t.output]));
|
|
1624
|
-
const waitForDeps = (fqns) => Effect.all(fqns.filter((fqn) => fqn in ready).map((fqn) => Deferred.await(ready[fqn])), { concurrency: "unbounded" });
|
|
1736
|
+
const waitForDeps = (fqns) => Effect.all(fqns.filter((fqn) => fqn in ready).map((fqn) => plan.cycleMembers.has(fqn) ? Deferred.await(ready[fqn]) : Deferred.await(readyStable[fqn])), { concurrency: "unbounded" });
|
|
1625
1737
|
const waitForStableDeps = (fqns) => Effect.all(fqns.filter((fqn) => fqn in readyStable).map((fqn) => Deferred.await(readyStable[fqn])), { concurrency: "unbounded" });
|
|
1626
1738
|
const failures = [];
|
|
1627
1739
|
yield* Effect.all(Object.entries(allNodes).map(([fqn, node]) => node.kind === "action" ? executeActionNode(fqn, node, tracker, ready, readyStable, terminalStatuses, session, state, stackName, stage$1, getOutputs, waitForStableDeps, failures) : executeNode(fqn, node, tracker, ready, readyStable, terminalStatuses, session, state, stackName, stage$1, getOutputs, waitForDeps, failures, plan.cycleMembers.has(fqn))), { concurrency: "unbounded" });
|
|
@@ -2420,7 +2532,7 @@ var __rewriteRelativeImportExtension = void 0 && (void 0).__rewriteRelativeImpor
|
|
|
2420
2532
|
};
|
|
2421
2533
|
const USER = Config.string("USER").pipe(Config.orElse(() => Config.string("USERNAME")), Config.withDefault("unknown"));
|
|
2422
2534
|
const STAGE = Config.string("stage").pipe(Config.option, (a) => a, Effect.map(Option.getOrUndefined));
|
|
2423
|
-
const stage = Flag.string("stage").pipe(Flag.withSchema(
|
|
2535
|
+
const stage = Flag.string("stage").pipe(Flag.withSchema(Schema.String.check(Schema.isPattern(/^[a-z0-9]+([-_a-z0-9]+)*$/gi))), Flag.withDescription("Stage to deploy to, defaults to dev_${USER}"), Flag.optional, Flag.map(Option.getOrUndefined), Flag.mapEffect(Effect.fn(function* (stage$1) {
|
|
2424
2536
|
if (stage$1) return stage$1;
|
|
2425
2537
|
return yield* STAGE.pipe(Effect.catch(() => Effect.fail(new CliError.MissingOption({ option: "stage" }))), Effect.flatMap((s) => s === void 0 ? USER.pipe(Effect.map((user) => `dev_${user}`), Effect.catch(() => Effect.succeed("unknown"))) : Effect.succeed(s)));
|
|
2426
2538
|
})));
|
|
@@ -2451,26 +2563,55 @@ const resourceFilter = Flag.string("filter").pipe(Flag.withDescription("Comma-se
|
|
|
2451
2563
|
* ```
|
|
2452
2564
|
*/
|
|
2453
2565
|
const instrumentCommand = (command, attrs) => (handler) => (args) => handler(args).pipe(Effect.withSpan(`cli.${command}`, { attributes: attrs ? attrs(args) : {} }), recordCli(command));
|
|
2566
|
+
/**
|
|
2567
|
+
* Render a profile's stored credential entries the same way across
|
|
2568
|
+
* `alchemy login` and `alchemy profile show`: one `── Provider ──`
|
|
2569
|
+
* header per entry, then either the provider's own `prettyPrint` block
|
|
2570
|
+
* (preferred) or a JSON-style fallback when the provider isn't
|
|
2571
|
+
* registered in the supplied {@link AuthProviders} registry.
|
|
2572
|
+
*/
|
|
2573
|
+
const printProfile = Effect.fn(function* (profile$1, stored, registry) {
|
|
2574
|
+
yield* Console.log(`Profile: ${profile$1}`);
|
|
2575
|
+
const names = Object.keys(stored).sort();
|
|
2576
|
+
if (names.length === 0) {
|
|
2577
|
+
yield* Console.log("(no providers configured)");
|
|
2578
|
+
return;
|
|
2579
|
+
}
|
|
2580
|
+
for (const name of names) {
|
|
2581
|
+
const cfg = stored[name];
|
|
2582
|
+
yield* Console.log("");
|
|
2583
|
+
yield* Console.log(`── ${name} ──`);
|
|
2584
|
+
const provider = registry[name];
|
|
2585
|
+
if (provider == null) {
|
|
2586
|
+
yield* Console.log(` method: ${cfg.method}`);
|
|
2587
|
+
const { method: _method,...rest } = cfg;
|
|
2588
|
+
for (const [k, v] of Object.entries(rest)) yield* Console.log(` ${k}: ${typeof v === "string" ? v : JSON.stringify(v)}`);
|
|
2589
|
+
continue;
|
|
2590
|
+
}
|
|
2591
|
+
yield* provider.prettyPrint(profile$1, cfg);
|
|
2592
|
+
}
|
|
2593
|
+
});
|
|
2454
2594
|
const importStack = Effect.fn(function* (main) {
|
|
2455
2595
|
const path$1 = yield* Path$1.Path;
|
|
2456
|
-
const
|
|
2596
|
+
const url = import.meta.resolve(path$1.resolve(main));
|
|
2597
|
+
const stackEffect = (yield* Effect.promise(() => import(__rewriteRelativeImportExtension(url)))).default;
|
|
2457
2598
|
if (!Effect.isEffect(stackEffect)) return yield* Effect.die(/* @__PURE__ */ new Error(`Main file '${main}' must export a default stack definition (export default Alchemy.Stack({...}))`));
|
|
2458
2599
|
return stackEffect;
|
|
2459
2600
|
});
|
|
2460
2601
|
|
|
2461
2602
|
//#endregion
|
|
2462
2603
|
//#region lib/Cli/commands/deploy.js
|
|
2463
|
-
const ExecStackOptions =
|
|
2464
|
-
main:
|
|
2465
|
-
stage:
|
|
2466
|
-
envFile:
|
|
2467
|
-
profile:
|
|
2468
|
-
dryRun:
|
|
2469
|
-
force:
|
|
2470
|
-
yes:
|
|
2471
|
-
destroy:
|
|
2472
|
-
dev:
|
|
2473
|
-
adopt:
|
|
2604
|
+
const ExecStackOptions = Schema.Struct({
|
|
2605
|
+
main: Schema.String,
|
|
2606
|
+
stage: Schema.String,
|
|
2607
|
+
envFile: Schema.OptionFromOptional(Schema.String),
|
|
2608
|
+
profile: Schema.optional(Schema.String),
|
|
2609
|
+
dryRun: Schema.optional(Schema.Boolean),
|
|
2610
|
+
force: Schema.optional(Schema.Boolean),
|
|
2611
|
+
yes: Schema.optional(Schema.Boolean),
|
|
2612
|
+
destroy: Schema.optional(Schema.Boolean),
|
|
2613
|
+
dev: Schema.optional(Schema.Boolean),
|
|
2614
|
+
adopt: Schema.optional(Schema.Boolean)
|
|
2474
2615
|
});
|
|
2475
2616
|
const stackSpanAttrs = (args) => ({
|
|
2476
2617
|
"alchemy.stage": args.stage,
|
|
@@ -3341,8 +3482,8 @@ const selectCli = () => isNonInteractive() ? LoggingCli : inkCLI();
|
|
|
3341
3482
|
|
|
3342
3483
|
//#endregion
|
|
3343
3484
|
//#region lib/Cli/exec.js
|
|
3344
|
-
const services = Layer.
|
|
3345
|
-
const exec = () => execStack(
|
|
3485
|
+
const services = Layer.merge(selectCli(), fromEnv()).pipe(Layer.provideMerge(Layer.mergeAll(AlchemyContextLive, ProfileLive, CredentialsStoreLive)), Layer.provideMerge(Layer.mergeAll(PlatformServices, FetchHttpClient.layer, ConfigProvider.layer(ConfigProvider.fromEnv()))));
|
|
3486
|
+
const exec = () => execStack(Schema.decodeSync(ExecStackOptions)(JSON.parse(process.env.ALCHEMY_EXEC_OPTIONS))).pipe(Effect.provide(services), Effect.scoped);
|
|
3346
3487
|
|
|
3347
3488
|
//#endregion
|
|
3348
3489
|
//#region bin/exec.ts
|