diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..0dbe104 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,91 @@ +# Edgee Contributor Guidelines + +Welcome! This project is created by the team at [Edgee](https://www.edgee.cloud). +We're glad you're interested in contributing! We welcome contributions from people of all backgrounds +who are interested in making great software with us. + +At Edgee, we aspire to empower everyone to create interactive experiences. To do this, +we're exploring and pushing the boundaries of new technologies, and sharing our learnings with the open source community. + +If you have ideas for collaboration, email us at opensource@edgee.cloud or join our [Discord](https://www.edgee.cloud/discord)! + +We're also hiring full-time engineers to work with us everywhere! Check out our current job postings [here](https://github.com/edgee-cloud/careers/issues). + +## Issues + +### Feature Requests + +If you have ideas or how to improve our projects, you can suggest features by opening a GitHub issue. +Make sure to include details about the feature or change, and describe any uses cases it would enable. + +Feature requests will be tagged as `enhancement` and their status will be updated in the comments of the issue. + +### Bugs + +When reporting a bug or unexpected behavior in a project, make sure your issue describes steps +to reproduce the behavior, including the platform you were using, what steps you took, and any error messages. + +Reproducible bugs will be tagged as `bug` and their status will be updated in the comments of the issue. + +### Wontfix + +Issues will be closed and tagged as `wontfix` if we decide that we do not wish to implement it, +usually due to being misaligned with the project vision or out of scope. We will comment on the issue with more detailed reasoning. + +## Contribution Workflow + +### Open Issues + +If you're ready to contribute, start by looking at our open issues tagged as [`help wanted`](../../issues?q=is%3Aopen+is%3Aissue+label%3A"help+wanted") or [`good first issue`](../../issues?q=is%3Aopen+is%3Aissue+label%3A"good+first+issue"). + +You can comment on the issue to let others know you're interested in working on it or to ask questions. + +### Making Changes + +1. Fork the repository. + +2. Review the [Development Workflow](#development-workflow) section to understand how to run the project locally. + +3. Create a new feature [branch](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-and-deleting-branches-within-your-repository). + +4. Make your changes on your branch. Ensure that there are no build errors by running the project with your changes locally. + +5. [Submit the branch as a Pull Request](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork) pointing to the `main` branch of the Edgee repository. A maintainer should comment and/or review your Pull Request within a few days. Although depending on the circumstances, it may take longer. + +### Development Workflow + +#### Setup and run Edgee + +```bash +cargo run +``` + +#### Test + +```bash +cargo test +``` + +This command will be triggered to each PR as a requirement for merging it. + + +## Licensing + +Unless otherwise specified, all Edgee open source projects shall comply with the Apache 2.0 licence. Please see the [LICENSE](LICENSE) file for more information. + +## Contributor Terms + +Thank you for your interest in Edgee’ open source project. By providing a contribution (new or modified code, +other input, feedback or suggestions etc.) you agree to these Contributor Terms. + +You confirm that each of your contributions has been created by you and that you are the copyright owner. +You also confirm that you have the right to provide the contribution to us and that you do it under the +Apache 2.0 licence. + +If you want to contribute something that is not your original creation, you may submit it to Edgee separately +from any contribution, including details of its source and of any license or other restriction +(such as related patents, trademarks, agreements etc.) + +Please also note that our projects are released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md) to +ensure that they are welcoming places for everyone to contribute. By participating in any Edgee open source project, +you agree to keep to the Contributor Code of Conduct. diff --git a/Cargo.lock b/Cargo.lock index 38becbe..80b56e2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -175,6 +175,12 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" +[[package]] +name = "adler32" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" + [[package]] name = "aes" version = "0.8.4" @@ -287,27 +293,6 @@ version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" -[[package]] -name = "api-client" -version = "1.0.0" -dependencies = [ - "anyhow", - "bon", - "chrono", - "cookie", - "dirs", - "easy-ext", - "progenitor", - "progenitor-client", - "regress", - "reqwest 0.12.28", - "schemars 1.2.0", - "serde", - "serde_json", - "toml 0.9.10+spec-1.1.0", - "uuid", -] - [[package]] name = "arbitrary" version = "1.4.2" @@ -1043,7 +1028,7 @@ dependencies = [ "encode_unicode", "libc", "once_cell", - "unicode-width", + "unicode-width 0.2.2", "windows-sys 0.59.0", ] @@ -1099,6 +1084,15 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" +[[package]] +name = "core2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b49ba7ef1ad6107f8824dbe97de947cbaac53c44e7f9756a1fba0d37c1eec505" +dependencies = [ + "memchr", +] + [[package]] name = "cpp_demangle" version = "0.4.5" @@ -1399,6 +1393,12 @@ dependencies = [ "syn", ] +[[package]] +name = "dary_heap" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06d2e3287df1c007e74221c49ca10a95d557349e54b3a75dc2fb14712c751f04" + [[package]] name = "debugid" version = "0.8.0" @@ -1634,45 +1634,83 @@ checksum = "cc5d6d6a8504f8caedd7de14576464383900cd3840b7033a7a3dce5ac00121ca" name = "edgee-cli" version = "1.0.0" dependencies = [ + "addr", + "aes", "anyhow", - "api-client", + "base64 0.22.1", "bon", + "brotli", + "bytes", + "cargo-llvm-cov", + "cbc", "chrono", "clap", "clap_complete", "colored", "colored_json", + "cookie", "dirs", + "easy-ext", "edgee-components-runtime", + "edgee-dc-sdk", + "futures", + "hex", + "html-escape", "http 1.4.0", "http-body-util", "hyper 1.8.1", + "hyper-rustls 0.27.7", "hyper-util", "indexmap 2.12.1", "inquire", + "ipnetwork", + "json_comments", + "json_pretty", + "lazy_static", + "libflate", + "log", + "lol_html", + "miette", "notify", "open", "openssl", "os_info", - "proxy", + "pin-project", + "pretty_assertions", + "progenitor", + "progenitor-client", + "rand 0.9.2", + "regex", + "regress", "reqwest 0.12.28", + "rustls 0.23.35", + "rustls-pemfile 2.2.0", + "rustls-pki-types", + "schemars 1.2.0", "self_update", "sentry", "sentry-anyhow", "serde", "serde_json", + "serde_with", "serde_yaml_ng", "serial_test", "sha2", "slug", "tempfile", "tokio", + "tokio-rustls 0.26.4", "toml 0.9.10+spec-1.1.0", + "tower", + "tower-http", "tracing", "tracing-subscriber", "unicase", "url", "uuid", + "wasmtime", + "wasmtime-wasi", + "wasmtime-wasi-http", "wit-deps", "zip", ] @@ -2605,7 +2643,7 @@ dependencies = [ "console", "number_prefix", "portable-atomic", - "unicode-width", + "unicode-width 0.2.2", "web-time", ] @@ -2651,7 +2689,7 @@ dependencies = [ "fuzzy-matcher", "tempfile", "unicode-segmentation", - "unicode-width", + "unicode-width 0.2.2", ] [[package]] @@ -2867,6 +2905,30 @@ version = "0.2.178" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091" +[[package]] +name = "libflate" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3248b8d211bd23a104a42d81b4fa8bb8ac4a3b75e7a43d85d2c9ccb6179cd74" +dependencies = [ + "adler32", + "core2", + "crc32fast", + "dary_heap", + "libflate_lz77", +] + +[[package]] +name = "libflate_lz77" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a599cb10a9cd92b1300debcef28da8f70b935ec937f44fcd1b70a7c986a11c5c" +dependencies = [ + "core2", + "hashbrown 0.16.1", + "rle-decode-fast", +] + [[package]] name = "libm" version = "0.2.15" @@ -3020,6 +3082,28 @@ dependencies = [ "rustix 1.1.3", ] +[[package]] +name = "miette" +version = "7.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f98efec8807c63c752b5bd61f862c165c115b0a35685bdcfd9238c7aeb592b7" +dependencies = [ + "cfg-if", + "miette-derive", + "unicode-width 0.1.14", +] + +[[package]] +name = "miette-derive" +version = "7.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db5b29714e950dbb20d5e6f74f9dcec4edbcc1067bb7f8ed198c097b8c1a818b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "mime" version = "0.3.17" @@ -3778,52 +3862,6 @@ dependencies = [ "syn", ] -[[package]] -name = "proxy" -version = "1.0.0" -dependencies = [ - "addr", - "aes", - "anyhow", - "base64 0.22.1", - "bytes", - "cargo-llvm-cov", - "cbc", - "chrono", - "cookie", - "edgee-components-runtime", - "edgee-dc-sdk", - "futures", - "hex", - "html-escape", - "http 1.4.0", - "http-body-util", - "hyper 1.8.1", - "hyper-rustls 0.27.7", - "hyper-util", - "ipnetwork", - "json_comments", - "lazy_static", - "lol_html", - "pin-project", - "pretty_assertions", - "regex", - "reqwest 0.12.28", - "rustls 0.23.35", - "rustls-pemfile 2.2.0", - "rustls-pki-types", - "serde", - "serde_json", - "serde_with", - "tokio", - "tokio-rustls 0.26.4", - "tower", - "tower-http", - "tracing", - "url", - "uuid", -] - [[package]] name = "psl" version = "2.1.175" @@ -4253,6 +4291,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "rle-decode-fast" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3582f63211428f83597b51b2ddb88e2a91a9d52d12831f9d08f5e624e8977422" + [[package]] name = "rustc-demangle" version = "0.1.26" @@ -5787,6 +5831,12 @@ version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" +[[package]] +name = "unicode-width" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" + [[package]] name = "unicode-width" version = "0.2.2" @@ -6434,7 +6484,7 @@ dependencies = [ "bumpalo", "leb128fmt", "memchr", - "unicode-width", + "unicode-width 0.2.2", "wasm-encoder 0.243.0", ] diff --git a/Cargo.toml b/Cargo.toml index 8ef0ff6..45dfe56 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,9 +1,7 @@ -[workspace] -members = ["crates/*"] -resolver = "2" - -[workspace.package] +[package] +name = "edgee-cli" version = "1.0.0" +description = "Edgee CLI to play with AI Gateway, tools, components..." authors = ["Edgee "] license = "Apache-2.0" keywords = ["edgee"] @@ -12,7 +10,7 @@ homepage = "https://www.edgee.cloud" readme = true edition = "2021" -[workspace.dependencies] +[dependencies] addr = "0.15.6" aes = "0.8.4" anyhow = "1.0.98" @@ -20,14 +18,13 @@ base64 = "0.22.1" bon = "3.6.5" brotli = "8.0.1" bytes = "1.10.1" -cargo-llvm-cov = "0.6.18" -cbc = "0.1.2" -chrono = "0.4.41" -clap = "4.5.41" +cbc = { version = "0.1.2", features = ["std"] } +chrono = { version = "0.4.41", features = ["serde"] } +clap = { version = "4.5.41", features = ["derive", "env"] } clap_complete = "4.5.55" colored = "3.0.0" colored_json = "5.0.0" -cookie = "0.18.1" +cookie = { version = "0.18.1", features = ["percent-encode"] } dirs = "6.0.0" easy-ext = "1.0.2" edgee-dc-sdk = "1.9.0" @@ -37,11 +34,11 @@ hex = "0.4.3" html-escape = "0.2.13" http = "1.3.1" http-body-util = "0.1" -hyper = "1.6.0" -hyper-rustls = "0.27.7" -hyper-util = "0.1.15" +hyper = { version = "1.6.0", features = ["server"] } +hyper-rustls = { version = "0.27.7", features = ["ring", "http2"] } +hyper-util = { version = "0.1.15", features = ["server", "service", "tokio", "http1", "http2"] } indexmap = "2.10.0" -inquire = "0.9.1" +inquire = { version = "0.9.1", features = ["editor"] } ipnetwork = "0.21.1" json_comments = "0.2.2" json_pretty = "0.1.2" @@ -55,21 +52,20 @@ open = "5.3.2" openssl = "0.10.73" os_info = "3.12.0" pin-project = "1.1.10" -pretty_assertions = "1.4.1" progenitor = "0.11.0" progenitor-client = "0.11.0" rand = "0.9.2" regex = "1.11.1" regress = "0.10.4" -reqwest = "0.12.22" -rustls = "0.23.29" +reqwest = { version = "0.12.22", features = ["blocking", "json"] } +rustls = { version = "0.23.29", features = ["ring"] } rustls-pemfile = "2.2.0" rustls-pki-types = "1.12.0" -schemars = "1.0.4" +schemars = { version = "1.0.4", features = ["chrono04", "uuid1"] } self_update = "0.42.0" -sentry = "0.43.0" +sentry = { version = "0.43.0", features = ["anyhow"] } sentry-anyhow = "0.43.0" -serde = "1.0.219" +serde = { version = "1.0.219", features = ["derive"] } serde_json = "1.0.141" serde_with = "3.14.0" serde_yaml_ng = "0.10.0" @@ -77,21 +73,30 @@ serial_test = "3.2.0" sha2 = "0.10.9" slug = "0.1.6" tempfile = "3.20.0" -tokio = "1.46.1" +tokio = { version = "1.46.1", features = ["macros", "rt-multi-thread", "rt", "net"] } tokio-rustls = "0.26.2" -toml = "0.9.2" -tower = "0.5.2" -tower-http = "0.6.6" +toml = { version = "0.9.2", features = ["preserve_order"] } +tower = { version = "0.5.2", features = ["util"] } +tower-http = { version = "0.6.6", features = ["compression-full", "decompression-full"] } tracing = "0.1.41" -tracing-subscriber = "0.3.19" +tracing-subscriber = { version = "0.3.19", features = ["env-filter", "json"] } unicase = "2.8.1" -url = "2.5.4" -uuid = { version = "1.17.0", features = ["serde"] } +url = { version = "2.5.4", features = ["serde"] } +uuid = { version = "1.17.0", features = ["serde", "v4"] } wasmtime = "37.0" wasmtime-wasi = "37.0" wasmtime-wasi-http = "37.0" wit-deps = "0.5.0" zip = "5.1.1" -proxy = { path = "crates/proxy" } -api-client = { path = "crates/api-client" } \ No newline at end of file +[dev-dependencies] +cargo-llvm-cov = "0.6.18" +pretty_assertions = "1.4.1" + +[features] +bundled = ["openssl/vendored"] +no-self-update = [] + +[package.metadata.binstall] +pkg-fmt = "bin" +pkg-url = "{ repo }/releases/download/v{ version }/{ name }.{ target }{ archive-suffix }" \ No newline at end of file diff --git a/crates/api-client/Cargo.toml b/crates/api-client/Cargo.toml deleted file mode 100644 index 2e431c7..0000000 --- a/crates/api-client/Cargo.toml +++ /dev/null @@ -1,29 +0,0 @@ -[package] -name = "api-client" -publish = false -description = "Edgee API client" -version.workspace = true -authors.workspace = true -license.workspace = true -keywords.workspace = true -repository.workspace = true -homepage.workspace = true -readme.workspace = true -edition.workspace = true - -[dependencies] -anyhow.workspace = true -bon.workspace = true -chrono = { workspace = true, features = ["serde"] } -cookie = { workspace = true, features = ["percent-encode"] } -dirs.workspace = true -easy-ext.workspace = true -progenitor.workspace = true -progenitor-client.workspace = true -regress.workspace = true -reqwest = { workspace = true, features = ["json"] } -schemars = { workspace = true, features = ["chrono04", "uuid1"] } -serde = { workspace = true, features = ["derive"] } -serde_json.workspace = true -toml.workspace = true -uuid.workspace = true diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml deleted file mode 100644 index 1512a97..0000000 --- a/crates/cli/Cargo.toml +++ /dev/null @@ -1,67 +0,0 @@ -[package] -name = "edgee-cli" -description = "Edgee CLI to play with AI Gateway, tools, components..." -version.workspace = true -authors.workspace = true -license.workspace = true -keywords.workspace = true -repository.workspace = true -homepage.workspace = true -readme.workspace = true -edition.workspace = true - -[dependencies] -anyhow.workspace = true -bon.workspace = true -chrono.workspace = true -clap = { workspace = true, features = ["derive", "env"] } -clap_complete.workspace = true -colored.workspace = true -colored_json.workspace = true -dirs.workspace = true -edgee-components-runtime.workspace = true -http.workspace = true -http-body-util.workspace = true -hyper = { workspace = true, features = ["server"] } -hyper-util = { workspace = true, features = ["server", "service", "tokio", "http1", "http2"] } -indexmap.workspace = true -inquire = { workspace = true, features = ["editor"] } -notify.workspace = true -open.workspace = true -openssl.workspace = true -os_info.workspace = true -reqwest = { workspace = true, features = ["blocking"] } -self_update.workspace = true -sentry = { workspace = true, features = ["anyhow"] } -sentry-anyhow.workspace = true -serde = { workspace = true, features = ["derive"] } -serde_json.workspace = true -serde_yaml_ng.workspace = true -serial_test.workspace = true -sha2.workspace = true -slug.workspace = true -tempfile.workspace = true -tracing.workspace = true -tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } -toml = { workspace = true, features = ["preserve_order"] } -tracing-subscriber = { workspace = true, features = ["env-filter", "json"] } -unicase.workspace = true -url = { workspace = true, features = ["serde"] } -uuid = { workspace = true, features = ["v4"] } -wit-deps.workspace = true -zip.workspace = true - -api-client = { path = "../api-client" } -proxy = { path = "../proxy" } - -[[bin]] -name = "edgee" -path = "src/main.rs" - -[features] -bundled = ["openssl/vendored"] -no-self-update = [] - -[package.metadata.binstall] -pkg-fmt = "bin" -pkg-url = "{ repo }/releases/download/v{ version }/{ name }.{ target }{ archive-suffix }" diff --git a/crates/proxy/Cargo.toml b/crates/proxy/Cargo.toml deleted file mode 100644 index d02933f..0000000 --- a/crates/proxy/Cargo.toml +++ /dev/null @@ -1,56 +0,0 @@ -[package] -name = "proxy" -publish = false -description = "Edgee proxy" -version.workspace = true -authors.workspace = true -license.workspace = true -keywords.workspace = true -repository.workspace = true -homepage.workspace = true -readme.workspace = true -edition.workspace = true - -[dependencies] -addr.workspace = true -aes.workspace = true -anyhow.workspace = true -base64.workspace = true -bytes.workspace = true -cbc = { workspace = true, features = ["std"] } -chrono = { workspace = true, features = ["serde"] } -cookie.workspace = true -edgee-dc-sdk.workspace = true -edgee-components-runtime.workspace = true -futures.workspace = true -hex.workspace = true -html-escape.workspace = true -http-body-util.workspace = true -http.workspace = true -hyper = { workspace = true, features = ["server"] } -hyper-rustls = { workspace = true, features = ["ring", "http2"] } -hyper-util = { workspace = true, features = ["server", "service", "tokio", "http1", "http2"] } -ipnetwork.workspace = true -json_comments.workspace = true -lazy_static.workspace = true -lol_html.workspace = true -pin-project.workspace = true -regex.workspace = true -reqwest.workspace = true -rustls = { workspace = true, features = ["ring"] } -rustls-pemfile.workspace = true -rustls-pki-types.workspace = true -serde = { workspace = true, features = ["derive"] } -serde_json.workspace = true -serde_with.workspace = true -tokio = { workspace = true, features = ["rt", "net"] } -tokio-rustls.workspace = true -tower = { workspace = true, features = ["util"] } -tower-http = { workspace = true, features = ["compression-full", "decompression-full"] } -tracing.workspace = true -url.workspace = true -uuid = { workspace = true, features = ["v4", "serde"] } - -[dev-dependencies] -cargo-llvm-cov.workspace = true -pretty_assertions.workspace = true diff --git a/crates/proxy/src/server.rs b/crates/proxy/src/server.rs deleted file mode 100644 index e69de29..0000000 diff --git a/crates/api-client/dc-openapi.json b/openapi/dc-openapi.json similarity index 100% rename from crates/api-client/dc-openapi.json rename to openapi/dc-openapi.json diff --git a/crates/api-client/openapi.json b/openapi/openapi.json similarity index 100% rename from crates/api-client/openapi.json rename to openapi/openapi.json diff --git a/crates/api-client/src/auth.rs b/src/api_client/auth.rs similarity index 97% rename from crates/api-client/src/auth.rs rename to src/api_client/auth.rs index e2be43c..35f8a44 100644 --- a/crates/api-client/src/auth.rs +++ b/src/api_client/auth.rs @@ -4,8 +4,8 @@ use anyhow::{Context, Result}; use serde::{Deserialize, Serialize}; use crate::{ - connect_builder::{IsUnset, SetApiToken, SetBaseurl, State}, - ConnectBuilder, + api_client::connect_builder::{IsUnset, SetApiToken, SetBaseurl, State}, + api_client::ConnectBuilder, }; #[derive(Debug, Deserialize, Default, Serialize, Clone)] diff --git a/crates/api-client/src/data_collection.rs b/src/api_client/data_collection.rs similarity index 95% rename from crates/api-client/src/data_collection.rs rename to src/api_client/data_collection.rs index 47bac8e..adb4ecc 100644 --- a/crates/api-client/src/data_collection.rs +++ b/src/api_client/data_collection.rs @@ -2,10 +2,11 @@ use connect_builder::{ IsUnset, SetBaseurl, SetClientBuilder, SetCookies, SetDefaultHeaders, State, }; +#[allow(dead_code)] const PROD_DOMAIN: &str = "edgee.app"; progenitor::generate_api! { - spec = "dc-openapi.json", + spec = "openapi/dc-openapi.json", interface = Builder, derives = [ schemars::JsonSchema ], } @@ -58,6 +59,7 @@ impl ConnectBuilder { self.client_builder(f(Default::default())) } + #[allow(dead_code)] pub fn with_default_headers( self, f: impl Fn(&mut reqwest::header::HeaderMap), @@ -70,6 +72,7 @@ impl ConnectBuilder { self.default_headers(headers) } + #[allow(dead_code)] pub fn with_cookies(self, f: impl Fn(&mut cookie::CookieJar)) -> ConnectBuilder> where S::Cookies: IsUnset, @@ -79,6 +82,7 @@ impl ConnectBuilder { self.cookies(cookies) } + #[allow(dead_code)] pub fn project_name(self, name: impl Into) -> ConnectBuilder> where S::Baseurl: IsUnset, diff --git a/crates/api-client/src/lib.rs b/src/api_client/mod.rs similarity index 98% rename from crates/api-client/src/lib.rs rename to src/api_client/mod.rs index 4a9dc36..071fe51 100644 --- a/crates/api-client/src/lib.rs +++ b/src/api_client/mod.rs @@ -5,7 +5,7 @@ mod upload; pub const PROD_BASEURL: &str = "https://api.edgee.app"; progenitor::generate_api! { - spec = "openapi.json", + spec = "openapi/openapi.json", interface = Builder, derives = [ schemars::JsonSchema ], } diff --git a/crates/api-client/src/upload.rs b/src/api_client/upload.rs similarity index 100% rename from crates/api-client/src/upload.rs rename to src/api_client/upload.rs diff --git a/crates/cli/src/commands/auth/login.rs b/src/commands/auth/login.rs similarity index 93% rename from crates/cli/src/commands/auth/login.rs rename to src/commands/auth/login.rs index 12bf715..799d68c 100644 --- a/crates/cli/src/commands/auth/login.rs +++ b/src/commands/auth/login.rs @@ -1,6 +1,6 @@ use anyhow::Result; -use api_client::ResultExt; +use crate::api_client::ResultExt; setup_command! { #[arg(short, long, id = "PROFILE", env = "EDGEE_API_PROFILE")] @@ -13,7 +13,7 @@ setup_command! { pub async fn run(opts: Options) -> Result<()> { use inquire::{Confirm, Password, PasswordDisplayMode}; - use api_client::auth::{Config, Credentials}; + use crate::api_client::auth::{Config, Credentials}; let url = match opts.url { Some(url) => url, @@ -57,7 +57,7 @@ pub async fn run(opts: Options) -> Result<()> { url: Some(url), }; - let client = api_client::new().credentials(&creds).connect(); + let client = crate::api_client::new().credentials(&creds).connect(); let user = client .get_me() .send() diff --git a/crates/cli/src/commands/auth/mod.rs b/src/commands/auth/mod.rs similarity index 100% rename from crates/cli/src/commands/auth/mod.rs rename to src/commands/auth/mod.rs diff --git a/crates/cli/src/commands/auth/whoami.rs b/src/commands/auth/whoami.rs similarity index 88% rename from crates/cli/src/commands/auth/whoami.rs rename to src/commands/auth/whoami.rs index 3c5df49..4bc516c 100644 --- a/crates/cli/src/commands/auth/whoami.rs +++ b/src/commands/auth/whoami.rs @@ -1,4 +1,4 @@ -use api_client::ResultExt; +use crate::api_client::ResultExt; setup_command! { #[arg(short, long, id = "PROFILE", env = "EDGEE_API_PROFILE")] @@ -6,7 +6,7 @@ setup_command! { } pub async fn run(opts: Options) -> anyhow::Result<()> { - use api_client::auth::Config; + use crate::api_client::auth::Config; let config = Config::load()?; @@ -26,7 +26,7 @@ pub async fn run(opts: Options) -> anyhow::Result<()> { creds.check_api_token()?; - let client = api_client::new().credentials(&creds).connect(); + let client = crate::api_client::new().credentials(&creds).connect(); let user = client .get_me() .send() diff --git a/crates/cli/src/commands/completion.rs b/src/commands/completion.rs similarity index 100% rename from crates/cli/src/commands/completion.rs rename to src/commands/completion.rs diff --git a/crates/cli/src/commands/components/build.rs b/src/commands/components/build.rs similarity index 100% rename from crates/cli/src/commands/components/build.rs rename to src/commands/components/build.rs diff --git a/crates/cli/src/commands/components/check.rs b/src/commands/components/check.rs similarity index 96% rename from crates/cli/src/commands/components/check.rs rename to src/commands/components/check.rs index 4ffc397..b9fb5d3 100644 --- a/crates/cli/src/commands/components/check.rs +++ b/src/commands/components/check.rs @@ -132,10 +132,10 @@ pub async fn run(_opts: Options) -> anyhow::Result<()> { ( component_path.to_string(), match manifest.component.category { - api_client::types::ComponentCreateInputCategory::DataCollection => { + crate::api_client::types::ComponentCreateInputCategory::DataCollection => { ComponentType::DataCollection } - api_client::types::ComponentCreateInputCategory::EdgeFunction => { + crate::api_client::types::ComponentCreateInputCategory::EdgeFunction => { ComponentType::EdgeFunction } _ => anyhow::bail!( diff --git a/crates/cli/src/commands/components/fetch_wit.rs b/src/commands/components/fetch_wit.rs similarity index 100% rename from crates/cli/src/commands/components/fetch_wit.rs rename to src/commands/components/fetch_wit.rs diff --git a/crates/cli/src/commands/components/init.rs b/src/commands/components/init.rs similarity index 93% rename from crates/cli/src/commands/components/init.rs rename to src/commands/components/init.rs index 7696af6..1fc917f 100644 --- a/crates/cli/src/commands/components/init.rs +++ b/src/commands/components/init.rs @@ -38,10 +38,10 @@ pub async fn run(_opts: Options) -> anyhow::Result<()> { }; let subcategories = match component_category.value { - api_client::types::ComponentCreateInputCategory::DataCollection => { + crate::api_client::types::ComponentCreateInputCategory::DataCollection => { DATA_COLLECTION_SUBCATEGORY_OPTIONS.to_vec() } - api_client::types::ComponentCreateInputCategory::EdgeFunction => { + crate::api_client::types::ComponentCreateInputCategory::EdgeFunction => { EDGE_FUNCTION_SUBCATEGORY_OPTIONS.to_vec() } _ => { @@ -99,14 +99,14 @@ pub async fn run(_opts: Options) -> anyhow::Result<()> { Additional resources: [Resource example](https://your-resource-link.com) "#.to_string()), documentation: Some(Url::parse("https://www.edgee.cloud/docs/introduction")?), - repository: Some(Url::parse("https://www.github.com/edgee-cloud/cli")?), + repository: Some(Url::parse("https://www.github.com/edgee-cloud/edgee")?), settings: indexmap::indexmap! { "example".to_string() => Setting { description: Some("Here is a string".to_string()), options: None, required: true, title: "ExampleConfigField".to_string(), - type_: api_client::types::ConfigurationFieldType::String, + type_: crate::api_client::types::ConfigurationFieldType::String, secret: Some(false), }, }, diff --git a/crates/cli/src/commands/components/list.rs b/src/commands/components/list.rs similarity index 100% rename from crates/cli/src/commands/components/list.rs rename to src/commands/components/list.rs diff --git a/crates/cli/src/commands/components/mod.rs b/src/commands/components/mod.rs similarity index 100% rename from crates/cli/src/commands/components/mod.rs rename to src/commands/components/mod.rs diff --git a/crates/cli/src/commands/components/new.rs b/src/commands/components/new.rs similarity index 100% rename from crates/cli/src/commands/components/new.rs rename to src/commands/components/new.rs diff --git a/crates/cli/src/commands/components/pull.rs b/src/commands/components/pull.rs similarity index 100% rename from crates/cli/src/commands/components/pull.rs rename to src/commands/components/pull.rs diff --git a/crates/cli/src/commands/components/push.rs b/src/commands/components/push.rs similarity index 97% rename from crates/cli/src/commands/components/push.rs rename to src/commands/components/push.rs index b5c0cf4..a8a8c78 100644 --- a/crates/cli/src/commands/components/push.rs +++ b/src/commands/components/push.rs @@ -2,10 +2,10 @@ use std::io::Read; use anyhow::Result; use colored::Colorize; -use api_client::{auth::Config, ErrorExt, ResultExt}; +use crate::api_client::{auth::Config, ErrorExt, ResultExt}; use inquire::{Confirm, Editor, Select}; -use api_client::{types as api_types, Client}; +use crate::api_client::{types as api_types, Client}; use crate::components::manifest::Manifest; @@ -114,7 +114,7 @@ pub async fn run(opts: Options) -> Result<()> { anyhow::bail!("Component name must be at least 3 characters"); } - let client = api_client::new().credentials(&creds).connect(); + let client = crate::api_client::new().credentials(&creds).connect(); let organization = match opts.organization { Some(ref organization) => client @@ -144,9 +144,9 @@ pub async fn run(opts: Options) -> Result<()> { .send() .await { - Err(api_client::Error::ErrorResponse(err)) + Err(crate::api_client::Error::ErrorResponse(err)) if err.error.type_ - == api_client::types::ErrorResponseErrorType::NotFoundError => + == crate::api_client::types::ErrorResponseErrorType::NotFoundError => { tracing::info!( "Component {} does not exist yet!", @@ -350,7 +350,7 @@ async fn update_component( ) -> Result<()> { use inquire::Confirm; - use api_client::ResultExt; + use crate::api_client::ResultExt; let final_icon_url = if let Some(manifest_icon_path) = &manifest.component.icon_path { let manifest_avatar_hash = { @@ -457,7 +457,7 @@ async fn push_version( component_slug: &str, changelog: Option, ) -> Result<()> { - use api_client::ResultExt; + use crate::api_client::ResultExt; tracing::info!("Uploading WASM file..."); let asset_url = client diff --git a/crates/cli/src/commands/components/serialize.rs b/src/commands/components/serialize.rs similarity index 96% rename from crates/cli/src/commands/components/serialize.rs rename to src/commands/components/serialize.rs index 70049af..bf960c1 100644 --- a/crates/cli/src/commands/components/serialize.rs +++ b/src/commands/components/serialize.rs @@ -46,8 +46,8 @@ fn extract_from_manifest() -> anyhow::Result<(String, String, String)> { .context("Output path should be a valid UTF-8 string")?; let component_type = match manifest.component.category { - api_client::types::ComponentCreateInputCategory::DataCollection => "data-collection", - api_client::types::ComponentCreateInputCategory::EdgeFunction => "edge-function", + crate::api_client::types::ComponentCreateInputCategory::DataCollection => "data-collection", + crate::api_client::types::ComponentCreateInputCategory::EdgeFunction => "edge-function", _ => anyhow::bail!( "Invalid component type: {}, expected 'data-collection' or 'edge-function'", manifest.component.category diff --git a/crates/cli/src/commands/components/test/mod.rs b/src/commands/components/test/mod.rs similarity index 96% rename from crates/cli/src/commands/components/test/mod.rs rename to src/commands/components/test/mod.rs index bae6e9b..24a5358 100644 --- a/crates/cli/src/commands/components/test/mod.rs +++ b/src/commands/components/test/mod.rs @@ -72,7 +72,7 @@ pub async fn run(opts: Options) -> anyhow::Result<()> { crate::commands::components::build::do_build(&manifest, root_dir).await?; match manifest.component.category { - api_client::types::ComponentCreateInputCategory::DataCollection => { + crate::api_client::types::ComponentCreateInputCategory::DataCollection => { match manifest.component.wit_version.as_str() { "1.0.0" => { test_data_collection_v1_0_0::test_data_collection_component_1_0_0( @@ -94,7 +94,7 @@ pub async fn run(opts: Options) -> anyhow::Result<()> { } } } - api_client::types::ComponentCreateInputCategory::EdgeFunction => { + crate::api_client::types::ComponentCreateInputCategory::EdgeFunction => { match manifest.component.wit_version.as_str() { "1.0.0" => { test_edge_function_v1_0_0::test_edge_function_component(opts, &manifest) diff --git a/crates/cli/src/commands/components/test/test_data_collection_v1_0_0.rs b/src/commands/components/test/test_data_collection_v1_0_0.rs similarity index 100% rename from crates/cli/src/commands/components/test/test_data_collection_v1_0_0.rs rename to src/commands/components/test/test_data_collection_v1_0_0.rs diff --git a/crates/cli/src/commands/components/test/test_data_collection_v1_0_1.rs b/src/commands/components/test/test_data_collection_v1_0_1.rs similarity index 100% rename from crates/cli/src/commands/components/test/test_data_collection_v1_0_1.rs rename to src/commands/components/test/test_data_collection_v1_0_1.rs diff --git a/crates/cli/src/commands/components/test/test_edge_function_v1_0_0.rs b/src/commands/components/test/test_edge_function_v1_0_0.rs similarity index 100% rename from crates/cli/src/commands/components/test/test_edge_function_v1_0_0.rs rename to src/commands/components/test/test_edge_function_v1_0_0.rs diff --git a/crates/cli/src/commands/macros.rs b/src/commands/macros.rs similarity index 100% rename from crates/cli/src/commands/macros.rs rename to src/commands/macros.rs diff --git a/crates/cli/src/commands/mod.rs b/src/commands/mod.rs similarity index 82% rename from crates/cli/src/commands/mod.rs rename to src/commands/mod.rs index 1ea21ab..7b379b7 100644 --- a/crates/cli/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -7,9 +7,8 @@ setup_commands! { /// Components management commands #[command(subcommand, visible_alias = "component")] Components(components), - /// Run the Edgee server - #[command(visible_alias = "server")] - Serve(serve), + /// Run the Edgee proxy + Proxy(proxy), [cfg(not(feature = "no-self-update"))] /// Update the Edgee executable SelfUpdate(update), diff --git a/crates/cli/src/commands/proxy.rs b/src/commands/proxy.rs similarity index 87% rename from crates/cli/src/commands/proxy.rs rename to src/commands/proxy.rs index bf1a755..de08c97 100644 --- a/crates/cli/src/commands/proxy.rs +++ b/src/commands/proxy.rs @@ -27,10 +27,10 @@ pub async fn run(opts: Options) -> anyhow::Result<()> { logger::init(opts.log_format, log_filter); - proxy::init()?; + crate::proxy::init()?; tokio::select! { - Err(err) = proxy::monitor::start() => Err(err), - Err(err) = proxy::start() => Err(err), + Err(err) = crate::proxy::monitor::start() => Err(err), + Err(err) = crate::proxy::start() => Err(err), } } diff --git a/crates/cli/src/commands/serve.rs b/src/commands/serve.rs similarity index 87% rename from crates/cli/src/commands/serve.rs rename to src/commands/serve.rs index bf1a755..f93e9a1 100644 --- a/crates/cli/src/commands/serve.rs +++ b/src/commands/serve.rs @@ -27,10 +27,10 @@ pub async fn run(opts: Options) -> anyhow::Result<()> { logger::init(opts.log_format, log_filter); - proxy::init()?; + edgee_proxy::init()?; tokio::select! { - Err(err) = proxy::monitor::start() => Err(err), - Err(err) = proxy::start() => Err(err), + Err(err) = edgee_proxy::monitor::start() => Err(err), + Err(err) = edgee_proxy::start() => Err(err), } } diff --git a/crates/cli/src/commands/update.rs b/src/commands/update.rs similarity index 100% rename from crates/cli/src/commands/update.rs rename to src/commands/update.rs diff --git a/crates/cli/src/components/boilerplate.rs b/src/components/boilerplate.rs similarity index 99% rename from crates/cli/src/components/boilerplate.rs rename to src/components/boilerplate.rs index 987d09c..7d2cfd6 100644 --- a/crates/cli/src/components/boilerplate.rs +++ b/src/components/boilerplate.rs @@ -1,6 +1,6 @@ use std::fmt; -use api_client::types as api_types; +use crate::api_client::types as api_types; #[derive(Clone)] pub struct LanguageConfig { diff --git a/crates/cli/src/components/manifest.rs b/src/components/manifest.rs similarity index 99% rename from crates/cli/src/components/manifest.rs rename to src/components/manifest.rs index fb1ad17..d03d1e4 100644 --- a/crates/cli/src/components/manifest.rs +++ b/src/components/manifest.rs @@ -4,7 +4,7 @@ use anyhow::{Context, Result}; use indexmap::IndexMap; use serde::{Deserialize, Serialize}; -use api_client::types as api_types; +use crate::api_client::types as api_types; #[derive(Debug, Deserialize, Serialize)] #[serde(rename_all = "kebab-case")] diff --git a/crates/cli/src/components/mod.rs b/src/components/mod.rs similarity index 100% rename from crates/cli/src/components/mod.rs rename to src/components/mod.rs diff --git a/crates/cli/src/components/wit.rs b/src/components/wit.rs similarity index 100% rename from crates/cli/src/components/wit.rs rename to src/components/wit.rs diff --git a/crates/cli/src/config.rs b/src/config.rs similarity index 98% rename from crates/cli/src/config.rs rename to src/config.rs index b413635..ee49b9a 100644 --- a/crates/cli/src/config.rs +++ b/src/config.rs @@ -1,6 +1,6 @@ use std::path::Path; -use proxy::config::StaticConfiguration; +use crate::proxy::config::StaticConfiguration; fn read_config(path: Option<&Path>) -> Result { let toml_path = Path::new("edgee.toml"); @@ -55,7 +55,7 @@ pub fn init(config_path: Option<&Path>, trace_component: Option<&str>) { config.log.trace_component = Some(component.to_string()); } - proxy::config::set(config); + crate::proxy::config::set(config); } #[cfg(test)] mod tests { @@ -243,7 +243,7 @@ mod tests { let toml_path = create_temp_file(&dir, "edgee.toml", toml_content); init(Some(&toml_path), Some("component")); - let config = proxy::config::get(); + let config = crate::proxy::config::get(); assert_eq!(config.log.level.to_string(), "info"); assert_eq!(config.log.trace_component, Some("component".to_string())); } diff --git a/crates/cli/src/logger.rs b/src/logger.rs similarity index 98% rename from crates/cli/src/logger.rs rename to src/logger.rs index 4d5b1fb..824c089 100644 --- a/crates/cli/src/logger.rs +++ b/src/logger.rs @@ -26,7 +26,7 @@ pub fn init(log_format: LogFormat, log_filter: Option) { use tracing_subscriber::prelude::*; use tracing_subscriber::{fmt, EnvFilter}; - let config = &proxy::config::get().log; + let config = &crate::proxy::config::get().log; let with_target = log_filter.is_none(); let fmt_layer = fmt::layer().with_target(with_target); diff --git a/crates/cli/src/main.rs b/src/main.rs similarity index 97% rename from crates/cli/src/main.rs rename to src/main.rs index 340f354..d12e199 100644 --- a/crates/cli/src/main.rs +++ b/src/main.rs @@ -1,9 +1,11 @@ use clap::Parser; +mod api_client; mod commands; mod components; mod config; mod logger; +mod proxy; mod telemetry; use std::process::ExitCode; diff --git a/crates/proxy/src/config.rs b/src/proxy/config.rs similarity index 100% rename from crates/proxy/src/config.rs rename to src/proxy/config.rs diff --git a/crates/proxy/src/lib.rs b/src/proxy/mod.rs similarity index 96% rename from crates/proxy/src/lib.rs rename to src/proxy/mod.rs index 244ffdf..d15cc25 100644 --- a/crates/proxy/src/lib.rs +++ b/src/proxy/mod.rs @@ -18,8 +18,8 @@ use tracing::{error, info}; pub mod config; pub mod monitor; -mod proxy; -mod tools; +pub mod server; +pub mod tools; type Body = CompressionBody>; static COMPONENTS_CONTEXT: OnceCell = OnceCell::const_new(); @@ -172,7 +172,7 @@ async fn https() -> anyhow::Result<()> { fn make_service( remote_addr: SocketAddr, proto: &str, -) -> BoxCloneService, anyhow::Error> { +) -> BoxCloneService, anyhow::Error> { use tower::{ServiceBuilder, ServiceExt}; use tower_http::compression::CompressionLayer; @@ -181,7 +181,7 @@ fn make_service( .layer(CompressionLayer::new()) .service_fn(move |req| { let proto = proto.clone(); - async move { proxy::handle_request(req, remote_addr, &proto).await } + async move { server::handle_request(req, remote_addr, &proto).await } }) .boxed_clone() } @@ -189,7 +189,7 @@ fn make_service( #[cfg(test)] mod tests { use super::*; - use crate::config::init_test_config; + use config::init_test_config; use pretty_assertions::assert_eq; #[test] diff --git a/crates/proxy/src/monitor.rs b/src/proxy/monitor.rs similarity index 98% rename from crates/proxy/src/monitor.rs rename to src/proxy/monitor.rs index af7684b..9669eac 100644 --- a/crates/proxy/src/monitor.rs +++ b/src/proxy/monitor.rs @@ -1,4 +1,4 @@ -use crate::config; +use crate::proxy::config; use bytes::Bytes; use http::{Request, Response, StatusCode}; use http_body_util::{combinators::BoxBody, BodyExt, Empty}; diff --git a/crates/proxy/public/502.html b/src/proxy/public/502.html similarity index 100% rename from crates/proxy/public/502.html rename to src/proxy/public/502.html diff --git a/crates/proxy/src/proxy/compute/data_collection/mod.rs b/src/proxy/server/compute/data_collection/mod.rs similarity index 99% rename from crates/proxy/src/proxy/compute/data_collection/mod.rs rename to src/proxy/server/compute/data_collection/mod.rs index c63ae9a..e2b5549 100644 --- a/crates/proxy/src/proxy/compute/data_collection/mod.rs +++ b/src/proxy/server/compute/data_collection/mod.rs @@ -16,10 +16,10 @@ use payload::{Consent, EventData, EventType, Payload}; use regex::Regex; use tracing::{error, info, warn, Instrument}; -use crate::proxy::compute::html::Document; -use crate::proxy::context::incoming::RequestHandle; -use crate::tools::edgee_cookie; -use crate::{config, get_components_ctx}; +use crate::proxy::server::compute::html::Document; +use crate::proxy::server::context::incoming::RequestHandle; +use crate::proxy::tools::edgee_cookie; +use crate::proxy::{config, get_components_ctx}; pub mod payload; diff --git a/crates/proxy/src/proxy/compute/data_collection/payload.rs b/src/proxy/server/compute/data_collection/payload.rs similarity index 100% rename from crates/proxy/src/proxy/compute/data_collection/payload.rs rename to src/proxy/server/compute/data_collection/payload.rs diff --git a/crates/proxy/src/proxy/compute/html.rs b/src/proxy/server/compute/html.rs similarity index 98% rename from crates/proxy/src/proxy/compute/html.rs rename to src/proxy/server/compute/html.rs index 9c06f26..5d2841d 100644 --- a/crates/proxy/src/proxy/compute/html.rs +++ b/src/proxy/server/compute/html.rs @@ -1,4 +1,4 @@ -use crate::{config, tools}; +use crate::proxy::{config, tools}; #[derive(Debug, Default)] pub struct Document { @@ -440,7 +440,7 @@ mod tests { #[test] fn parse_html_without_data_layer() { - crate::config::init_test_config(); + crate::proxy::config::init_test_config(); let document = parse_html(&sample_html_without_data_layer(), "test.com"); assert_eq!(document.title, "ABC"); // add check @@ -455,7 +455,7 @@ mod tests { #[test] fn parse_html_with_sdk_in_body() { - crate::config::init_test_config(); + crate::proxy::config::init_test_config(); let document = parse_html(&sample_html_full_sdk_in_body(), "test.com"); assert_eq!(document.title, "ABC"); // add check @@ -484,7 +484,7 @@ mod tests { #[test] fn parse_html_doesnt_break_if_invalid_sdk_version() { - crate::config::init_test_config(); + crate::proxy::config::init_test_config(); let html = ""; // invalid let document = parse_html(html, "test.com"); assert_eq!(document.title, ""); diff --git a/crates/proxy/src/proxy/compute/mod.rs b/src/proxy/server/compute/mod.rs similarity index 97% rename from crates/proxy/src/proxy/compute/mod.rs rename to src/proxy/server/compute/mod.rs index 3567dfd..d0ea685 100644 --- a/crates/proxy/src/proxy/compute/mod.rs +++ b/src/proxy/server/compute/mod.rs @@ -6,10 +6,10 @@ use http::header::{CACHE_CONTROL, ETAG, EXPIRES, LAST_MODIFIED}; use http::response::Parts; use http::{HeaderName, HeaderValue}; -use crate::config; -use crate::proxy::context::incoming::RequestHandle; -use crate::proxy::set_edgee_header; -use crate::tools::{ +use crate::proxy::config; +use crate::proxy::server::context::incoming::RequestHandle; +use crate::proxy::server::set_edgee_header; +use crate::proxy::tools::{ self, edgee_cookie::{self}, }; @@ -145,7 +145,7 @@ fn do_process_payload(request: &RequestHandle, response: &mut Parts) -> Result ProxyContext<'a> { pub async fn forward_request(self) -> anyhow::Result { use tower::{Service, ServiceBuilder, ServiceExt}; - use crate::config::BackendConfiguration; + use crate::proxy::config::BackendConfiguration; let BackendConfiguration { enable_ssl, diff --git a/crates/proxy/src/proxy/context/redirection.rs b/src/proxy/server/context/redirection.rs similarity index 92% rename from crates/proxy/src/proxy/context/redirection.rs rename to src/proxy/server/context/redirection.rs index b31a944..8aedf1c 100644 --- a/crates/proxy/src/proxy/context/redirection.rs +++ b/src/proxy/server/context/redirection.rs @@ -1,5 +1,4 @@ use super::incoming::RequestHandle; -use crate::config; pub struct RedirectionContext { pub target: String, @@ -7,7 +6,7 @@ pub struct RedirectionContext { impl RedirectionContext { pub fn from_request(request: &RequestHandle) -> Option { - let cfg = &config::get().routing; + let cfg = &crate::proxy::config::get().routing; let routing = cfg .iter() .find(|r| r.domain.as_str() == request.get_host().as_str())? diff --git a/crates/proxy/src/proxy/context/routing.rs b/src/proxy/server/context/routing.rs similarity index 99% rename from crates/proxy/src/proxy/context/routing.rs rename to src/proxy/server/context/routing.rs index 4dfa36c..1e2bb94 100644 --- a/crates/proxy/src/proxy/context/routing.rs +++ b/src/proxy/server/context/routing.rs @@ -1,5 +1,5 @@ use super::incoming::RequestHandle; -use crate::config; +use crate::proxy::config; use http::uri::PathAndQuery; use regex::Regex; use std::str::FromStr; diff --git a/crates/proxy/src/proxy/controller.rs b/src/proxy/server/controller.rs similarity index 98% rename from crates/proxy/src/proxy/controller.rs rename to src/proxy/server/controller.rs index 9d43f9d..4940a63 100644 --- a/crates/proxy/src/proxy/controller.rs +++ b/src/proxy/server/controller.rs @@ -13,7 +13,7 @@ use url::Url; use super::compute::{self}; use super::context::incoming::{IncomingContext, RequestHandle}; use super::context::redirection::RedirectionContext; -use crate::{config, tools}; +use crate::proxy::{config, tools}; type Response = http::Response>; @@ -268,7 +268,10 @@ pub fn bad_gateway_error( request: &RequestHandle, timer_start: Instant, ) -> anyhow::Result { - static HTML: &str = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/public/502.html")); + static HTML: &str = include_str!(concat!( + env!("CARGO_MANIFEST_DIR"), + "/src/proxy/public/502.html" + )); info!( "502 - {} {}{} - {}ms", diff --git a/crates/proxy/src/proxy/mod.rs b/src/proxy/server/mod.rs similarity index 99% rename from crates/proxy/src/proxy/mod.rs rename to src/proxy/server/mod.rs index a6e3b19..d15e0b6 100644 --- a/crates/proxy/src/proxy/mod.rs +++ b/src/proxy/server/mod.rs @@ -12,7 +12,7 @@ use lol_html::html_content::ContentType; use lol_html::{element, rewrite_str, RewriteStrSettings}; use tracing::{error, info}; -use crate::{config, get_components_ctx}; +use crate::proxy::{config, get_components_ctx}; use context::{ body::ProxyBody, incoming::IncomingContext, proxy::ProxyContext, redirection::RedirectionContext, routing::RoutingContext, diff --git a/crates/proxy/src/tools/cacheable.rs b/src/proxy/tools/cacheable.rs similarity index 100% rename from crates/proxy/src/tools/cacheable.rs rename to src/proxy/tools/cacheable.rs diff --git a/crates/proxy/src/tools/crypto.rs b/src/proxy/tools/crypto.rs similarity index 98% rename from crates/proxy/src/tools/crypto.rs rename to src/proxy/tools/crypto.rs index b42127b..67b89a5 100644 --- a/crates/proxy/src/tools/crypto.rs +++ b/src/proxy/tools/crypto.rs @@ -1,4 +1,4 @@ -use crate::config; +use crate::proxy::config; use aes::cipher::{block_padding::Pkcs7, BlockDecryptMut, BlockEncryptMut, KeyIvInit}; type Aes128CbcEnc = cbc::Encryptor; @@ -77,7 +77,7 @@ pub fn decrypt(text: &str) -> Result { #[cfg(test)] mod tests { use super::*; - use crate::config::init_test_config; + use crate::proxy::config::init_test_config; use pretty_assertions::assert_eq; #[test] diff --git a/crates/proxy/src/tools/edgee_cookie.rs b/src/proxy/tools/edgee_cookie.rs similarity index 98% rename from crates/proxy/src/tools/edgee_cookie.rs rename to src/proxy/tools/edgee_cookie.rs index 312be3f..6d09bd5 100644 --- a/crates/proxy/src/tools/edgee_cookie.rs +++ b/src/proxy/tools/edgee_cookie.rs @@ -13,10 +13,10 @@ use serde_json::Error; use uuid::Uuid; use super::crypto::{decrypt, encrypt}; -use crate::config; -use crate::proxy::compute::data_collection::payload::{Payload, User}; -use crate::proxy::context::incoming::RequestHandle; -use crate::proxy::DATA_COLLECTION_ENDPOINT_FROM_THIRD_PARTY_SDK; +use crate::proxy::config; +use crate::proxy::server::compute::data_collection::payload::{Payload, User}; +use crate::proxy::server::context::incoming::RequestHandle; +use crate::proxy::server::DATA_COLLECTION_ENDPOINT_FROM_THIRD_PARTY_SDK; static SESSION_DURATION: Duration = Duration::minutes(30); diff --git a/crates/proxy/src/tools/mod.rs b/src/proxy/tools/mod.rs similarity index 100% rename from crates/proxy/src/tools/mod.rs rename to src/proxy/tools/mod.rs diff --git a/crates/proxy/src/tools/real_ip.rs b/src/proxy/tools/real_ip.rs similarity index 100% rename from crates/proxy/src/tools/real_ip.rs rename to src/proxy/tools/real_ip.rs diff --git a/crates/cli/src/telemetry.rs b/src/telemetry.rs similarity index 97% rename from crates/cli/src/telemetry.rs rename to src/telemetry.rs index 4d25463..9bad335 100644 --- a/crates/cli/src/telemetry.rs +++ b/src/telemetry.rs @@ -7,7 +7,7 @@ use anyhow::Result; use serde::{Deserialize, Serialize}; use tokio::sync::Mutex; -use api_client::{data_collection as dc, types::UserWithRoles}; +use crate::api_client::{data_collection as dc, types::UserWithRoles}; use event_builder::{IsComplete, IsUnset, SetProperties, State}; static STATE_DIR: LazyLock> = LazyLock::new(|| { @@ -57,11 +57,11 @@ impl Data { } async fn check_user(&mut self) -> Result<()> { - use api_client::auth::Config; + use crate::api_client::auth::Config; if !self.is_logged_in { if let Some(creds) = Config::load().ok().and_then(|config| config.get(&None)) { - let client = api_client::new().credentials(&creds).connect(); + let client = crate::api_client::new().credentials(&creds).connect(); let user = client.get_me().send().await?; self.is_logged_in = true;