@alchemy.run/modal 0.0.0 → 2.0.0-beta.86
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/LICENSE +201 -0
- package/README.md +96 -4
- package/lib/App.d.ts +143 -0
- package/lib/App.d.ts.map +1 -0
- package/lib/App.js +198 -0
- package/lib/App.js.map +1 -0
- package/lib/AuthProvider.d.ts +53 -0
- package/lib/AuthProvider.d.ts.map +1 -0
- package/lib/AuthProvider.js +209 -0
- package/lib/AuthProvider.js.map +1 -0
- package/lib/BindingHttp.d.ts +56 -0
- package/lib/BindingHttp.d.ts.map +1 -0
- package/lib/BindingHttp.js +50 -0
- package/lib/BindingHttp.js.map +1 -0
- package/lib/Blob.d.ts +34 -0
- package/lib/Blob.d.ts.map +1 -0
- package/lib/Blob.js +59 -0
- package/lib/Blob.js.map +1 -0
- package/lib/Bootstrap.d.ts +8 -0
- package/lib/Bootstrap.d.ts.map +1 -0
- package/lib/Bootstrap.js +26 -0
- package/lib/Bootstrap.js.map +1 -0
- package/lib/Cbor.d.ts +10 -0
- package/lib/Cbor.d.ts.map +1 -0
- package/lib/Cbor.js +177 -0
- package/lib/Cbor.js.map +1 -0
- package/lib/ConnectSandbox.d.ts +64 -0
- package/lib/ConnectSandbox.d.ts.map +1 -0
- package/lib/ConnectSandbox.js +33 -0
- package/lib/ConnectSandbox.js.map +1 -0
- package/lib/Container.d.ts +124 -0
- package/lib/Container.d.ts.map +1 -0
- package/lib/Container.js +1 -0
- package/lib/Container.js.map +1 -0
- package/lib/Contributions.d.ts +7 -0
- package/lib/Contributions.d.ts.map +1 -0
- package/lib/Contributions.js +6 -0
- package/lib/Contributions.js.map +1 -0
- package/lib/CreateDict.d.ts +83 -0
- package/lib/CreateDict.d.ts.map +1 -0
- package/lib/CreateDict.js +3 -0
- package/lib/CreateDict.js.map +1 -0
- package/lib/CreateDictHttp.d.ts +33 -0
- package/lib/CreateDictHttp.d.ts.map +1 -0
- package/lib/CreateDictHttp.js +67 -0
- package/lib/CreateDictHttp.js.map +1 -0
- package/lib/CreateImage.d.ts +98 -0
- package/lib/CreateImage.d.ts.map +1 -0
- package/lib/CreateImage.js +3 -0
- package/lib/CreateImage.js.map +1 -0
- package/lib/CreateImageHttp.d.ts +51 -0
- package/lib/CreateImageHttp.d.ts.map +1 -0
- package/lib/CreateImageHttp.js +87 -0
- package/lib/CreateImageHttp.js.map +1 -0
- package/lib/CreateQueue.d.ts +83 -0
- package/lib/CreateQueue.d.ts.map +1 -0
- package/lib/CreateQueue.js +3 -0
- package/lib/CreateQueue.js.map +1 -0
- package/lib/CreateQueueHttp.d.ts +31 -0
- package/lib/CreateQueueHttp.d.ts.map +1 -0
- package/lib/CreateQueueHttp.js +67 -0
- package/lib/CreateQueueHttp.js.map +1 -0
- package/lib/CreateSandbox.d.ts +186 -0
- package/lib/CreateSandbox.d.ts.map +1 -0
- package/lib/CreateSandbox.js +3 -0
- package/lib/CreateSandbox.js.map +1 -0
- package/lib/CreateSandboxHttp.d.ts +17 -0
- package/lib/CreateSandboxHttp.d.ts.map +1 -0
- package/lib/CreateSandboxHttp.js +117 -0
- package/lib/CreateSandboxHttp.js.map +1 -0
- package/lib/CreateSecret.d.ts +95 -0
- package/lib/CreateSecret.d.ts.map +1 -0
- package/lib/CreateSecret.js +3 -0
- package/lib/CreateSecret.js.map +1 -0
- package/lib/CreateSecretHttp.d.ts +24 -0
- package/lib/CreateSecretHttp.d.ts.map +1 -0
- package/lib/CreateSecretHttp.js +60 -0
- package/lib/CreateSecretHttp.js.map +1 -0
- package/lib/CreateVolume.d.ts +84 -0
- package/lib/CreateVolume.d.ts.map +1 -0
- package/lib/CreateVolume.js +3 -0
- package/lib/CreateVolume.js.map +1 -0
- package/lib/CreateVolumeHttp.d.ts +32 -0
- package/lib/CreateVolumeHttp.d.ts.map +1 -0
- package/lib/CreateVolumeHttp.js +69 -0
- package/lib/CreateVolumeHttp.js.map +1 -0
- package/lib/Credentials.d.ts +32 -0
- package/lib/Credentials.d.ts.map +1 -0
- package/lib/Credentials.js +44 -0
- package/lib/Credentials.js.map +1 -0
- package/lib/Dict.d.ts +147 -0
- package/lib/Dict.d.ts.map +1 -0
- package/lib/Dict.js +175 -0
- package/lib/Dict.js.map +1 -0
- package/lib/DictClient.d.ts +55 -0
- package/lib/DictClient.d.ts.map +1 -0
- package/lib/DictClient.js +89 -0
- package/lib/DictClient.js.map +1 -0
- package/lib/Domain.d.ts +86 -0
- package/lib/Domain.d.ts.map +1 -0
- package/lib/Domain.js +113 -0
- package/lib/Domain.js.map +1 -0
- package/lib/Endpoint.d.ts +181 -0
- package/lib/Endpoint.d.ts.map +1 -0
- package/lib/Endpoint.js +283 -0
- package/lib/Endpoint.js.map +1 -0
- package/lib/Environment.d.ts +174 -0
- package/lib/Environment.d.ts.map +1 -0
- package/lib/Environment.js +244 -0
- package/lib/Environment.js.map +1 -0
- package/lib/FetchServer.d.ts +105 -0
- package/lib/FetchServer.d.ts.map +1 -0
- package/lib/FetchServer.js +3 -0
- package/lib/FetchServer.js.map +1 -0
- package/lib/FetchServerHttp.d.ts +21 -0
- package/lib/FetchServerHttp.d.ts.map +1 -0
- package/lib/FetchServerHttp.js +84 -0
- package/lib/FetchServerHttp.js.map +1 -0
- package/lib/Function.d.ts +236 -0
- package/lib/Function.d.ts.map +1 -0
- package/lib/Function.js +273 -0
- package/lib/Function.js.map +1 -0
- package/lib/FunctionAutoscaler.d.ts +99 -0
- package/lib/FunctionAutoscaler.d.ts.map +1 -0
- package/lib/FunctionAutoscaler.js +136 -0
- package/lib/FunctionAutoscaler.js.map +1 -0
- package/lib/FunctionTarget.d.ts +61 -0
- package/lib/FunctionTarget.d.ts.map +1 -0
- package/lib/FunctionTarget.js +136 -0
- package/lib/FunctionTarget.js.map +1 -0
- package/lib/Image.d.ts +159 -0
- package/lib/Image.d.ts.map +1 -0
- package/lib/Image.js +203 -0
- package/lib/Image.js.map +1 -0
- package/lib/ImageBuild.d.ts +108 -0
- package/lib/ImageBuild.d.ts.map +1 -0
- package/lib/ImageBuild.js +157 -0
- package/lib/ImageBuild.js.map +1 -0
- package/lib/ImagePlan.d.ts +31 -0
- package/lib/ImagePlan.d.ts.map +1 -0
- package/lib/ImagePlan.js +70 -0
- package/lib/ImagePlan.js.map +1 -0
- package/lib/InferEnv.d.ts +26 -0
- package/lib/InferEnv.d.ts.map +1 -0
- package/lib/InferEnv.js +1 -0
- package/lib/InferEnv.js.map +1 -0
- package/lib/InvokeFunction.d.ts +186 -0
- package/lib/InvokeFunction.d.ts.map +1 -0
- package/lib/InvokeFunction.js +10 -0
- package/lib/InvokeFunction.js.map +1 -0
- package/lib/InvokeFunctionHttp.d.ts +39 -0
- package/lib/InvokeFunctionHttp.d.ts.map +1 -0
- package/lib/InvokeFunctionHttp.js +210 -0
- package/lib/InvokeFunctionHttp.js.map +1 -0
- package/lib/ModalBindings.d.ts +138 -0
- package/lib/ModalBindings.d.ts.map +1 -0
- package/lib/ModalBindings.js +223 -0
- package/lib/ModalBindings.js.map +1 -0
- package/lib/MountBucket.d.ts +80 -0
- package/lib/MountBucket.d.ts.map +1 -0
- package/lib/MountBucket.js +44 -0
- package/lib/MountBucket.js.map +1 -0
- package/lib/MountVolume.d.ts +77 -0
- package/lib/MountVolume.d.ts.map +1 -0
- package/lib/MountVolume.js +41 -0
- package/lib/MountVolume.js.map +1 -0
- package/lib/Mounts.d.ts +134 -0
- package/lib/Mounts.d.ts.map +1 -0
- package/lib/Mounts.js +87 -0
- package/lib/Mounts.js.map +1 -0
- package/lib/PersistentSandbox.d.ts +75 -0
- package/lib/PersistentSandbox.d.ts.map +1 -0
- package/lib/PersistentSandbox.js +93 -0
- package/lib/PersistentSandbox.js.map +1 -0
- package/lib/Providers.d.ts +23 -0
- package/lib/Providers.d.ts.map +1 -0
- package/lib/Providers.js +64 -0
- package/lib/Providers.js.map +1 -0
- package/lib/Proxy.d.ts +94 -0
- package/lib/Proxy.d.ts.map +1 -0
- package/lib/Proxy.js +132 -0
- package/lib/Proxy.js.map +1 -0
- package/lib/Queue.d.ts +147 -0
- package/lib/Queue.d.ts.map +1 -0
- package/lib/Queue.js +177 -0
- package/lib/Queue.js.map +1 -0
- package/lib/QueueClient.d.ts +64 -0
- package/lib/QueueClient.d.ts.map +1 -0
- package/lib/QueueClient.js +73 -0
- package/lib/QueueClient.js.map +1 -0
- package/lib/ReadApp.d.ts +85 -0
- package/lib/ReadApp.d.ts.map +1 -0
- package/lib/ReadApp.js +3 -0
- package/lib/ReadApp.js.map +1 -0
- package/lib/ReadAppHttp.d.ts +26 -0
- package/lib/ReadAppHttp.d.ts.map +1 -0
- package/lib/ReadAppHttp.js +106 -0
- package/lib/ReadAppHttp.js.map +1 -0
- package/lib/ReadDict.d.ts +39 -0
- package/lib/ReadDict.d.ts.map +1 -0
- package/lib/ReadDict.js +3 -0
- package/lib/ReadDict.js.map +1 -0
- package/lib/ReadDictHttp.d.ts +12 -0
- package/lib/ReadDictHttp.d.ts.map +1 -0
- package/lib/ReadDictHttp.js +23 -0
- package/lib/ReadDictHttp.js.map +1 -0
- package/lib/ReadFunction.d.ts +73 -0
- package/lib/ReadFunction.d.ts.map +1 -0
- package/lib/ReadFunction.js +3 -0
- package/lib/ReadFunction.js.map +1 -0
- package/lib/ReadFunctionHttp.d.ts +25 -0
- package/lib/ReadFunctionHttp.d.ts.map +1 -0
- package/lib/ReadFunctionHttp.js +63 -0
- package/lib/ReadFunctionHttp.js.map +1 -0
- package/lib/ReadQueue.d.ts +39 -0
- package/lib/ReadQueue.d.ts.map +1 -0
- package/lib/ReadQueue.js +3 -0
- package/lib/ReadQueue.js.map +1 -0
- package/lib/ReadQueueHttp.d.ts +12 -0
- package/lib/ReadQueueHttp.d.ts.map +1 -0
- package/lib/ReadQueueHttp.js +23 -0
- package/lib/ReadQueueHttp.js.map +1 -0
- package/lib/ReadServer.d.ts +72 -0
- package/lib/ReadServer.d.ts.map +1 -0
- package/lib/ReadServer.js +3 -0
- package/lib/ReadServer.js.map +1 -0
- package/lib/ReadServerHttp.d.ts +25 -0
- package/lib/ReadServerHttp.d.ts.map +1 -0
- package/lib/ReadServerHttp.js +70 -0
- package/lib/ReadServerHttp.js.map +1 -0
- package/lib/ReadVolume.d.ts +40 -0
- package/lib/ReadVolume.d.ts.map +1 -0
- package/lib/ReadVolume.js +3 -0
- package/lib/ReadVolume.js.map +1 -0
- package/lib/ReadVolumeHttp.d.ts +12 -0
- package/lib/ReadVolumeHttp.d.ts.map +1 -0
- package/lib/ReadVolumeHttp.js +24 -0
- package/lib/ReadVolumeHttp.js.map +1 -0
- package/lib/ReadWriteDict.d.ts +39 -0
- package/lib/ReadWriteDict.d.ts.map +1 -0
- package/lib/ReadWriteDict.js +3 -0
- package/lib/ReadWriteDict.js.map +1 -0
- package/lib/ReadWriteDictHttp.d.ts +12 -0
- package/lib/ReadWriteDictHttp.d.ts.map +1 -0
- package/lib/ReadWriteDictHttp.js +23 -0
- package/lib/ReadWriteDictHttp.js.map +1 -0
- package/lib/ReadWriteQueue.d.ts +40 -0
- package/lib/ReadWriteQueue.d.ts.map +1 -0
- package/lib/ReadWriteQueue.js +3 -0
- package/lib/ReadWriteQueue.js.map +1 -0
- package/lib/ReadWriteQueueHttp.d.ts +12 -0
- package/lib/ReadWriteQueueHttp.d.ts.map +1 -0
- package/lib/ReadWriteQueueHttp.js +23 -0
- package/lib/ReadWriteQueueHttp.js.map +1 -0
- package/lib/ReadWriteVolume.d.ts +40 -0
- package/lib/ReadWriteVolume.d.ts.map +1 -0
- package/lib/ReadWriteVolume.js +3 -0
- package/lib/ReadWriteVolume.js.map +1 -0
- package/lib/ReadWriteVolumeHttp.d.ts +12 -0
- package/lib/ReadWriteVolumeHttp.d.ts.map +1 -0
- package/lib/ReadWriteVolumeHttp.js +24 -0
- package/lib/ReadWriteVolumeHttp.js.map +1 -0
- package/lib/RuntimeOwner.d.ts +39 -0
- package/lib/RuntimeOwner.d.ts.map +1 -0
- package/lib/RuntimeOwner.js +85 -0
- package/lib/RuntimeOwner.js.map +1 -0
- package/lib/Sandbox.d.ts +215 -0
- package/lib/Sandbox.d.ts.map +1 -0
- package/lib/Sandbox.js +278 -0
- package/lib/Sandbox.js.map +1 -0
- package/lib/SandboxClient.d.ts +748 -0
- package/lib/SandboxClient.d.ts.map +1 -0
- package/lib/SandboxClient.js +710 -0
- package/lib/SandboxClient.js.map +1 -0
- package/lib/ScaleFunction.d.ts +54 -0
- package/lib/ScaleFunction.d.ts.map +1 -0
- package/lib/ScaleFunction.js +3 -0
- package/lib/ScaleFunction.js.map +1 -0
- package/lib/ScaleFunctionHttp.d.ts +21 -0
- package/lib/ScaleFunctionHttp.d.ts.map +1 -0
- package/lib/ScaleFunctionHttp.js +39 -0
- package/lib/ScaleFunctionHttp.js.map +1 -0
- package/lib/Secret.d.ts +170 -0
- package/lib/Secret.d.ts.map +1 -0
- package/lib/Secret.js +196 -0
- package/lib/Secret.js.map +1 -0
- package/lib/Server.d.ts +155 -0
- package/lib/Server.d.ts.map +1 -0
- package/lib/Server.js +184 -0
- package/lib/Server.js.map +1 -0
- package/lib/ServiceUser.d.ts +139 -0
- package/lib/ServiceUser.d.ts.map +1 -0
- package/lib/ServiceUser.js +210 -0
- package/lib/ServiceUser.js.map +1 -0
- package/lib/Volume.d.ts +170 -0
- package/lib/Volume.d.ts.map +1 -0
- package/lib/Volume.js +220 -0
- package/lib/Volume.js.map +1 -0
- package/lib/VolumeClient.d.ts +53 -0
- package/lib/VolumeClient.d.ts.map +1 -0
- package/lib/VolumeClient.js +22 -0
- package/lib/VolumeClient.js.map +1 -0
- package/lib/VolumeFiles.d.ts +94 -0
- package/lib/VolumeFiles.d.ts.map +1 -0
- package/lib/VolumeFiles.js +139 -0
- package/lib/VolumeFiles.js.map +1 -0
- package/lib/WebhookToken.d.ts +102 -0
- package/lib/WebhookToken.d.ts.map +1 -0
- package/lib/WebhookToken.js +176 -0
- package/lib/WebhookToken.js.map +1 -0
- package/lib/WorkspaceSettings.d.ts +70 -0
- package/lib/WorkspaceSettings.d.ts.map +1 -0
- package/lib/WorkspaceSettings.js +105 -0
- package/lib/WorkspaceSettings.js.map +1 -0
- package/lib/WriteApp.d.ts +38 -0
- package/lib/WriteApp.d.ts.map +1 -0
- package/lib/WriteApp.js +3 -0
- package/lib/WriteApp.js.map +1 -0
- package/lib/WriteAppHttp.d.ts +23 -0
- package/lib/WriteAppHttp.d.ts.map +1 -0
- package/lib/WriteAppHttp.js +36 -0
- package/lib/WriteAppHttp.js.map +1 -0
- package/lib/WriteDict.d.ts +39 -0
- package/lib/WriteDict.d.ts.map +1 -0
- package/lib/WriteDict.js +3 -0
- package/lib/WriteDict.js.map +1 -0
- package/lib/WriteDictHttp.d.ts +12 -0
- package/lib/WriteDictHttp.d.ts.map +1 -0
- package/lib/WriteDictHttp.js +23 -0
- package/lib/WriteDictHttp.js.map +1 -0
- package/lib/WriteQueue.d.ts +39 -0
- package/lib/WriteQueue.d.ts.map +1 -0
- package/lib/WriteQueue.js +3 -0
- package/lib/WriteQueue.js.map +1 -0
- package/lib/WriteQueueHttp.d.ts +12 -0
- package/lib/WriteQueueHttp.d.ts.map +1 -0
- package/lib/WriteQueueHttp.js +23 -0
- package/lib/WriteQueueHttp.js.map +1 -0
- package/lib/WriteSecret.d.ts +53 -0
- package/lib/WriteSecret.d.ts.map +1 -0
- package/lib/WriteSecret.js +3 -0
- package/lib/WriteSecret.js.map +1 -0
- package/lib/WriteSecretHttp.d.ts +23 -0
- package/lib/WriteSecretHttp.d.ts.map +1 -0
- package/lib/WriteSecretHttp.js +44 -0
- package/lib/WriteSecretHttp.js.map +1 -0
- package/lib/WriteVolume.d.ts +39 -0
- package/lib/WriteVolume.d.ts.map +1 -0
- package/lib/WriteVolume.js +3 -0
- package/lib/WriteVolume.js.map +1 -0
- package/lib/WriteVolumeHttp.d.ts +12 -0
- package/lib/WriteVolumeHttp.d.ts.map +1 -0
- package/lib/WriteVolumeHttp.js +24 -0
- package/lib/WriteVolumeHttp.js.map +1 -0
- package/lib/index.d.ts +80 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +78 -0
- package/lib/index.js.map +1 -0
- package/lib/internal/Declared.d.ts +29 -0
- package/lib/internal/Declared.d.ts.map +1 -0
- package/lib/internal/Declared.js +31 -0
- package/lib/internal/Declared.js.map +1 -0
- package/lib/internal/Deploy.d.ts +110 -0
- package/lib/internal/Deploy.d.ts.map +1 -0
- package/lib/internal/Deploy.js +230 -0
- package/lib/internal/Deploy.js.map +1 -0
- package/lib/internal/Entrypoint.d.ts +52 -0
- package/lib/internal/Entrypoint.d.ts.map +1 -0
- package/lib/internal/Entrypoint.js +193 -0
- package/lib/internal/Entrypoint.js.map +1 -0
- package/lib/internal/Rpc.d.ts +17 -0
- package/lib/internal/Rpc.d.ts.map +1 -0
- package/lib/internal/Rpc.js +49 -0
- package/lib/internal/Rpc.js.map +1 -0
- package/lib/internal/RpcAuth.d.ts +41 -0
- package/lib/internal/RpcAuth.d.ts.map +1 -0
- package/lib/internal/RpcAuth.js +100 -0
- package/lib/internal/RpcAuth.js.map +1 -0
- package/lib/internal/Runtime.d.ts +127 -0
- package/lib/internal/Runtime.d.ts.map +1 -0
- package/lib/internal/Runtime.js +246 -0
- package/lib/internal/Runtime.js.map +1 -0
- package/lib/internal/Tags.d.ts +19 -0
- package/lib/internal/Tags.d.ts.map +1 -0
- package/lib/internal/Tags.js +33 -0
- package/lib/internal/Tags.js.map +1 -0
- package/lib/internal/TcpConnect.d.ts +12 -0
- package/lib/internal/TcpConnect.d.ts.map +1 -0
- package/lib/internal/TcpConnect.js +46 -0
- package/lib/internal/TcpConnect.js.map +1 -0
- package/lib/internal/Transport.d.ts +13 -0
- package/lib/internal/Transport.d.ts.map +1 -0
- package/lib/internal/Transport.js +16 -0
- package/lib/internal/Transport.js.map +1 -0
- package/lib/internal.d.ts +71 -0
- package/lib/internal.d.ts.map +1 -0
- package/lib/internal.js +102 -0
- package/lib/internal.js.map +1 -0
- package/package.json +59 -3
- package/src/App.ts +262 -0
- package/src/AuthProvider.ts +295 -0
- package/src/BindingHttp.ts +112 -0
- package/src/Blob.ts +71 -0
- package/src/Bootstrap.ts +52 -0
- package/src/Cbor.ts +158 -0
- package/src/ConnectSandbox.ts +99 -0
- package/src/Container.ts +121 -0
- package/src/Contributions.ts +9 -0
- package/src/CreateDict.ts +95 -0
- package/src/CreateDictHttp.ts +91 -0
- package/src/CreateImage.ts +105 -0
- package/src/CreateImageHttp.ts +117 -0
- package/src/CreateQueue.ts +95 -0
- package/src/CreateQueueHttp.ts +91 -0
- package/src/CreateSandbox.ts +228 -0
- package/src/CreateSandboxHttp.ts +160 -0
- package/src/CreateSecret.ts +109 -0
- package/src/CreateSecretHttp.ts +83 -0
- package/src/CreateVolume.ts +96 -0
- package/src/CreateVolumeHttp.ts +93 -0
- package/src/Credentials.ts +74 -0
- package/src/Dict.ts +245 -0
- package/src/DictClient.ts +166 -0
- package/src/Domain.ts +147 -0
- package/src/Endpoint.ts +406 -0
- package/src/Environment.ts +373 -0
- package/src/FetchServer.ts +126 -0
- package/src/FetchServerHttp.ts +110 -0
- package/src/Function.ts +397 -0
- package/src/FunctionAutoscaler.ts +210 -0
- package/src/FunctionTarget.ts +181 -0
- package/src/Image.ts +281 -0
- package/src/ImageBuild.ts +228 -0
- package/src/ImagePlan.ts +78 -0
- package/src/InferEnv.ts +27 -0
- package/src/InvokeFunction.ts +211 -0
- package/src/InvokeFunctionHttp.ts +316 -0
- package/src/ModalBindings.ts +310 -0
- package/src/MountBucket.ts +137 -0
- package/src/MountVolume.ts +113 -0
- package/src/Mounts.ts +230 -0
- package/src/PersistentSandbox.ts +142 -0
- package/src/Providers.ts +100 -0
- package/src/Proxy.ts +191 -0
- package/src/Queue.ts +258 -0
- package/src/QueueClient.ts +149 -0
- package/src/ReadApp.ts +101 -0
- package/src/ReadAppHttp.ts +142 -0
- package/src/ReadDict.ts +44 -0
- package/src/ReadDictHttp.ts +27 -0
- package/src/ReadFunction.ts +107 -0
- package/src/ReadFunctionHttp.ts +91 -0
- package/src/ReadQueue.ts +44 -0
- package/src/ReadQueueHttp.ts +27 -0
- package/src/ReadServer.ts +98 -0
- package/src/ReadServerHttp.ts +101 -0
- package/src/ReadVolume.ts +45 -0
- package/src/ReadVolumeHttp.ts +28 -0
- package/src/ReadWriteDict.ts +44 -0
- package/src/ReadWriteDictHttp.ts +27 -0
- package/src/ReadWriteQueue.ts +45 -0
- package/src/ReadWriteQueueHttp.ts +27 -0
- package/src/ReadWriteVolume.ts +45 -0
- package/src/ReadWriteVolumeHttp.ts +28 -0
- package/src/RuntimeOwner.ts +111 -0
- package/src/Sandbox.ts +402 -0
- package/src/SandboxClient.ts +1404 -0
- package/src/ScaleFunction.ts +70 -0
- package/src/ScaleFunctionHttp.ts +54 -0
- package/src/Secret.ts +296 -0
- package/src/Server.ts +285 -0
- package/src/ServiceUser.ts +295 -0
- package/src/Volume.ts +320 -0
- package/src/VolumeClient.ts +108 -0
- package/src/VolumeFiles.ts +194 -0
- package/src/WebhookToken.ts +230 -0
- package/src/WorkspaceSettings.ts +160 -0
- package/src/WriteApp.ts +43 -0
- package/src/WriteAppHttp.ts +51 -0
- package/src/WriteDict.ts +44 -0
- package/src/WriteDictHttp.ts +27 -0
- package/src/WriteQueue.ts +44 -0
- package/src/WriteQueueHttp.ts +27 -0
- package/src/WriteSecret.ts +60 -0
- package/src/WriteSecretHttp.ts +56 -0
- package/src/WriteVolume.ts +44 -0
- package/src/WriteVolumeHttp.ts +28 -0
- package/src/globals.d.ts +2 -0
- package/src/index.ts +85 -0
- package/src/internal/Declared.ts +80 -0
- package/src/internal/Deploy.ts +309 -0
- package/src/internal/Entrypoint.ts +198 -0
- package/src/internal/Rpc.ts +59 -0
- package/src/internal/RpcAuth.ts +132 -0
- package/src/internal/Runtime.ts +386 -0
- package/src/internal/Tags.ts +44 -0
- package/src/internal/TcpConnect.ts +78 -0
- package/src/internal/Transport.ts +25 -0
- package/src/internal.ts +147 -0
package/lib/Image.js
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import * as BuildPlan from "@alchemy.run/docker/BuildPlan";
|
|
2
|
+
import * as image from "@distilled.cloud/modal/image";
|
|
3
|
+
import { isResolved } from "alchemy/Diff";
|
|
4
|
+
import * as Provider from "alchemy/Provider";
|
|
5
|
+
import { Resource } from "alchemy/Resource";
|
|
6
|
+
import { sha256Object } from "alchemy/Util/sha256";
|
|
7
|
+
import * as Data from "effect/Data";
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import { buildImage, ImageBuildOps } from "./ImageBuild.js";
|
|
10
|
+
import { checkCommands, lowerPlan, MODAL_CAPABILITIES } from "./ImagePlan.js";
|
|
11
|
+
import { declarable } from "./internal/Declared.js";
|
|
12
|
+
import { createSandbox, SandboxOps } from "./SandboxClient.js";
|
|
13
|
+
/** A `run` command of a warm-base image exited non-zero. */
|
|
14
|
+
export class ImageSetupFailed extends Data.TaggedError("Modal.ImageSetupFailed") {
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A Modal Image: a container image built by Modal's own builder (not
|
|
18
|
+
* Docker), from a registry image, a Dockerfile, or another Modal Image plus
|
|
19
|
+
* commands. Sandboxes boot from it.
|
|
20
|
+
*
|
|
21
|
+
* With `run`, the image becomes a warm base: Alchemy boots a sandbox from the
|
|
22
|
+
* built image, runs the commands, snapshots its filesystem, and terminates
|
|
23
|
+
* it. Sandboxes created from the result start with the repo cloned and
|
|
24
|
+
* dependencies installed. Runtime snapshots (`sandbox.snapshotFilesystem()`)
|
|
25
|
+
* are images too and work anywhere an image does.
|
|
26
|
+
*
|
|
27
|
+
* Modal builds remotely: deploying needs no local Docker.
|
|
28
|
+
*
|
|
29
|
+
* ### Building an Image
|
|
30
|
+
* **Example:** From a registry image with extra packages
|
|
31
|
+
* ```typescript
|
|
32
|
+
* import * as Modal from "@alchemy.run/modal";
|
|
33
|
+
*
|
|
34
|
+
* export const Coder = Modal.App("Coder", {});
|
|
35
|
+
* export const Node = Modal.Image("Node", {
|
|
36
|
+
* app: Coder,
|
|
37
|
+
* image: "node:22-bookworm",
|
|
38
|
+
* commands: ["RUN apt-get update && apt-get install -y git ripgrep"],
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* **Example:** From an inline Dockerfile
|
|
43
|
+
* ```typescript
|
|
44
|
+
* import * as Dockerfile from "@alchemy.run/docker/Dockerfile";
|
|
45
|
+
* import * as Modal from "@alchemy.run/modal";
|
|
46
|
+
*
|
|
47
|
+
* export const Coder = Modal.App("Coder", {});
|
|
48
|
+
* export const Python = Modal.Image("Python", {
|
|
49
|
+
* app: Coder,
|
|
50
|
+
* dockerfile: Dockerfile.inline`
|
|
51
|
+
* FROM python:3.12-slim
|
|
52
|
+
* RUN pip install pandas
|
|
53
|
+
* `,
|
|
54
|
+
* });
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* ### A warm base to fork from
|
|
58
|
+
* **Example:** Clone and install once, start every sandbox from it
|
|
59
|
+
* ```typescript
|
|
60
|
+
* import * as Modal from "@alchemy.run/modal";
|
|
61
|
+
*
|
|
62
|
+
* export const Coder = Modal.App("Coder", {});
|
|
63
|
+
* export const Node = Modal.Image("Node", { app: Coder, image: "node:22-bookworm" });
|
|
64
|
+
* export const Warm = Modal.Image("Warm", {
|
|
65
|
+
* app: Coder,
|
|
66
|
+
* from: Node,
|
|
67
|
+
* run: [
|
|
68
|
+
* "git clone https://github.com/alchemy-run/alchemy /work",
|
|
69
|
+
* "cd /work && corepack enable && pnpm install",
|
|
70
|
+
* ],
|
|
71
|
+
* });
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* @resource
|
|
75
|
+
* @product Image
|
|
76
|
+
*/
|
|
77
|
+
export const Image = declarable()(Resource("Modal.Image"));
|
|
78
|
+
const idOf = (value, key) => typeof value === "object" && value !== null && key in value
|
|
79
|
+
? value[key]
|
|
80
|
+
: undefined;
|
|
81
|
+
/** The build spec for an Image's props (Dockerfile lowered, context collected). */
|
|
82
|
+
/**
|
|
83
|
+
* Plan an Image's build with the shared {@link BuildPlan}: its environment
|
|
84
|
+
* (`image`, `dockerfile`/`context`, or a Modal base via `from`) checked
|
|
85
|
+
* against what Modal's builder runs, then the `commands` appended.
|
|
86
|
+
*/
|
|
87
|
+
const planOf = Effect.fn(function* (news) {
|
|
88
|
+
const fromId = idOf(news.from, "imageId");
|
|
89
|
+
const source = fromId !== undefined
|
|
90
|
+
? { dockerfile: { content: "FROM base\n" } }
|
|
91
|
+
: news.dockerfile !== undefined || news.context !== undefined
|
|
92
|
+
? { dockerfile: news.dockerfile, context: news.context }
|
|
93
|
+
: { image: news.image ?? "debian:bookworm-slim" };
|
|
94
|
+
const plan = yield* BuildPlan.plan(source, { capabilities: MODAL_CAPABILITIES });
|
|
95
|
+
const extra = yield* checkCommands(news.commands ?? []);
|
|
96
|
+
const lowered = yield* lowerPlan(plan, extra);
|
|
97
|
+
const spec = {
|
|
98
|
+
...lowered,
|
|
99
|
+
// `FROM base` names the Modal image passed as a base image.
|
|
100
|
+
...(fromId !== undefined ? { baseImageId: fromId, commands: lowered.commands.slice(1) } : {}),
|
|
101
|
+
secretIds: (news.secrets ?? []).flatMap((s) => idOf(s, "secretId") ?? []),
|
|
102
|
+
registry: news.registry
|
|
103
|
+
? { authType: news.registry.type, secretId: idOf(news.registry.secret, "secretId") ?? "" }
|
|
104
|
+
: undefined,
|
|
105
|
+
gpu: news.gpu,
|
|
106
|
+
builderVersion: news.builderVersion,
|
|
107
|
+
};
|
|
108
|
+
const hash = yield* sha256Object({
|
|
109
|
+
plan: plan.hash,
|
|
110
|
+
from: fromId,
|
|
111
|
+
extra,
|
|
112
|
+
secrets: spec.secretIds,
|
|
113
|
+
registry: spec.registry,
|
|
114
|
+
gpu: spec.gpu,
|
|
115
|
+
builder: spec.builderVersion,
|
|
116
|
+
// `tag` and `run` happen after the build; part of the hash so a change re-runs reconcile.
|
|
117
|
+
tag: news.tag,
|
|
118
|
+
run: news.run,
|
|
119
|
+
});
|
|
120
|
+
return { spec, hash, warnings: plan.warnings };
|
|
121
|
+
});
|
|
122
|
+
export const ImageProvider = () => Provider.effect(Image, Effect.gen(function* () {
|
|
123
|
+
return {
|
|
124
|
+
stables: [],
|
|
125
|
+
diff: Effect.fn(function* ({ news, output }) {
|
|
126
|
+
if (!isResolved(news) || output === undefined)
|
|
127
|
+
return undefined;
|
|
128
|
+
// A changed build input (including files under `context`) is a new image.
|
|
129
|
+
const { hash } = yield* planOf(news);
|
|
130
|
+
return hash !== output.hash ? { action: "update" } : undefined;
|
|
131
|
+
}),
|
|
132
|
+
read: Effect.fn(function* ({ output }) {
|
|
133
|
+
if (output === undefined)
|
|
134
|
+
return undefined;
|
|
135
|
+
const found = yield* image
|
|
136
|
+
.imageFromId({ imageId: output.imageId })
|
|
137
|
+
.pipe(Effect.catchTag("ImageNotFound", () => Effect.undefined));
|
|
138
|
+
return found?.imageId ? output : undefined;
|
|
139
|
+
}),
|
|
140
|
+
reconcile: Effect.fn(function* ({ news, output, session }) {
|
|
141
|
+
const appId = idOf(news.app, "appId") ?? "";
|
|
142
|
+
const { spec, hash, warnings } = yield* planOf(news);
|
|
143
|
+
for (const warning of warnings)
|
|
144
|
+
yield* session.note(warning);
|
|
145
|
+
// Observe: an image built from the same inputs still exists.
|
|
146
|
+
if (output !== undefined && output.hash === hash && output.appId === appId) {
|
|
147
|
+
const found = yield* image
|
|
148
|
+
.imageFromId({ imageId: output.imageId })
|
|
149
|
+
.pipe(Effect.catchTag("ImageNotFound", () => Effect.undefined));
|
|
150
|
+
if (found?.imageId)
|
|
151
|
+
return output;
|
|
152
|
+
}
|
|
153
|
+
// Ensure: Modal content-addresses builds, so this is a no-op for
|
|
154
|
+
// inputs it has built before.
|
|
155
|
+
let imageId = yield* buildImage(yield* ImageBuildOps, appId, spec, {
|
|
156
|
+
note: session.note,
|
|
157
|
+
});
|
|
158
|
+
// Warm base: run setup in a sandbox and snapshot its filesystem.
|
|
159
|
+
if (news.run && news.run.length > 0) {
|
|
160
|
+
yield* session.note(`Running setup for image ${imageId}...`);
|
|
161
|
+
const box = yield* createSandbox(yield* SandboxOps, { appId }, {
|
|
162
|
+
image: { imageId },
|
|
163
|
+
secrets: spec.secretIds?.map((secretId) => ({ secretId })),
|
|
164
|
+
timeout: "1 hour",
|
|
165
|
+
});
|
|
166
|
+
const snapshot = yield* Effect.gen(function* () {
|
|
167
|
+
for (const command of news.run ?? []) {
|
|
168
|
+
const result = yield* box.exec(["sh", "-lc", command]);
|
|
169
|
+
if (result.exitCode !== 0) {
|
|
170
|
+
return yield* new ImageSetupFailed({
|
|
171
|
+
command,
|
|
172
|
+
exitCode: result.exitCode,
|
|
173
|
+
message: `\`${command}\` exited ${result.exitCode}: ${result.stderr.slice(-2000)}`,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return yield* box.snapshotFilesystem("5 minutes");
|
|
178
|
+
}).pipe(Effect.ensuring(Effect.ignore(box.terminate())));
|
|
179
|
+
imageId = snapshot.imageId;
|
|
180
|
+
}
|
|
181
|
+
if (news.tag !== undefined) {
|
|
182
|
+
yield* image.publishImage({
|
|
183
|
+
imageId,
|
|
184
|
+
tag: news.tag,
|
|
185
|
+
environmentName: idOf(news.app, "environment") ?? "",
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
return {
|
|
189
|
+
imageId,
|
|
190
|
+
appId,
|
|
191
|
+
appName: idOf(news.app, "name"),
|
|
192
|
+
environment: idOf(news.app, "environment"),
|
|
193
|
+
hash,
|
|
194
|
+
};
|
|
195
|
+
}),
|
|
196
|
+
delete: Effect.fn(function* ({ output }) {
|
|
197
|
+
yield* image
|
|
198
|
+
.deleteImage({ imageId: output.imageId })
|
|
199
|
+
.pipe(Effect.catchTag("ImageNotFound", () => Effect.void));
|
|
200
|
+
}),
|
|
201
|
+
};
|
|
202
|
+
}));
|
|
203
|
+
//# sourceMappingURL=Image.js.map
|
package/lib/Image.js.map
ADDED
|
@@ -0,0 +1 @@
|
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C,eAAe,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QAC/D,CAAC,CAAC;KACH,CAAC;AACJ,CAAC,CAAC,CACH,CAAC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import * as image from "@distilled.cloud/modal/image";
|
|
2
|
+
import * as mount from "@distilled.cloud/modal/mount";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
declare const ImageBuildFailed_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
5
|
+
readonly _tag: "Modal.ImageBuildFailed";
|
|
6
|
+
} & Readonly<A>;
|
|
7
|
+
/** Modal's builder finished the image build with a failure. */
|
|
8
|
+
export declare class ImageBuildFailed extends ImageBuildFailed_base<{
|
|
9
|
+
readonly imageId: string;
|
|
10
|
+
readonly status: string;
|
|
11
|
+
readonly message: string;
|
|
12
|
+
/** The last lines the build printed. */
|
|
13
|
+
readonly logs: string;
|
|
14
|
+
}> {
|
|
15
|
+
}
|
|
16
|
+
declare const ImageBuildTimeout_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
17
|
+
readonly _tag: "Modal.ImageBuildTimeout";
|
|
18
|
+
} & Readonly<A>;
|
|
19
|
+
/** The build didn't finish within its time budget. */
|
|
20
|
+
export declare class ImageBuildTimeout extends ImageBuildTimeout_base<{
|
|
21
|
+
readonly imageId: string;
|
|
22
|
+
readonly message: string;
|
|
23
|
+
}> {
|
|
24
|
+
}
|
|
25
|
+
/** What an image is built from, after Dockerfile lowering. */
|
|
26
|
+
export interface ImageBuildSpec {
|
|
27
|
+
/** A registry image to start from (`FROM <ref>`). */
|
|
28
|
+
readonly dockerTag?: string;
|
|
29
|
+
/** A Modal image to start from. */
|
|
30
|
+
readonly baseImageId?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Dockerfile commands. With `dockerTag`/`baseImageId` they follow the
|
|
33
|
+
* generated `FROM`; otherwise they are a whole Dockerfile.
|
|
34
|
+
*/
|
|
35
|
+
readonly commands: ReadonlyArray<string>;
|
|
36
|
+
/**
|
|
37
|
+
* Files the commands `COPY`, by context-relative path. They are uploaded
|
|
38
|
+
* as a mount owned by the app, so their size isn't limited by Modal's
|
|
39
|
+
* 2 MB cap on an image definition.
|
|
40
|
+
*/
|
|
41
|
+
readonly contextFiles?: ReadonlyArray<{
|
|
42
|
+
readonly filename: string;
|
|
43
|
+
readonly data: Uint8Array;
|
|
44
|
+
/** Permission bits. @default 0o644 */
|
|
45
|
+
readonly mode?: number;
|
|
46
|
+
}>;
|
|
47
|
+
/**
|
|
48
|
+
* A mount whose files the commands `COPY` (e.g. Modal's standalone
|
|
49
|
+
* Python). Not combined with {@link contextFiles}.
|
|
50
|
+
*/
|
|
51
|
+
readonly contextMountId?: string;
|
|
52
|
+
/** Build arguments (`ARG` values). */
|
|
53
|
+
readonly buildArgs?: Readonly<Record<string, string>>;
|
|
54
|
+
/** Secrets (ids) the build steps see as environment variables. */
|
|
55
|
+
readonly secretIds?: ReadonlyArray<string>;
|
|
56
|
+
/** Credentials to pull a private base image. */
|
|
57
|
+
readonly registry?: {
|
|
58
|
+
readonly authType: "aws" | "gcp" | "static";
|
|
59
|
+
readonly secretId: string;
|
|
60
|
+
};
|
|
61
|
+
/** Run the build on a GPU (`"A10G"`, `"H100"`, ...). */
|
|
62
|
+
readonly gpu?: string;
|
|
63
|
+
readonly builderVersion?: string;
|
|
64
|
+
readonly forceBuild?: boolean;
|
|
65
|
+
}
|
|
66
|
+
/** A `"A100-80GB:2"`-style GPU spec as Modal's `GPUConfig`. */
|
|
67
|
+
export declare const gpuConfig: (gpu: string | undefined) => image.GPUConfig | undefined;
|
|
68
|
+
/** The operations a build needs, resolved by `ModalBindings.withCredentials` (or at deploy). */
|
|
69
|
+
export declare const ImageBuildOps: Effect.Effect<{
|
|
70
|
+
readonly getOrCreate: (input: image.ImageGetOrCreateRequest) => Effect.Effect<image.ImageGetOrCreateResponse, image.ModalOpError, never>;
|
|
71
|
+
readonly joinStreaming: import("@distilled.cloud/core/api").StreamingCall<image.ImageJoinStreamingRequest, image.ImageJoinStreamingStream, image.ImageJoinStreamingError, never, image.ImageJoinStreamingResponse>;
|
|
72
|
+
readonly putFile: (input: mount.MountPutFileRequest) => Effect.Effect<mount.MountPutFileResponse, image.ModalOpError, never>;
|
|
73
|
+
readonly getOrCreateMount: (input: mount.MountGetOrCreateRequest) => Effect.Effect<mount.MountGetOrCreateResponse, mount.MountGetOrCreateError, never>;
|
|
74
|
+
readonly blobs: {
|
|
75
|
+
readonly create: (input: import("@distilled.cloud/modal/blob").CreateBlobRequest) => Effect.Effect<import("@distilled.cloud/modal/blob").CreateBlobResponse, image.ModalOpError, never>;
|
|
76
|
+
readonly get: (input: import("@distilled.cloud/modal/blob").GetBlobRequest) => Effect.Effect<import("@distilled.cloud/modal/blob").GetBlobResponse, image.ModalOpError, never>;
|
|
77
|
+
readonly http: import("effect/http/HttpClient").HttpClient;
|
|
78
|
+
};
|
|
79
|
+
}, never, import("./internal.ts").OperationServices>;
|
|
80
|
+
export type ImageBuildOps = Effect.Success<typeof ImageBuildOps>;
|
|
81
|
+
declare const ImageBuildUnexpectedResponse_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
82
|
+
readonly _tag: "Modal.ImageBuildUnexpectedResponse";
|
|
83
|
+
} & Readonly<A>;
|
|
84
|
+
/** Modal returned a response without a field the build needs. */
|
|
85
|
+
export declare class ImageBuildUnexpectedResponse extends ImageBuildUnexpectedResponse_base<{
|
|
86
|
+
readonly message: string;
|
|
87
|
+
}> {
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Build (or reuse) an image with Modal's builder and wait until it is ready.
|
|
91
|
+
* Modal content-addresses images, so the same spec returns the same image
|
|
92
|
+
* without rebuilding. Fails with {@link ImageBuildFailed} on a failed build.
|
|
93
|
+
*/
|
|
94
|
+
export declare const buildImage: (ops: {
|
|
95
|
+
readonly getOrCreate: (input: image.ImageGetOrCreateRequest) => Effect.Effect<image.ImageGetOrCreateResponse, image.ModalOpError, never>;
|
|
96
|
+
readonly joinStreaming: import("@distilled.cloud/core/api").StreamingCall<image.ImageJoinStreamingRequest, image.ImageJoinStreamingStream, image.ImageJoinStreamingError, never, image.ImageJoinStreamingResponse>;
|
|
97
|
+
readonly putFile: (input: mount.MountPutFileRequest) => Effect.Effect<mount.MountPutFileResponse, image.ModalOpError, never>;
|
|
98
|
+
readonly getOrCreateMount: (input: mount.MountGetOrCreateRequest) => Effect.Effect<mount.MountGetOrCreateResponse, mount.MountGetOrCreateError, never>;
|
|
99
|
+
readonly blobs: {
|
|
100
|
+
readonly create: (input: import("@distilled.cloud/modal/blob").CreateBlobRequest) => Effect.Effect<import("@distilled.cloud/modal/blob").CreateBlobResponse, image.ModalOpError, never>;
|
|
101
|
+
readonly get: (input: import("@distilled.cloud/modal/blob").GetBlobRequest) => Effect.Effect<import("@distilled.cloud/modal/blob").GetBlobResponse, image.ModalOpError, never>;
|
|
102
|
+
readonly http: import("effect/http/HttpClient").HttpClient;
|
|
103
|
+
};
|
|
104
|
+
}, appId: string, spec: ImageBuildSpec, options?: {
|
|
105
|
+
readonly note?: (message: string) => Effect.Effect<void>;
|
|
106
|
+
} | undefined) => Effect.Effect<string, import("@distilled.cloud/core/errors").BadGateway | import("./Blob.ts").BlobTransferFailed | import("@distilled.cloud/core/config").ConfigError | import("@distilled.cloud/core/errors").GatewayTimeout | import("effect/http/HttpClientError").HttpClientError | ImageBuildFailed | ImageBuildTimeout | ImageBuildUnexpectedResponse | image.ImageNotFound | import("@distilled.cloud/core/errors").InternalServerError | import("@distilled.cloud/core/protocol-http").InvalidInput | import("@distilled.cloud/modal/Errors").ModalParseError | mount.MountNotFound | import("@distilled.cloud/core/sdk-error").SdkError | import("@distilled.cloud/core/errors").ServiceUnavailable | import("@distilled.cloud/core/errors").TooManyRequests | import("@distilled.cloud/core/errors").Unauthorized | import("@distilled.cloud/modal/Errors").UnknownModalError, never>;
|
|
107
|
+
export {};
|
|
108
|
+
//# sourceMappingURL=ImageBuild.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImageBuild.d.ts","sources":["../src/ImageBuild.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,8BAA8B,CAAC;AACtD,OAAO,KAAK,KAAK,MAAM,8BAA8B,CAAC;AAEtD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;;;;AAIxC,+DAA+D;AAC/D,qBAAa,gBAAiB,SAAQ,sBAA2C;IAC/E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,wCAAwC;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;CAAG;;;;AAEL,sDAAsD;AACtD,qBAAa,iBAAkB,SAAQ,uBAA4C;IACjF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,CAAC;CAAG;AAEL,8DAA8D;AAC9D,MAAM,WAAW,cAAc;IAC7B,qDAAqD;IACrD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,mCAAmC;IACnC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACzC;;;;OAIG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,aAAa,CAAC;QACpC,Q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M,CAAC,MAAM,CAAC,IAAI,CAAC;i3BAuEnE,CAAC"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import * as image from "@distilled.cloud/modal/image";
|
|
3
|
+
import * as mount from "@distilled.cloud/modal/mount";
|
|
4
|
+
import * as Data from "effect/Data";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
import { BlobOps, MAX_INLINE_BYTES, uploadBlob } from "./Blob.js";
|
|
7
|
+
import { operations } from "./internal.js";
|
|
8
|
+
/** Modal's builder finished the image build with a failure. */
|
|
9
|
+
export class ImageBuildFailed extends Data.TaggedError("Modal.ImageBuildFailed") {
|
|
10
|
+
}
|
|
11
|
+
/** The build didn't finish within its time budget. */
|
|
12
|
+
export class ImageBuildTimeout extends Data.TaggedError("Modal.ImageBuildTimeout") {
|
|
13
|
+
}
|
|
14
|
+
const AUTH_TYPE = {
|
|
15
|
+
aws: "REGISTRY_AUTH_TYPE_AWS",
|
|
16
|
+
gcp: "REGISTRY_AUTH_TYPE_GCP",
|
|
17
|
+
static: "REGISTRY_AUTH_TYPE_STATIC_CREDS",
|
|
18
|
+
};
|
|
19
|
+
/** A `"A100-80GB:2"`-style GPU spec as Modal's `GPUConfig`. */
|
|
20
|
+
export const gpuConfig = (gpu) => {
|
|
21
|
+
if (gpu === undefined)
|
|
22
|
+
return undefined;
|
|
23
|
+
const [type, count] = gpu.split(":");
|
|
24
|
+
return { gpuType: type.toUpperCase(), count: count ? Number(count) : 1 };
|
|
25
|
+
};
|
|
26
|
+
/** The operations a build needs, resolved by `ModalBindings.withCredentials` (or at deploy). */
|
|
27
|
+
export const ImageBuildOps = operations({
|
|
28
|
+
getOrCreate: image.imageGetOrCreate,
|
|
29
|
+
joinStreaming: image.imageJoinStreaming,
|
|
30
|
+
putFile: mount.mountPutFile,
|
|
31
|
+
getOrCreateMount: mount.mountGetOrCreate,
|
|
32
|
+
blobs: BlobOps,
|
|
33
|
+
});
|
|
34
|
+
/** Modal returned a response without a field the build needs. */
|
|
35
|
+
export class ImageBuildUnexpectedResponse extends Data.TaggedError("Modal.ImageBuildUnexpectedResponse") {
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Upload build context files as a mount owned by the app, the way Modal's
|
|
39
|
+
* clients send `COPY` sources. Modal stores files by content hash, so
|
|
40
|
+
* unchanged files are not sent again.
|
|
41
|
+
*/
|
|
42
|
+
const contextMount = Effect.fn(function* (ops, appId, files) {
|
|
43
|
+
const entries = [];
|
|
44
|
+
for (const file of files) {
|
|
45
|
+
const sha256Hex = yield* Effect.sync(() => createHash("sha256").update(file.data).digest("hex"));
|
|
46
|
+
const known = yield* ops.putFile({ sha256Hex });
|
|
47
|
+
if (!known.exists) {
|
|
48
|
+
const upload = file.data.length > MAX_INLINE_BYTES
|
|
49
|
+
? { dataBlobId: yield* uploadBlob(ops.blobs, file.data) }
|
|
50
|
+
: { data: yield* Effect.sync(() => Buffer.from(file.data).toString("base64")) };
|
|
51
|
+
const put = yield* ops.putFile({ sha256Hex, ...upload });
|
|
52
|
+
if (!put.exists) {
|
|
53
|
+
return yield* new ImageBuildUnexpectedResponse({
|
|
54
|
+
message: `Modal didn't store build context file ${file.filename}`,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
entries.push({
|
|
59
|
+
filename: `/${file.filename.replace(/^\/+/, "")}`,
|
|
60
|
+
sha256Hex,
|
|
61
|
+
size: String(file.data.length),
|
|
62
|
+
mode: 0o100000 | ((file.mode ?? 0o644) & 0o7777),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
const { mountId } = yield* ops.getOrCreateMount({
|
|
66
|
+
objectCreationType: "OBJECT_CREATION_TYPE_ANONYMOUS_OWNED_BY_APP",
|
|
67
|
+
appId,
|
|
68
|
+
files: entries,
|
|
69
|
+
});
|
|
70
|
+
if (!mountId) {
|
|
71
|
+
return yield* new ImageBuildUnexpectedResponse({
|
|
72
|
+
message: "Modal returned no id for the build context mount",
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return mountId;
|
|
76
|
+
});
|
|
77
|
+
const FINISHED = (status) => status !== undefined && status !== "GENERIC_STATUS_UNSPECIFIED";
|
|
78
|
+
/**
|
|
79
|
+
* Build (or reuse) an image with Modal's builder and wait until it is ready.
|
|
80
|
+
* Modal content-addresses images, so the same spec returns the same image
|
|
81
|
+
* without rebuilding. Fails with {@link ImageBuildFailed} on a failed build.
|
|
82
|
+
*/
|
|
83
|
+
export const buildImage = Effect.fn(function* (ops, appId, spec, options = {}) {
|
|
84
|
+
const from = spec.baseImageId
|
|
85
|
+
? { baseImages: [{ imageId: spec.baseImageId, dockerTag: "base" }], first: ["FROM base"] }
|
|
86
|
+
: spec.dockerTag
|
|
87
|
+
? { baseImages: [], first: [`FROM ${spec.dockerTag}`] }
|
|
88
|
+
: { baseImages: [], first: [] };
|
|
89
|
+
const contextMountId = spec.contextFiles !== undefined && spec.contextFiles.length > 0
|
|
90
|
+
? yield* contextMount(ops, appId, spec.contextFiles)
|
|
91
|
+
: spec.contextMountId;
|
|
92
|
+
const created = yield* ops.getOrCreate({
|
|
93
|
+
appId,
|
|
94
|
+
image: {
|
|
95
|
+
baseImages: from.baseImages,
|
|
96
|
+
dockerfileCommands: [...from.first, ...spec.commands],
|
|
97
|
+
contextMountId,
|
|
98
|
+
secretIds: spec.secretIds ? [...spec.secretIds] : undefined,
|
|
99
|
+
imageRegistryConfig: spec.registry
|
|
100
|
+
? { registryAuthType: AUTH_TYPE[spec.registry.authType], secretId: spec.registry.secretId }
|
|
101
|
+
: undefined,
|
|
102
|
+
gpuConfig: gpuConfig(spec.gpu),
|
|
103
|
+
buildArgs: spec.buildArgs ? { ...spec.buildArgs } : undefined,
|
|
104
|
+
},
|
|
105
|
+
builderVersion: spec.builderVersion,
|
|
106
|
+
forceBuild: spec.forceBuild,
|
|
107
|
+
});
|
|
108
|
+
const imageId = created.imageId;
|
|
109
|
+
if (!imageId) {
|
|
110
|
+
return yield* new ImageBuildFailed({
|
|
111
|
+
imageId: "",
|
|
112
|
+
status: "GENERIC_STATUS_UNSPECIFIED",
|
|
113
|
+
message: "Modal returned no image id",
|
|
114
|
+
logs: "",
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
let result = created.result;
|
|
118
|
+
let lastEntryId;
|
|
119
|
+
const logs = [];
|
|
120
|
+
// Each join call streams build logs for up to ~55 s; a build may take many.
|
|
121
|
+
for (let attempt = 0; !FINISHED(result?.status) && attempt < 60; attempt++) {
|
|
122
|
+
if (attempt === 0 && options.note)
|
|
123
|
+
yield* options.note(`Building image ${imageId}...`);
|
|
124
|
+
const { items } = yield* ops.joinStreaming({
|
|
125
|
+
imageId,
|
|
126
|
+
timeout: 55,
|
|
127
|
+
lastEntryId,
|
|
128
|
+
includeLogsForFinished: true,
|
|
129
|
+
});
|
|
130
|
+
for (const item of items) {
|
|
131
|
+
if (item.entryId)
|
|
132
|
+
lastEntryId = item.entryId;
|
|
133
|
+
for (const log of item.taskLogs ?? []) {
|
|
134
|
+
if (log.data)
|
|
135
|
+
logs.push(log.data);
|
|
136
|
+
}
|
|
137
|
+
if (FINISHED(item.result?.status))
|
|
138
|
+
result = item.result;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (!FINISHED(result?.status)) {
|
|
142
|
+
return yield* new ImageBuildTimeout({
|
|
143
|
+
imageId,
|
|
144
|
+
message: `Modal image ${imageId} was still building after 55 minutes`,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
if (result?.status !== "GENERIC_STATUS_SUCCESS") {
|
|
148
|
+
return yield* new ImageBuildFailed({
|
|
149
|
+
imageId,
|
|
150
|
+
status: result?.status ?? "GENERIC_STATUS_UNSPECIFIED",
|
|
151
|
+
message: result?.exception || `Modal image build ${imageId} ended with ${result?.status}`,
|
|
152
|
+
logs: logs.join("").split("\n").slice(-40).join("\n"),
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
return image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;YAC7C,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,QAAQ,IAAI,EAAE,EAAE,CAAC;gBACtC,IAAI,GAAG,CAAC,IAAI;oBAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACpC,CAAC;YACD,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;gBAAE,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1D,CAAC;IACH,CAAC;IACD,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC,CAAC,IAAI,iBAAiB,CAAC;YAClC,OAAO;YACP,OAAO,EAAE,eAAe,OAAO,sCAAsC;SACtE,CAAC,CAAC;IACL,CAAC;IACD,IAAI,MAAM,EAAE,MAAM,KAAK,wBAAwB,EAAE,CAAC;QAChD,OAAO,KAAK,CAAC,CAAC,IAAI,gBAAgB,CAAC;YACjC,OAAO;YACP,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,4BAA4B;YACtD,OAAO,EAAE,MAAM,EAAE,SAAS,IAAI,qBAAqB,OAAO,eAAe,MAAM,EAAE,MAAM,EAAE;YACzF,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;SACtD,CAAC,CAAC;IACL,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as BuildPlan from "@alchemy.run/docker/BuildPlan";
|
|
2
|
+
import * as DockerfileParser from "@alchemy.run/docker/DockerfileParser";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
/**
|
|
5
|
+
* What Modal's image builder runs. It isn't Docker: it ignores `USER`
|
|
6
|
+
* (containers run as root), doesn't implement `EXPOSE`, `HEALTHCHECK`,
|
|
7
|
+
* `LABEL`, `ONBUILD`, `STOPSIGNAL` or `VOLUME`, has no BuildKit mounts, and
|
|
8
|
+
* builds `linux/amd64` images. A Dockerfile outside this fails at plan with
|
|
9
|
+
* the offending lines.
|
|
10
|
+
*/
|
|
11
|
+
export declare const MODAL_CAPABILITIES: BuildPlan.Capabilities;
|
|
12
|
+
/**
|
|
13
|
+
* Lower a {@link BuildPlan.BuildPlan} to Modal's build inputs: the plan's
|
|
14
|
+
* Dockerfile as commands, every context file it reads, and its build args.
|
|
15
|
+
* `extra` lines (already checked) follow the plan's instructions.
|
|
16
|
+
*/
|
|
17
|
+
export declare const lowerPlan: (plan: BuildPlan.BuildPlan, extra?: readonly string[] | undefined) => Effect.Effect<{
|
|
18
|
+
commands: string[];
|
|
19
|
+
contextFiles: {
|
|
20
|
+
filename: string;
|
|
21
|
+
data: Uint8Array<ArrayBufferLike>;
|
|
22
|
+
mode: number;
|
|
23
|
+
}[];
|
|
24
|
+
buildArgs: Readonly<Record<string, string>>;
|
|
25
|
+
}, import("effect/PlatformError").PlatformError, import("effect/FileSystem").FileSystem>;
|
|
26
|
+
/**
|
|
27
|
+
* Parse and check Dockerfile lines appended to a plan (`commands`), the way
|
|
28
|
+
* {@link BuildPlan.plan} checks the Dockerfile itself.
|
|
29
|
+
*/
|
|
30
|
+
export declare const checkCommands: (commands: readonly string[]) => Effect.Effect<string[], DockerfileParser.DockerfileSyntaxError | BuildPlan.UnsupportedDockerfile, never>;
|
|
31
|
+
//# sourceMappingURL=ImagePlan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImagePlan.d.ts","sources":["../src/ImagePlan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,gBAAgB,MAAM,sCAAsC,CAAC;AACzE,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AASxC;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,EAAE,SAAS,CAAC,YAe1C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,SAAS;;;;;;;;wFAgBpB,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,aAAa,2IAexB,CAAC"}
|
package/lib/ImagePlan.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import * as BuildPlan from "@alchemy.run/docker/BuildPlan";
|
|
2
|
+
import * as DockerfileParser from "@alchemy.run/docker/DockerfileParser";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
/*
|
|
5
|
+
* Deploy-time image planning. Kept out of ImageBuild.ts because
|
|
6
|
+
* `@alchemy.run/docker/BuildPlan` imports the bundler, which must never
|
|
7
|
+
* reach a runtime bundle.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* What Modal's image builder runs. It isn't Docker: it ignores `USER`
|
|
11
|
+
* (containers run as root), doesn't implement `EXPOSE`, `HEALTHCHECK`,
|
|
12
|
+
* `LABEL`, `ONBUILD`, `STOPSIGNAL` or `VOLUME`, has no BuildKit mounts, and
|
|
13
|
+
* builds `linux/amd64` images. A Dockerfile outside this fails at plan with
|
|
14
|
+
* the offending lines.
|
|
15
|
+
*/
|
|
16
|
+
export const MODAL_CAPABILITIES = {
|
|
17
|
+
target: "Modal.Image",
|
|
18
|
+
multiStage: false,
|
|
19
|
+
heredocs: false,
|
|
20
|
+
runMounts: false,
|
|
21
|
+
platforms: ["linux/amd64"],
|
|
22
|
+
instructions: {
|
|
23
|
+
USER: "ignored",
|
|
24
|
+
EXPOSE: "unsupported",
|
|
25
|
+
HEALTHCHECK: "unsupported",
|
|
26
|
+
LABEL: "unsupported",
|
|
27
|
+
ONBUILD: "unsupported",
|
|
28
|
+
STOPSIGNAL: "unsupported",
|
|
29
|
+
VOLUME: "unsupported",
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Lower a {@link BuildPlan.BuildPlan} to Modal's build inputs: the plan's
|
|
34
|
+
* Dockerfile as commands, every context file it reads, and its build args.
|
|
35
|
+
* `extra` lines (already checked) follow the plan's instructions.
|
|
36
|
+
*/
|
|
37
|
+
export const lowerPlan = Effect.fn(function* (plan, extra = []) {
|
|
38
|
+
const contextFiles = yield* Effect.forEach(plan.files, (file) => Effect.map(BuildPlan.readContextFile(file), (data) => ({
|
|
39
|
+
filename: file.path,
|
|
40
|
+
data,
|
|
41
|
+
mode: file.mode,
|
|
42
|
+
})));
|
|
43
|
+
return {
|
|
44
|
+
commands: [...BuildPlan.renderLines(plan), ...extra],
|
|
45
|
+
contextFiles,
|
|
46
|
+
buildArgs: plan.args,
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
/**
|
|
50
|
+
* Parse and check Dockerfile lines appended to a plan (`commands`), the way
|
|
51
|
+
* {@link BuildPlan.plan} checks the Dockerfile itself.
|
|
52
|
+
*/
|
|
53
|
+
export const checkCommands = Effect.fn(function* (commands) {
|
|
54
|
+
if (commands.length === 0)
|
|
55
|
+
return [];
|
|
56
|
+
const parsed = yield* DockerfileParser.parse(`FROM scratch\n${commands.join("\n")}\n`);
|
|
57
|
+
const { violations } = BuildPlan.check(parsed, MODAL_CAPABILITIES, "linux/amd64");
|
|
58
|
+
if (violations.length > 0) {
|
|
59
|
+
return yield* new BuildPlan.UnsupportedDockerfile({
|
|
60
|
+
target: MODAL_CAPABILITIES.target,
|
|
61
|
+
violations,
|
|
62
|
+
message: [
|
|
63
|
+
`${MODAL_CAPABILITIES.target} cannot build these commands:`,
|
|
64
|
+
...violations.map((v) => ` ${v.instruction}: ${v.reason}`),
|
|
65
|
+
].join("\n"),
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return DockerfileParser.renderLines(parsed).slice(1);
|
|
69
|
+
});
|
|
70
|
+
//# sourceMappingURL=ImagePlan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImagePlan.js","sources":["../src/ImageP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G;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,QAA+B;IAC/E,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAc,CAAC;IACjD,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC,iBAAiB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvF,MAAM,EAAE,UAAU,EAAE,GAAG,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,kBAAkB,EAAE,aAAa,CAAC,CAAC;IAClF,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC,CAAC,IAAI,SAAS,CAAC,qBAAqB,CAAC;YAChD,MAAM,EAAE,kBAAkB,CAAC,MAAM;YACjC,UAAU;YACV,OAAO,EAAE;gBACP,GAAG,kBAAkB,CAAC,MAAM,+BAA+B;gBAC3D,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,WAAW,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;aAC5D,CAAC,IAAI,CAAC,IAAI,CAAC;SACb,CAAC,CAAC;IACL,CAAC;IACD,OAAO,gBAAgB,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACvD,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type * as Effect from "effect/Effect";
|
|
2
|
+
/**
|
|
3
|
+
* The `process.env` an async `Modal.Sandbox` program sees: one string per
|
|
4
|
+
* `env` entry of the declaration.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* // alchemy.run.ts
|
|
9
|
+
* export const Agent = Modal.Sandbox("Agent", { main: "./src/agent.ts", app: Coder, env: { GREETING: "hi" } });
|
|
10
|
+
* export type AgentEnv = Modal.InferEnv<typeof Agent>;
|
|
11
|
+
*
|
|
12
|
+
* // src/agent.ts
|
|
13
|
+
* import type { AgentEnv } from "../alchemy.run.ts";
|
|
14
|
+
* const env = process.env as unknown as AgentEnv;
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export type InferEnv<F> = F extends Effect.Effect<infer A, infer _E, infer _R> ? InferEnv<A> : F extends {
|
|
18
|
+
readonly Props: {
|
|
19
|
+
readonly env?: infer E;
|
|
20
|
+
};
|
|
21
|
+
} ? InferEnvRecord<Exclude<E, undefined>> : InferEnvRecord<F>;
|
|
22
|
+
type InferEnvRecord<E> = {
|
|
23
|
+
readonly [K in keyof E]: string;
|
|
24
|
+
};
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=InferEnv.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InferEnv.d.ts","sources":["../src/InferEnv.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAE7C;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,IACpB,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,GAChD,QAAQ,CAAC,CAAC,CAAC,GACX,CAAC,SAAS;IAAE,QAAQ,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAA;KAAE,CAAA;CAAE,GACtD,cAAc,CAAC,OAAO,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,GACrC,cAAc,CAAC,CAAC,CAAC,CAAC;AAE1B,KAAK,cAAc,CAAC,CAAC,IAAI;IACvB,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,GAAG,MAAM;CAChC,CAAC"}
|
package/lib/InferEnv.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=InferEnv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InferEnv.js","sources":["../src/InferEnv.ts"],"names":[],"mappings":""}
|