diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d75f86a047..4334303735 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -110,7 +110,7 @@ jobs: - name: Build Cache uses: ./.github/actions/build-cache - name: Test WASM - run: cd sqlc-gen-ftl && cargo test --features ci --test sqlc_gen_ftl_test -- --nocapture + run: just test-sqlc-gen-ftl - name: Check for uncommitted changes run: | if [[ -n $(git status -s) ]]; then diff --git a/Justfile b/Justfile index 169092a843..0291e89f87 100644 --- a/Justfile +++ b/Justfile @@ -199,6 +199,9 @@ build-sqlc-gen-ftl: build-rust-protos "cd sqlc-gen-ftl && \ cargo build --target wasm32-wasip1 --release" +test-sqlc-gen-ftl: + @cargo test --manifest-path sqlc-gen-ftl/Cargo.toml --features ci --test sqlc_gen_ftl_test -- --nocapture + # Generate Rust protos build-rust-protos: @mk sqlc-gen-ftl/src/protos : backend/protos -- \ diff --git a/backend/protos/src/protos/xyz.block.ftl.console.v1.rs b/backend/protos/src/protos/xyz.block.ftl.console.v1.rs new file mode 100644 index 0000000000..22f65a69bf --- /dev/null +++ b/backend/protos/src/protos/xyz.block.ftl.console.v1.rs @@ -0,0 +1,174 @@ +// @generated +// This file is @generated by prost-build. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Config { + #[prost(message, optional, tag="1")] + pub config: ::core::option::Option, + #[prost(message, repeated, tag="2")] + pub references: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Data { + #[prost(message, optional, tag="1")] + pub data: ::core::option::Option, + #[prost(string, tag="2")] + pub schema: ::prost::alloc::string::String, + #[prost(message, repeated, tag="3")] + pub references: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Database { + #[prost(message, optional, tag="1")] + pub database: ::core::option::Option, + #[prost(message, repeated, tag="2")] + pub references: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Enum { + #[prost(message, optional, tag="1")] + pub r#enum: ::core::option::Option, + #[prost(message, repeated, tag="2")] + pub references: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Topic { + #[prost(message, optional, tag="1")] + pub topic: ::core::option::Option, + #[prost(message, repeated, tag="2")] + pub references: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct TypeAlias { + #[prost(message, optional, tag="1")] + pub typealias: ::core::option::Option, + #[prost(message, repeated, tag="2")] + pub references: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Secret { + #[prost(message, optional, tag="1")] + pub secret: ::core::option::Option, + #[prost(message, repeated, tag="2")] + pub references: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Verb { + #[prost(message, optional, tag="1")] + pub verb: ::core::option::Option, + #[prost(string, tag="2")] + pub schema: ::prost::alloc::string::String, + #[prost(string, tag="3")] + pub json_request_schema: ::prost::alloc::string::String, + #[prost(message, repeated, tag="4")] + pub references: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Module { + #[prost(string, tag="1")] + pub name: ::prost::alloc::string::String, + #[prost(string, tag="2")] + pub deployment_key: ::prost::alloc::string::String, + #[prost(string, tag="3")] + pub language: ::prost::alloc::string::String, + #[prost(string, tag="4")] + pub schema: ::prost::alloc::string::String, + #[prost(message, repeated, tag="5")] + pub verbs: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="6")] + pub data: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="7")] + pub secrets: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="8")] + pub configs: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="9")] + pub databases: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="10")] + pub enums: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="11")] + pub topics: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="12")] + pub typealiases: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct TopologyGroup { + #[prost(string, repeated, tag="1")] + pub modules: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Topology { + #[prost(message, repeated, tag="1")] + pub levels: ::prost::alloc::vec::Vec, +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct GetModulesRequest { +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetModulesResponse { + #[prost(message, repeated, tag="1")] + pub modules: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag="2")] + pub topology: ::core::option::Option, +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct StreamModulesRequest { +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct StreamModulesResponse { + #[prost(message, repeated, tag="1")] + pub modules: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag="2")] + pub topology: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetConfigRequest { + #[prost(string, tag="1")] + pub name: ::prost::alloc::string::String, + #[prost(string, optional, tag="2")] + pub module: ::core::option::Option<::prost::alloc::string::String>, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetConfigResponse { + #[prost(bytes="bytes", tag="1")] + pub value: ::prost::bytes::Bytes, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SetConfigRequest { + #[prost(string, tag="1")] + pub name: ::prost::alloc::string::String, + #[prost(string, optional, tag="2")] + pub module: ::core::option::Option<::prost::alloc::string::String>, + #[prost(bytes="bytes", tag="3")] + pub value: ::prost::bytes::Bytes, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SetConfigResponse { + #[prost(bytes="bytes", tag="1")] + pub value: ::prost::bytes::Bytes, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetSecretRequest { + #[prost(string, tag="1")] + pub name: ::prost::alloc::string::String, + #[prost(string, optional, tag="2")] + pub module: ::core::option::Option<::prost::alloc::string::String>, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetSecretResponse { + #[prost(bytes="bytes", tag="1")] + pub value: ::prost::bytes::Bytes, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SetSecretRequest { + #[prost(string, tag="1")] + pub name: ::prost::alloc::string::String, + #[prost(string, optional, tag="2")] + pub module: ::core::option::Option<::prost::alloc::string::String>, + #[prost(bytes="bytes", tag="3")] + pub value: ::prost::bytes::Bytes, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SetSecretResponse { + #[prost(bytes="bytes", tag="1")] + pub value: ::prost::bytes::Bytes, +} +// @@protoc_insertion_point(module) diff --git a/backend/protos/src/protos/xyz.block.ftl.deployment.v1.rs b/backend/protos/src/protos/xyz.block.ftl.deployment.v1.rs new file mode 100644 index 0000000000..3e8224ed36 --- /dev/null +++ b/backend/protos/src/protos/xyz.block.ftl.deployment.v1.rs @@ -0,0 +1,71 @@ +// @generated +// This file is @generated by prost-build. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetDeploymentContextRequest { + #[prost(string, tag="1")] + pub deployment: ::prost::alloc::string::String, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetDeploymentContextResponse { + #[prost(string, tag="1")] + pub module: ::prost::alloc::string::String, + #[prost(string, tag="2")] + pub deployment: ::prost::alloc::string::String, + #[prost(map="string, bytes", tag="3")] + pub configs: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::bytes::Bytes>, + #[prost(map="string, bytes", tag="4")] + pub secrets: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::bytes::Bytes>, + #[prost(message, repeated, tag="5")] + pub databases: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="6")] + pub routes: ::prost::alloc::vec::Vec, +} +/// Nested message and enum types in `GetDeploymentContextResponse`. +pub mod get_deployment_context_response { + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct Dsn { + #[prost(string, tag="1")] + pub name: ::prost::alloc::string::String, + #[prost(enumeration="DbType", tag="2")] + pub r#type: i32, + #[prost(string, tag="3")] + pub dsn: ::prost::alloc::string::String, + } + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct Route { + #[prost(string, tag="1")] + pub deployment: ::prost::alloc::string::String, + #[prost(string, tag="2")] + pub uri: ::prost::alloc::string::String, + } + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] + #[repr(i32)] + pub enum DbType { + Unspecified = 0, + Postgres = 1, + Mysql = 2, + } + impl DbType { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Self::Unspecified => "DB_TYPE_UNSPECIFIED", + Self::Postgres => "DB_TYPE_POSTGRES", + Self::Mysql => "DB_TYPE_MYSQL", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "DB_TYPE_UNSPECIFIED" => Some(Self::Unspecified), + "DB_TYPE_POSTGRES" => Some(Self::Postgres), + "DB_TYPE_MYSQL" => Some(Self::Mysql), + _ => None, + } + } + } +} +// @@protoc_insertion_point(module) diff --git a/backend/protos/src/protos/xyz.block.ftl.language.v1.rs b/backend/protos/src/protos/xyz.block.ftl.language.v1.rs new file mode 100644 index 0000000000..5b7da23705 --- /dev/null +++ b/backend/protos/src/protos/xyz.block.ftl.language.v1.rs @@ -0,0 +1,408 @@ +// @generated +// This file is @generated by prost-build. +/// ModuleConfig contains the configuration for a module, found in the module's ftl.toml file. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ModuleConfig { + /// Name of the module + #[prost(string, tag="1")] + pub name: ::prost::alloc::string::String, + /// Absolute path to the module's directory + #[prost(string, tag="2")] + pub dir: ::prost::alloc::string::String, + /// The language of the module + #[prost(string, tag="3")] + pub language: ::prost::alloc::string::String, + /// Absolute path to the directory containing all of this module's build artifacts for deployments + #[prost(string, tag="4")] + pub deploy_dir: ::prost::alloc::string::String, + /// Build is the command to build the module. + #[prost(string, optional, tag="5")] + pub build: ::core::option::Option<::prost::alloc::string::String>, + /// DevModeBuild is the command to build the module in dev mode. + #[prost(string, optional, tag="6")] + pub dev_mode_build: ::core::option::Option<::prost::alloc::string::String>, + /// Build lock path to prevent concurrent builds + #[prost(string, tag="7")] + pub build_lock: ::prost::alloc::string::String, + /// Patterns to watch for file changes + #[prost(string, repeated, tag="9")] + pub watch: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + /// LanguageConfig contains any metadata specific to a specific language. + /// These are stored in the ftl.toml file under the same key as the language (eg: "go", "java") + #[prost(message, optional, tag="10")] + pub language_config: ::core::option::Option<::prost_types::Struct>, + /// The directory containing the SQL migration files + #[prost(string, tag="11")] + pub sql_migration_dir: ::prost::alloc::string::String, +} +/// ProjectConfig contains the configuration for a project, found in the ftl-project.toml file. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ProjectConfig { + #[prost(string, tag="1")] + pub dir: ::prost::alloc::string::String, + #[prost(string, tag="2")] + pub name: ::prost::alloc::string::String, + #[prost(bool, tag="3")] + pub no_git: bool, + #[prost(bool, tag="4")] + pub hermit: bool, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetCreateModuleFlagsRequest { + #[prost(string, tag="1")] + pub language: ::prost::alloc::string::String, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetCreateModuleFlagsResponse { + #[prost(message, repeated, tag="1")] + pub flags: ::prost::alloc::vec::Vec, +} +/// Nested message and enum types in `GetCreateModuleFlagsResponse`. +pub mod get_create_module_flags_response { + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct Flag { + #[prost(string, tag="1")] + pub name: ::prost::alloc::string::String, + #[prost(string, tag="2")] + pub help: ::prost::alloc::string::String, + #[prost(string, optional, tag="3")] + pub envar: ::core::option::Option<::prost::alloc::string::String>, + /// short must be a single character + #[prost(string, optional, tag="4")] + pub short: ::core::option::Option<::prost::alloc::string::String>, + #[prost(string, optional, tag="5")] + pub placeholder: ::core::option::Option<::prost::alloc::string::String>, + #[prost(string, optional, tag="6")] + pub default: ::core::option::Option<::prost::alloc::string::String>, + } +} +/// Request to create a new module. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CreateModuleRequest { + #[prost(string, tag="1")] + pub name: ::prost::alloc::string::String, + /// The root directory for the module, which does not yet exist. + /// The plugin should create the directory. + #[prost(string, tag="2")] + pub dir: ::prost::alloc::string::String, + /// The project configuration + #[prost(message, optional, tag="3")] + pub project_config: ::core::option::Option, + /// Flags contains any values set for those configured in the GetCreateModuleFlags call + #[prost(message, optional, tag="4")] + pub flags: ::core::option::Option<::prost_types::Struct>, +} +/// Response to a create module request. +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct CreateModuleResponse { +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ModuleConfigDefaultsRequest { + #[prost(string, tag="1")] + pub dir: ::prost::alloc::string::String, +} +/// ModuleConfigDefaultsResponse provides defaults for ModuleConfig. +/// +/// The result may be cached by FTL, so defaulting logic should not be changing due to normal module changes. +/// For example, it is valid to return defaults based on which build tool is configured within the module directory, +/// as that is not expected to change during normal operation. +/// It is not recommended to read the module's toml file to determine defaults, as when the toml file is updated, +/// the module defaults will not be recalculated. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ModuleConfigDefaultsResponse { + /// Default relative path to the directory containing all build artifacts for deployments + #[prost(string, tag="1")] + pub deploy_dir: ::prost::alloc::string::String, + /// Default build command + #[prost(string, optional, tag="2")] + pub build: ::core::option::Option<::prost::alloc::string::String>, + /// Dev mode build command, if different from the regular build command + #[prost(string, optional, tag="3")] + pub dev_mode_build: ::core::option::Option<::prost::alloc::string::String>, + /// Build lock path to prevent concurrent builds + #[prost(string, optional, tag="4")] + pub build_lock: ::core::option::Option<::prost::alloc::string::String>, + /// Default patterns to watch for file changes, relative to the module directory + #[prost(string, repeated, tag="6")] + pub watch: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + /// Default language specific configuration. + /// These defaults are filled in by looking at each root key only. If the key is not present, the default is used. + #[prost(message, optional, tag="7")] + pub language_config: ::core::option::Option<::prost_types::Struct>, + /// Default directory containing the SQL migration files + #[prost(string, tag="8")] + pub sql_migration_dir: ::prost::alloc::string::String, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetDependenciesRequest { + #[prost(message, optional, tag="1")] + pub module_config: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetDependenciesResponse { + #[prost(string, repeated, tag="1")] + pub modules: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, +} +/// BuildContext contains contextual information needed to build. +/// +/// Plugins must include the build context's id when a build succeeds or fails. +/// For automatic rebuilds, plugins must use the most recent build context they have received. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct BuildContext { + #[prost(string, tag="1")] + pub id: ::prost::alloc::string::String, + /// The configuration for the module + #[prost(message, optional, tag="2")] + pub module_config: ::core::option::Option, + /// The FTL schema including all dependencies + #[prost(message, optional, tag="3")] + pub schema: ::core::option::Option, + /// The dependencies for the module + #[prost(string, repeated, tag="4")] + pub dependencies: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + /// Build environment provides environment variables to be set for the build command + #[prost(string, repeated, tag="5")] + pub build_env: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct BuildContextUpdatedRequest { + #[prost(message, optional, tag="1")] + pub build_context: ::core::option::Option, +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct BuildContextUpdatedResponse { +} +/// Error contains information about an error that occurred during a build. +/// Errors do not always cause a build failure. Use lesser levels to help guide the user. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Error { + #[prost(string, tag="1")] + pub msg: ::prost::alloc::string::String, + #[prost(enumeration="error::ErrorLevel", tag="4")] + pub level: i32, + #[prost(message, optional, tag="5")] + pub pos: ::core::option::Option, + #[prost(enumeration="error::ErrorType", tag="6")] + pub r#type: i32, +} +/// Nested message and enum types in `Error`. +pub mod error { + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] + #[repr(i32)] + pub enum ErrorLevel { + Unspecified = 0, + Info = 1, + Warn = 2, + Error = 3, + } + impl ErrorLevel { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Self::Unspecified => "ERROR_LEVEL_UNSPECIFIED", + Self::Info => "ERROR_LEVEL_INFO", + Self::Warn => "ERROR_LEVEL_WARN", + Self::Error => "ERROR_LEVEL_ERROR", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "ERROR_LEVEL_UNSPECIFIED" => Some(Self::Unspecified), + "ERROR_LEVEL_INFO" => Some(Self::Info), + "ERROR_LEVEL_WARN" => Some(Self::Warn), + "ERROR_LEVEL_ERROR" => Some(Self::Error), + _ => None, + } + } + } + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] + #[repr(i32)] + pub enum ErrorType { + Unspecified = 0, + Ftl = 1, + /// Compiler errors are errors that are from the compiler. This is useful to avoid duplicate errors + /// being shown to the user when combining errors from multiple sources (eg: an IDE showing compiler + /// errors and FTL errors via LSP). + Compiler = 2, + } + impl ErrorType { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Self::Unspecified => "ERROR_TYPE_UNSPECIFIED", + Self::Ftl => "ERROR_TYPE_FTL", + Self::Compiler => "ERROR_TYPE_COMPILER", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "ERROR_TYPE_UNSPECIFIED" => Some(Self::Unspecified), + "ERROR_TYPE_FTL" => Some(Self::Ftl), + "ERROR_TYPE_COMPILER" => Some(Self::Compiler), + _ => None, + } + } + } +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Position { + #[prost(string, tag="1")] + pub filename: ::prost::alloc::string::String, + #[prost(int64, tag="2")] + pub line: i64, + #[prost(int64, tag="3")] + pub start_column: i64, + #[prost(int64, tag="4")] + pub end_column: i64, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ErrorList { + #[prost(message, repeated, tag="1")] + pub errors: ::prost::alloc::vec::Vec, +} +/// Request to build a module. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct BuildRequest { + /// The root path for the FTL project + #[prost(string, tag="1")] + pub project_root: ::prost::alloc::string::String, + /// The path to the directory containing all module stubs. Each module stub is in a subdirectory. + #[prost(string, tag="2")] + pub stubs_root: ::prost::alloc::string::String, + /// Indicates whether to watch for file changes and automatically rebuild + #[prost(bool, tag="3")] + pub rebuild_automatically: bool, + #[prost(message, optional, tag="4")] + pub build_context: ::core::option::Option, +} +/// AutoRebuildStarted should be sent when the plugin decides to start rebuilding automatically. +/// +/// It is not required to send this event, though it helps inform the user that their changes are not yet built. +/// FTL may ignore this event if it does not match FTL's current build context and state. +/// If the plugin decides to cancel the build because another build started, no failure or cancellation event needs +/// to be sent. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct AutoRebuildStarted { + #[prost(string, tag="1")] + pub context_id: ::prost::alloc::string::String, +} +/// BuildSuccess should be sent when a build succeeds. +/// +/// FTL may ignore this event if it does not match FTL's current build context and state. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct BuildSuccess { + /// The id of build context used while building. + #[prost(string, tag="1")] + pub context_id: ::prost::alloc::string::String, + /// Indicates whether the build was automatically started by the plugin, rather than due to a Build rpc call. + #[prost(bool, tag="2")] + pub is_automatic_rebuild: bool, + /// Module schema for the built module + #[prost(message, optional, tag="3")] + pub module: ::core::option::Option, + /// Paths for files/directories to be deployed + #[prost(string, repeated, tag="4")] + pub deploy: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + /// Name of the docker image to use for the runner + #[prost(string, tag="5")] + pub docker_image: ::prost::alloc::string::String, + /// Errors contains any errors that occurred during the build + /// No errors can have a level of ERROR, instead a BuildFailure should be sent + /// Instead this is useful for INFO and WARN level errors. + #[prost(message, optional, tag="6")] + pub errors: ::core::option::Option, + /// Dev mode endpoint URI. If this is set then rather than trying to deploy the module, FTL will start a runner that + /// connects to this endpoint. + #[prost(string, optional, tag="7")] + pub dev_endpoint: ::core::option::Option<::prost::alloc::string::String>, + /// Dev mode debug port + #[prost(int32, optional, tag="8")] + pub debug_port: ::core::option::Option, + /// Dev mode runner info file, this file is used to allow the runner to communicate provisioner info back to the plugin + #[prost(string, optional, tag="9")] + pub dev_runner_info_file: ::core::option::Option<::prost::alloc::string::String>, +} +/// BuildFailure should be sent when a build fails. +/// +/// FTL may ignore this event if it does not match FTL's current build context and state. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct BuildFailure { + /// The id of build context used while building. + #[prost(string, tag="1")] + pub context_id: ::prost::alloc::string::String, + /// Indicates whether the build was automatically started by the plugin, rather than due to a Build rpc call. + #[prost(bool, tag="2")] + pub is_automatic_rebuild: bool, + /// Errors contains any errors that occurred during the build + #[prost(message, optional, tag="3")] + pub errors: ::core::option::Option, + /// Indicates the plugin determined that the dependencies in the BuildContext are out of date. + /// If a Build stream is being kept open for automatic rebuilds, FTL will call GetDependencies, followed by + /// BuildContextUpdated. + #[prost(bool, tag="4")] + pub invalidate_dependencies: bool, +} +/// Every type of message that can be streamed from the language plugin for a build. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct BuildResponse { + #[prost(oneof="build_response::Event", tags="2, 3, 4")] + pub event: ::core::option::Option, +} +/// Nested message and enum types in `BuildResponse`. +pub mod build_response { + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Event { + #[prost(message, tag="2")] + AutoRebuildStarted(super::AutoRebuildStarted), + #[prost(message, tag="3")] + BuildSuccess(super::BuildSuccess), + #[prost(message, tag="4")] + BuildFailure(super::BuildFailure), + } +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GenerateStubsRequest { + /// The directory path to generate stubs into + #[prost(string, tag="1")] + pub dir: ::prost::alloc::string::String, + /// The schema of the module to generate stubs for + #[prost(message, optional, tag="2")] + pub module: ::core::option::Option, + /// The module's configuration to generate stubs for + #[prost(message, optional, tag="3")] + pub module_config: ::core::option::Option, + /// Native module configuration is the configuration for a module that uses the plugin's language, if + /// the main moduleConfig provided is of a different language. It is provided as a mechanism to derive + /// language specific information. For example, the language version. + #[prost(message, optional, tag="4")] + pub native_module_config: ::core::option::Option, +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct GenerateStubsResponse { +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SyncStubReferencesRequest { + #[prost(message, optional, tag="1")] + pub module_config: ::core::option::Option, + /// The path of the directory containing all module stubs. Each module is in a subdirectory + #[prost(string, tag="2")] + pub stubs_root: ::prost::alloc::string::String, + /// The names of all modules that have had stubs generated + #[prost(string, repeated, tag="3")] + pub modules: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + /// The complete FTL schema + #[prost(message, optional, tag="4")] + pub schema: ::core::option::Option, +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct SyncStubReferencesResponse { +} +// @@protoc_insertion_point(module) diff --git a/backend/protos/src/protos/xyz.block.ftl.lease.v1.rs b/backend/protos/src/protos/xyz.block.ftl.lease.v1.rs new file mode 100644 index 0000000000..9000b83491 --- /dev/null +++ b/backend/protos/src/protos/xyz.block.ftl.lease.v1.rs @@ -0,0 +1,13 @@ +// @generated +// This file is @generated by prost-build. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct AcquireLeaseRequest { + #[prost(string, repeated, tag="1")] + pub key: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + #[prost(message, optional, tag="3")] + pub ttl: ::core::option::Option<::prost_types::Duration>, +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct AcquireLeaseResponse { +} +// @@protoc_insertion_point(module) diff --git a/backend/protos/src/protos/xyz.block.ftl.provisioner.v1beta1.rs b/backend/protos/src/protos/xyz.block.ftl.provisioner.v1beta1.rs new file mode 100644 index 0000000000..772a7f2370 --- /dev/null +++ b/backend/protos/src/protos/xyz.block.ftl.provisioner.v1beta1.rs @@ -0,0 +1,105 @@ +// @generated +// This file is @generated by prost-build. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ProvisionRequest { + #[prost(string, tag="1")] + pub ftl_cluster_id: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub desired_module: ::core::option::Option, + #[prost(message, optional, tag="3")] + pub previous_module: ::core::option::Option, + #[prost(string, repeated, tag="4")] + pub kinds: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ProvisionResponse { + #[prost(string, tag="1")] + pub provisioning_token: ::prost::alloc::string::String, + #[prost(enumeration="provision_response::ProvisionResponseStatus", tag="2")] + pub status: i32, +} +/// Nested message and enum types in `ProvisionResponse`. +pub mod provision_response { + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] + #[repr(i32)] + pub enum ProvisionResponseStatus { + Unspecified = 0, + Submitted = 1, + } + impl ProvisionResponseStatus { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Self::Unspecified => "PROVISION_RESPONSE_STATUS_UNSPECIFIED", + Self::Submitted => "PROVISION_RESPONSE_STATUS_SUBMITTED", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "PROVISION_RESPONSE_STATUS_UNSPECIFIED" => Some(Self::Unspecified), + "PROVISION_RESPONSE_STATUS_SUBMITTED" => Some(Self::Submitted), + _ => None, + } + } + } +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct StatusRequest { + #[prost(string, tag="1")] + pub provisioning_token: ::prost::alloc::string::String, + /// The outputs of this module are updated if the the status is a success + #[prost(message, optional, tag="2")] + pub desired_module: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ProvisioningEvent { + #[prost(oneof="provisioning_event::Value", tags="1, 2, 3, 4")] + pub value: ::core::option::Option, +} +/// Nested message and enum types in `ProvisioningEvent`. +pub mod provisioning_event { + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Value { + #[prost(message, tag="1")] + ModuleRuntimeEvent(super::super::super::schema::v1::ModuleRuntimeEvent), + #[prost(message, tag="2")] + DatabaseRuntimeEvent(super::super::super::schema::v1::DatabaseRuntimeEvent), + #[prost(message, tag="3")] + TopicRuntimeEvent(super::super::super::schema::v1::TopicRuntimeEvent), + #[prost(message, tag="4")] + VerbRuntimeEvent(super::super::super::schema::v1::VerbRuntimeEvent), + } +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct StatusResponse { + #[prost(oneof="status_response::Status", tags="1, 2")] + pub status: ::core::option::Option, +} +/// Nested message and enum types in `StatusResponse`. +pub mod status_response { + #[derive(Clone, Copy, PartialEq, ::prost::Message)] + pub struct ProvisioningRunning { + } + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct ProvisioningFailed { + #[prost(string, tag="1")] + pub error_message: ::prost::alloc::string::String, + } + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct ProvisioningSuccess { + #[prost(message, repeated, tag="1")] + pub events: ::prost::alloc::vec::Vec, + } + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Status { + #[prost(message, tag="1")] + Running(ProvisioningRunning), + #[prost(message, tag="2")] + Success(ProvisioningSuccess), + } +} +// @@protoc_insertion_point(module) diff --git a/backend/protos/src/protos/xyz.block.ftl.publish.v1.rs b/backend/protos/src/protos/xyz.block.ftl.publish.v1.rs new file mode 100644 index 0000000000..5ceecca335 --- /dev/null +++ b/backend/protos/src/protos/xyz.block.ftl.publish.v1.rs @@ -0,0 +1,18 @@ +// @generated +// This file is @generated by prost-build. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PublishEventRequest { + #[prost(message, optional, tag="1")] + pub topic: ::core::option::Option, + #[prost(bytes="bytes", tag="2")] + pub body: ::prost::bytes::Bytes, + #[prost(string, tag="3")] + pub key: ::prost::alloc::string::String, + /// Only verb name is included because this verb will be in the same module as topic + #[prost(string, tag="4")] + pub caller: ::prost::alloc::string::String, +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct PublishEventResponse { +} +// @@protoc_insertion_point(module) diff --git a/backend/protos/src/protos/xyz.block.ftl.raft.v1.rs b/backend/protos/src/protos/xyz.block.ftl.raft.v1.rs new file mode 100644 index 0000000000..5e3dd375ca --- /dev/null +++ b/backend/protos/src/protos/xyz.block.ftl.raft.v1.rs @@ -0,0 +1,15 @@ +// @generated +// This file is @generated by prost-build. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct AddMemberRequest { + #[prost(string, tag="1")] + pub address: ::prost::alloc::string::String, + #[prost(uint64, tag="2")] + pub replica_id: u64, + #[prost(uint64, repeated, tag="3")] + pub shard_ids: ::prost::alloc::vec::Vec, +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct AddMemberResponse { +} +// @@protoc_insertion_point(module) diff --git a/backend/protos/src/protos/xyz.block.ftl.timeline.v1.rs b/backend/protos/src/protos/xyz.block.ftl.timeline.v1.rs new file mode 100644 index 0000000000..5042f7da33 --- /dev/null +++ b/backend/protos/src/protos/xyz.block.ftl.timeline.v1.rs @@ -0,0 +1,534 @@ +// @generated +// This file is @generated by prost-build. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct LogEvent { + #[prost(string, tag="1")] + pub deployment_key: ::prost::alloc::string::String, + #[prost(string, optional, tag="2")] + pub request_key: ::core::option::Option<::prost::alloc::string::String>, + #[prost(message, optional, tag="3")] + pub timestamp: ::core::option::Option<::prost_types::Timestamp>, + #[prost(int32, tag="4")] + pub log_level: i32, + #[prost(map="string, string", tag="5")] + pub attributes: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>, + #[prost(string, tag="6")] + pub message: ::prost::alloc::string::String, + #[prost(string, optional, tag="7")] + pub error: ::core::option::Option<::prost::alloc::string::String>, + #[prost(string, optional, tag="8")] + pub stack: ::core::option::Option<::prost::alloc::string::String>, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CallEvent { + #[prost(string, optional, tag="1")] + pub request_key: ::core::option::Option<::prost::alloc::string::String>, + #[prost(string, tag="2")] + pub deployment_key: ::prost::alloc::string::String, + #[prost(message, optional, tag="3")] + pub timestamp: ::core::option::Option<::prost_types::Timestamp>, + #[prost(message, optional, tag="11")] + pub source_verb_ref: ::core::option::Option, + #[prost(message, optional, tag="12")] + pub destination_verb_ref: ::core::option::Option, + #[prost(message, optional, tag="6")] + pub duration: ::core::option::Option<::prost_types::Duration>, + #[prost(string, tag="7")] + pub request: ::prost::alloc::string::String, + #[prost(string, tag="8")] + pub response: ::prost::alloc::string::String, + #[prost(string, optional, tag="9")] + pub error: ::core::option::Option<::prost::alloc::string::String>, + #[prost(string, optional, tag="10")] + pub stack: ::core::option::Option<::prost::alloc::string::String>, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct DeploymentCreatedEvent { + #[prost(string, tag="1")] + pub key: ::prost::alloc::string::String, + #[prost(string, tag="2")] + pub language: ::prost::alloc::string::String, + #[prost(string, tag="3")] + pub module_name: ::prost::alloc::string::String, + #[prost(int32, tag="4")] + pub min_replicas: i32, + #[prost(string, optional, tag="5")] + pub replaced: ::core::option::Option<::prost::alloc::string::String>, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct DeploymentUpdatedEvent { + #[prost(string, tag="1")] + pub key: ::prost::alloc::string::String, + #[prost(int32, tag="2")] + pub min_replicas: i32, + #[prost(int32, tag="3")] + pub prev_min_replicas: i32, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct IngressEvent { + #[prost(string, tag="1")] + pub deployment_key: ::prost::alloc::string::String, + #[prost(string, optional, tag="2")] + pub request_key: ::core::option::Option<::prost::alloc::string::String>, + #[prost(message, optional, tag="3")] + pub verb_ref: ::core::option::Option, + #[prost(string, tag="4")] + pub method: ::prost::alloc::string::String, + #[prost(string, tag="5")] + pub path: ::prost::alloc::string::String, + #[prost(int32, tag="7")] + pub status_code: i32, + #[prost(message, optional, tag="8")] + pub timestamp: ::core::option::Option<::prost_types::Timestamp>, + #[prost(message, optional, tag="9")] + pub duration: ::core::option::Option<::prost_types::Duration>, + #[prost(string, tag="10")] + pub request: ::prost::alloc::string::String, + #[prost(string, tag="11")] + pub request_header: ::prost::alloc::string::String, + #[prost(string, tag="12")] + pub response: ::prost::alloc::string::String, + #[prost(string, tag="13")] + pub response_header: ::prost::alloc::string::String, + #[prost(string, optional, tag="14")] + pub error: ::core::option::Option<::prost::alloc::string::String>, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CronScheduledEvent { + #[prost(string, tag="1")] + pub deployment_key: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub verb_ref: ::core::option::Option, + #[prost(message, optional, tag="3")] + pub timestamp: ::core::option::Option<::prost_types::Timestamp>, + #[prost(message, optional, tag="4")] + pub duration: ::core::option::Option<::prost_types::Duration>, + #[prost(message, optional, tag="5")] + pub scheduled_at: ::core::option::Option<::prost_types::Timestamp>, + #[prost(string, tag="6")] + pub schedule: ::prost::alloc::string::String, + #[prost(string, optional, tag="7")] + pub error: ::core::option::Option<::prost::alloc::string::String>, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct AsyncExecuteEvent { + #[prost(string, tag="1")] + pub deployment_key: ::prost::alloc::string::String, + #[prost(string, optional, tag="2")] + pub request_key: ::core::option::Option<::prost::alloc::string::String>, + #[prost(message, optional, tag="3")] + pub verb_ref: ::core::option::Option, + #[prost(message, optional, tag="4")] + pub timestamp: ::core::option::Option<::prost_types::Timestamp>, + #[prost(message, optional, tag="5")] + pub duration: ::core::option::Option<::prost_types::Duration>, + #[prost(enumeration="AsyncExecuteEventType", tag="6")] + pub async_event_type: i32, + #[prost(string, optional, tag="7")] + pub error: ::core::option::Option<::prost::alloc::string::String>, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PubSubPublishEvent { + #[prost(string, tag="1")] + pub deployment_key: ::prost::alloc::string::String, + #[prost(string, optional, tag="2")] + pub request_key: ::core::option::Option<::prost::alloc::string::String>, + #[prost(message, optional, tag="3")] + pub verb_ref: ::core::option::Option, + #[prost(message, optional, tag="4")] + pub timestamp: ::core::option::Option<::prost_types::Timestamp>, + #[prost(message, optional, tag="5")] + pub duration: ::core::option::Option<::prost_types::Duration>, + #[prost(string, tag="6")] + pub topic: ::prost::alloc::string::String, + #[prost(string, tag="7")] + pub request: ::prost::alloc::string::String, + #[prost(string, optional, tag="8")] + pub error: ::core::option::Option<::prost::alloc::string::String>, + #[prost(int32, tag="9")] + pub partition: i32, + #[prost(int64, tag="10")] + pub offset: i64, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PubSubConsumeEvent { + #[prost(string, tag="1")] + pub deployment_key: ::prost::alloc::string::String, + #[prost(string, optional, tag="2")] + pub request_key: ::core::option::Option<::prost::alloc::string::String>, + #[prost(string, optional, tag="3")] + pub dest_verb_module: ::core::option::Option<::prost::alloc::string::String>, + #[prost(string, optional, tag="4")] + pub dest_verb_name: ::core::option::Option<::prost::alloc::string::String>, + #[prost(message, optional, tag="5")] + pub timestamp: ::core::option::Option<::prost_types::Timestamp>, + #[prost(message, optional, tag="6")] + pub duration: ::core::option::Option<::prost_types::Duration>, + #[prost(string, tag="7")] + pub topic: ::prost::alloc::string::String, + #[prost(string, optional, tag="8")] + pub error: ::core::option::Option<::prost::alloc::string::String>, + #[prost(int32, tag="9")] + pub partition: i32, + #[prost(int64, tag="10")] + pub offset: i64, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Event { + #[prost(message, optional, tag="1")] + pub timestamp: ::core::option::Option<::prost_types::Timestamp>, + /// Unique ID for event. + #[prost(int64, tag="2")] + pub id: i64, + #[prost(oneof="event::Entry", tags="3, 4, 5, 6, 7, 8, 9, 10, 11")] + pub entry: ::core::option::Option, +} +/// Nested message and enum types in `Event`. +pub mod event { + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Entry { + #[prost(message, tag="3")] + Log(super::LogEvent), + #[prost(message, tag="4")] + Call(super::CallEvent), + #[prost(message, tag="5")] + DeploymentCreated(super::DeploymentCreatedEvent), + #[prost(message, tag="6")] + DeploymentUpdated(super::DeploymentUpdatedEvent), + #[prost(message, tag="7")] + Ingress(super::IngressEvent), + #[prost(message, tag="8")] + CronScheduled(super::CronScheduledEvent), + #[prost(message, tag="9")] + AsyncExecute(super::AsyncExecuteEvent), + #[prost(message, tag="10")] + PubsubPublish(super::PubSubPublishEvent), + #[prost(message, tag="11")] + PubsubConsume(super::PubSubConsumeEvent), + } +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum EventType { + Unspecified = 0, + Log = 1, + Call = 2, + DeploymentCreated = 3, + DeploymentUpdated = 4, + Ingress = 5, + CronScheduled = 6, + AsyncExecute = 7, + PubsubPublish = 8, + PubsubConsume = 9, +} +impl EventType { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Self::Unspecified => "EVENT_TYPE_UNSPECIFIED", + Self::Log => "EVENT_TYPE_LOG", + Self::Call => "EVENT_TYPE_CALL", + Self::DeploymentCreated => "EVENT_TYPE_DEPLOYMENT_CREATED", + Self::DeploymentUpdated => "EVENT_TYPE_DEPLOYMENT_UPDATED", + Self::Ingress => "EVENT_TYPE_INGRESS", + Self::CronScheduled => "EVENT_TYPE_CRON_SCHEDULED", + Self::AsyncExecute => "EVENT_TYPE_ASYNC_EXECUTE", + Self::PubsubPublish => "EVENT_TYPE_PUBSUB_PUBLISH", + Self::PubsubConsume => "EVENT_TYPE_PUBSUB_CONSUME", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "EVENT_TYPE_UNSPECIFIED" => Some(Self::Unspecified), + "EVENT_TYPE_LOG" => Some(Self::Log), + "EVENT_TYPE_CALL" => Some(Self::Call), + "EVENT_TYPE_DEPLOYMENT_CREATED" => Some(Self::DeploymentCreated), + "EVENT_TYPE_DEPLOYMENT_UPDATED" => Some(Self::DeploymentUpdated), + "EVENT_TYPE_INGRESS" => Some(Self::Ingress), + "EVENT_TYPE_CRON_SCHEDULED" => Some(Self::CronScheduled), + "EVENT_TYPE_ASYNC_EXECUTE" => Some(Self::AsyncExecute), + "EVENT_TYPE_PUBSUB_PUBLISH" => Some(Self::PubsubPublish), + "EVENT_TYPE_PUBSUB_CONSUME" => Some(Self::PubsubConsume), + _ => None, + } + } +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum AsyncExecuteEventType { + Unspecified = 0, + Cron = 1, + Pubsub = 2, +} +impl AsyncExecuteEventType { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Self::Unspecified => "ASYNC_EXECUTE_EVENT_TYPE_UNSPECIFIED", + Self::Cron => "ASYNC_EXECUTE_EVENT_TYPE_CRON", + Self::Pubsub => "ASYNC_EXECUTE_EVENT_TYPE_PUBSUB", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "ASYNC_EXECUTE_EVENT_TYPE_UNSPECIFIED" => Some(Self::Unspecified), + "ASYNC_EXECUTE_EVENT_TYPE_CRON" => Some(Self::Cron), + "ASYNC_EXECUTE_EVENT_TYPE_PUBSUB" => Some(Self::Pubsub), + _ => None, + } + } +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum LogLevel { + Unspecified = 0, + Trace = 1, + Debug = 5, + Info = 9, + Warn = 13, + Error = 17, +} +impl LogLevel { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Self::Unspecified => "LOG_LEVEL_UNSPECIFIED", + Self::Trace => "LOG_LEVEL_TRACE", + Self::Debug => "LOG_LEVEL_DEBUG", + Self::Info => "LOG_LEVEL_INFO", + Self::Warn => "LOG_LEVEL_WARN", + Self::Error => "LOG_LEVEL_ERROR", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "LOG_LEVEL_UNSPECIFIED" => Some(Self::Unspecified), + "LOG_LEVEL_TRACE" => Some(Self::Trace), + "LOG_LEVEL_DEBUG" => Some(Self::Debug), + "LOG_LEVEL_INFO" => Some(Self::Info), + "LOG_LEVEL_WARN" => Some(Self::Warn), + "LOG_LEVEL_ERROR" => Some(Self::Error), + _ => None, + } + } +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetTimelineRequest { + #[prost(message, repeated, tag="1")] + pub filters: ::prost::alloc::vec::Vec, + #[prost(int32, tag="2")] + pub limit: i32, + /// Ordering is done by id which matches publication order. + /// This roughly corresponds to the time of the event, but not strictly. + #[prost(enumeration="get_timeline_request::Order", tag="3")] + pub order: i32, +} +/// Nested message and enum types in `GetTimelineRequest`. +pub mod get_timeline_request { + /// Filters events by log level. + #[derive(Clone, Copy, PartialEq, ::prost::Message)] + pub struct LogLevelFilter { + #[prost(enumeration="super::LogLevel", tag="1")] + pub log_level: i32, + } + /// Filters events by deployment key. + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct DeploymentFilter { + #[prost(string, repeated, tag="1")] + pub deployments: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + } + /// Filters events by request key. + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct RequestFilter { + #[prost(string, repeated, tag="1")] + pub requests: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + } + /// Filters events by event type. + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct EventTypeFilter { + #[prost(enumeration="super::EventType", repeated, tag="1")] + pub event_types: ::prost::alloc::vec::Vec, + } + /// Filters events by time. + /// + /// Either end of the time range can be omitted to indicate no bound. + #[derive(Clone, Copy, PartialEq, ::prost::Message)] + pub struct TimeFilter { + #[prost(message, optional, tag="1")] + pub older_than: ::core::option::Option<::prost_types::Timestamp>, + #[prost(message, optional, tag="2")] + pub newer_than: ::core::option::Option<::prost_types::Timestamp>, + } + /// Filters events by ID. + /// + /// Either end of the ID range can be omitted to indicate no bound. + #[derive(Clone, Copy, PartialEq, ::prost::Message)] + pub struct IdFilter { + #[prost(int64, optional, tag="1")] + pub lower_than: ::core::option::Option, + #[prost(int64, optional, tag="2")] + pub higher_than: ::core::option::Option, + } + /// Filters events by call. + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct CallFilter { + #[prost(string, tag="1")] + pub dest_module: ::prost::alloc::string::String, + #[prost(string, optional, tag="2")] + pub dest_verb: ::core::option::Option<::prost::alloc::string::String>, + #[prost(string, optional, tag="3")] + pub source_module: ::core::option::Option<::prost::alloc::string::String>, + } + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct ModuleFilter { + #[prost(string, tag="1")] + pub module: ::prost::alloc::string::String, + #[prost(string, optional, tag="2")] + pub verb: ::core::option::Option<::prost::alloc::string::String>, + } + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct Filter { + /// These map 1:1 with filters in backend/timeline/filters.go + #[prost(oneof="filter::Filter", tags="1, 2, 3, 4, 5, 6, 7, 8")] + pub filter: ::core::option::Option, + } + /// Nested message and enum types in `Filter`. + pub mod filter { + /// These map 1:1 with filters in backend/timeline/filters.go + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Filter { + #[prost(message, tag="1")] + LogLevel(super::LogLevelFilter), + #[prost(message, tag="2")] + Deployments(super::DeploymentFilter), + #[prost(message, tag="3")] + Requests(super::RequestFilter), + #[prost(message, tag="4")] + EventTypes(super::EventTypeFilter), + #[prost(message, tag="5")] + Time(super::TimeFilter), + #[prost(message, tag="6")] + Id(super::IdFilter), + #[prost(message, tag="7")] + Call(super::CallFilter), + #[prost(message, tag="8")] + Module(super::ModuleFilter), + } + } + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] + #[repr(i32)] + pub enum Order { + Unspecified = 0, + Asc = 1, + Desc = 2, + } + impl Order { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Self::Unspecified => "ORDER_UNSPECIFIED", + Self::Asc => "ORDER_ASC", + Self::Desc => "ORDER_DESC", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "ORDER_UNSPECIFIED" => Some(Self::Unspecified), + "ORDER_ASC" => Some(Self::Asc), + "ORDER_DESC" => Some(Self::Desc), + _ => None, + } + } + } +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetTimelineResponse { + #[prost(message, repeated, tag="1")] + pub events: ::prost::alloc::vec::Vec, + /// For pagination, this cursor is where we should start our next query + #[prost(int64, optional, tag="2")] + pub cursor: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct StreamTimelineRequest { + #[prost(message, optional, tag="1")] + pub update_interval: ::core::option::Option<::prost_types::Duration>, + #[prost(message, optional, tag="2")] + pub query: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct StreamTimelineResponse { + #[prost(message, repeated, tag="1")] + pub events: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CreateEventsRequest { + #[prost(message, repeated, tag="1")] + pub entries: ::prost::alloc::vec::Vec, +} +/// Nested message and enum types in `CreateEventsRequest`. +pub mod create_events_request { + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct EventEntry { + #[prost(message, optional, tag="1")] + pub timestamp: ::core::option::Option<::prost_types::Timestamp>, + #[prost(oneof="event_entry::Entry", tags="2, 3, 4, 5, 6, 7, 8, 9, 10")] + pub entry: ::core::option::Option, + } + /// Nested message and enum types in `EventEntry`. + pub mod event_entry { + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Entry { + #[prost(message, tag="2")] + Log(super::super::LogEvent), + #[prost(message, tag="3")] + Call(super::super::CallEvent), + #[prost(message, tag="4")] + DeploymentCreated(super::super::DeploymentCreatedEvent), + #[prost(message, tag="5")] + DeploymentUpdated(super::super::DeploymentUpdatedEvent), + #[prost(message, tag="6")] + Ingress(super::super::IngressEvent), + #[prost(message, tag="7")] + CronScheduled(super::super::CronScheduledEvent), + #[prost(message, tag="8")] + AsyncExecute(super::super::AsyncExecuteEvent), + #[prost(message, tag="9")] + PubsubPublish(super::super::PubSubPublishEvent), + #[prost(message, tag="10")] + PubsubConsume(super::super::PubSubConsumeEvent), + } + } +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct CreateEventsResponse { +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct DeleteOldEventsRequest { + #[prost(enumeration="EventType", tag="1")] + pub event_type: i32, + #[prost(int64, tag="2")] + pub age_seconds: i64, +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct DeleteOldEventsResponse { + #[prost(int64, tag="1")] + pub deleted_count: i64, +} +// @@protoc_insertion_point(module) diff --git a/backend/protos/src/protos/xyz.block.ftl.v1.rs b/backend/protos/src/protos/xyz.block.ftl.v1.rs new file mode 100644 index 0000000000..40575fbb25 --- /dev/null +++ b/backend/protos/src/protos/xyz.block.ftl.v1.rs @@ -0,0 +1,547 @@ +// @generated +// This file is @generated by prost-build. +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct PingRequest { +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PingResponse { + /// If present, the service is not ready to accept requests and this is the + /// reason. + #[prost(string, optional, tag="1")] + pub not_ready: ::core::option::Option<::prost::alloc::string::String>, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Metadata { + #[prost(message, repeated, tag="1")] + pub values: ::prost::alloc::vec::Vec, +} +/// Nested message and enum types in `Metadata`. +pub mod metadata { + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct Pair { + #[prost(string, tag="1")] + pub key: ::prost::alloc::string::String, + #[prost(string, tag="2")] + pub value: ::prost::alloc::string::String, + } +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ConfigRef { + #[prost(string, optional, tag="1")] + pub module: ::core::option::Option<::prost::alloc::string::String>, + #[prost(string, tag="2")] + pub name: ::prost::alloc::string::String, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ConfigListRequest { + #[prost(string, optional, tag="1")] + pub module: ::core::option::Option<::prost::alloc::string::String>, + #[prost(bool, optional, tag="2")] + pub include_values: ::core::option::Option, + #[prost(enumeration="ConfigProvider", optional, tag="3")] + pub provider: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ConfigListResponse { + #[prost(message, repeated, tag="1")] + pub configs: ::prost::alloc::vec::Vec, +} +/// Nested message and enum types in `ConfigListResponse`. +pub mod config_list_response { + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct Config { + #[prost(string, tag="1")] + pub ref_path: ::prost::alloc::string::String, + #[prost(bytes="bytes", optional, tag="2")] + pub value: ::core::option::Option<::prost::bytes::Bytes>, + } +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ConfigGetRequest { + #[prost(message, optional, tag="1")] + pub r#ref: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ConfigGetResponse { + #[prost(bytes="bytes", tag="1")] + pub value: ::prost::bytes::Bytes, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ConfigSetRequest { + #[prost(enumeration="ConfigProvider", optional, tag="1")] + pub provider: ::core::option::Option, + #[prost(message, optional, tag="2")] + pub r#ref: ::core::option::Option, + #[prost(bytes="bytes", tag="3")] + pub value: ::prost::bytes::Bytes, +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct ConfigSetResponse { +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ConfigUnsetRequest { + #[prost(enumeration="ConfigProvider", optional, tag="1")] + pub provider: ::core::option::Option, + #[prost(message, optional, tag="2")] + pub r#ref: ::core::option::Option, +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct ConfigUnsetResponse { +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SecretsListRequest { + #[prost(string, optional, tag="1")] + pub module: ::core::option::Option<::prost::alloc::string::String>, + #[prost(bool, optional, tag="2")] + pub include_values: ::core::option::Option, + #[prost(enumeration="SecretProvider", optional, tag="3")] + pub provider: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SecretsListResponse { + #[prost(message, repeated, tag="1")] + pub secrets: ::prost::alloc::vec::Vec, +} +/// Nested message and enum types in `SecretsListResponse`. +pub mod secrets_list_response { + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct Secret { + #[prost(string, tag="1")] + pub ref_path: ::prost::alloc::string::String, + #[prost(bytes="bytes", optional, tag="2")] + pub value: ::core::option::Option<::prost::bytes::Bytes>, + } +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SecretGetRequest { + #[prost(message, optional, tag="1")] + pub r#ref: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SecretGetResponse { + #[prost(bytes="bytes", tag="1")] + pub value: ::prost::bytes::Bytes, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SecretSetRequest { + #[prost(enumeration="SecretProvider", optional, tag="1")] + pub provider: ::core::option::Option, + #[prost(message, optional, tag="2")] + pub r#ref: ::core::option::Option, + #[prost(bytes="bytes", tag="3")] + pub value: ::prost::bytes::Bytes, +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct SecretSetResponse { +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SecretUnsetRequest { + #[prost(enumeration="SecretProvider", optional, tag="1")] + pub provider: ::core::option::Option, + #[prost(message, optional, tag="2")] + pub r#ref: ::core::option::Option, +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct SecretUnsetResponse { +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MapConfigsForModuleRequest { + #[prost(string, tag="1")] + pub module: ::prost::alloc::string::String, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MapConfigsForModuleResponse { + #[prost(map="string, bytes", tag="1")] + pub values: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::bytes::Bytes>, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MapSecretsForModuleRequest { + #[prost(string, tag="1")] + pub module: ::prost::alloc::string::String, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MapSecretsForModuleResponse { + #[prost(map="string, bytes", tag="1")] + pub values: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::bytes::Bytes>, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum ConfigProvider { + Unspecified = 0, + /// Write values inline in the configuration file. + Inline = 1, + /// Print configuration as environment variables. + Envar = 2, +} +impl ConfigProvider { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Self::Unspecified => "CONFIG_PROVIDER_UNSPECIFIED", + Self::Inline => "CONFIG_PROVIDER_INLINE", + Self::Envar => "CONFIG_PROVIDER_ENVAR", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "CONFIG_PROVIDER_UNSPECIFIED" => Some(Self::Unspecified), + "CONFIG_PROVIDER_INLINE" => Some(Self::Inline), + "CONFIG_PROVIDER_ENVAR" => Some(Self::Envar), + _ => None, + } + } +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum SecretProvider { + Unspecified = 0, + /// Write values inline in the configuration file. + Inline = 1, + /// Print configuration as environment variables. + Envar = 2, + /// Write to the system keychain. + Keychain = 3, + /// Store a secret in the 1Password vault. + Op = 4, + /// Store a secret in the AWS Secrets Manager. + Asm = 5, +} +impl SecretProvider { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Self::Unspecified => "SECRET_PROVIDER_UNSPECIFIED", + Self::Inline => "SECRET_PROVIDER_INLINE", + Self::Envar => "SECRET_PROVIDER_ENVAR", + Self::Keychain => "SECRET_PROVIDER_KEYCHAIN", + Self::Op => "SECRET_PROVIDER_OP", + Self::Asm => "SECRET_PROVIDER_ASM", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "SECRET_PROVIDER_UNSPECIFIED" => Some(Self::Unspecified), + "SECRET_PROVIDER_INLINE" => Some(Self::Inline), + "SECRET_PROVIDER_ENVAR" => Some(Self::Envar), + "SECRET_PROVIDER_KEYCHAIN" => Some(Self::Keychain), + "SECRET_PROVIDER_OP" => Some(Self::Op), + "SECRET_PROVIDER_ASM" => Some(Self::Asm), + _ => None, + } + } +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetArtefactDiffsRequest { + #[prost(string, repeated, tag="1")] + pub client_digests: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetArtefactDiffsResponse { + #[prost(string, repeated, tag="1")] + pub missing_digests: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + /// Artefacts that the client already has, and their path+executable status. + #[prost(message, repeated, tag="2")] + pub client_artefacts: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct UploadArtefactRequest { + #[prost(bytes="bytes", tag="1")] + pub content: ::prost::bytes::Bytes, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct UploadArtefactResponse { + #[prost(bytes="bytes", tag="2")] + pub digest: ::prost::bytes::Bytes, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct DeploymentArtefact { + #[prost(string, tag="1")] + pub digest: ::prost::alloc::string::String, + #[prost(string, tag="2")] + pub path: ::prost::alloc::string::String, + #[prost(bool, tag="3")] + pub executable: bool, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CreateDeploymentRequest { + #[prost(message, optional, tag="1")] + pub schema: ::core::option::Option, + #[prost(message, repeated, tag="2")] + pub artefacts: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CreateDeploymentResponse { + #[prost(string, tag="1")] + pub deployment_key: ::prost::alloc::string::String, + /// Currently active deployment for this module, if any. + #[prost(string, optional, tag="2")] + pub active_deployment_key: ::core::option::Option<::prost::alloc::string::String>, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetDeploymentArtefactsRequest { + #[prost(string, tag="1")] + pub deployment_key: ::prost::alloc::string::String, + #[prost(message, repeated, tag="2")] + pub have_artefacts: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetDeploymentArtefactsResponse { + #[prost(message, optional, tag="1")] + pub artefact: ::core::option::Option, + #[prost(bytes="bytes", tag="2")] + pub chunk: ::prost::bytes::Bytes, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetDeploymentRequest { + #[prost(string, tag="1")] + pub deployment_key: ::prost::alloc::string::String, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetDeploymentResponse { + #[prost(message, optional, tag="1")] + pub schema: ::core::option::Option, + #[prost(message, repeated, tag="2")] + pub artefacts: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct RegisterRunnerRequest { + #[prost(string, tag="1")] + pub key: ::prost::alloc::string::String, + #[prost(string, tag="2")] + pub endpoint: ::prost::alloc::string::String, + #[prost(string, tag="3")] + pub deployment: ::prost::alloc::string::String, + #[prost(message, optional, tag="5")] + pub labels: ::core::option::Option<::prost_types::Struct>, +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct RegisterRunnerResponse { +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct UpdateDeployRequest { + #[prost(string, tag="1")] + pub deployment_key: ::prost::alloc::string::String, + #[prost(int32, optional, tag="2")] + pub min_replicas: ::core::option::Option, +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct UpdateDeployResponse { +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ReplaceDeployRequest { + #[prost(string, tag="1")] + pub deployment_key: ::prost::alloc::string::String, + #[prost(int32, tag="2")] + pub min_replicas: i32, +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct ReplaceDeployResponse { +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct StatusRequest { +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct StatusResponse { + #[prost(message, repeated, tag="1")] + pub controllers: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="2")] + pub runners: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="3")] + pub deployments: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="5")] + pub routes: ::prost::alloc::vec::Vec, +} +/// Nested message and enum types in `StatusResponse`. +pub mod status_response { + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct Controller { + #[prost(string, tag="1")] + pub key: ::prost::alloc::string::String, + #[prost(string, tag="2")] + pub endpoint: ::prost::alloc::string::String, + #[prost(string, tag="3")] + pub version: ::prost::alloc::string::String, + } + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct Runner { + #[prost(string, tag="1")] + pub key: ::prost::alloc::string::String, + #[prost(string, tag="2")] + pub endpoint: ::prost::alloc::string::String, + #[prost(string, optional, tag="3")] + pub deployment: ::core::option::Option<::prost::alloc::string::String>, + #[prost(message, optional, tag="4")] + pub labels: ::core::option::Option<::prost_types::Struct>, + } + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct Deployment { + #[prost(string, tag="1")] + pub key: ::prost::alloc::string::String, + #[prost(string, tag="2")] + pub language: ::prost::alloc::string::String, + #[prost(string, tag="3")] + pub name: ::prost::alloc::string::String, + #[prost(int32, tag="4")] + pub min_replicas: i32, + #[prost(int32, tag="7")] + pub replicas: i32, + #[prost(message, optional, tag="5")] + pub labels: ::core::option::Option<::prost_types::Struct>, + #[prost(message, optional, tag="6")] + pub schema: ::core::option::Option, + } + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct Route { + #[prost(string, tag="1")] + pub module: ::prost::alloc::string::String, + #[prost(string, tag="2")] + pub deployment: ::prost::alloc::string::String, + #[prost(string, tag="3")] + pub endpoint: ::prost::alloc::string::String, + } +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct ProcessListRequest { +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ProcessListResponse { + #[prost(message, repeated, tag="1")] + pub processes: ::prost::alloc::vec::Vec, +} +/// Nested message and enum types in `ProcessListResponse`. +pub mod process_list_response { + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct ProcessRunner { + #[prost(string, tag="1")] + pub key: ::prost::alloc::string::String, + #[prost(string, tag="2")] + pub endpoint: ::prost::alloc::string::String, + #[prost(message, optional, tag="3")] + pub labels: ::core::option::Option<::prost_types::Struct>, + } + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct Process { + #[prost(string, tag="1")] + pub deployment: ::prost::alloc::string::String, + #[prost(int32, tag="2")] + pub min_replicas: i32, + #[prost(message, optional, tag="3")] + pub labels: ::core::option::Option<::prost_types::Struct>, + #[prost(message, optional, tag="4")] + pub runner: ::core::option::Option, + } +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct GetSchemaRequest { +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetSchemaResponse { + #[prost(message, optional, tag="1")] + pub schema: ::core::option::Option, +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct PullSchemaRequest { +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PullSchemaResponse { + /// Will not be set for builtin modules. + #[prost(string, optional, tag="1")] + pub deployment_key: ::core::option::Option<::prost::alloc::string::String>, + #[prost(string, tag="2")] + pub module_name: ::prost::alloc::string::String, + /// For deletes this will not be present. + #[prost(message, optional, tag="4")] + pub schema: ::core::option::Option, + /// If true there are more schema changes immediately following this one as part of the initial batch. + /// If false this is the last schema change in the initial batch, but others may follow later. + #[prost(bool, tag="3")] + pub more: bool, + #[prost(enumeration="DeploymentChangeType", tag="5")] + pub change_type: i32, + /// If this is true then the module was removed as well as the deployment. This is only set for DEPLOYMENT_REMOVED. + #[prost(bool, tag="6")] + pub module_removed: bool, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct UpdateDeploymentRuntimeRequest { + #[prost(string, tag="1")] + pub deployment: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub event: ::core::option::Option, +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct UpdateDeploymentRuntimeResponse { +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum DeploymentChangeType { + Unspecified = 0, + Added = 1, + Removed = 2, + Changed = 3, +} +impl DeploymentChangeType { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Self::Unspecified => "DEPLOYMENT_CHANGE_TYPE_UNSPECIFIED", + Self::Added => "DEPLOYMENT_CHANGE_TYPE_ADDED", + Self::Removed => "DEPLOYMENT_CHANGE_TYPE_REMOVED", + Self::Changed => "DEPLOYMENT_CHANGE_TYPE_CHANGED", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "DEPLOYMENT_CHANGE_TYPE_UNSPECIFIED" => Some(Self::Unspecified), + "DEPLOYMENT_CHANGE_TYPE_ADDED" => Some(Self::Added), + "DEPLOYMENT_CHANGE_TYPE_REMOVED" => Some(Self::Removed), + "DEPLOYMENT_CHANGE_TYPE_CHANGED" => Some(Self::Changed), + _ => None, + } + } +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CallRequest { + #[prost(message, optional, tag="1")] + pub metadata: ::core::option::Option, + #[prost(message, optional, tag="2")] + pub verb: ::core::option::Option, + #[prost(bytes="bytes", tag="3")] + pub body: ::prost::bytes::Bytes, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CallResponse { + #[prost(oneof="call_response::Response", tags="1, 2")] + pub response: ::core::option::Option, +} +/// Nested message and enum types in `CallResponse`. +pub mod call_response { + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct Error { + #[prost(string, tag="1")] + pub message: ::prost::alloc::string::String, + /// TODO: Richer error type. + #[prost(string, optional, tag="2")] + pub stack: ::core::option::Option<::prost::alloc::string::String>, + } + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Response { + #[prost(bytes, tag="1")] + Body(::prost::bytes::Bytes), + #[prost(message, tag="2")] + Error(Error), + } +} +// @@protoc_insertion_point(module) diff --git a/sqlc-gen-ftl/src/plugin/mod.rs b/sqlc-gen-ftl/src/plugin/mod.rs index 0b77e39891..4dd9256f24 100644 --- a/sqlc-gen-ftl/src/plugin/mod.rs +++ b/sqlc-gen-ftl/src/plugin/mod.rs @@ -57,13 +57,19 @@ fn to_verb(query: &pluginpb::Query, module_name: &str) -> schemapb::Decl { let request_type = if !query.params.is_empty() { Some(to_schema_ref(module_name, &format!("{}Query", query.name))) } else { - None + Some(to_schema_unit()) }; - let response_type = if query.cmd == ":exec" { - None - } else { - Some(to_schema_ref(module_name, &format!("{}Result", query.name))) + let response_type = match query.cmd.as_str() { + ":exec" => Some(to_schema_unit()), + ":one" => Some(to_schema_ref(module_name, &format!("{}Result", query.name))), + ":many" => Some(schemapb::Type { + value: Some(schemapb::r#type::Value::Array(Box::new(schemapb::Array { + pos: None, + element: Some(Box::new(to_schema_ref(module_name, &format!("{}Result", query.name)))), + }))), + }), + _ => Some(to_schema_unit()), }; schemapb::Decl { @@ -87,9 +93,12 @@ fn to_verb_request(query: &pluginpb::Query) -> schemapb::Decl { export: false, type_parameters: Vec::new(), fields: query.params.iter().map(|param| { - let name = param.column.as_ref() - .map(|col| col.name.clone()) - .unwrap_or_else(|| format!("param{}", param.number)); + let name = if let Some(col) = ¶m.column { + col.name.clone() + } else { + format!("arg{}", param.number) + }; + let sql_type = param.column.as_ref().and_then(|col| col.r#type.as_ref()); to_schema_field(name, sql_type) }).collect(), @@ -142,6 +151,14 @@ fn to_schema_ref(module_name: &str, name: &str) -> schemapb::Type { } } +fn to_schema_unit() -> schemapb::Type { + schemapb::Type { + value: Some(schemapb::r#type::Value::Unit(schemapb::Unit { + pos: None, + })) + } +} + fn to_schema_type(sql_type: &pluginpb::Identifier) -> schemapb::Type { let value = match sql_type.name.as_str() { "integer" | "bigint" | "smallint" | "serial" | "bigserial" => diff --git a/sqlc-gen-ftl/test/sqlc_gen_ftl_test.rs b/sqlc-gen-ftl/test/sqlc_gen_ftl_test.rs index 28977762cf..bfdb361af3 100644 --- a/sqlc-gen-ftl/test/sqlc_gen_ftl_test.rs +++ b/sqlc-gen-ftl/test/sqlc_gen_ftl_test.rs @@ -40,9 +40,7 @@ fn expected_module_schema() -> schemapb::Module { schemapb::Field { name: "id".to_string(), r#type: Some(schemapb::Type { - value: Some(schemapb::r#type::Value::Int(schemapb::Int { - pos: None, - })) + value: Some(schemapb::r#type::Value::Int(schemapb::Int { pos: None })) }), pos: None, comments: vec![], @@ -63,9 +61,7 @@ fn expected_module_schema() -> schemapb::Module { schemapb::Field { name: "id".to_string(), r#type: Some(schemapb::Type { - value: Some(schemapb::r#type::Value::Int(schemapb::Int { - pos: None, - })) + value: Some(schemapb::r#type::Value::Int(schemapb::Int { pos: None })) }), pos: None, comments: vec![], @@ -74,9 +70,7 @@ fn expected_module_schema() -> schemapb::Module { schemapb::Field { name: "name".to_string(), r#type: Some(schemapb::Type { - value: Some(schemapb::r#type::Value::String(schemapb::String { - pos: None, - })) + value: Some(schemapb::r#type::Value::String(schemapb::String { pos: None })) }), pos: None, comments: vec![], @@ -85,9 +79,7 @@ fn expected_module_schema() -> schemapb::Module { schemapb::Field { name: "email".to_string(), r#type: Some(schemapb::Type { - value: Some(schemapb::r#type::Value::String(schemapb::String { - pos: None, - })) + value: Some(schemapb::r#type::Value::String(schemapb::String { pos: None })) }), pos: None, comments: vec![], @@ -134,9 +126,7 @@ fn expected_module_schema() -> schemapb::Module { schemapb::Field { name: "name".to_string(), r#type: Some(schemapb::Type { - value: Some(schemapb::r#type::Value::String(schemapb::String { - pos: None, - })) + value: Some(schemapb::r#type::Value::String(schemapb::String { pos: None })) }), pos: None, comments: vec![], @@ -145,9 +135,7 @@ fn expected_module_schema() -> schemapb::Module { schemapb::Field { name: "email".to_string(), r#type: Some(schemapb::Type { - value: Some(schemapb::r#type::Value::String(schemapb::String { - pos: None, - })) + value: Some(schemapb::r#type::Value::String(schemapb::String { pos: None })) }), pos: None, comments: vec![], @@ -172,7 +160,98 @@ fn expected_module_schema() -> schemapb::Module { type_parameters: vec![], })) }), - response: None, + response: Some(schemapb::Type { + value: Some(schemapb::r#type::Value::Unit(schemapb::Unit { pos: None })) + }), + pos: None, + comments: vec![], + metadata: vec![], + })), + }, + schemapb::Decl { + value: Some(schemapb::decl::Value::Data(schemapb::Data { + name: "GetRequestDataResult".to_string(), + export: false, + type_parameters: vec![], + fields: vec![ + schemapb::Field { + name: "data".to_string(), + r#type: Some(schemapb::Type { + value: Some(schemapb::r#type::Value::String(schemapb::String { pos: None })) + }), + pos: None, + comments: vec![], + metadata: vec![], + } + ], + pos: None, + comments: vec![], + metadata: vec![], + })), + }, + schemapb::Decl { + value: Some(schemapb::decl::Value::Verb(schemapb::Verb { + name: "GetRequestData".to_string(), + export: false, + runtime: None, + request: Some(schemapb::Type { + value: Some(schemapb::r#type::Value::Unit(schemapb::Unit { pos: None })) + }), + response: Some(schemapb::Type { + value: Some(schemapb::r#type::Value::Array(Box::new(schemapb::Array { + pos: None, + element: Some(Box::new(schemapb::Type { + value: Some(schemapb::r#type::Value::Ref(schemapb::Ref { + module: "echo".to_string(), + name: "GetRequestDataResult".to_string(), + pos: None, + type_parameters: vec![], + })) + })), + }))) + }), + pos: None, + comments: vec![], + metadata: vec![], + })), + }, + schemapb::Decl { + value: Some(schemapb::decl::Value::Data(schemapb::Data { + name: "CreateRequestQuery".to_string(), + export: false, + type_parameters: vec![], + fields: vec![ + schemapb::Field { + name: "data".to_string(), + r#type: Some(schemapb::Type { + value: Some(schemapb::r#type::Value::String(schemapb::String { pos: None })) + }), + pos: None, + comments: vec![], + metadata: vec![], + } + ], + pos: None, + comments: vec![], + metadata: vec![], + })), + }, + schemapb::Decl { + value: Some(schemapb::decl::Value::Verb(schemapb::Verb { + name: "CreateRequest".to_string(), + export: false, + runtime: None, + request: Some(schemapb::Type { + value: Some(schemapb::r#type::Value::Ref(schemapb::Ref { + module: "echo".to_string(), + name: "CreateRequestQuery".to_string(), + pos: None, + type_parameters: vec![], + })) + }), + response: Some(schemapb::Type { + value: Some(schemapb::r#type::Value::Unit(schemapb::Unit { pos: None })) + }), pos: None, comments: vec![], metadata: vec![], @@ -182,7 +261,7 @@ fn expected_module_schema() -> schemapb::Module { } } -fn get_sqlc_config(wasm_path: &PathBuf) -> Result> { +fn get_sqlc_config(wasm_path: &PathBuf, engine: &str) -> Result> { let wasm_contents = fs::read(wasm_path)?; let mut hasher = Sha256::new(); hasher.update(&wasm_contents); @@ -198,13 +277,14 @@ plugins: sql: - schema: schema.sql queries: queries.sql - engine: postgresql + engine: {} codegen: - out: gen plugin: ftl options: module: echo"#, sha256_hash, + engine, )) } @@ -219,59 +299,61 @@ mod tests { return Err(format!("Failed to build WASM: {}", e).into()); } - let temp_dir = TempDir::new()?; - let gen_dir = temp_dir.path().join("gen"); - std::fs::create_dir(&gen_dir)?; - - let root_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - let test_dir = root_dir.join("test"); - let wasm_path = temp_dir.path().join("sqlc-gen-ftl.wasm"); + for engine in ["mysql", "postgresql"] { + let temp_dir = TempDir::new()?; + let gen_dir = temp_dir.path().join("gen"); + std::fs::create_dir(&gen_dir)?; + + let root_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")); + let test_dir = root_dir.join("test"); + let wasm_path = temp_dir.path().join("sqlc-gen-ftl.wasm"); - std::fs::copy( - test_dir.join("testdata/schema.sql"), - temp_dir.path().join("schema.sql") - )?; - std::fs::copy( - test_dir.join("testdata/queries.sql"), - temp_dir.path().join("queries.sql") - )?; - std::fs::copy( - root_dir.join("target/wasm32-wasip1/release/sqlc-gen-ftl.wasm"), - &wasm_path - )?; - - let config_contents = get_sqlc_config(&wasm_path)?; - let config_path = temp_dir.path().join("sqlc.yaml"); - std::fs::write(&config_path, config_contents)?; + std::fs::copy( + test_dir.join(format!("testdata/{}/schema.sql", engine)), + temp_dir.path().join("schema.sql") + )?; + std::fs::copy( + test_dir.join(format!("testdata/{}/queries.sql", engine)), + temp_dir.path().join("queries.sql") + )?; + std::fs::copy( + root_dir.join("target/wasm32-wasip1/release/sqlc-gen-ftl.wasm"), + &wasm_path + )?; + + let config_contents = get_sqlc_config(&wasm_path, engine)?; + let config_path = temp_dir.path().join("sqlc.yaml"); + std::fs::write(&config_path, config_contents)?; - let output = Command::new("sqlc") - .arg("generate") - .arg("--file") - .arg(&config_path) - .current_dir(temp_dir.path()) - .env("SQLC_VERSION", "dev") - .env("SQLCDEBUG", "true") - .output()?; + let output = Command::new("sqlc") + .arg("generate") + .arg("--file") + .arg(&config_path) + .current_dir(temp_dir.path()) + .output()?; - if !output.status.success() { - return Err(format!( - "sqlc generate failed with status: {}\nstderr: {}", - output.status, - String::from_utf8_lossy(&output.stderr) - ).into()); - } + if !output.status.success() { + return Err(format!( + "sqlc generate failed for {} with status: {}\nstderr: {}", + engine, + output.status, + String::from_utf8_lossy(&output.stderr) + ).into()); + } - let pb_contents = std::fs::read(gen_dir.join("queries.pb"))?; - let actual_module = schemapb::Module::decode(&*pb_contents)?; - let expected_module = expected_module_schema(); + let pb_contents = std::fs::read(gen_dir.join("queries.pb"))?; + let actual_module = schemapb::Module::decode(&*pb_contents)?; + let expected_module = expected_module_schema(); - assert_eq!( - &actual_module, - &expected_module, - "Schema mismatch.\nActual: {:#?}\nExpected: {:#?}", - actual_module, - expected_module - ); + assert_eq!( + &actual_module, + &expected_module, + "Schema mismatch for {}.\nActual: {:#?}\nExpected: {:#?}", + engine, + actual_module, + expected_module + ); + } Ok(()) } diff --git a/sqlc-gen-ftl/test/testdata/mysql/queries.sql b/sqlc-gen-ftl/test/testdata/mysql/queries.sql new file mode 100644 index 0000000000..82ccf3b492 --- /dev/null +++ b/sqlc-gen-ftl/test/testdata/mysql/queries.sql @@ -0,0 +1,12 @@ +-- name: GetUserByID :one +SELECT id, name, email FROM users WHERE id = ?; + +-- name: CreateUser :exec +INSERT INTO users (name, email) VALUES (?, ?); + +-- name: GetRequestData :many +SELECT data FROM requests; + +-- name: CreateRequest :exec +INSERT INTO requests (data) VALUES (?); + diff --git a/sqlc-gen-ftl/test/testdata/mysql/schema.sql b/sqlc-gen-ftl/test/testdata/mysql/schema.sql new file mode 100644 index 0000000000..d62ff06957 --- /dev/null +++ b/sqlc-gen-ftl/test/testdata/mysql/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE users ( + id SERIAL PRIMARY KEY, + name TEXT NOT NULL, + email TEXT +); + +CREATE TABLE requests +( + data TEXT, + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP +); diff --git a/sqlc-gen-ftl/test/testdata/postgresql/queries.sql b/sqlc-gen-ftl/test/testdata/postgresql/queries.sql new file mode 100644 index 0000000000..fb07f90971 --- /dev/null +++ b/sqlc-gen-ftl/test/testdata/postgresql/queries.sql @@ -0,0 +1,12 @@ +-- name: GetUserByID :one +SELECT id, name, email FROM users WHERE id = $1; + +-- name: CreateUser :exec +INSERT INTO users (name, email) VALUES ($1, $2); + +-- name: GetRequestData :many +SELECT data FROM requests; + +-- name: CreateRequest :exec +INSERT INTO requests (data) VALUES ($1); + diff --git a/sqlc-gen-ftl/test/testdata/postgresql/schema.sql b/sqlc-gen-ftl/test/testdata/postgresql/schema.sql new file mode 100644 index 0000000000..d62ff06957 --- /dev/null +++ b/sqlc-gen-ftl/test/testdata/postgresql/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE users ( + id SERIAL PRIMARY KEY, + name TEXT NOT NULL, + email TEXT +); + +CREATE TABLE requests +( + data TEXT, + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP +);