@alchemy.run/modal 0.0.0 → 2.0.0-beta.87
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,27 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Layer from "effect/Layer";
|
|
3
|
+
import { makeModalBinding } from "./BindingHttp.ts";
|
|
4
|
+
import type { Dict } from "./Dict.ts";
|
|
5
|
+
import { DictOps, makeReadDictClient } from "./DictClient.ts";
|
|
6
|
+
import { ReadDict } from "./ReadDict.ts";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* {@link ReadDict} over Modal's API. Grants the host's identity (a scoped
|
|
10
|
+
* `Modal.ServiceUser`) the `viewer` role on the dict's environment.
|
|
11
|
+
*
|
|
12
|
+
* @layer
|
|
13
|
+
* @product Dict
|
|
14
|
+
* @provides Modal.ReadDict
|
|
15
|
+
*/
|
|
16
|
+
export const ReadDictHttp = Layer.effect(
|
|
17
|
+
ReadDict,
|
|
18
|
+
makeModalBinding({
|
|
19
|
+
tag: "Modal.ReadDict",
|
|
20
|
+
operations: DictOps,
|
|
21
|
+
role: "viewer",
|
|
22
|
+
make: Effect.fn(function* (dict: Dict, ops) {
|
|
23
|
+
const dictId = yield* dict.dictId;
|
|
24
|
+
return makeReadDictClient(dictId, ops);
|
|
25
|
+
}),
|
|
26
|
+
}),
|
|
27
|
+
);
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type * as functions from "@distilled.cloud/modal/functions";
|
|
2
|
+
import * as Binding from "alchemy/Binding";
|
|
3
|
+
import type { RuntimeContext } from "alchemy/RuntimeContext";
|
|
4
|
+
import type * as Effect from "effect/Effect";
|
|
5
|
+
import type { FunctionLookupError } from "./FunctionTarget.ts";
|
|
6
|
+
import type { OpError } from "./internal.ts";
|
|
7
|
+
import type { FunctionTarget } from "./InvokeFunction.ts";
|
|
8
|
+
import type { ReadFunctionOps } from "./ReadFunctionHttp.ts";
|
|
9
|
+
import type { Server } from "./Server.ts";
|
|
10
|
+
|
|
11
|
+
/** A time range: `Date`s, ISO strings, or epoch milliseconds. */
|
|
12
|
+
export interface TimeRange {
|
|
13
|
+
readonly since: Date | string | number;
|
|
14
|
+
readonly until?: Date | string | number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Observe a function: load, call counts and metrics. */
|
|
18
|
+
export interface FunctionReader {
|
|
19
|
+
/** Inputs waiting and running, and the containers serving them, right now. */
|
|
20
|
+
stats(): Effect.Effect<
|
|
21
|
+
{
|
|
22
|
+
readonly backlog: number;
|
|
23
|
+
readonly runningInputs: number;
|
|
24
|
+
readonly containers: number;
|
|
25
|
+
readonly inputHeadroom: number;
|
|
26
|
+
},
|
|
27
|
+
FunctionLookupError | OpError<ReadFunctionOps, "currentStats">,
|
|
28
|
+
RuntimeContext
|
|
29
|
+
>;
|
|
30
|
+
/** Input outcomes, latency percentiles and container counts over a time range. */
|
|
31
|
+
timeRangeStats(
|
|
32
|
+
range: TimeRange & { readonly containerId?: string },
|
|
33
|
+
): Effect.Effect<
|
|
34
|
+
functions.FunctionGetTimeRangeStatsResponse,
|
|
35
|
+
FunctionLookupError | OpError<ReadFunctionOps, "timeRangeStats">,
|
|
36
|
+
RuntimeContext
|
|
37
|
+
>;
|
|
38
|
+
/** Metric series (`containers`, `calls`) over a time range. */
|
|
39
|
+
metrics(
|
|
40
|
+
range: TimeRange & {
|
|
41
|
+
/** Seconds per bucket. @default 3600 */
|
|
42
|
+
readonly bucketSecs?: number;
|
|
43
|
+
readonly groups?: ReadonlyArray<string>;
|
|
44
|
+
},
|
|
45
|
+
): Effect.Effect<
|
|
46
|
+
functions.FunctionGetMetricsResponse,
|
|
47
|
+
FunctionLookupError | OpError<ReadFunctionOps, "metrics">,
|
|
48
|
+
RuntimeContext
|
|
49
|
+
>;
|
|
50
|
+
/** Calls started per time bucket. */
|
|
51
|
+
callCount(
|
|
52
|
+
range: TimeRange & {
|
|
53
|
+
/** Seconds per bucket. @default 3600 */
|
|
54
|
+
readonly bucketSecs?: number;
|
|
55
|
+
},
|
|
56
|
+
): Effect.Effect<
|
|
57
|
+
functions.FunctionCallCountResponse,
|
|
58
|
+
FunctionLookupError | OpError<ReadFunctionOps, "callCount">,
|
|
59
|
+
RuntimeContext
|
|
60
|
+
>;
|
|
61
|
+
/** The inputs of one call, by outcome. */
|
|
62
|
+
callInfo(call: {
|
|
63
|
+
readonly functionCallId: string;
|
|
64
|
+
}): Effect.Effect<
|
|
65
|
+
functions.FunctionCallGetInfoResponse,
|
|
66
|
+
FunctionLookupError | OpError<ReadFunctionOps, "callInfo">,
|
|
67
|
+
RuntimeContext
|
|
68
|
+
>;
|
|
69
|
+
/** The autoscaler settings in effect. */
|
|
70
|
+
autoscaler(): Effect.Effect<
|
|
71
|
+
functions.AutoscalerSettings | undefined,
|
|
72
|
+
FunctionLookupError | OpError<ReadFunctionOps, "schedulingParams">,
|
|
73
|
+
RuntimeContext
|
|
74
|
+
>;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Read a Modal Function's (or Server's) live state from any runtime:
|
|
79
|
+
* backlog and running inputs, call counts, outcome counts, latency
|
|
80
|
+
* percentiles and metric series. Bind a resource of the Stack, or a function
|
|
81
|
+
* deployed with `modal deploy` by name.
|
|
82
|
+
*
|
|
83
|
+
* ### Watch the backlog
|
|
84
|
+
* **Example:** Shed load when the queue is long
|
|
85
|
+
* ```typescript
|
|
86
|
+
* const embed = yield* Modal.ReadFunction(Embed);
|
|
87
|
+
* const { backlog } = yield* embed.stats();
|
|
88
|
+
* if (backlog > 100) return HttpServerResponse.text("busy", { status: 503 });
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* ### History
|
|
92
|
+
* **Example:** Failures in the last hour
|
|
93
|
+
* ```typescript
|
|
94
|
+
* const stats = yield* embed.timeRangeStats({ since: new Date(Date.now() - 3_600_000) });
|
|
95
|
+
* yield* Effect.log(`${stats.inputFailureCount} failed of ${stats.inputSuccessCount}`);
|
|
96
|
+
* ```
|
|
97
|
+
*
|
|
98
|
+
* @binding
|
|
99
|
+
* @product Function
|
|
100
|
+
*/
|
|
101
|
+
export interface ReadFunction extends Binding.Service<
|
|
102
|
+
ReadFunction,
|
|
103
|
+
"Modal.ReadFunction",
|
|
104
|
+
(target: FunctionTarget | Server) => Effect.Effect<FunctionReader>
|
|
105
|
+
> {}
|
|
106
|
+
|
|
107
|
+
export const ReadFunction = Binding.Service<ReadFunction>("Modal.ReadFunction");
|
|
@@ -0,0 +1,91 @@
|
|
|
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 { makeFunctionBinding } from "./FunctionTarget.ts";
|
|
5
|
+
import { operations, timestampOf } from "./internal.ts";
|
|
6
|
+
import type { FunctionTarget } from "./InvokeFunction.ts";
|
|
7
|
+
import { ReadFunction, type FunctionReader } from "./ReadFunction.ts";
|
|
8
|
+
import type { Server } from "./Server.ts";
|
|
9
|
+
|
|
10
|
+
/** Bucket width when a query doesn't set one: Modal requires a positive one. */
|
|
11
|
+
const DEFAULT_BUCKET_SECS = 3600;
|
|
12
|
+
|
|
13
|
+
/** The operations the client calls, resolved by `ModalBindings.withCredentials`. */
|
|
14
|
+
const ReadFunctionOps = operations({
|
|
15
|
+
currentStats: functions.functionGetCurrentStats,
|
|
16
|
+
timeRangeStats: functions.functionGetTimeRangeStats,
|
|
17
|
+
metrics: functions.functionGetMetrics,
|
|
18
|
+
callCount: functions.functionCallCount,
|
|
19
|
+
callInfo: functions.functionCallGetInfo,
|
|
20
|
+
schedulingParams: functions.functionGetSchedulingParams,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export type ReadFunctionOps = Effect.Success<typeof ReadFunctionOps>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* {@link ReadFunction} over Modal's API. Grants the host's identity (a scoped
|
|
27
|
+
* `Modal.ServiceUser`) the `viewer` role on the function's environment.
|
|
28
|
+
*
|
|
29
|
+
* @layer
|
|
30
|
+
* @product Function
|
|
31
|
+
* @provides Modal.ReadFunction
|
|
32
|
+
*/
|
|
33
|
+
export const ReadFunctionHttp = Layer.effect(
|
|
34
|
+
ReadFunction,
|
|
35
|
+
makeFunctionBinding({
|
|
36
|
+
tag: "Modal.ReadFunction",
|
|
37
|
+
operations: ReadFunctionOps,
|
|
38
|
+
role: "viewer",
|
|
39
|
+
make: ({ functionId }, ops, _target: FunctionTarget | Server) =>
|
|
40
|
+
Effect.succeed({
|
|
41
|
+
stats: () =>
|
|
42
|
+
Effect.flatMap(functionId, (id) => ops.currentStats({ functionId: id })).pipe(
|
|
43
|
+
Effect.map((stats) => ({
|
|
44
|
+
backlog: stats.backlog ?? 0,
|
|
45
|
+
runningInputs: stats.numRunningInputs ?? 0,
|
|
46
|
+
containers: stats.numTotalTasks ?? 0,
|
|
47
|
+
inputHeadroom: stats.inputHeadroom ?? 0,
|
|
48
|
+
})),
|
|
49
|
+
),
|
|
50
|
+
timeRangeStats: (range) =>
|
|
51
|
+
Effect.flatMap(functionId, (id) =>
|
|
52
|
+
ops.timeRangeStats({
|
|
53
|
+
functionId: id,
|
|
54
|
+
since: timestampOf(range.since),
|
|
55
|
+
until: timestampOf(range.until ?? Date.now()),
|
|
56
|
+
containerId: range.containerId,
|
|
57
|
+
}),
|
|
58
|
+
),
|
|
59
|
+
metrics: (range) =>
|
|
60
|
+
Effect.flatMap(functionId, (id) =>
|
|
61
|
+
ops.metrics({
|
|
62
|
+
functionId: id,
|
|
63
|
+
since: timestampOf(range.since),
|
|
64
|
+
until: timestampOf(range.until ?? Date.now()),
|
|
65
|
+
bucketSecs: range.bucketSecs ?? DEFAULT_BUCKET_SECS,
|
|
66
|
+
groups: range.groups ? [...range.groups] : undefined,
|
|
67
|
+
}),
|
|
68
|
+
),
|
|
69
|
+
callCount: (range) =>
|
|
70
|
+
Effect.flatMap(functionId, (id) =>
|
|
71
|
+
ops.callCount({
|
|
72
|
+
functionId: id,
|
|
73
|
+
since: timestampOf(range.since),
|
|
74
|
+
until: timestampOf(range.until ?? Date.now()),
|
|
75
|
+
bucketSecs: range.bucketSecs ?? DEFAULT_BUCKET_SECS,
|
|
76
|
+
}),
|
|
77
|
+
),
|
|
78
|
+
callInfo: (call) =>
|
|
79
|
+
Effect.flatMap(functionId, (id) =>
|
|
80
|
+
ops.callInfo({
|
|
81
|
+
functionId: id,
|
|
82
|
+
functionCallId: call.functionCallId,
|
|
83
|
+
}),
|
|
84
|
+
),
|
|
85
|
+
autoscaler: () =>
|
|
86
|
+
Effect.flatMap(functionId, (id) => ops.schedulingParams({ functionId: id })).pipe(
|
|
87
|
+
Effect.map((response) => response.autoscalerConfiguration?.settings),
|
|
88
|
+
),
|
|
89
|
+
} satisfies FunctionReader),
|
|
90
|
+
}),
|
|
91
|
+
);
|
package/src/ReadQueue.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as Binding from "alchemy/Binding";
|
|
2
|
+
import type * as Effect from "effect/Effect";
|
|
3
|
+
import type { Queue } from "./Queue.ts";
|
|
4
|
+
import type { ReadQueueClient } from "./QueueClient.ts";
|
|
5
|
+
|
|
6
|
+
export type { ReadQueueClient } from "./QueueClient.ts";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Take items from a Modal Queue from any runtime: take (removes), peek and len. Items are JSON.
|
|
10
|
+
*
|
|
11
|
+
* ### Bind a queue
|
|
12
|
+
* **Example:** From a Cloudflare Worker
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import * as Cloudflare from "@alchemy.run/cloudflare";
|
|
15
|
+
* import * as Modal from "@alchemy.run/modal";
|
|
16
|
+
* import * as Effect from "effect/Effect";
|
|
17
|
+
* import * as HttpServerResponse from "effect/http/HttpServerResponse";
|
|
18
|
+
* import { Jobs } from "./Storage.ts";
|
|
19
|
+
*
|
|
20
|
+
* export default class Api extends Cloudflare.Worker<Api>()(
|
|
21
|
+
* "Api",
|
|
22
|
+
* { main: import.meta.url },
|
|
23
|
+
* Effect.gen(function* () {
|
|
24
|
+
* const queue = yield* Modal.ReadQueue(Jobs);
|
|
25
|
+
* return {
|
|
26
|
+
* fetch: Effect.gen(function* () {
|
|
27
|
+
* const [job] = yield* queue.take({ timeout: "5 seconds" });
|
|
28
|
+
* return yield* HttpServerResponse.json(job ?? null);
|
|
29
|
+
* }).pipe(Effect.orDie),
|
|
30
|
+
* };
|
|
31
|
+
* }).pipe(Effect.provide(Modal.ReadQueueHttp)),
|
|
32
|
+
* ) {}
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @binding
|
|
36
|
+
* @product Queue
|
|
37
|
+
*/
|
|
38
|
+
export interface ReadQueue extends Binding.Service<
|
|
39
|
+
ReadQueue,
|
|
40
|
+
"Modal.ReadQueue",
|
|
41
|
+
(queue: Queue) => Effect.Effect<ReadQueueClient>
|
|
42
|
+
> {}
|
|
43
|
+
|
|
44
|
+
export const ReadQueue = Binding.Service<ReadQueue>("Modal.ReadQueue");
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Layer from "effect/Layer";
|
|
3
|
+
import { makeModalBinding } from "./BindingHttp.ts";
|
|
4
|
+
import type { Queue } from "./Queue.ts";
|
|
5
|
+
import { QueueOps, makeReadQueueClient } from "./QueueClient.ts";
|
|
6
|
+
import { ReadQueue } from "./ReadQueue.ts";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* {@link ReadQueue} over Modal's API. Grants the host's identity (a scoped
|
|
10
|
+
* `Modal.ServiceUser`) the `contributor` role on the queue's environment.
|
|
11
|
+
*
|
|
12
|
+
* @layer
|
|
13
|
+
* @product Queue
|
|
14
|
+
* @provides Modal.ReadQueue
|
|
15
|
+
*/
|
|
16
|
+
export const ReadQueueHttp = Layer.effect(
|
|
17
|
+
ReadQueue,
|
|
18
|
+
makeModalBinding({
|
|
19
|
+
tag: "Modal.ReadQueue",
|
|
20
|
+
operations: QueueOps,
|
|
21
|
+
role: "contributor",
|
|
22
|
+
make: Effect.fn(function* (queue: Queue, ops) {
|
|
23
|
+
const queueId = yield* queue.queueId;
|
|
24
|
+
return makeReadQueueClient(queueId, ops);
|
|
25
|
+
}),
|
|
26
|
+
}),
|
|
27
|
+
);
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type * as server from "@distilled.cloud/modal/server";
|
|
2
|
+
import * as Binding from "alchemy/Binding";
|
|
3
|
+
import type { RuntimeContext } from "alchemy/RuntimeContext";
|
|
4
|
+
import type * as Effect from "effect/Effect";
|
|
5
|
+
import type { FunctionLookupError } from "./FunctionTarget.ts";
|
|
6
|
+
import type { OpError } from "./internal.ts";
|
|
7
|
+
import type { TimeRange } from "./ReadFunction.ts";
|
|
8
|
+
import type { ReadServerOps } from "./ReadServerHttp.ts";
|
|
9
|
+
import type { Server } from "./Server.ts";
|
|
10
|
+
|
|
11
|
+
/** One request a Server handled. */
|
|
12
|
+
export interface ServerRequest {
|
|
13
|
+
readonly route: string | undefined;
|
|
14
|
+
readonly timestamp: string | undefined;
|
|
15
|
+
readonly containerId: string | undefined;
|
|
16
|
+
readonly durationSeconds: number | undefined;
|
|
17
|
+
readonly status: number | undefined;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** A container serving a Server's requests. */
|
|
21
|
+
export interface ServerContainer {
|
|
22
|
+
readonly containerId: string;
|
|
23
|
+
readonly host: string | undefined;
|
|
24
|
+
readonly port: number | undefined;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Observe a Server: requests, status codes, latency and containers. */
|
|
28
|
+
export interface ServerReader {
|
|
29
|
+
/** Request counts by status code, latency percentiles and inference stats over a time range. */
|
|
30
|
+
stats(
|
|
31
|
+
range: TimeRange & { readonly containerId?: string },
|
|
32
|
+
): Effect.Effect<
|
|
33
|
+
server.ServerGetTimeRangeStatsResponse,
|
|
34
|
+
FunctionLookupError | OpError<ReadServerOps, "stats">,
|
|
35
|
+
RuntimeContext
|
|
36
|
+
>;
|
|
37
|
+
/**
|
|
38
|
+
* Requests the Server handled: the most recent `limit` (newest first, last
|
|
39
|
+
* seven days), or those in a time range (oldest first).
|
|
40
|
+
*/
|
|
41
|
+
requests(
|
|
42
|
+
query: { readonly limit: number } | TimeRange,
|
|
43
|
+
): Effect.Effect<
|
|
44
|
+
ReadonlyArray<ServerRequest>,
|
|
45
|
+
FunctionLookupError | OpError<ReadServerOps, "requests">,
|
|
46
|
+
RuntimeContext
|
|
47
|
+
>;
|
|
48
|
+
/** Requests per time bucket. */
|
|
49
|
+
requestCount(
|
|
50
|
+
range: TimeRange & { readonly bucketSecs?: number },
|
|
51
|
+
): Effect.Effect<
|
|
52
|
+
server.ServerCountRequestsResponse,
|
|
53
|
+
FunctionLookupError | OpError<ReadServerOps, "requestCount">,
|
|
54
|
+
RuntimeContext
|
|
55
|
+
>;
|
|
56
|
+
/** Metric series (`containers`, `requests`) over a time range. */
|
|
57
|
+
metrics(
|
|
58
|
+
range: TimeRange & { readonly bucketSecs?: number; readonly groups?: ReadonlyArray<string> },
|
|
59
|
+
): Effect.Effect<
|
|
60
|
+
server.ServerGetMetricsResponse,
|
|
61
|
+
FunctionLookupError | OpError<ReadServerOps, "metrics">,
|
|
62
|
+
RuntimeContext
|
|
63
|
+
>;
|
|
64
|
+
/** Containers registered to serve requests right now. */
|
|
65
|
+
containers(): Effect.Effect<
|
|
66
|
+
ReadonlyArray<ServerContainer>,
|
|
67
|
+
FunctionLookupError | OpError<ReadServerOps, "containers">,
|
|
68
|
+
RuntimeContext
|
|
69
|
+
>;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Read a `Modal.Server`'s traffic from any runtime: request log, status
|
|
74
|
+
* codes, latency percentiles, metric series and live containers.
|
|
75
|
+
*
|
|
76
|
+
* ### Error rate
|
|
77
|
+
* **Example:** 5xx responses in the last ten minutes
|
|
78
|
+
* ```typescript
|
|
79
|
+
* const api = yield* Modal.ReadServer(Api);
|
|
80
|
+
* const stats = yield* api.stats({ since: new Date(Date.now() - 600_000) });
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* ### Recent requests
|
|
84
|
+
* **Example:** The last 20 requests
|
|
85
|
+
* ```typescript
|
|
86
|
+
* const recent = yield* api.requests({ limit: 20 });
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* @binding
|
|
90
|
+
* @product Server
|
|
91
|
+
*/
|
|
92
|
+
export interface ReadServer extends Binding.Service<
|
|
93
|
+
ReadServer,
|
|
94
|
+
"Modal.ReadServer",
|
|
95
|
+
(server: Server) => Effect.Effect<ServerReader>
|
|
96
|
+
> {}
|
|
97
|
+
|
|
98
|
+
export const ReadServer = Binding.Service<ReadServer>("Modal.ReadServer");
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import * as flash from "@distilled.cloud/modal/flash";
|
|
2
|
+
import * as server from "@distilled.cloud/modal/server";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Layer from "effect/Layer";
|
|
5
|
+
import { makeFunctionBinding } from "./FunctionTarget.ts";
|
|
6
|
+
import { operations, timestampOf } from "./internal.ts";
|
|
7
|
+
import { ReadServer, type ServerReader } from "./ReadServer.ts";
|
|
8
|
+
import type { Server } from "./Server.ts";
|
|
9
|
+
|
|
10
|
+
/** The operations the client calls, resolved by `ModalBindings.withCredentials`. */
|
|
11
|
+
const ReadServerOps = operations({
|
|
12
|
+
stats: server.serverGetTimeRangeStats,
|
|
13
|
+
requests: server.fetchServerRequest,
|
|
14
|
+
requestCount: server.serverCountRequests,
|
|
15
|
+
metrics: server.serverGetMetrics,
|
|
16
|
+
containers: flash.listFlashContainer,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export type ReadServerOps = Effect.Success<typeof ReadServerOps>;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* {@link ReadServer} over Modal's API. Grants the host's identity (a scoped
|
|
23
|
+
* `Modal.ServiceUser`) the `viewer` role on the server's environment.
|
|
24
|
+
*
|
|
25
|
+
* @layer
|
|
26
|
+
* @product Server
|
|
27
|
+
* @provides Modal.ReadServer
|
|
28
|
+
*/
|
|
29
|
+
export const ReadServerHttp = Layer.effect(
|
|
30
|
+
ReadServer,
|
|
31
|
+
makeFunctionBinding({
|
|
32
|
+
tag: "Modal.ReadServer",
|
|
33
|
+
operations: ReadServerOps,
|
|
34
|
+
role: "viewer",
|
|
35
|
+
make: ({ functionId }, ops, _server: Server) =>
|
|
36
|
+
Effect.succeed({
|
|
37
|
+
stats: (range) =>
|
|
38
|
+
Effect.flatMap(functionId, (id) =>
|
|
39
|
+
ops.stats({
|
|
40
|
+
functionId: id,
|
|
41
|
+
since: timestampOf(range.since),
|
|
42
|
+
until: timestampOf(range.until ?? Date.now()),
|
|
43
|
+
containerId: range.containerId,
|
|
44
|
+
}),
|
|
45
|
+
),
|
|
46
|
+
requests: (query) =>
|
|
47
|
+
Effect.flatMap(functionId, (id) =>
|
|
48
|
+
ops.requests(
|
|
49
|
+
"limit" in query
|
|
50
|
+
? { functionId: id, tail: { count: query.limit } }
|
|
51
|
+
: {
|
|
52
|
+
functionId: id,
|
|
53
|
+
range: {
|
|
54
|
+
since: timestampOf(query.since),
|
|
55
|
+
until: timestampOf(query.until ?? Date.now()),
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
),
|
|
59
|
+
).pipe(
|
|
60
|
+
Effect.map((response) =>
|
|
61
|
+
(response.requests ?? []).map((request) => ({
|
|
62
|
+
route: request.route,
|
|
63
|
+
timestamp: request.timestamp,
|
|
64
|
+
containerId: request.containerId,
|
|
65
|
+
durationSeconds: request.durationSeconds,
|
|
66
|
+
status: request.status,
|
|
67
|
+
})),
|
|
68
|
+
),
|
|
69
|
+
),
|
|
70
|
+
requestCount: (range) =>
|
|
71
|
+
Effect.flatMap(functionId, (id) =>
|
|
72
|
+
ops.requestCount({
|
|
73
|
+
functionId: id,
|
|
74
|
+
since: timestampOf(range.since),
|
|
75
|
+
until: timestampOf(range.until ?? Date.now()),
|
|
76
|
+
bucketSecs: range.bucketSecs,
|
|
77
|
+
}),
|
|
78
|
+
),
|
|
79
|
+
metrics: (range) =>
|
|
80
|
+
Effect.flatMap(functionId, (id) =>
|
|
81
|
+
ops.metrics({
|
|
82
|
+
functionId: id,
|
|
83
|
+
since: timestampOf(range.since),
|
|
84
|
+
until: timestampOf(range.until ?? Date.now()),
|
|
85
|
+
bucketSecs: range.bucketSecs,
|
|
86
|
+
groups: range.groups ? [...range.groups] : undefined,
|
|
87
|
+
}),
|
|
88
|
+
),
|
|
89
|
+
containers: () =>
|
|
90
|
+
Effect.flatMap(functionId, (id) => ops.containers({ functionId: id })).pipe(
|
|
91
|
+
Effect.map((response) =>
|
|
92
|
+
(response.containers ?? []).map((container) => ({
|
|
93
|
+
containerId: container.taskId ?? "",
|
|
94
|
+
host: container.host,
|
|
95
|
+
port: container.port,
|
|
96
|
+
})),
|
|
97
|
+
),
|
|
98
|
+
),
|
|
99
|
+
} satisfies ServerReader),
|
|
100
|
+
}),
|
|
101
|
+
);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as Binding from "alchemy/Binding";
|
|
2
|
+
import type * as Effect from "effect/Effect";
|
|
3
|
+
import type { Volume } from "./Volume.ts";
|
|
4
|
+
import type { ReadVolumeClient } from "./VolumeClient.ts";
|
|
5
|
+
|
|
6
|
+
export type { ReadVolumeClient } from "./VolumeClient.ts";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Read a Modal Volume's files from any runtime (a Worker, a Lambda, a Modal sandbox) without mounting it: list directories and read files over Modal's volume API.
|
|
10
|
+
*
|
|
11
|
+
* ### Bind a volume
|
|
12
|
+
* **Example:** Read from a Cloudflare Worker
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import * as Cloudflare from "@alchemy.run/cloudflare";
|
|
15
|
+
* import * as Modal from "@alchemy.run/modal";
|
|
16
|
+
* import * as Effect from "effect/Effect";
|
|
17
|
+
* import * as HttpServerResponse from "effect/http/HttpServerResponse";
|
|
18
|
+
* import { Workspace } from "./Storage.ts";
|
|
19
|
+
*
|
|
20
|
+
* export default class Api extends Cloudflare.Worker<Api>()(
|
|
21
|
+
* "Api",
|
|
22
|
+
* { main: import.meta.url },
|
|
23
|
+
* Effect.gen(function* () {
|
|
24
|
+
* const volume = yield* Modal.ReadVolume(Workspace);
|
|
25
|
+
* return {
|
|
26
|
+
* fetch: Effect.gen(function* () {
|
|
27
|
+
* const files = yield* volume.listFiles("/");
|
|
28
|
+
* const readme = yield* volume.readFileString("/README.md");
|
|
29
|
+
* return yield* HttpServerResponse.json({ files, readme });
|
|
30
|
+
* }).pipe(Effect.orDie),
|
|
31
|
+
* };
|
|
32
|
+
* }).pipe(Effect.provide(Modal.ReadVolumeHttp)),
|
|
33
|
+
* ) {}
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @binding
|
|
37
|
+
* @product Volume
|
|
38
|
+
*/
|
|
39
|
+
export interface ReadVolume extends Binding.Service<
|
|
40
|
+
ReadVolume,
|
|
41
|
+
"Modal.ReadVolume",
|
|
42
|
+
(volume: Volume) => Effect.Effect<ReadVolumeClient>
|
|
43
|
+
> {}
|
|
44
|
+
|
|
45
|
+
export const ReadVolume = Binding.Service<ReadVolume>("Modal.ReadVolume");
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Layer from "effect/Layer";
|
|
3
|
+
import { makeModalBinding } from "./BindingHttp.ts";
|
|
4
|
+
import { ReadVolume } from "./ReadVolume.ts";
|
|
5
|
+
import type { Volume } from "./Volume.ts";
|
|
6
|
+
import { makeReadVolumeClient } from "./VolumeClient.ts";
|
|
7
|
+
import { VolumeFileOps } from "./VolumeFiles.ts";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* {@link ReadVolume} over Modal's volume API. Grants the host's identity (a scoped
|
|
11
|
+
* `Modal.ServiceUser`) the `viewer` role on the volume's environment.
|
|
12
|
+
*
|
|
13
|
+
* @layer
|
|
14
|
+
* @product Volume
|
|
15
|
+
* @provides Modal.ReadVolume
|
|
16
|
+
*/
|
|
17
|
+
export const ReadVolumeHttp = Layer.effect(
|
|
18
|
+
ReadVolume,
|
|
19
|
+
makeModalBinding({
|
|
20
|
+
tag: "Modal.ReadVolume",
|
|
21
|
+
operations: VolumeFileOps,
|
|
22
|
+
role: "viewer",
|
|
23
|
+
make: Effect.fn(function* (volume: Volume, ops) {
|
|
24
|
+
const volumeId = yield* volume.volumeId;
|
|
25
|
+
return makeReadVolumeClient(volumeId, ops);
|
|
26
|
+
}),
|
|
27
|
+
}),
|
|
28
|
+
);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as Binding from "alchemy/Binding";
|
|
2
|
+
import type * as Effect from "effect/Effect";
|
|
3
|
+
import type { Dict } from "./Dict.ts";
|
|
4
|
+
import type { ReadWriteDictClient } from "./DictClient.ts";
|
|
5
|
+
|
|
6
|
+
export type { ReadWriteDictClient } from "./DictClient.ts";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Read and write a Modal Dict from any runtime. Keys and values are JSON.
|
|
10
|
+
*
|
|
11
|
+
* ### Bind a dict
|
|
12
|
+
* **Example:** From a Cloudflare Worker
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import * as Cloudflare from "@alchemy.run/cloudflare";
|
|
15
|
+
* import * as Modal from "@alchemy.run/modal";
|
|
16
|
+
* import * as Effect from "effect/Effect";
|
|
17
|
+
* import * as HttpServerResponse from "effect/http/HttpServerResponse";
|
|
18
|
+
* import { Results } from "./Storage.ts";
|
|
19
|
+
*
|
|
20
|
+
* export default class Api extends Cloudflare.Worker<Api>()(
|
|
21
|
+
* "Api",
|
|
22
|
+
* { main: import.meta.url },
|
|
23
|
+
* Effect.gen(function* () {
|
|
24
|
+
* const dict = yield* Modal.ReadWriteDict(Results);
|
|
25
|
+
* return {
|
|
26
|
+
* fetch: Effect.gen(function* () {
|
|
27
|
+
* yield* dict.put("hits", ((yield* dict.get<number>("hits")) ?? 0) + 1);
|
|
28
|
+
* return yield* HttpServerResponse.json({ hits: yield* dict.get("hits") });
|
|
29
|
+
* }).pipe(Effect.orDie),
|
|
30
|
+
* };
|
|
31
|
+
* }).pipe(Effect.provide(Modal.ReadWriteDictHttp)),
|
|
32
|
+
* ) {}
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @binding
|
|
36
|
+
* @product Dict
|
|
37
|
+
*/
|
|
38
|
+
export interface ReadWriteDict extends Binding.Service<
|
|
39
|
+
ReadWriteDict,
|
|
40
|
+
"Modal.ReadWriteDict",
|
|
41
|
+
(dict: Dict) => Effect.Effect<ReadWriteDictClient>
|
|
42
|
+
> {}
|
|
43
|
+
|
|
44
|
+
export const ReadWriteDict = Binding.Service<ReadWriteDict>("Modal.ReadWriteDict");
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Layer from "effect/Layer";
|
|
3
|
+
import { makeModalBinding } from "./BindingHttp.ts";
|
|
4
|
+
import type { Dict } from "./Dict.ts";
|
|
5
|
+
import { DictOps, makeReadWriteDictClient } from "./DictClient.ts";
|
|
6
|
+
import { ReadWriteDict } from "./ReadWriteDict.ts";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* {@link ReadWriteDict} over Modal's API. Grants the host's identity (a scoped
|
|
10
|
+
* `Modal.ServiceUser`) the `contributor` role on the dict's environment.
|
|
11
|
+
*
|
|
12
|
+
* @layer
|
|
13
|
+
* @product Dict
|
|
14
|
+
* @provides Modal.ReadWriteDict
|
|
15
|
+
*/
|
|
16
|
+
export const ReadWriteDictHttp = Layer.effect(
|
|
17
|
+
ReadWriteDict,
|
|
18
|
+
makeModalBinding({
|
|
19
|
+
tag: "Modal.ReadWriteDict",
|
|
20
|
+
operations: DictOps,
|
|
21
|
+
role: "contributor",
|
|
22
|
+
make: Effect.fn(function* (dict: Dict, ops) {
|
|
23
|
+
const dictId = yield* dict.dictId;
|
|
24
|
+
return makeReadWriteDictClient(dictId, ops);
|
|
25
|
+
}),
|
|
26
|
+
}),
|
|
27
|
+
);
|