@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
package/src/Queue.ts
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import * as queue from "@distilled.cloud/modal/queue";
|
|
2
|
+
import { Unowned } from "alchemy/AdoptPolicy";
|
|
3
|
+
import { isResolved } from "alchemy/Diff";
|
|
4
|
+
import * as Provider from "alchemy/Provider";
|
|
5
|
+
import { Resource } from "alchemy/Resource";
|
|
6
|
+
import * as Data from "effect/Data";
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
import {
|
|
9
|
+
type EnvironmentInput,
|
|
10
|
+
envNameOf,
|
|
11
|
+
environmentNames,
|
|
12
|
+
environmentOf,
|
|
13
|
+
isGeneratedName,
|
|
14
|
+
listAll,
|
|
15
|
+
objectName,
|
|
16
|
+
} from "./internal.ts";
|
|
17
|
+
import { declarable } from "./internal/Declared.ts";
|
|
18
|
+
import type { Providers } from "./Providers.ts";
|
|
19
|
+
import { isRuntimeName } from "./RuntimeOwner.ts";
|
|
20
|
+
|
|
21
|
+
export class QueueUnexpectedResponse extends Data.TaggedError("Modal.QueueUnexpectedResponse")<{
|
|
22
|
+
readonly message: string;
|
|
23
|
+
}> {}
|
|
24
|
+
|
|
25
|
+
export interface QueueProps {
|
|
26
|
+
/**
|
|
27
|
+
* Queue name, unique per environment. If omitted, a unique name is
|
|
28
|
+
* generated from the stack, stage and logical ID. Changing it replaces the
|
|
29
|
+
* queue (Modal can't rename queues).
|
|
30
|
+
*/
|
|
31
|
+
name?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Environment the queue lives in. Changing it replaces the queue.
|
|
34
|
+
* @default the workspace's default environment
|
|
35
|
+
*/
|
|
36
|
+
environment?: EnvironmentInput;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface QueueAttributes {
|
|
40
|
+
/** Queue ID (`qu-…`). */
|
|
41
|
+
queueId: string;
|
|
42
|
+
/** Queue name. */
|
|
43
|
+
name: string;
|
|
44
|
+
/** Environment name, or `undefined` for the workspace default. */
|
|
45
|
+
environment: string | undefined;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* A Modal Queue: a distributed FIFO queue shared by every container, Sandbox
|
|
50
|
+
* and client in the workspace, with optional named partitions. Items expire
|
|
51
|
+
* 24 hours after they are put (partitions can set their own TTL).
|
|
52
|
+
*
|
|
53
|
+
* Bind it with {@link WriteQueue} to put items, {@link ReadQueue} to take
|
|
54
|
+
* them, or {@link ReadWriteQueue} for both, from a Worker, Lambda or any
|
|
55
|
+
* other runtime. Values travel as bytes: the bindings encode them as JSON by
|
|
56
|
+
* default.
|
|
57
|
+
*
|
|
58
|
+
* Modal queues have no tags. Ownership is inferred from Alchemy state: a
|
|
59
|
+
* queue found under an explicit `name` without prior state is reported as
|
|
60
|
+
* unowned.
|
|
61
|
+
*
|
|
62
|
+
* ### Creating a Queue
|
|
63
|
+
* **Example:** A queue with a generated name
|
|
64
|
+
* ```typescript
|
|
65
|
+
* import * as Modal from "@alchemy.run/modal";
|
|
66
|
+
*
|
|
67
|
+
* export const Jobs = Modal.Queue("Jobs", {});
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* **Example:** A named queue in an environment
|
|
71
|
+
* ```typescript
|
|
72
|
+
* import * as Modal from "@alchemy.run/modal";
|
|
73
|
+
*
|
|
74
|
+
* export const Agents = Modal.Environment("Agents", {});
|
|
75
|
+
* export const Tasks = Modal.Queue("Tasks", { name: "tasks", environment: Agents });
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* ### Producing from a Worker
|
|
79
|
+
* **Example:** Bind write access and put a job
|
|
80
|
+
* ```typescript
|
|
81
|
+
* import * as Cloudflare from "@alchemy.run/cloudflare";
|
|
82
|
+
* import * as Modal from "@alchemy.run/modal";
|
|
83
|
+
* import * as Effect from "effect/Effect";
|
|
84
|
+
* import * as HttpServerResponse from "effect/http/HttpServerResponse";
|
|
85
|
+
* import { Jobs } from "./Storage.ts";
|
|
86
|
+
*
|
|
87
|
+
* export default class Api extends Cloudflare.Worker<Api>()(
|
|
88
|
+
* "Api",
|
|
89
|
+
* { main: import.meta.url },
|
|
90
|
+
* Effect.gen(function* () {
|
|
91
|
+
* const jobs = yield* Modal.WriteQueue(Jobs);
|
|
92
|
+
* return {
|
|
93
|
+
* fetch: Effect.gen(function* () {
|
|
94
|
+
* yield* jobs.put({ repo: "alchemy-run/alchemy", command: "pnpm test" });
|
|
95
|
+
* return HttpServerResponse.text("queued");
|
|
96
|
+
* }).pipe(Effect.orDie),
|
|
97
|
+
* };
|
|
98
|
+
* }).pipe(Effect.provide(Modal.WriteQueueHttp)),
|
|
99
|
+
* ) {}
|
|
100
|
+
* ```
|
|
101
|
+
*
|
|
102
|
+
* ### Looking up an existing queue
|
|
103
|
+
* `Queue.lookup` references a queue Alchemy doesn't manage (created with
|
|
104
|
+
* the Modal CLI or by another stack). It is read during plan/deploy, never
|
|
105
|
+
* created, updated or deleted.
|
|
106
|
+
*
|
|
107
|
+
* **Example:** Reference an existing queue
|
|
108
|
+
* ```typescript
|
|
109
|
+
* const jobs = Modal.Queue.lookup({ name: "jobs" });
|
|
110
|
+
* ```
|
|
111
|
+
*
|
|
112
|
+
* @resource
|
|
113
|
+
* @product Queue
|
|
114
|
+
*/
|
|
115
|
+
export const Queue = declarable<Queue>()(Resource<Queue>("Modal.Queue"));
|
|
116
|
+
|
|
117
|
+
export type Queue = Resource<
|
|
118
|
+
"Modal.Queue",
|
|
119
|
+
QueueProps,
|
|
120
|
+
QueueAttributes,
|
|
121
|
+
never,
|
|
122
|
+
Providers,
|
|
123
|
+
QueueLookup
|
|
124
|
+
>;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Props for {@link Queue.lookup}: find a queue this stack
|
|
128
|
+
* doesn't manage by its name.
|
|
129
|
+
*/
|
|
130
|
+
export interface QueueLookup {
|
|
131
|
+
/** Queue name. */
|
|
132
|
+
name: string;
|
|
133
|
+
/**
|
|
134
|
+
* Modal environment the object lives in.
|
|
135
|
+
* @default the workspace's default environment
|
|
136
|
+
*/
|
|
137
|
+
environment?: string;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** A queue by name, or `undefined` when missing. */
|
|
141
|
+
export const lookupQueue = Effect.fn(function* (
|
|
142
|
+
getOrCreate: Effect.Success<typeof queue.queueGetOrCreate>,
|
|
143
|
+
name: string,
|
|
144
|
+
env: string | undefined,
|
|
145
|
+
) {
|
|
146
|
+
const found = yield* getOrCreate({
|
|
147
|
+
deploymentName: name,
|
|
148
|
+
environmentName: environmentOf(env),
|
|
149
|
+
objectCreationType: "OBJECT_CREATION_TYPE_UNSPECIFIED",
|
|
150
|
+
}).pipe(Effect.catchTag("QueueNotFound", () => Effect.undefined));
|
|
151
|
+
if (!found?.queueId) return undefined;
|
|
152
|
+
return { queueId: found.queueId, name, environment: env } satisfies QueueAttributes;
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Get a queue by name, creating it when missing: the one implementation behind
|
|
157
|
+
* {@link Queue}'s reconcile and the runtime {@link CreateQueue} client.
|
|
158
|
+
*/
|
|
159
|
+
export const ensureQueue = Effect.fn(function* (
|
|
160
|
+
getOrCreate: Effect.Success<typeof queue.queueGetOrCreate>,
|
|
161
|
+
name: string,
|
|
162
|
+
env: string | undefined,
|
|
163
|
+
) {
|
|
164
|
+
const created = yield* getOrCreate({
|
|
165
|
+
deploymentName: name,
|
|
166
|
+
environmentName: environmentOf(env),
|
|
167
|
+
objectCreationType: "OBJECT_CREATION_TYPE_CREATE_IF_MISSING",
|
|
168
|
+
});
|
|
169
|
+
if (!created.queueId) {
|
|
170
|
+
return yield* new QueueUnexpectedResponse({
|
|
171
|
+
message: `Modal returned no id for queue ${name}`,
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
return { queueId: created.queueId, name, environment: env } satisfies QueueAttributes;
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
export const QueueProvider = () =>
|
|
178
|
+
Provider.effect(
|
|
179
|
+
Queue,
|
|
180
|
+
Effect.gen(function* () {
|
|
181
|
+
const observe = Effect.fn(function* (
|
|
182
|
+
queueId: string | undefined,
|
|
183
|
+
name: string,
|
|
184
|
+
env: string | undefined,
|
|
185
|
+
) {
|
|
186
|
+
if (queueId !== undefined) {
|
|
187
|
+
const byId = yield* queue
|
|
188
|
+
.queueGetById({ queueId })
|
|
189
|
+
.pipe(Effect.catchTag("QueueNotFound", () => Effect.undefined));
|
|
190
|
+
if (byId?.queueId) {
|
|
191
|
+
return {
|
|
192
|
+
queueId: byId.queueId,
|
|
193
|
+
name: byId.metadata?.name ?? name,
|
|
194
|
+
environment: env,
|
|
195
|
+
} satisfies QueueAttributes;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return yield* lookupQueue(yield* queue.queueGetOrCreate, name, env);
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
return {
|
|
202
|
+
stables: ["queueId", "name", "environment"],
|
|
203
|
+
diff: Effect.fn(function* ({ id, news, olds, output }) {
|
|
204
|
+
if (!isResolved(news)) return undefined;
|
|
205
|
+
if (envNameOf(news.environment) !== envNameOf(olds?.environment))
|
|
206
|
+
return { action: "replace" } as const;
|
|
207
|
+
const name = yield* objectName(id, news.name);
|
|
208
|
+
if (output !== undefined && name !== output.name) return { action: "replace" } as const;
|
|
209
|
+
return undefined;
|
|
210
|
+
}),
|
|
211
|
+
lookup: Effect.fn(function* ({ name, environment }) {
|
|
212
|
+
return yield* observe(undefined, name, environment);
|
|
213
|
+
}),
|
|
214
|
+
|
|
215
|
+
read: Effect.fn(function* ({ id, olds, output }) {
|
|
216
|
+
const name = output?.name ?? (yield* objectName(id, olds?.name));
|
|
217
|
+
const observed = yield* observe(output?.queueId, name, envNameOf(olds?.environment));
|
|
218
|
+
if (!observed) return undefined;
|
|
219
|
+
return output !== undefined || olds?.name === undefined ? observed : Unowned(observed);
|
|
220
|
+
}),
|
|
221
|
+
reconcile: Effect.fn(function* ({ id, news, output, session }) {
|
|
222
|
+
const name = output?.name ?? (yield* objectName(id, news.name));
|
|
223
|
+
const current = yield* observe(output?.queueId, name, envNameOf(news.environment));
|
|
224
|
+
if (current) return current;
|
|
225
|
+
yield* session.note(`Creating queue ${name}...`);
|
|
226
|
+
return yield* ensureQueue(
|
|
227
|
+
yield* queue.queueGetOrCreate,
|
|
228
|
+
name,
|
|
229
|
+
envNameOf(news.environment),
|
|
230
|
+
);
|
|
231
|
+
}),
|
|
232
|
+
delete: Effect.fn(function* ({ output }) {
|
|
233
|
+
yield* queue
|
|
234
|
+
.deleteQueue({ queueId: output.queueId })
|
|
235
|
+
.pipe(Effect.catchTag("QueueNotFound", () => Effect.void));
|
|
236
|
+
}),
|
|
237
|
+
list: Effect.fn(function* () {
|
|
238
|
+
const envs = yield* environmentNames;
|
|
239
|
+
const all: QueueAttributes[] = [];
|
|
240
|
+
for (const env of envs) {
|
|
241
|
+
const items = yield* listAll(
|
|
242
|
+
(pagination) =>
|
|
243
|
+
queue
|
|
244
|
+
.listQueue({ environmentName: env, pagination })
|
|
245
|
+
.pipe(Effect.map((response) => response.queues ?? [])),
|
|
246
|
+
(item) => item.createdAt,
|
|
247
|
+
);
|
|
248
|
+
for (const item of items) {
|
|
249
|
+
if (!item.queueId || !(isGeneratedName(item.name) || isRuntimeName(item.name)))
|
|
250
|
+
continue;
|
|
251
|
+
all.push({ queueId: item.queueId, name: item.name ?? "", environment: env });
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
return all;
|
|
255
|
+
}),
|
|
256
|
+
};
|
|
257
|
+
}),
|
|
258
|
+
);
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import * as queue from "@distilled.cloud/modal/queue";
|
|
2
|
+
import type { RuntimeContext } from "alchemy/RuntimeContext";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import { decodeJson, encodeJson, type ModalValueNotJson } from "./BindingHttp.ts";
|
|
5
|
+
import { type OpError, operations, seconds } from "./internal.ts";
|
|
6
|
+
|
|
7
|
+
/** The queue operations the clients call, resolved by `ModalBindings.withCredentials`. */
|
|
8
|
+
export const QueueOps = operations({
|
|
9
|
+
clearQueue: queue.clearQueue,
|
|
10
|
+
getQueue: queue.getQueue,
|
|
11
|
+
putQueue: queue.putQueue,
|
|
12
|
+
queueLen: queue.queueLen,
|
|
13
|
+
queueNextItems: queue.queueNextItems,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export type QueueOps = Effect.Success<typeof QueueOps>;
|
|
17
|
+
|
|
18
|
+
/** A queue call's error: the operation's typed errors, and items that aren't JSON. */
|
|
19
|
+
export type QueueError<K extends keyof QueueOps> = OpError<QueueOps, K> | ModalValueNotJson;
|
|
20
|
+
|
|
21
|
+
/** Which partition of a queue a call uses; omitted means the default partition. */
|
|
22
|
+
export interface QueuePartitionOptions {
|
|
23
|
+
readonly partition?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Take items from one queue. Items are JSON (the bytes of `JSON.stringify`),
|
|
28
|
+
* so Python consumers read them with `json.loads`.
|
|
29
|
+
*/
|
|
30
|
+
export interface ReadQueueClient {
|
|
31
|
+
readonly queueId: Effect.Effect<string>;
|
|
32
|
+
/**
|
|
33
|
+
* Remove and return up to `count` items, waiting up to `timeout` for the
|
|
34
|
+
* first one (an empty array when none arrived).
|
|
35
|
+
*/
|
|
36
|
+
take<A = unknown>(
|
|
37
|
+
options?: QueuePartitionOptions & {
|
|
38
|
+
readonly count?: number;
|
|
39
|
+
readonly timeout?: number | string;
|
|
40
|
+
},
|
|
41
|
+
): Effect.Effect<ReadonlyArray<A>, QueueError<"getQueue">, RuntimeContext>;
|
|
42
|
+
/** Items currently in the queue, without removing them. */
|
|
43
|
+
peek<A = unknown>(
|
|
44
|
+
options?: QueuePartitionOptions,
|
|
45
|
+
): Effect.Effect<ReadonlyArray<A>, QueueError<"queueNextItems">, RuntimeContext>;
|
|
46
|
+
/** Number of items in a partition (or, with `total`, in every partition). */
|
|
47
|
+
len(
|
|
48
|
+
options?: QueuePartitionOptions & { readonly total?: boolean },
|
|
49
|
+
): Effect.Effect<number, OpError<QueueOps, "queueLen">, RuntimeContext>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Put items into one queue. */
|
|
53
|
+
export interface WriteQueueClient {
|
|
54
|
+
readonly queueId: Effect.Effect<string>;
|
|
55
|
+
/** Append one item. */
|
|
56
|
+
put(
|
|
57
|
+
value: unknown,
|
|
58
|
+
options?: QueuePartitionOptions & { readonly partitionTtl?: number | string },
|
|
59
|
+
): Effect.Effect<void, OpError<QueueOps, "putQueue">, RuntimeContext>;
|
|
60
|
+
/** Append many items in order. */
|
|
61
|
+
putMany(
|
|
62
|
+
values: Iterable<unknown>,
|
|
63
|
+
options?: QueuePartitionOptions & { readonly partitionTtl?: number | string },
|
|
64
|
+
): Effect.Effect<void, OpError<QueueOps, "putQueue">, RuntimeContext>;
|
|
65
|
+
/** Remove every item of a partition (or of all partitions). */
|
|
66
|
+
clear(
|
|
67
|
+
options?: QueuePartitionOptions & { readonly all?: boolean },
|
|
68
|
+
): Effect.Effect<void, OpError<QueueOps, "clearQueue">, RuntimeContext>;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Put and take items. */
|
|
72
|
+
export interface ReadWriteQueueClient extends ReadQueueClient, WriteQueueClient {}
|
|
73
|
+
|
|
74
|
+
export const makeReadQueueClient = (
|
|
75
|
+
queueId: Effect.Effect<string>,
|
|
76
|
+
ops: QueueOps,
|
|
77
|
+
): ReadQueueClient => ({
|
|
78
|
+
queueId,
|
|
79
|
+
take: <A>(options: Parameters<ReadQueueClient["take"]>[0] = {}) =>
|
|
80
|
+
Effect.gen(function* () {
|
|
81
|
+
const id = yield* queueId;
|
|
82
|
+
const { values } = yield* ops.getQueue({
|
|
83
|
+
queueId: id,
|
|
84
|
+
partitionKey: options.partition,
|
|
85
|
+
nValues: options.count ?? 1,
|
|
86
|
+
timeout: seconds(options.timeout) ?? 0,
|
|
87
|
+
});
|
|
88
|
+
return yield* Effect.forEach(values ?? [], (value) => decodeJson<A>(value));
|
|
89
|
+
}),
|
|
90
|
+
peek: <A>(options: QueuePartitionOptions = {}) =>
|
|
91
|
+
Effect.gen(function* () {
|
|
92
|
+
const id = yield* queueId;
|
|
93
|
+
const { items } = yield* ops.queueNextItems({
|
|
94
|
+
queueId: id,
|
|
95
|
+
partitionKey: options.partition,
|
|
96
|
+
itemPollTimeout: 0,
|
|
97
|
+
});
|
|
98
|
+
return yield* Effect.forEach(items ?? [], (item) => decodeJson<A>(item.value ?? ""));
|
|
99
|
+
}),
|
|
100
|
+
len: (options = {}) =>
|
|
101
|
+
Effect.gen(function* () {
|
|
102
|
+
const id = yield* queueId;
|
|
103
|
+
const response = yield* ops.queueLen({
|
|
104
|
+
queueId: id,
|
|
105
|
+
partitionKey: options.partition,
|
|
106
|
+
total: options.total,
|
|
107
|
+
});
|
|
108
|
+
return response.len ?? 0;
|
|
109
|
+
}),
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
export const makeWriteQueueClient = (
|
|
113
|
+
queueId: Effect.Effect<string>,
|
|
114
|
+
ops: QueueOps,
|
|
115
|
+
): WriteQueueClient => {
|
|
116
|
+
const putMany: WriteQueueClient["putMany"] = (values, options = {}) =>
|
|
117
|
+
Effect.gen(function* () {
|
|
118
|
+
const id = yield* queueId;
|
|
119
|
+
const encoded = yield* Effect.forEach([...values], (value) => encodeJson(value));
|
|
120
|
+
yield* ops.putQueue({
|
|
121
|
+
queueId: id,
|
|
122
|
+
values: encoded,
|
|
123
|
+
partitionKey: options.partition,
|
|
124
|
+
partitionTtlSeconds: seconds(options.partitionTtl),
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
return {
|
|
128
|
+
queueId,
|
|
129
|
+
put: (value, options) => putMany([value], options),
|
|
130
|
+
putMany,
|
|
131
|
+
clear: (options = {}) =>
|
|
132
|
+
Effect.gen(function* () {
|
|
133
|
+
const id = yield* queueId;
|
|
134
|
+
yield* ops.clearQueue({
|
|
135
|
+
queueId: id,
|
|
136
|
+
partitionKey: options.partition,
|
|
137
|
+
allPartitions: options.all,
|
|
138
|
+
});
|
|
139
|
+
}),
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export const makeReadWriteQueueClient = (
|
|
144
|
+
queueId: Effect.Effect<string>,
|
|
145
|
+
ops: QueueOps,
|
|
146
|
+
): ReadWriteQueueClient => ({
|
|
147
|
+
...makeReadQueueClient(queueId, ops),
|
|
148
|
+
...makeWriteQueueClient(queueId, ops),
|
|
149
|
+
});
|
package/src/ReadApp.ts
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type * as app from "@distilled.cloud/modal/app";
|
|
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 { App } from "./App.ts";
|
|
6
|
+
import type { OpError } from "./internal.ts";
|
|
7
|
+
import type { ReadAppOps } from "./ReadAppHttp.ts";
|
|
8
|
+
import type { TimeRange } from "./ReadFunction.ts";
|
|
9
|
+
|
|
10
|
+
/** One log line. */
|
|
11
|
+
export interface AppLogLine {
|
|
12
|
+
readonly data: string;
|
|
13
|
+
/** Epoch seconds. */
|
|
14
|
+
readonly timestamp: number | undefined;
|
|
15
|
+
readonly stream: "stdout" | "stderr" | "info" | undefined;
|
|
16
|
+
readonly functionId: string | undefined;
|
|
17
|
+
readonly functionCallId: string | undefined;
|
|
18
|
+
readonly containerId: string | undefined;
|
|
19
|
+
readonly sandboxId: string | undefined;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Filters for an App's logs. */
|
|
23
|
+
export interface AppLogFilter {
|
|
24
|
+
readonly functionId?: string;
|
|
25
|
+
readonly functionCallId?: string;
|
|
26
|
+
readonly containerId?: string;
|
|
27
|
+
readonly sandboxId?: string;
|
|
28
|
+
readonly search?: string;
|
|
29
|
+
readonly stream?: "stdout" | "stderr" | "info";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Observe an App: logs, functions, and deployment history. */
|
|
33
|
+
export interface AppReader {
|
|
34
|
+
/** Log lines in a time range, oldest first. */
|
|
35
|
+
logs(
|
|
36
|
+
query: TimeRange & AppLogFilter & { readonly limit?: number },
|
|
37
|
+
): Effect.Effect<ReadonlyArray<AppLogLine>, OpError<ReadAppOps, "fetchLogs">, RuntimeContext>;
|
|
38
|
+
/**
|
|
39
|
+
* Follow the App's logs: lines after `cursor` (or the latest), waiting up
|
|
40
|
+
* to `timeout` for new ones. Pass the returned cursor to the next call.
|
|
41
|
+
*/
|
|
42
|
+
tail(
|
|
43
|
+
query?: AppLogFilter & { readonly cursor?: string; readonly timeout?: number },
|
|
44
|
+
): Effect.Effect<
|
|
45
|
+
{ readonly lines: ReadonlyArray<AppLogLine>; readonly cursor: string | undefined },
|
|
46
|
+
OpError<ReadAppOps, "getLogs">,
|
|
47
|
+
RuntimeContext
|
|
48
|
+
>;
|
|
49
|
+
/** Log lines per time bucket. */
|
|
50
|
+
logCount(
|
|
51
|
+
query: TimeRange & AppLogFilter & { readonly bucketSecs?: number },
|
|
52
|
+
): Effect.Effect<app.AppCountLogsResponse, OpError<ReadAppOps, "countLogs">, RuntimeContext>;
|
|
53
|
+
/** The App's metadata and a summary of each function. */
|
|
54
|
+
info(): Effect.Effect<app.AppGetInfoResponse, OpError<ReadAppOps, "info">, RuntimeContext>;
|
|
55
|
+
/** When the App was created, deployed and stopped, and by whom. */
|
|
56
|
+
lifecycle(): Effect.Effect<
|
|
57
|
+
app.AppLifecycle | undefined,
|
|
58
|
+
OpError<ReadAppOps, "lifecycle">,
|
|
59
|
+
RuntimeContext
|
|
60
|
+
>;
|
|
61
|
+
/** The functions and classes the App serves, by name. */
|
|
62
|
+
layout(): Effect.Effect<
|
|
63
|
+
{ readonly functionIds: Record<string, string>; readonly classIds: Record<string, string> },
|
|
64
|
+
OpError<ReadAppOps, "layout">,
|
|
65
|
+
RuntimeContext
|
|
66
|
+
>;
|
|
67
|
+
/** Every deployed version, and the version in production. */
|
|
68
|
+
deployments(): Effect.Effect<
|
|
69
|
+
app.AppDeploymentHistoryResponse,
|
|
70
|
+
OpError<ReadAppOps, "deployments">,
|
|
71
|
+
RuntimeContext
|
|
72
|
+
>;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Read a Modal App from any runtime: its logs (every function, server and
|
|
77
|
+
* sandbox in it), function summaries and deployment history.
|
|
78
|
+
*
|
|
79
|
+
* ### Logs
|
|
80
|
+
* **Example:** Errors from the last hour
|
|
81
|
+
* ```typescript
|
|
82
|
+
* const backend = yield* Modal.ReadApp(Backend);
|
|
83
|
+
* const lines = yield* backend.logs({ since: new Date(Date.now() - 3_600_000), stream: "stderr" });
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* ### Deployments
|
|
87
|
+
* **Example:** The version in production
|
|
88
|
+
* ```typescript
|
|
89
|
+
* const { productionAppVersion } = yield* backend.deployments();
|
|
90
|
+
* ```
|
|
91
|
+
*
|
|
92
|
+
* @binding
|
|
93
|
+
* @product App
|
|
94
|
+
*/
|
|
95
|
+
export interface ReadApp extends Binding.Service<
|
|
96
|
+
ReadApp,
|
|
97
|
+
"Modal.ReadApp",
|
|
98
|
+
(app: App) => Effect.Effect<AppReader>
|
|
99
|
+
> {}
|
|
100
|
+
|
|
101
|
+
export const ReadApp = Binding.Service<ReadApp>("Modal.ReadApp");
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import * as app from "@distilled.cloud/modal/app";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Layer from "effect/Layer";
|
|
4
|
+
import type { App } from "./App.ts";
|
|
5
|
+
import { makeModalBinding } from "./BindingHttp.ts";
|
|
6
|
+
import { operations, stringMap, timestampOf } from "./internal.ts";
|
|
7
|
+
import { ReadApp, type AppLogFilter, type AppLogLine, type AppReader } from "./ReadApp.ts";
|
|
8
|
+
|
|
9
|
+
const STREAM = {
|
|
10
|
+
stdout: "FILE_DESCRIPTOR_STDOUT",
|
|
11
|
+
stderr: "FILE_DESCRIPTOR_STDERR",
|
|
12
|
+
info: "FILE_DESCRIPTOR_INFO",
|
|
13
|
+
} as const;
|
|
14
|
+
|
|
15
|
+
const streamOf = (fd: string | undefined): AppLogLine["stream"] =>
|
|
16
|
+
fd === STREAM.stdout
|
|
17
|
+
? "stdout"
|
|
18
|
+
: fd === STREAM.stderr
|
|
19
|
+
? "stderr"
|
|
20
|
+
: fd === STREAM.info
|
|
21
|
+
? "info"
|
|
22
|
+
: undefined;
|
|
23
|
+
|
|
24
|
+
const filterOf = (filter: AppLogFilter) => ({
|
|
25
|
+
functionId: filter.functionId,
|
|
26
|
+
functionCallId: filter.functionCallId,
|
|
27
|
+
taskId: filter.containerId,
|
|
28
|
+
sandboxId: filter.sandboxId,
|
|
29
|
+
searchText: filter.search,
|
|
30
|
+
source: filter.stream ? STREAM[filter.stream] : undefined,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
/** The operations the client calls, resolved by `ModalBindings.withCredentials`. */
|
|
34
|
+
const ReadAppOps = operations({
|
|
35
|
+
fetchLogs: app.appFetchLogs,
|
|
36
|
+
getLogs: app.appGetLogs,
|
|
37
|
+
countLogs: app.appCountLogs,
|
|
38
|
+
info: app.appGetInfo,
|
|
39
|
+
lifecycle: app.appGetLifecycle,
|
|
40
|
+
layout: app.appGetLayout,
|
|
41
|
+
deployments: app.appDeploymentHistory,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export type ReadAppOps = Effect.Success<typeof ReadAppOps>;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* {@link ReadApp} over Modal's API. Grants the host's identity (a scoped
|
|
48
|
+
* `Modal.ServiceUser`) the `viewer` role on the App's environment.
|
|
49
|
+
*
|
|
50
|
+
* @layer
|
|
51
|
+
* @product App
|
|
52
|
+
* @provides Modal.ReadApp
|
|
53
|
+
*/
|
|
54
|
+
export const ReadAppHttp = Layer.effect(
|
|
55
|
+
ReadApp,
|
|
56
|
+
makeModalBinding({
|
|
57
|
+
tag: "Modal.ReadApp",
|
|
58
|
+
operations: ReadAppOps,
|
|
59
|
+
role: "viewer",
|
|
60
|
+
make: Effect.fn(function* (target: App, ops) {
|
|
61
|
+
const appId = yield* target.appId;
|
|
62
|
+
return {
|
|
63
|
+
logs: (query) =>
|
|
64
|
+
Effect.flatMap(appId, (id) =>
|
|
65
|
+
ops.fetchLogs({
|
|
66
|
+
appId: id,
|
|
67
|
+
since: timestampOf(query.since),
|
|
68
|
+
until: timestampOf(query.until ?? Date.now()),
|
|
69
|
+
limit: query.limit,
|
|
70
|
+
...filterOf(query),
|
|
71
|
+
}),
|
|
72
|
+
).pipe(
|
|
73
|
+
Effect.map((response) =>
|
|
74
|
+
(response.batches ?? []).flatMap((batch) =>
|
|
75
|
+
(batch.items ?? []).map((line) => ({
|
|
76
|
+
data: line.data ?? "",
|
|
77
|
+
timestamp: line.timestamp,
|
|
78
|
+
stream: streamOf(line.fileDescriptor),
|
|
79
|
+
functionId: batch.functionId,
|
|
80
|
+
functionCallId: line.functionCallId,
|
|
81
|
+
containerId: line.containerId ?? batch.taskId,
|
|
82
|
+
sandboxId: batch.sandboxId,
|
|
83
|
+
})),
|
|
84
|
+
),
|
|
85
|
+
),
|
|
86
|
+
),
|
|
87
|
+
tail: (query = {}) =>
|
|
88
|
+
Effect.flatMap(appId, (id) =>
|
|
89
|
+
ops.getLogs({
|
|
90
|
+
appId: id,
|
|
91
|
+
timeout: query.timeout ?? 10,
|
|
92
|
+
lastEntryId: query.cursor,
|
|
93
|
+
functionId: query.functionId,
|
|
94
|
+
functionCallId: query.functionCallId,
|
|
95
|
+
taskId: query.containerId,
|
|
96
|
+
sandboxId: query.sandboxId,
|
|
97
|
+
searchText: query.search,
|
|
98
|
+
fileDescriptor: query.stream ? STREAM[query.stream] : undefined,
|
|
99
|
+
}),
|
|
100
|
+
).pipe(
|
|
101
|
+
Effect.map(({ items }) => ({
|
|
102
|
+
lines: items.flatMap((batch) =>
|
|
103
|
+
(batch.items ?? []).map((line) => ({
|
|
104
|
+
data: line.data ?? "",
|
|
105
|
+
timestamp: line.timestamp,
|
|
106
|
+
stream: streamOf(line.fileDescriptor),
|
|
107
|
+
functionId: batch.functionId,
|
|
108
|
+
functionCallId: line.functionCallId,
|
|
109
|
+
containerId: line.containerId ?? batch.taskId,
|
|
110
|
+
sandboxId: batch.sandboxId,
|
|
111
|
+
})),
|
|
112
|
+
),
|
|
113
|
+
cursor: items.findLast((batch) => batch.entryId)?.entryId ?? query.cursor,
|
|
114
|
+
})),
|
|
115
|
+
),
|
|
116
|
+
logCount: (query) =>
|
|
117
|
+
Effect.flatMap(appId, (id) =>
|
|
118
|
+
ops.countLogs({
|
|
119
|
+
appId: id,
|
|
120
|
+
since: timestampOf(query.since),
|
|
121
|
+
until: timestampOf(query.until ?? Date.now()),
|
|
122
|
+
bucketSecs: query.bucketSecs,
|
|
123
|
+
...filterOf(query),
|
|
124
|
+
}),
|
|
125
|
+
),
|
|
126
|
+
info: () => Effect.flatMap(appId, (id) => ops.info({ appId: id })),
|
|
127
|
+
lifecycle: () =>
|
|
128
|
+
Effect.flatMap(appId, (id) => ops.lifecycle({ appId: id })).pipe(
|
|
129
|
+
Effect.map((response) => response.lifecycle),
|
|
130
|
+
),
|
|
131
|
+
layout: () =>
|
|
132
|
+
Effect.flatMap(appId, (id) => ops.layout({ appId: id })).pipe(
|
|
133
|
+
Effect.map(({ appLayout }) => ({
|
|
134
|
+
functionIds: stringMap(appLayout?.functionIds),
|
|
135
|
+
classIds: stringMap(appLayout?.classIds),
|
|
136
|
+
})),
|
|
137
|
+
),
|
|
138
|
+
deployments: () => Effect.flatMap(appId, (id) => ops.deployments({ appId: id })),
|
|
139
|
+
} satisfies AppReader;
|
|
140
|
+
}),
|
|
141
|
+
}),
|
|
142
|
+
);
|
package/src/ReadDict.ts
ADDED
|
@@ -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 { ReadDictClient } from "./DictClient.ts";
|
|
5
|
+
|
|
6
|
+
export type { ReadDictClient } from "./DictClient.ts";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Read a Modal Dict from any runtime: get, contains, len and entries. 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.ReadDict(Results);
|
|
25
|
+
* return {
|
|
26
|
+
* fetch: Effect.gen(function* () {
|
|
27
|
+
* const last = yield* dict.get("last-run");
|
|
28
|
+
* return yield* HttpServerResponse.json(last ?? null);
|
|
29
|
+
* }).pipe(Effect.orDie),
|
|
30
|
+
* };
|
|
31
|
+
* }).pipe(Effect.provide(Modal.ReadDictHttp)),
|
|
32
|
+
* ) {}
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @binding
|
|
36
|
+
* @product Dict
|
|
37
|
+
*/
|
|
38
|
+
export interface ReadDict extends Binding.Service<
|
|
39
|
+
ReadDict,
|
|
40
|
+
"Modal.ReadDict",
|
|
41
|
+
(dict: Dict) => Effect.Effect<ReadDictClient>
|
|
42
|
+
> {}
|
|
43
|
+
|
|
44
|
+
export const ReadDict = Binding.Service<ReadDict>("Modal.ReadDict");
|