@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
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import * as Binding from "alchemy/Binding";
|
|
2
|
+
import type { Input } from "alchemy/Input";
|
|
3
|
+
import type { Rpc } from "alchemy/Rpc";
|
|
4
|
+
import type { RuntimeContext } from "alchemy/RuntimeContext";
|
|
5
|
+
import type * as Effect from "effect/Effect";
|
|
6
|
+
import type { downloadBlob, uploadBlob } from "./Blob.ts";
|
|
7
|
+
import type { Function } from "./Function.ts";
|
|
8
|
+
import type { FunctionLookupError } from "./FunctionTarget.ts";
|
|
9
|
+
import type { ErrorOf, OpError } from "./internal.ts";
|
|
10
|
+
import type { InvokeOps } from "./InvokeFunctionHttp.ts";
|
|
11
|
+
/** A function deployed outside the Stack (`modal deploy`), by name. */
|
|
12
|
+
export interface FunctionRef {
|
|
13
|
+
/** Name of the deployed App (`modal deploy` / `modal.App("…")`). */
|
|
14
|
+
readonly app: string;
|
|
15
|
+
/** Function name in the App (`"embed"`), or `"Class.method"` for a class method. */
|
|
16
|
+
readonly function: string;
|
|
17
|
+
/** Environment the App is deployed in. @default the workspace default */
|
|
18
|
+
readonly environment?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Parameters of a parameterized class (`modal.parameter()` fields), for a
|
|
21
|
+
* `"Class.method"` target. Modal runs one set of containers per value set.
|
|
22
|
+
*/
|
|
23
|
+
readonly parameters?: Record<string, string | number | boolean | Uint8Array>;
|
|
24
|
+
}
|
|
25
|
+
/** What a function binding targets: a `Modal.Function` of the Stack, or a deployed function by name. */
|
|
26
|
+
export type FunctionTarget = Function | FunctionRef;
|
|
27
|
+
declare const FunctionCallFailed_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 & {
|
|
28
|
+
readonly _tag: "Modal.FunctionCallFailed";
|
|
29
|
+
} & Readonly<A>;
|
|
30
|
+
/** The function raised, or Modal failed the call. */
|
|
31
|
+
export declare class FunctionCallFailed extends FunctionCallFailed_base<{
|
|
32
|
+
readonly status: string;
|
|
33
|
+
readonly message: string;
|
|
34
|
+
readonly traceback?: string;
|
|
35
|
+
}> {
|
|
36
|
+
}
|
|
37
|
+
/** Calling a function: looking it up, sending inputs, reading outputs, and the call's own failure. */
|
|
38
|
+
export type InvokeError = FunctionLookupError | OpError<InvokeOps, "map" | "putInputs" | "getOutputs"> | ErrorOf<typeof uploadBlob | typeof downloadBlob> | FunctionCallFailed | FunctionCallTimeout;
|
|
39
|
+
declare const FunctionCallTimeout_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 & {
|
|
40
|
+
readonly _tag: "Modal.FunctionCallTimeout";
|
|
41
|
+
} & Readonly<A>;
|
|
42
|
+
/** The call didn't finish within its timeout. */
|
|
43
|
+
export declare class FunctionCallTimeout extends FunctionCallTimeout_base<{
|
|
44
|
+
readonly functionCallId: string;
|
|
45
|
+
readonly message: string;
|
|
46
|
+
}> {
|
|
47
|
+
}
|
|
48
|
+
/** Options for one call. */
|
|
49
|
+
export interface CallOptions {
|
|
50
|
+
/** How long to wait for the result (seconds, or `"10 minutes"`). @default 300 seconds */
|
|
51
|
+
readonly timeout?: number | string;
|
|
52
|
+
}
|
|
53
|
+
/** Call one function. Arguments and results travel as CBOR. */
|
|
54
|
+
export interface FunctionClient {
|
|
55
|
+
/** Call the function and wait for its result. */
|
|
56
|
+
call<A = unknown>(args?: ReadonlyArray<unknown>, kwargs?: Record<string, unknown>, options?: CallOptions): Effect.Effect<A, InvokeError, RuntimeContext>;
|
|
57
|
+
/**
|
|
58
|
+
* Call the function once per input, in parallel across containers, and
|
|
59
|
+
* return the results in input order. Each input is a list of positional
|
|
60
|
+
* arguments. Fails with the first failed input.
|
|
61
|
+
*/
|
|
62
|
+
map<A = unknown>(inputs: ReadonlyArray<ReadonlyArray<unknown>>, options?: CallOptions): Effect.Effect<A[], InvokeError, RuntimeContext>;
|
|
63
|
+
/** Start a call without waiting; read it later with {@link result}. */
|
|
64
|
+
spawn(args?: ReadonlyArray<unknown>, kwargs?: Record<string, unknown>): Effect.Effect<{
|
|
65
|
+
readonly functionCallId: string;
|
|
66
|
+
}, InvokeError, RuntimeContext>;
|
|
67
|
+
/** The result of a spawned call, waiting up to `timeout`. */
|
|
68
|
+
result<A = unknown>(call: {
|
|
69
|
+
readonly functionCallId: string;
|
|
70
|
+
}, options?: CallOptions): Effect.Effect<A, InvokeError, RuntimeContext>;
|
|
71
|
+
/** Cancel a spawned call. */
|
|
72
|
+
cancel(call: {
|
|
73
|
+
readonly functionCallId: string;
|
|
74
|
+
}): Effect.Effect<void, FunctionLookupError | OpError<InvokeOps, "cancel">, RuntimeContext>;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The RPC methods of a `Modal.Function` program: every function it returns
|
|
78
|
+
* besides `fetch` and `run`, called through Modal with the same arguments
|
|
79
|
+
* and results.
|
|
80
|
+
*/
|
|
81
|
+
export type FunctionStub<Shape> = Omit<Shape, "fetch" | "run">;
|
|
82
|
+
/**
|
|
83
|
+
* Call a Modal Function from any runtime: a Worker, a Lambda, a Durable
|
|
84
|
+
* Object, another Modal Function. Bind a `Modal.Function` of the Stack, or
|
|
85
|
+
* a function deployed with `modal deploy` by name.
|
|
86
|
+
*
|
|
87
|
+
* A `Modal.Function` program's RPC methods come back as a typed client:
|
|
88
|
+
* each call goes through Modal (queued, retried and autoscaled like any
|
|
89
|
+
* Modal call) to the method of that name. Arguments and results are JSON
|
|
90
|
+
* values, and a typed failure reaches the caller by its `_tag`. A method
|
|
91
|
+
* that returns a `Stream` arrives whole, once the call finishes. The
|
|
92
|
+
* binding gives the host its own key for the function, which every call
|
|
93
|
+
* carries: the program answers only callers bound to it.
|
|
94
|
+
*
|
|
95
|
+
* A Python function, or an async program, gets a {@link FunctionClient}
|
|
96
|
+
* instead: `call`, `map` and `spawn` with CBOR arguments (Modal's
|
|
97
|
+
* cross-language format). Payloads over 2 MiB go through Modal's blob store.
|
|
98
|
+
*
|
|
99
|
+
* ### Call a function
|
|
100
|
+
* **Example:** RPC methods of a `Modal.Function`
|
|
101
|
+
* ```typescript
|
|
102
|
+
* // src/Embed.ts
|
|
103
|
+
* import * as Modal from "@alchemy.run/modal";
|
|
104
|
+
* import * as Effect from "effect/Effect";
|
|
105
|
+
* import { Inference } from "./Inference.ts";
|
|
106
|
+
*
|
|
107
|
+
* export default class Embed extends Modal.Function<Embed>()(
|
|
108
|
+
* "Embed",
|
|
109
|
+
* { main: import.meta.url, app: Inference },
|
|
110
|
+
* Effect.gen(function* () {
|
|
111
|
+
* return {
|
|
112
|
+
* embed: Effect.fn(function* (text: string) {
|
|
113
|
+
* return { tokens: text.split(/\s+/).length };
|
|
114
|
+
* }),
|
|
115
|
+
* };
|
|
116
|
+
* }),
|
|
117
|
+
* ) {}
|
|
118
|
+
* ```
|
|
119
|
+
*
|
|
120
|
+
* **Example:** Call it from a Cloudflare Worker
|
|
121
|
+
* ```typescript
|
|
122
|
+
* import * as Cloudflare from "@alchemy.run/cloudflare";
|
|
123
|
+
* import * as Modal from "@alchemy.run/modal";
|
|
124
|
+
* import * as Effect from "effect/Effect";
|
|
125
|
+
* import * as HttpServerResponse from "effect/http/HttpServerResponse";
|
|
126
|
+
* import Embed from "./Embed.ts";
|
|
127
|
+
*
|
|
128
|
+
* export default class Api extends Cloudflare.Worker<Api>()(
|
|
129
|
+
* "Api",
|
|
130
|
+
* { main: import.meta.url, compatibility: { flags: ["nodejs_compat"] } },
|
|
131
|
+
* Effect.gen(function* () {
|
|
132
|
+
* const embed = yield* Modal.InvokeFunction(Embed);
|
|
133
|
+
* return {
|
|
134
|
+
* fetch: Effect.gen(function* () {
|
|
135
|
+
* const { tokens } = yield* embed.embed("hello world");
|
|
136
|
+
* return yield* HttpServerResponse.json({ tokens });
|
|
137
|
+
* }).pipe(Effect.orDie),
|
|
138
|
+
* };
|
|
139
|
+
* }).pipe(Effect.provide(Modal.InvokeFunctionHttp)),
|
|
140
|
+
* ) {}
|
|
141
|
+
* ```
|
|
142
|
+
*
|
|
143
|
+
* **Example:** A Python function deployed with `modal deploy`
|
|
144
|
+
* ```typescript
|
|
145
|
+
* const embed = yield* Modal.InvokeFunction({ app: "inference", function: "embed" });
|
|
146
|
+
* const vector = yield* embed.call<number[]>(["hello world"]);
|
|
147
|
+
* ```
|
|
148
|
+
*
|
|
149
|
+
* **Example:** A method of a parameterized Python class
|
|
150
|
+
* ```typescript
|
|
151
|
+
* const model = yield* Modal.InvokeFunction({
|
|
152
|
+
* app: "inference",
|
|
153
|
+
* function: "Model.generate",
|
|
154
|
+
* parameters: { size: "7b" },
|
|
155
|
+
* });
|
|
156
|
+
* const text = yield* model.call<string>(["hello"]);
|
|
157
|
+
* ```
|
|
158
|
+
*
|
|
159
|
+
* ### Fan out
|
|
160
|
+
* **Example:** One call per input, in parallel
|
|
161
|
+
* ```typescript
|
|
162
|
+
* const results = yield* embed.map<{ tokens: number }>([["a"], ["b"], ["c"]]);
|
|
163
|
+
* ```
|
|
164
|
+
*
|
|
165
|
+
* ### Fire and forget
|
|
166
|
+
* **Example:** Spawn, then read the result later
|
|
167
|
+
* ```typescript
|
|
168
|
+
* const job = yield* train.spawn([], { epochs: 3 });
|
|
169
|
+
* const metrics = yield* train.result(job, { timeout: "30 minutes" });
|
|
170
|
+
* ```
|
|
171
|
+
*
|
|
172
|
+
* @binding
|
|
173
|
+
* @product Function
|
|
174
|
+
*/
|
|
175
|
+
export interface InvokeFunction extends Binding.Service<InvokeFunction, "Modal.InvokeFunction", (target: FunctionTarget) => Effect.Effect<FunctionClient>> {
|
|
176
|
+
}
|
|
177
|
+
/** InvokeFunction's call signatures, typed from the target's program. */
|
|
178
|
+
export interface InvokeFunctionCall {
|
|
179
|
+
/** A `Modal.Function` of the Stack whose program has RPC methods: its typed client. */
|
|
180
|
+
<Shape, Req = never>(target: (Function & Rpc<Shape>) | Effect.Effect<Function & Rpc<Shape>, never, Req>): Effect.Effect<FunctionStub<Shape>, never, InvokeFunction | Req>;
|
|
181
|
+
/** A deployed function by name, or an async program: `call`, `map` and `spawn`. */
|
|
182
|
+
<Req = never>(target: Input<FunctionTarget> | Effect.Effect<FunctionTarget, never, Req>): Effect.Effect<FunctionClient, never, InvokeFunction | Req>;
|
|
183
|
+
}
|
|
184
|
+
export declare const InvokeFunction: InvokeFunctionCall & InvokeFunction;
|
|
185
|
+
export {};
|
|
186
|
+
//# sourceMappingURL=InvokeFunction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InvokeFunction.d.ts","sources":["../src/InvokeFunction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEzD,uEAAuE;AACvE,MAAM,WAAW,WAAW;IAC1B,oEAAoE;IACpE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,oFAAoF;IACpF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,yEAAyE;IACzE,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,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EJ,yEAAyE;AACzE,MAAM,WAAW,kBAAkB;IACjC,uFAAuF;IACvF,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,EACjB,MAAM,EAAE,CAAC,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,GACjF,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,cAAc,GAAG,GAAG,CAAC,CAAC;IACnE,mFAAmF;IACnF,CAAC,GAAG,GAAG,KAAK,EACV,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,KAAK,EAAE,GAAG,CAAC,GACxE,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,KAAK,EAAE,cAAc,GAAG,GAAG,CAAC,CAAC;CAC/D;AAED,eAAO,MAAM,cAAc,EAEX,kBAAkB,GAAG,cAAc,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as Binding from "alchemy/Binding";
|
|
2
|
+
import * as Data from "effect/Data";
|
|
3
|
+
/** The function raised, or Modal failed the call. */
|
|
4
|
+
export class FunctionCallFailed extends Data.TaggedError("Modal.FunctionCallFailed") {
|
|
5
|
+
}
|
|
6
|
+
/** The call didn't finish within its timeout. */
|
|
7
|
+
export class FunctionCallTimeout extends Data.TaggedError("Modal.FunctionCallTimeout") {
|
|
8
|
+
}
|
|
9
|
+
export const InvokeFunction = Binding.Service("Modal.InvokeFunction");
|
|
10
|
+
//# sourceMappingURL=InvokeFunction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InvokeFunction.js","sources":["../src/InvokeFunction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAC;AAI3C,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AA0BpC,qDAAqD;AACrD,MAAM,OAAO,kBAAmB,SAAQ,IAAI,CAAC,WAAW,CAAC,0BAA0B,CAIjF;CAAG;AAUL,iDAAiD;AACjD,MAAM,OAAO,mBAAoB,SAAQ,IAAI,CAAC,WAAW,CAAC,2BAA2B,CAGnF;CAAG;AA+JL,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC,OAAO,CAC3C,sBAAsB,CAC2B,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as functions from "@distilled.cloud/modal/functions";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Layer from "effect/Layer";
|
|
4
|
+
import { type ResolvedFunction } from "./FunctionTarget.ts";
|
|
5
|
+
import { InvokeFunction, type FunctionClient } from "./InvokeFunction.ts";
|
|
6
|
+
/** The operations the client calls, resolved by `ModalBindings.withCredentials`. */
|
|
7
|
+
declare const InvokeOps: Effect.Effect<{
|
|
8
|
+
readonly map: (input: functions.FunctionMapRequest) => Effect.Effect<functions.FunctionMapResponse, functions.FunctionMapError, never>;
|
|
9
|
+
readonly putInputs: (input: functions.FunctionPutInputsRequest) => Effect.Effect<functions.FunctionPutInputsResponse, functions.ModalOpError, never>;
|
|
10
|
+
readonly getOutputs: (input: functions.GetFunctionOutputsRequest) => Effect.Effect<functions.GetFunctionOutputsResponse, functions.GetFunctionOutputsError, never>;
|
|
11
|
+
readonly cancel: (input: functions.CancelFunctionCallRequest) => Effect.Effect<functions.CancelFunctionCallResponse, functions.CancelFunctionCallError, never>;
|
|
12
|
+
readonly blobs: {
|
|
13
|
+
readonly create: (input: import("@distilled.cloud/modal/blob").CreateBlobRequest) => Effect.Effect<import("@distilled.cloud/modal/blob").CreateBlobResponse, functions.ModalOpError, never>;
|
|
14
|
+
readonly get: (input: import("@distilled.cloud/modal/blob").GetBlobRequest) => Effect.Effect<import("@distilled.cloud/modal/blob").GetBlobResponse, functions.ModalOpError, never>;
|
|
15
|
+
readonly http: import("effect/http/HttpClient").HttpClient;
|
|
16
|
+
};
|
|
17
|
+
}, never, import("./internal.ts").OperationServices>;
|
|
18
|
+
export type InvokeOps = Effect.Success<typeof InvokeOps>;
|
|
19
|
+
/** A client for a resolved function. */
|
|
20
|
+
export declare const makeFunctionClient: (resolved: ResolvedFunction, ops: InvokeOps) => FunctionClient;
|
|
21
|
+
/**
|
|
22
|
+
* The typed client of a `Modal.Function` program's RPC methods. Each method
|
|
23
|
+
* is a call to the function's method of that name; its result is the
|
|
24
|
+
* program's JSON answer, a failure envelope the call fails with, or a
|
|
25
|
+
* stream's values. A Function without methods (an async program) keeps
|
|
26
|
+
* the {@link FunctionClient} operations.
|
|
27
|
+
*/
|
|
28
|
+
export declare const makeRpcClient: (resolved: ResolvedFunction, ops: InvokeOps, methods: Effect.Effect<ReadonlyArray<string> | undefined>, key: Effect.Effect<string | undefined>) => Record<string, unknown>;
|
|
29
|
+
/**
|
|
30
|
+
* {@link InvokeFunction} over Modal's API. Grants the host's identity (a scoped
|
|
31
|
+
* `Modal.ServiceUser`) the `contributor` role on the function's environment.
|
|
32
|
+
*
|
|
33
|
+
* @layer
|
|
34
|
+
* @product Function
|
|
35
|
+
* @provides Modal.InvokeFunction
|
|
36
|
+
*/
|
|
37
|
+
export declare const InvokeFunctionHttp: Layer.Layer<InvokeFunction, never, never>;
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=InvokeFunctionHttp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InvokeFunctionHttp.d.ts","sources":["../src/InvokeFunctionHttp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,kCAAkC,CAAC;AAO9D,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAItC,OAAO,EAAsC,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAIhG,OAAO,EAGL,cAAc,EAEd,KAAK,cAAc,EAEpB,MAAM,qBAAqB,CAAC;AAE7B,oFAAoF;AACpF,QAAA,MAAM,SAAS;;;;;;;;;;oDAMb,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,SAAS,CAAC,CAAC;AA6DzD,wCAAwC;AACxC,eAAO,MAAM,kBAAkB,aAAc,gBAAgB,OAAO,SAAS,KAAG,cAgH/E,CAAC;AAQF;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,aACd,gBAAgB,OACrB,SAAS,WACL,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC,OACpD,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,SAAS,CAAC,KACrC,MAAM,CAAC,MAAM,EAAE,OAAO,CAsDxB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,2CAuB9B,CAAC"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import * as functions from "@distilled.cloud/modal/functions";
|
|
2
|
+
import { asEffectOrStream, decodeRpcResponseStream, decodeRpcResult, RpcCallError, } from "alchemy/Rpc";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Layer from "effect/Layer";
|
|
5
|
+
import * as Stream from "effect/Stream";
|
|
6
|
+
import { BlobOps, downloadBlob, MAX_INLINE_BYTES, uploadBlob } from "./Blob.js";
|
|
7
|
+
import { decodeCbor, encodeCbor } from "./Cbor.js";
|
|
8
|
+
import { isFunctionRef, makeFunctionBinding } from "./FunctionTarget.js";
|
|
9
|
+
import { operations, seconds } from "./internal.js";
|
|
10
|
+
import { RPC_STREAM_KEY } from "./internal/Entrypoint.js";
|
|
11
|
+
import { RPC_KEY_KWARG, RpcCaller } from "./internal/RpcAuth.js";
|
|
12
|
+
import { FunctionCallFailed, FunctionCallTimeout, InvokeFunction, } from "./InvokeFunction.js";
|
|
13
|
+
/** The operations the client calls, resolved by `ModalBindings.withCredentials`. */
|
|
14
|
+
const InvokeOps = operations({
|
|
15
|
+
map: functions.functionMap,
|
|
16
|
+
putInputs: functions.functionPutInputs,
|
|
17
|
+
getOutputs: functions.getFunctionOutputs,
|
|
18
|
+
cancel: functions.cancelFunctionCall,
|
|
19
|
+
blobs: BlobOps,
|
|
20
|
+
});
|
|
21
|
+
/** One input: CBOR `[args, kwargs]`, inline or (over 2 MiB) as a blob. */
|
|
22
|
+
const encodeInput = Effect.fn(function* (blobs, args, kwargs, method) {
|
|
23
|
+
const bytes = yield* Effect.try({
|
|
24
|
+
try: () => encodeCbor([args, kwargs]),
|
|
25
|
+
catch: (cause) => new FunctionCallFailed({
|
|
26
|
+
status: "INVALID_ARGUMENTS",
|
|
27
|
+
message: `Arguments aren't CBOR-encodable: ${String(cause)}`,
|
|
28
|
+
}),
|
|
29
|
+
});
|
|
30
|
+
const payload = bytes.length > MAX_INLINE_BYTES
|
|
31
|
+
? { argsBlobId: yield* uploadBlob(blobs, bytes) }
|
|
32
|
+
: { args: yield* Effect.sync(() => Buffer.from(bytes).toString("base64")) };
|
|
33
|
+
return {
|
|
34
|
+
...payload,
|
|
35
|
+
dataFormat: "DATA_FORMAT_CBOR",
|
|
36
|
+
methodName: method,
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
/** The value of a finished output, or its failure. */
|
|
40
|
+
const decodeOutput = Effect.fn(function* (blobs, functionCallId, output) {
|
|
41
|
+
const result = output.result;
|
|
42
|
+
if (result?.status !== "GENERIC_STATUS_SUCCESS") {
|
|
43
|
+
return yield* new FunctionCallFailed({
|
|
44
|
+
status: result?.status ?? "GENERIC_STATUS_UNSPECIFIED",
|
|
45
|
+
message: result?.exception || `Function call ${functionCallId} failed`,
|
|
46
|
+
traceback: result?.traceback,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
const bytes = result.dataBlobId
|
|
50
|
+
? yield* downloadBlob(blobs, result.dataBlobId)
|
|
51
|
+
: result.data
|
|
52
|
+
? yield* Effect.sync(() => new Uint8Array(Buffer.from(result.data, "base64")))
|
|
53
|
+
: undefined;
|
|
54
|
+
if (bytes === undefined)
|
|
55
|
+
return null;
|
|
56
|
+
return yield* Effect.try({
|
|
57
|
+
try: () => decodeCbor(bytes),
|
|
58
|
+
catch: (cause) => new FunctionCallFailed({
|
|
59
|
+
status: "INVALID_RESULT",
|
|
60
|
+
message: `The result isn't CBOR (return plain values, or set the function's serialization): ${String(cause)}`,
|
|
61
|
+
}),
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
/** Inputs per `FunctionPutInputs` request. */
|
|
65
|
+
const BATCH = 49;
|
|
66
|
+
/** A client for a resolved function. */
|
|
67
|
+
export const makeFunctionClient = (resolved, ops) => {
|
|
68
|
+
const { functionId, method } = resolved;
|
|
69
|
+
/** Collect `count` outputs of a call, by input index. */
|
|
70
|
+
const collect = Effect.fn(function* (functionCallId, count, timeout) {
|
|
71
|
+
const budget = seconds(timeout) ?? 300;
|
|
72
|
+
const rounds = Math.max(1, Math.ceil(budget / 55));
|
|
73
|
+
const values = new Map();
|
|
74
|
+
let lastEntryId = "0-0";
|
|
75
|
+
for (let round = 0; round < rounds && values.size < count; round++) {
|
|
76
|
+
const response = yield* ops.getOutputs({
|
|
77
|
+
functionCallId,
|
|
78
|
+
maxValues: Math.min(1000, count - values.size),
|
|
79
|
+
timeout: Math.min(55, budget),
|
|
80
|
+
lastEntryId,
|
|
81
|
+
// A map's outputs stay until all are read; a single output is popped.
|
|
82
|
+
clearOnSuccess: count === 1,
|
|
83
|
+
});
|
|
84
|
+
if (response.lastEntryId)
|
|
85
|
+
lastEntryId = response.lastEntryId;
|
|
86
|
+
for (const output of response.outputs ?? []) {
|
|
87
|
+
if (!output.result)
|
|
88
|
+
continue;
|
|
89
|
+
values.set(output.idx ?? 0, yield* decodeOutput(ops.blobs, functionCallId, output));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (values.size < count) {
|
|
93
|
+
return yield* new FunctionCallTimeout({
|
|
94
|
+
functionCallId,
|
|
95
|
+
message: `Function call ${functionCallId} didn't finish within ${budget} seconds`,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
return Array.from({ length: count }, (_, idx) => values.get(idx));
|
|
99
|
+
});
|
|
100
|
+
/**
|
|
101
|
+
* Start a function call the way Modal's clients do: a unary call sends its
|
|
102
|
+
* input with `FunctionMap` (or with `FunctionPutInputs` when Modal doesn't
|
|
103
|
+
* take it there); a map creates the call, then sends every input with
|
|
104
|
+
* `FunctionPutInputs`.
|
|
105
|
+
*/
|
|
106
|
+
const start = Effect.fn(function* (inputs, type, invocation) {
|
|
107
|
+
const id = yield* functionId;
|
|
108
|
+
const items = yield* Effect.forEach(inputs, ([args, kwargs], idx) => Effect.map(encodeInput(ops.blobs, args, kwargs, method), (input) => ({ idx, input })));
|
|
109
|
+
const unary = type === "FUNCTION_CALL_TYPE_UNARY";
|
|
110
|
+
const response = yield* ops.map({
|
|
111
|
+
functionId: id,
|
|
112
|
+
functionCallType: type,
|
|
113
|
+
functionCallInvocationType: invocation,
|
|
114
|
+
returnExceptions: false,
|
|
115
|
+
pipelinedInputs: unary ? items : undefined,
|
|
116
|
+
});
|
|
117
|
+
const functionCallId = response.functionCallId ?? "";
|
|
118
|
+
const sent = unary && (response.pipelinedInputs ?? []).length > 0 ? items.length : 0;
|
|
119
|
+
for (let offset = sent; offset < items.length; offset += BATCH) {
|
|
120
|
+
yield* ops.putInputs({
|
|
121
|
+
functionId: id,
|
|
122
|
+
functionCallId,
|
|
123
|
+
inputs: items.slice(offset, offset + BATCH),
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return functionCallId;
|
|
127
|
+
});
|
|
128
|
+
return {
|
|
129
|
+
call: (args = [], kwargs = {}, options = {}) => start([[args, kwargs]], "FUNCTION_CALL_TYPE_UNARY", "FUNCTION_CALL_INVOCATION_TYPE_SYNC").pipe(Effect.flatMap((id) => collect(id, 1, options.timeout)),
|
|
130
|
+
// CBOR results are untyped; the caller names the shape it expects.
|
|
131
|
+
Effect.map(([value]) => value)),
|
|
132
|
+
map: (inputs, options = {}) => inputs.length === 0
|
|
133
|
+
? Effect.succeed([])
|
|
134
|
+
: start(inputs.map((args) => [args, {}]), "FUNCTION_CALL_TYPE_MAP", "FUNCTION_CALL_INVOCATION_TYPE_SYNC").pipe(Effect.flatMap((id) => collect(id, inputs.length, options.timeout)), Effect.map((values) => values)),
|
|
135
|
+
spawn: (args = [], kwargs = {}) => start([[args, kwargs]], "FUNCTION_CALL_TYPE_UNARY", "FUNCTION_CALL_INVOCATION_TYPE_ASYNC").pipe(Effect.map((functionCallId) => ({ functionCallId }))),
|
|
136
|
+
result: (call, options = {}) => collect(call.functionCallId, 1, options.timeout).pipe(Effect.map(([value]) => value)),
|
|
137
|
+
cancel: (call) => ops.cancel({ functionCallId: call.functionCallId }).pipe(Effect.catchTag("FunctionCallNotFound", () => Effect.void), Effect.asVoid),
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
/** Whether a call's result is a streamed RPC result (see `RPC_STREAM_KEY`). */
|
|
141
|
+
const isStreamResult = (value) => typeof value === "object" &&
|
|
142
|
+
value !== null &&
|
|
143
|
+
Array.isArray(value[RPC_STREAM_KEY]);
|
|
144
|
+
/**
|
|
145
|
+
* The typed client of a `Modal.Function` program's RPC methods. Each method
|
|
146
|
+
* is a call to the function's method of that name; its result is the
|
|
147
|
+
* program's JSON answer, a failure envelope the call fails with, or a
|
|
148
|
+
* stream's values. A Function without methods (an async program) keeps
|
|
149
|
+
* the {@link FunctionClient} operations.
|
|
150
|
+
*/
|
|
151
|
+
export const makeRpcClient = (resolved, ops, methods, key) => {
|
|
152
|
+
const client = makeFunctionClient(resolved, ops);
|
|
153
|
+
const callMethod = (name, args) => key.pipe(Effect.flatMap((value) => makeFunctionClient({ ...resolved, method: name }, ops).call(args,
|
|
154
|
+
// The binding's key: the program serves only callers it issued keys to.
|
|
155
|
+
value === undefined ? {} : { [RPC_KEY_KWARG]: value })), Effect.flatMap((value) => isStreamResult(value)
|
|
156
|
+
? // The stream's values, re-encoded as the NDJSON the RPC codec
|
|
157
|
+
// decodes (byte chunks and a trailing failure marker included).
|
|
158
|
+
Effect.succeed(Stream.fromIterable(value[RPC_STREAM_KEY]).pipe(Stream.map((item) => `${JSON.stringify(item)}\n`), Stream.encodeText, decodeRpcResponseStream))
|
|
159
|
+
: decodeRpcResult(value)));
|
|
160
|
+
return new Proxy({}, {
|
|
161
|
+
get: (_, prop) => {
|
|
162
|
+
// Never thenable, and no symbol members.
|
|
163
|
+
if (typeof prop !== "string" || prop === "then")
|
|
164
|
+
return undefined;
|
|
165
|
+
const call = (args) => Effect.gen(function* () {
|
|
166
|
+
const names = (yield* methods) ?? [];
|
|
167
|
+
if (names.includes(prop))
|
|
168
|
+
return yield* callMethod(prop, args);
|
|
169
|
+
const operation = client[prop];
|
|
170
|
+
if (typeof operation === "function") {
|
|
171
|
+
return yield* operation(...args);
|
|
172
|
+
}
|
|
173
|
+
return yield* new RpcCallError({
|
|
174
|
+
method: prop,
|
|
175
|
+
cause: `The function has no RPC method ${prop}`,
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
return (...args) => asEffectOrStream(
|
|
179
|
+
// oxlint-disable-next-line effecttsgo/unsafe-effect-type-assertion -- the stub's declared method types carry `RuntimeContext`, which the caller's runtime provides
|
|
180
|
+
call(args));
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
};
|
|
184
|
+
/**
|
|
185
|
+
* {@link InvokeFunction} over Modal's API. Grants the host's identity (a scoped
|
|
186
|
+
* `Modal.ServiceUser`) the `contributor` role on the function's environment.
|
|
187
|
+
*
|
|
188
|
+
* @layer
|
|
189
|
+
* @product Function
|
|
190
|
+
* @provides Modal.InvokeFunction
|
|
191
|
+
*/
|
|
192
|
+
export const InvokeFunctionHttp = Layer.effect(InvokeFunction, Effect.gen(function* () {
|
|
193
|
+
const caller = yield* RpcCaller;
|
|
194
|
+
return yield* makeFunctionBinding({
|
|
195
|
+
tag: "Modal.InvokeFunction",
|
|
196
|
+
operations: InvokeOps,
|
|
197
|
+
role: "contributor",
|
|
198
|
+
make: Effect.fn(function* (resolved, ops, target) {
|
|
199
|
+
if (isFunctionRef(target))
|
|
200
|
+
return makeFunctionClient(resolved, ops);
|
|
201
|
+
// This host's key for the Function's RPC methods (minted at deploy).
|
|
202
|
+
const key = yield* caller(target);
|
|
203
|
+
// The program's methods, recorded at deploy (an attribute of the Function).
|
|
204
|
+
const methods = yield* target.methods;
|
|
205
|
+
// Typed by `InvokeFunction`'s call signatures from the target's program.
|
|
206
|
+
return makeRpcClient(resolved, ops, methods, key);
|
|
207
|
+
}),
|
|
208
|
+
});
|
|
209
|
+
}));
|
|
210
|
+
//# sourceMappingURL=InvokeFunctionHttp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InvokeFunctionHttp.js","sources":["../src/InvokeFunctionHttp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,kCAAkC,CAAC;AAC9D,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,eAAe,EACf,YAAY,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAChF,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAyB,MAAM,qBAAqB,CAAC;AAChG,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACjE,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BAAmB,CAAC;QAChC,GAAG,EAAE,sBAAsB;QAC3B,UAAU,EAAE,SAAS;QACrB,IAAI,EAAE,aAAa;QACnB,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAsB;YAC9D,IAAI,aAAa,CAAC,MAAM,CAAC;gBAAE,OAAO,kBAAkB,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;YACpE,qEAAqE;YACrE,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,MAAmD,CAAC,CAAC;YAC/E,4EAA4E;YAC5E,MAAM,OAAO,GAAG,KAAK,CAAC,CACpB,MAGD,CAAC,OAAO,CAAC;YACV,yEAAyE;YACzE,OAAO,aAAa,CAAC,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,CAA8B,CAAC;QACjF,CAAC,CAAC;KACH,CAAC,CAAC;AACL,CAAC,CAAC,CACH,CAAC"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import type { Input } from "alchemy/Input";
|
|
2
|
+
import * as Context from "effect/Context";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Layer from "effect/Layer";
|
|
5
|
+
import type * as Stream from "effect/Stream";
|
|
6
|
+
import type { OperationServices } from "./internal.ts";
|
|
7
|
+
/**
|
|
8
|
+
* How a Modal binding reaches Modal from its host.
|
|
9
|
+
*
|
|
10
|
+
* Modal grants access per environment, as a `viewer` or a `contributor`. So:
|
|
11
|
+
*
|
|
12
|
+
* - a Modal Function or Server: nothing is bound. It calls Modal as its own
|
|
13
|
+
* container, over the API socket Modal gives every container
|
|
14
|
+
* (`fromContainer`), the way Modal's Python client does there. No
|
|
15
|
+
* credential is stored. A host with `restrictModalAccess` has no such
|
|
16
|
+
* access, so it gets a service user like any other host;
|
|
17
|
+
* - any other host (a Cloudflare Worker, a Lambda, a Modal Sandbox):
|
|
18
|
+
* {@link Bind} creates a scoped `Modal.ServiceUser` for the
|
|
19
|
+
* host (`<host>ModalIdentity`), grants it the role each binding asks for
|
|
20
|
+
* on the bound resource's environment, and binds its token pair into the
|
|
21
|
+
* host's env (`MODAL_TOKEN_ID`, and `MODAL_TOKEN_SECRET` kept `Redacted`);
|
|
22
|
+
* - no host (a script or a deploy-time Action): nothing is bound, and calls
|
|
23
|
+
* use the deployer's credentials.
|
|
24
|
+
*
|
|
25
|
+
* Modal's Starter plan has no service users. There, provide
|
|
26
|
+
* {@link DeployerHostIdentity} to bind the deployer's own token pair into
|
|
27
|
+
* each host instead: hosts then act with the deployer's workspace-wide
|
|
28
|
+
* access, not the roles their bindings ask for.
|
|
29
|
+
*
|
|
30
|
+
* Import it as a namespace. A binding resolves its operations with
|
|
31
|
+
* {@link withCredentials} and gets its `bind` from {@link Bind} when its layer
|
|
32
|
+
* is built, then binds behind its own `__ALCHEMY_RUNTIME__` guard:
|
|
33
|
+
*
|
|
34
|
+
* ```ts
|
|
35
|
+
* Effect.gen(function* () {
|
|
36
|
+
* const put = yield* ModalBindings.withCredentials(modalQueue.putQueue);
|
|
37
|
+
* const bind = yield* ModalBindings.Bind;
|
|
38
|
+
* return Effect.fn(function* (queue: Queue) {
|
|
39
|
+
* if (!globalThis.__ALCHEMY_RUNTIME__) {
|
|
40
|
+
* yield* bind`Modal.WriteQueue(${queue})`({
|
|
41
|
+
* roles: [{ environment: queue.environment, role: "contributor" }],
|
|
42
|
+
* });
|
|
43
|
+
* }
|
|
44
|
+
* const queueId = yield* queue.queueId;
|
|
45
|
+
* return (value) => put({ queueId: yield* queueId, values: [...] });
|
|
46
|
+
* });
|
|
47
|
+
* })
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare const TOKEN_ENV: {
|
|
51
|
+
readonly id: "MODAL_TOKEN_ID";
|
|
52
|
+
readonly secret: "MODAL_TOKEN_SECRET";
|
|
53
|
+
readonly serverUrl: "ALCHEMY_MODAL_SERVER_URL";
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* The identity {@link Bind} gives a binding's host:
|
|
57
|
+
*
|
|
58
|
+
* - `"service-user"`: a scoped `Modal.ServiceUser` per host with only the
|
|
59
|
+
* roles its bindings ask for (needs Modal's Team or Enterprise plan);
|
|
60
|
+
* - `"deployer"`: the deployer's own token pair, with its workspace-wide
|
|
61
|
+
* access (for the Starter plan, which has no service users).
|
|
62
|
+
*
|
|
63
|
+
* Set it with {@link DeployerHostIdentity}.
|
|
64
|
+
*/
|
|
65
|
+
export declare const HostIdentity: Context.Reference<"deployer" | "service-user">;
|
|
66
|
+
/**
|
|
67
|
+
* Bind the deployer's own Modal token into binding hosts instead of a
|
|
68
|
+
* scoped service user per host. Use it on Modal's Starter plan, which has
|
|
69
|
+
* no service users; hosts then have the deployer's workspace-wide access.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* export default Alchemy.Stack(
|
|
74
|
+
* "App",
|
|
75
|
+
* { providers: Layer.mergeAll(Cloudflare.providers(), Modal.providers(), Modal.DeployerHostIdentity) },
|
|
76
|
+
* Effect.gen(function* () { ... }),
|
|
77
|
+
* );
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export declare const DeployerHostIdentity: Layer.Layer<never>;
|
|
81
|
+
/** A role a binding needs in one environment. */
|
|
82
|
+
export interface EnvironmentGrant {
|
|
83
|
+
/** The environment's name; `undefined` is the workspace default. */
|
|
84
|
+
readonly environment: Input<string | undefined>;
|
|
85
|
+
readonly role: "viewer" | "contributor";
|
|
86
|
+
}
|
|
87
|
+
/** What a Modal binding attaches to its host. */
|
|
88
|
+
export interface HostBinding {
|
|
89
|
+
/** Environment roles the host's identity needs. */
|
|
90
|
+
readonly roles?: ReadonlyArray<EnvironmentGrant>;
|
|
91
|
+
/** Env vars the binding reads at runtime. */
|
|
92
|
+
readonly env?: Record<string, unknown>;
|
|
93
|
+
}
|
|
94
|
+
/** The signature {@link Bind} yields. */
|
|
95
|
+
export type BindHost = (label: TemplateStringsArray, ...args: unknown[]) => (data?: HostBinding) => Effect.Effect<void>;
|
|
96
|
+
/**
|
|
97
|
+
* The `bind` for a binding's layer: yield it while the layer is built, then
|
|
98
|
+
* call it from the returned function behind a literal
|
|
99
|
+
* `if (!globalThis.__ALCHEMY_RUNTIME__)` so the bundler drops it. On a host it
|
|
100
|
+
* grants `data.roles` to the host's service user and binds that user's token
|
|
101
|
+
* pair (and `data.env`) into the host's env; with no host it does nothing.
|
|
102
|
+
*/
|
|
103
|
+
export declare const Bind: Effect.Effect<BindHost>;
|
|
104
|
+
/**
|
|
105
|
+
* Resolve a distilled operation (or several, with `Effect.all`) once when
|
|
106
|
+
* the binding's layer is built: with the token pair {@link Bind} bound into
|
|
107
|
+
* the host, or the deployer's credentials when there is none.
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```ts
|
|
111
|
+
* const ops = yield* ModalBindings.withCredentials(
|
|
112
|
+
* operations({ getFile: volume.volumeGetFile2, putFiles: volume.volumePutFiles2 }),
|
|
113
|
+
* );
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
export declare const withCredentials: <Op>(operation: Effect.Effect<Op, never, OperationServices>) => Effect.Effect<Op>;
|
|
117
|
+
/**
|
|
118
|
+
* Resolve a task command router operation for one sandbox: the router runs
|
|
119
|
+
* per task, at a URL with its own JWT (from `sandboxGetCommandRouterAccess`).
|
|
120
|
+
* The router credentials are applied on every call, because a resolved
|
|
121
|
+
* operation runs with its caller's `Credentials` (the control plane's) over
|
|
122
|
+
* the ones it captured. `withTaskCommandRouter` also supplies the HTTP/2
|
|
123
|
+
* client the router requires.
|
|
124
|
+
*/
|
|
125
|
+
export declare const withRouter: <I, O, E>(operation: (input: I) => Effect.Effect<O, E, OperationServices>) => (access: RouterAccess) => Effect.Effect<(input: I) => Effect.Effect<O, E>>;
|
|
126
|
+
/**
|
|
127
|
+
* {@link withRouter} for a server-streaming router operation: its `.stream`,
|
|
128
|
+
* which emits each message as the router sends it.
|
|
129
|
+
*/
|
|
130
|
+
export declare const streamRouter: <I, A, E>(operation: {
|
|
131
|
+
readonly stream: (input: I) => Stream.Stream<A, E, OperationServices>;
|
|
132
|
+
}) => (access: RouterAccess) => Effect.Effect<(input: I) => Stream.Stream<A, E>>;
|
|
133
|
+
/** A task's command router: its URL and JWT, from `sandboxGetCommandRouterAccess`. */
|
|
134
|
+
export interface RouterAccess {
|
|
135
|
+
readonly url: string;
|
|
136
|
+
readonly jwt: string;
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=ModalBindings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModalBindings.d.ts","sources":["../src/ModalBindings.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAG3C,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAGtC,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAE7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAIvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,eAAO,MAAM,SAAS;aACpB,EAAE,EAAE,gBAAgB;aACpB,MAAM,EAAE,oBAAoB;aAG5B,SAAS,EAAE,0BAA0B;CAC7B,CAAC;AAEX;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,gDAEvB,CAAC;AAEH;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAA2C,CAAC;AAEhG,iDAAiD;AACjD,MAAM,WAAW,gBAAgB;IAC/B,oEAAoE;IACpE,QAAQ,CAAC,WAAW,EAAE,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAChD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