diff --git a/Cargo.lock b/Cargo.lock index 1aa7263e..cdd0418c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1256,7 +1256,7 @@ dependencies = [ "env_logger", "tokio", "tracing-subscriber", - "trailbase-core", + "trailbase", ] [[package]] @@ -6159,29 +6159,8 @@ dependencies = [ ] [[package]] -name = "trailbase-cli" -version = "0.2.0" -dependencies = [ - "axum", - "chrono", - "clap", - "env_logger", - "log", - "mimalloc", - "serde", - "serde_json", - "tokio", - "tracing-subscriber", - "trailbase-core", - "trailbase-sqlite", - "utoipa", - "utoipa-swagger-ui", - "uuid", -] - -[[package]] -name = "trailbase-core" -version = "0.1.0" +name = "trailbase" +version = "0.0.1" dependencies = [ "anyhow", "arc-swap", @@ -6253,6 +6232,27 @@ dependencies = [ "validator", ] +[[package]] +name = "trailbase-cli" +version = "0.2.0" +dependencies = [ + "axum", + "chrono", + "clap", + "env_logger", + "log", + "mimalloc", + "serde", + "serde_json", + "tokio", + "tracing-subscriber", + "trailbase", + "trailbase-sqlite", + "utoipa", + "utoipa-swagger-ui", + "uuid", +] + [[package]] name = "trailbase-extension" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 4e56e423..a4c6b0af 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,8 +36,9 @@ codegen-units = 1 opt-level = 1 [workspace.dependencies] -refinery = { package = "refinery", path = "vendor/refinery/refinery", default-features = false, features = ["rusqlite"] } +refinery = { package = "refinery", path = "vendor/refinery/refinery", default-features = false, features = ["rusqlite-bundled"] } refinery-core = { package = "refinery-core", path = "vendor/refinery/refinery_core" } +libsqlite3-sys = { version = "0.30.1", features = ["bundled"] } rusqlite = { version = "^0.32.1", default-features = false, features = [ "bundled", "column_decltype", @@ -51,3 +52,4 @@ rusqlite = { version = "^0.32.1", default-features = false, features = [ trailbase-sqlean = { path = "vendor/sqlean", version = "^0.0.1" } trailbase-extension = { path = "trailbase-extension", version = "^0.1.0" } trailbase-sqlite = { path = "trailbase-sqlite", version = "^0.1.0" } +trailbase = { path = "trailbase-core", version = "^0.0.1" } diff --git a/examples/custom-binary/Cargo.toml b/examples/custom-binary/Cargo.toml index 2030a5e4..ee368f5b 100644 --- a/examples/custom-binary/Cargo.toml +++ b/examples/custom-binary/Cargo.toml @@ -8,4 +8,4 @@ axum = { version = "^0.7.5" } env_logger = "^0.11.3" tokio = { version = "^1.38.0", features=["macros", "rt-multi-thread"] } tracing-subscriber = "0.3.18" -trailbase-core = { path = "../../trailbase-core" } +trailbase = { workspace = true } diff --git a/examples/custom-binary/src/main.rs b/examples/custom-binary/src/main.rs index 71e28aaf..568dca6a 100644 --- a/examples/custom-binary/src/main.rs +++ b/examples/custom-binary/src/main.rs @@ -4,7 +4,7 @@ use axum::{ routing::{get, Router}, }; use tracing_subscriber::{filter, prelude::*}; -use trailbase_core::{AppState, DataDir, Server, ServerOptions, User}; +use trailbase::{AppState, DataDir, Server, ServerOptions, User}; type BoxError = Box; @@ -44,8 +44,7 @@ async fn main() -> Result<(), BoxError> { // This declares **where** tracing is being logged to, e.g. stderr, file, sqlite. let _layer = tracing_subscriber::registry() .with( - trailbase_core::logging::SqliteLogLayer::new(app.state()) - .with_filter(filter::LevelFilter::INFO), + trailbase::logging::SqliteLogLayer::new(app.state()).with_filter(filter::LevelFilter::INFO), ) .with( tracing_subscriber::fmt::layer().compact().with_filter( diff --git a/trailbase-cli/Cargo.toml b/trailbase-cli/Cargo.toml index d013c5f2..b1d6c9f0 100644 --- a/trailbase-cli/Cargo.toml +++ b/trailbase-cli/Cargo.toml @@ -15,7 +15,7 @@ axum = { version = "^0.7.5", features=["multipart"] } chrono = "^0.4.38" clap = { version = "^4.4.11", features=["derive", "env"] } env_logger = "^0.11.3" -trailbase-core = { path = "../trailbase-core" } +trailbase = { workspace = true } trailbase-sqlite = { path = "../trailbase-sqlite" } log = "^0.4.21" mimalloc = { version = "^0.1.41", default-features = false } diff --git a/trailbase-cli/src/args.rs b/trailbase-cli/src/args.rs index 986b7ec4..ea492ba7 100644 --- a/trailbase-cli/src/args.rs +++ b/trailbase-cli/src/args.rs @@ -1,7 +1,7 @@ use clap::{Args, Parser, Subcommand, ValueEnum}; -use trailbase_core::api::JsonSchemaMode; -use trailbase_core::DataDir; +use trailbase::api::JsonSchemaMode; +use trailbase::DataDir; #[derive(ValueEnum, Clone, Copy, Debug)] pub enum JsonSchemaModeArg { diff --git a/trailbase-cli/src/bin/trail.rs b/trailbase-cli/src/bin/trail.rs index ac10feba..5ba3c2b1 100644 --- a/trailbase-cli/src/bin/trail.rs +++ b/trailbase-cli/src/bin/trail.rs @@ -10,7 +10,7 @@ use serde::Deserialize; use std::rc::Rc; use tokio::{fs, io::AsyncWriteExt}; use tracing_subscriber::{filter, prelude::*}; -use trailbase_core::{ +use trailbase::{ api::{self, init_app_state, Email, InitArgs, TokenClaims}, constants::USER_TABLE, DataDir, Server, ServerOptions, @@ -32,7 +32,7 @@ fn init_logger(dev: bool) { const DEFAULT: &str = "info,refinery_core=warn,tracing::span=warn"; env_logger::init_from_env(if dev { - env_logger::Env::new().default_filter_or(format!("{DEFAULT},trailbase_core=debug")) + env_logger::Env::new().default_filter_or(format!("{DEFAULT},trailbase=debug")) } else { env_logger::Env::new().default_filter_or(DEFAULT) }); @@ -98,8 +98,7 @@ async fn async_main() -> Result<(), BoxError> { // FIXME: Without the sqlite logger here, logging is broken despite us trying to initialize // in app.server() as well. let layer = tracing_subscriber::registry().with( - trailbase_core::logging::SqliteLogLayer::new(app.state()) - .with_filter(filter::LevelFilter::INFO), + trailbase::logging::SqliteLogLayer::new(app.state()).with_filter(filter::LevelFilter::INFO), ); if stderr_logging { @@ -131,7 +130,7 @@ async fn async_main() -> Result<(), BoxError> { let run_server = |port: u16| async move { let router = axum::Router::new().merge( - SwaggerUi::new("/docs").url("/api/openapi.json", trailbase_core::openapi::Doc::openapi()), + SwaggerUi::new("/docs").url("/api/openapi.json", trailbase::openapi::Doc::openapi()), ); let addr = format!("localhost:{port}"); @@ -143,7 +142,7 @@ async fn async_main() -> Result<(), BoxError> { match cmd { Some(OpenApiSubCommands::Print) => { - let json = trailbase_core::openapi::Doc::openapi().to_pretty_json()?; + let json = trailbase::openapi::Doc::openapi().to_pretty_json()?; println!("{json}"); } Some(OpenApiSubCommands::Run { port }) => { @@ -165,7 +164,7 @@ async fn async_main() -> Result<(), BoxError> { let table_name = &cmd.table; if let Some(table) = table_metadata.get(table_name) { - let (_validator, schema) = trailbase_core::api::build_json_schema( + let (_validator, schema) = trailbase::api::build_json_schema( table.name(), &*table, cmd.mode.unwrap_or(JsonSchemaModeArg::Insert).into(), @@ -173,7 +172,7 @@ async fn async_main() -> Result<(), BoxError> { println!("{}", serde_json::to_string_pretty(&schema)?); } else if let Some(view) = table_metadata.get_view(table_name) { - let (_validator, schema) = trailbase_core::api::build_json_schema( + let (_validator, schema) = trailbase::api::build_json_schema( view.name(), &*view, cmd.mode.unwrap_or(JsonSchemaModeArg::Insert).into(), diff --git a/trailbase-core/Cargo.toml b/trailbase-core/Cargo.toml index a065ea9f..1f11afac 100644 --- a/trailbase-core/Cargo.toml +++ b/trailbase-core/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "trailbase-core" -version = "0.1.0" +name = "trailbase" +version = "0.0.1" edition = "2021" license = "OSL-3.0" diff --git a/trailbase-core/tests/admin_permissions_test.rs b/trailbase-core/tests/admin_permissions_test.rs index 35a9ef85..2900186d 100644 --- a/trailbase-core/tests/admin_permissions_test.rs +++ b/trailbase-core/tests/admin_permissions_test.rs @@ -2,7 +2,7 @@ use axum::http::StatusCode; use axum_test::TestServer; use std::rc::Rc; -use trailbase_core::{DataDir, Server, ServerOptions}; +use trailbase::{DataDir, Server, ServerOptions}; #[test] fn test_admin_permissions() { diff --git a/trailbase-core/tests/integration_test.rs b/trailbase-core/tests/integration_test.rs index 6457f351..c7c34758 100644 --- a/trailbase-core/tests/integration_test.rs +++ b/trailbase-core/tests/integration_test.rs @@ -7,13 +7,13 @@ use std::rc::Rc; use tracing_subscriber::prelude::*; use trailbase_sqlite::params; -use trailbase_core::api::{create_user_handler, login_with_password, CreateUserRequest}; -use trailbase_core::config::proto::PermissionFlag; -use trailbase_core::constants::{COOKIE_AUTH_TOKEN, RECORD_API_PATH}; -use trailbase_core::records::*; -use trailbase_core::util::id_to_b64; -use trailbase_core::AppState; -use trailbase_core::{DataDir, Server, ServerOptions}; +use trailbase::api::{create_user_handler, login_with_password, CreateUserRequest}; +use trailbase::config::proto::PermissionFlag; +use trailbase::constants::{COOKIE_AUTH_TOKEN, RECORD_API_PATH}; +use trailbase::records::*; +use trailbase::util::id_to_b64; +use trailbase::AppState; +use trailbase::{DataDir, Server, ServerOptions}; #[test] fn integration_tests() { @@ -86,7 +86,7 @@ async fn test_record_apis() { // Set up logging: declares **where** tracing is being logged to, e.g. stderr, file, sqlite. tracing_subscriber::registry() - .with(trailbase_core::logging::SqliteLogLayer::new(app.state())) + .with(trailbase::logging::SqliteLogLayer::new(app.state())) .try_init() .unwrap();