From 1588e7bec01d4cc38533430dfdf0a64ea62c3283 Mon Sep 17 00:00:00 2001 From: JesusPerez Date: Sat, 28 Aug 2021 15:23:34 +0100 Subject: [PATCH] chore: add src & cargo files --- Cargo.lock | 3937 ++++++++++++++++++++++++++++++++++++++ Cargo.toml | 79 + src/defs.rs | 104 + src/filters.rs | 411 ++++ src/graphql.rs | 172 ++ src/handlers.rs | 3 + src/handlers/h_config.rs | 564 ++++++ src/handlers/h_data.rs | 442 +++++ src/handlers/h_defs.rs | 162 ++ src/klouds.rs | 95 + src/main.rs | 349 ++++ src/reqenv.rs | 114 ++ 12 files changed, 6432 insertions(+) create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 src/defs.rs create mode 100644 src/filters.rs create mode 100644 src/graphql.rs create mode 100644 src/handlers.rs create mode 100644 src/handlers/h_config.rs create mode 100644 src/handlers/h_data.rs create mode 100644 src/handlers/h_defs.rs create mode 100644 src/klouds.rs create mode 100644 src/main.rs create mode 100644 src/reqenv.rs diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..d74afdb --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,3937 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "Inflector" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" +dependencies = [ + "lazy_static", + "regex", +] + +[[package]] +name = "addr2line" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e61f2b7f93d2c7d2b08263acaa4a363b3e276806c68af6134c44f523bf1aacd" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "aead" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e3e798aa0c8239776f54415bc06f3d74b1850f3f830b45c35cfc80556973f70" +dependencies = [ + "generic-array 0.14.4", +] + +[[package]] +name = "aes" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "495ee669413bfbe9e8cace80f4d3d78e6d8c8d99579f97fb93bde351b185f2d4" +dependencies = [ + "cfg-if 1.0.0", + "cipher", + "cpufeatures", + "opaque-debug 0.3.0", +] + +[[package]] +name = "aes-gcm-siv" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee286776afefcaf21bdb58bfe49e371d80ee60f382806b01aaecc366323ae842" +dependencies = [ + "aead", + "aes", + "cipher", + "ctr", + "polyval", + "subtle", + "zeroize", +] + +[[package]] +name = "ahash" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43bb833f0bf979d8475d38fbf09ed3b8a55e1885fe93ad3f93239fc6a4f17b98" +dependencies = [ + "getrandom 0.2.3", + "once_cell", + "version_check", +] + +[[package]] +name = "aho-corasick" +version = "0.7.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +dependencies = [ + "memchr", +] + +[[package]] +name = "alloc-no-stdlib" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5192ec435945d87bc2f70992b4d818154b5feede43c09fb7592146374eac90a6" + +[[package]] +name = "alloc-stdlib" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "697ed7edc0f1711de49ce108c541623a0af97c6c60b2f6e2b65229847ac843c2" +dependencies = [ + "alloc-no-stdlib", +] + +[[package]] +name = "ansi_term" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +dependencies = [ + "winapi", +] + +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + +[[package]] +name = "anyhow" +version = "1.0.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "595d3cfa7a60d4555cb5067b99f07142a08ea778de5cf993f7b75c7d8fabc486" + +[[package]] +name = "app_auth" +version = "0.1.0" +dependencies = [ + "anyhow", + "app_env", + "app_tools", + "base64", + "casbin", + "chrono", + "dotenv", + "envmnt 0.9.0", + "error-chain", + "glob", + "json", + "once_cell", + "parking_lot", + "rand 0.8.4", + "regex", + "serde", + "serde_derive", + "serde_json", + "serde_yaml", + "slab", + "tempfile", + "tera", + "thiserror", + "tokio", + "toml", + "url", + "uuid", + "warp", + "yaml-rust", +] + +[[package]] +name = "app_auth_filters" +version = "0.1.0" +dependencies = [ + "anyhow", + "app_auth", + "app_auth_handlers", + "app_env", + "app_tools", + "base64", + "casbin", + "chrono", + "dotenv", + "envmnt 0.9.0", + "error-chain", + "glob", + "json", + "once_cell", + "parking_lot", + "rand 0.8.4", + "regex", + "serde", + "serde_derive", + "serde_json", + "serde_yaml", + "slab", + "tempfile", + "tera", + "thiserror", + "tokio", + "toml", + "url", + "uuid", + "warp", + "yaml-rust", +] + +[[package]] +name = "app_auth_handlers" +version = "0.1.0" +dependencies = [ + "anyhow", + "app_auth", + "app_env", + "app_tools", + "base64", + "casbin", + "chrono", + "dotenv", + "envmnt 0.9.0", + "error-chain", + "glob", + "json", + "once_cell", + "parking_lot", + "rand 0.8.4", + "regex", + "reqtasks", + "serde", + "serde_derive", + "serde_json", + "serde_yaml", + "slab", + "tempfile", + "tera", + "thiserror", + "tokio", + "toml", + "url", + "uuid", + "warp", + "yaml-rust", +] + +[[package]] +name = "app_env" +version = "0.1.0" +dependencies = [ + "anyhow", + "app_tools", + "base64", + "dotenv", + "envmnt 0.9.0", + "json", + "once_cell", + "parking_lot", + "rand 0.8.4", + "regex", + "serde", + "serde_derive", + "serde_json", + "serde_yaml", + "tera", + "toml", + "uuid", +] + +[[package]] +name = "app_errors" +version = "0.1.0" +dependencies = [ + "error-chain", + "failure", + "serde", + "serde_derive", +] + +[[package]] +name = "app_file_filters" +version = "0.1.0" +dependencies = [ + "anyhow", + "app_auth", + "app_env", + "app_file_handlers", + "app_tools", + "base64", + "casbin", + "chrono", + "dotenv", + "envmnt 0.9.0", + "error-chain", + "glob", + "json", + "once_cell", + "parking_lot", + "rand 0.8.4", + "regex", + "serde", + "serde_derive", + "serde_json", + "serde_yaml", + "slab", + "tempfile", + "tera", + "thiserror", + "tokio", + "toml", + "url", + "uuid", + "warp", + "yaml-rust", +] + +[[package]] +name = "app_file_handlers" +version = "0.1.0" +dependencies = [ + "anyhow", + "app_auth", + "app_env", + "app_tools", + "base64", + "bytes", + "casbin", + "chrono", + "dotenv", + "envmnt 0.9.0", + "error-chain", + "futures 0.3.16", + "glob", + "json", + "once_cell", + "parking_lot", + "rand 0.8.4", + "regex", + "reqtasks", + "serde", + "serde_derive", + "serde_json", + "serde_yaml", + "slab", + "tempfile", + "tera", + "thiserror", + "tokio", + "toml", + "url", + "uuid", + "warp", + "yaml-rust", +] + +[[package]] +name = "app_tools" +version = "0.1.0" +dependencies = [ + "anyhow", + "base64", + "envmnt 0.9.0", + "json", + "rand 0.8.4", + "regex", + "reqwest", + "serde", + "serde_derive", + "serde_json", + "serde_yaml", + "slab", + "sthash", + "tempfile", + "tera", + "thiserror", + "toml", + "uuid", + "yaml-rust", +] + +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + +[[package]] +name = "arrayvec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" + +[[package]] +name = "arrayvec" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4dc07131ffa69b8072d35f5007352af944213cde02545e2103680baed38fcd" + +[[package]] +name = "async-channel" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2114d64672151c0c5eaa5e131ec84a74f06e1e559830dabba01ca30605d66319" +dependencies = [ + "concurrent-queue", + "event-listener", + "futures-core", +] + +[[package]] +name = "async-compression" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443ccbb270374a2b1055fc72da40e1f237809cd6bb0e97e66d264cd138473a6" +dependencies = [ + "brotli", + "flate2", + "futures-core", + "memchr", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "async-executor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "871f9bb5e0a22eeb7e8cf16641feb87c9dc67032ccf8ff49e772eb9941d3a965" +dependencies = [ + "async-task", + "concurrent-queue", + "fastrand", + "futures-lite", + "once_cell", + "slab", +] + +[[package]] +name = "async-global-executor" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9586ec52317f36de58453159d48351bc244bc24ced3effc1fce22f3d48664af6" +dependencies = [ + "async-channel", + "async-executor", + "async-io", + "async-mutex", + "blocking", + "futures-lite", + "num_cpus", + "once_cell", +] + +[[package]] +name = "async-graphql" +version = "2.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6745cb39edc36e207b5d6e35d6684fd8d7721f071010a7eff31aaeb5684e3da6" +dependencies = [ + "async-graphql-derive", + "async-graphql-parser", + "async-graphql-value", + "async-stream", + "async-trait", + "bytes", + "fnv", + "futures-util", + "http", + "indexmap", + "multer", + "once_cell", + "pin-project-lite", + "regex", + "serde", + "serde_json", + "static_assertions", + "tempfile", + "thiserror", +] + +[[package]] +name = "async-graphql-derive" +version = "2.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63ad0f21d7fab6d70b5cc5c78688ff1d73d2a7fedf7622e1f3cb76b84e6619b9" +dependencies = [ + "Inflector", + "async-graphql-parser", + "darling", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", + "thiserror", +] + +[[package]] +name = "async-graphql-parser" +version = "2.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ba07ce86d05abe3aa8948fde3fd1c76f44bb754b9c6156d9c885ae1491edcc2" +dependencies = [ + "async-graphql-value", + "pest", + "pest_derive", + "serde", + "serde_json", +] + +[[package]] +name = "async-graphql-value" +version = "2.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a0957e87f88e9e62a161e80662d6aa6e78e6d863c24aea55dc43ee8dc384ed9" +dependencies = [ + "bytes", + "serde", + "serde_json", +] + +[[package]] +name = "async-graphql-warp" +version = "2.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edd37032999dddbe659cb970f565435d159fc525d15d17ea8f27eecfad5299b2" +dependencies = [ + "async-graphql", + "futures-util", + "serde_json", + "warp", +] + +[[package]] +name = "async-io" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a811e6a479f2439f0c04038796b5cfb3d2ad56c230e0f2d3f7b04d68cfee607b" +dependencies = [ + "concurrent-queue", + "futures-lite", + "libc", + "log", + "once_cell", + "parking", + "polling", + "slab", + "socket2", + "waker-fn", + "winapi", +] + +[[package]] +name = "async-jobs" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46bda002da112fb12a3e21d700c693631c444aca27cacdda8825c8c70c943cf5" +dependencies = [ + "downcast-rs", + "futures 0.3.16", + "num_cpus", +] + +[[package]] +name = "async-lock" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6a8ea61bf9947a1007c5cada31e647dbc77b103c679858150003ba697ea798b" +dependencies = [ + "event-listener", +] + +[[package]] +name = "async-mutex" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479db852db25d9dbf6204e6cb6253698f175c15726470f78af0d918e99d6156e" +dependencies = [ + "event-listener", +] + +[[package]] +name = "async-std" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9f06685bad74e0570f5213741bea82158279a4103d988e57bfada11ad230341" +dependencies = [ + "async-channel", + "async-global-executor", + "async-io", + "async-lock", + "crossbeam-utils", + "futures-channel", + "futures-core", + "futures-io", + "futures-lite", + "gloo-timers", + "kv-log-macro", + "log", + "memchr", + "num_cpus", + "once_cell", + "pin-project-lite", + "pin-utils", + "slab", + "wasm-bindgen-futures", +] + +[[package]] +name = "async-stream" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "171374e7e3b2504e0e5236e3b59260560f9fe94bfe9ac39ba5e4e929c5590625" +dependencies = [ + "async-stream-impl", + "futures-core", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "648ed8c8d2ce5409ccd57453d9d1b214b342a0d69376a6feda1fd6cae3299308" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "async-task" +version = "4.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e91831deabf0d6d7ec49552e489aed63b7456a7a3c46cff62adad428110b0af0" + +[[package]] +name = "async-trait" +version = "0.1.51" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44318e776df68115a881de9a8fd1b9e53368d7a4a5ce4cc48517da3393233a5e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "atomic-waker" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "065374052e7df7ee4047b1160cca5e1467a12351a40b3da123c870ba0b8eda2a" + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + +[[package]] +name = "autocfg" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" + +[[package]] +name = "backtrace" +version = "0.3.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a905d892734eea339e896738c14b9afce22b5318f64b951e70bf3844419b01" +dependencies = [ + "addr2line", + "cc", + "cfg-if 1.0.0", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "base64" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" + +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + +[[package]] +name = "bitflags" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" + +[[package]] +name = "blake3" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b64485778c4f16a6a5a9d335e80d449ac6c70cdd6a06d2af18a6f6f775a125b3" +dependencies = [ + "arrayref", + "arrayvec 0.5.2", + "cc", + "cfg-if 0.1.10", + "constant_time_eq", + "crypto-mac", + "digest 0.9.0", +] + +[[package]] +name = "blake3" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcd555c66291d5f836dbb6883b48660ece810fe25a31f3bdfb911945dff2691f" +dependencies = [ + "arrayref", + "arrayvec 0.7.1", + "cc", + "cfg-if 1.0.0", + "constant_time_eq", + "digest 0.9.0", + "rayon", +] + +[[package]] +name = "block-buffer" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" +dependencies = [ + "block-padding", + "byte-tools", + "byteorder", + "generic-array 0.12.4", +] + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array 0.14.4", +] + +[[package]] +name = "block-padding" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" +dependencies = [ + "byte-tools", +] + +[[package]] +name = "blocking" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5e170dbede1f740736619b776d7251cb1b9095c435c34d8ca9f57fcd2f335e9" +dependencies = [ + "async-channel", + "async-task", + "atomic-waker", + "fastrand", + "futures-lite", + "once_cell", +] + +[[package]] +name = "brotli" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f29919120f08613aadcd4383764e00526fc9f18b6c0895814faeed0dd78613e" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", + "brotli-decompressor", +] + +[[package]] +name = "brotli-decompressor" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1052e1c3b8d4d80eb84a8b94f0a1498797b5fb96314c001156a1c761940ef4ec" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", +] + +[[package]] +name = "bstr" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90682c8d613ad3373e66de8c6411e0ae2ab2571e879d2efbf73558cc66f21279" +dependencies = [ + "memchr", +] + +[[package]] +name = "buf_redux" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b953a6887648bb07a535631f2bc00fbdb2a2216f135552cb3f534ed136b9c07f" +dependencies = [ + "memchr", + "safemem", +] + +[[package]] +name = "bumpalo" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c59e7af012c713f529e7a3ee57ce9b31ddd858d4b512923602f74608b009631" + +[[package]] +name = "byte-tools" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "bytes" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040" +dependencies = [ + "serde", +] + +[[package]] +name = "cache-padded" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "631ae5198c9be5e753e5cc215e1bd73c2b466a3565173db433f52bb9d3e66dba" + +[[package]] +name = "casbin" +version = "2.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abf280d468b50ee781d1fd6537bbaba44b35f3e2dc466269c36404b3a1eead25" +dependencies = [ + "async-std", + "async-trait", + "indexmap", + "lazy_static", + "regex", + "rhai", + "serde", + "thiserror", +] + +[[package]] +name = "cc" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e70cc2f62c6ce1868963827bd677764c62d07c3d9a3e1fb1177ee1a9ab199eb2" + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chacha20" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea8756167ea0aca10e066cdbe7813bd71d2f24e69b0bc7b50509590cef2ce0b9" +dependencies = [ + "cfg-if 1.0.0", + "cipher", + "cpufeatures", + "zeroize", +] + +[[package]] +name = "chacha20poly1305" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "175a11316f33592cf2b71416ee65283730b5b7849813c4891d02a12906ed9acc" +dependencies = [ + "aead", + "chacha20", + "cipher", + "poly1305", + "zeroize", +] + +[[package]] +name = "chrono" +version = "0.4.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" +dependencies = [ + "libc", + "num-integer", + "num-traits", + "time", + "winapi", +] + +[[package]] +name = "chrono-tz" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2554a3155fec064362507487171dcc4edc3df60cb10f3a1fb10ed8094822b120" +dependencies = [ + "chrono", + "parse-zoneinfo", +] + +[[package]] +name = "cipher" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" +dependencies = [ + "generic-array 0.14.4", +] + +[[package]] +name = "clap" +version = "2.33.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" +dependencies = [ + "ansi_term 0.11.0", + "atty", + "bitflags", + "strsim 0.8.0", + "textwrap", + "unicode-width", + "vec_map", +] + +[[package]] +name = "clds" +version = "0.1.0" +dependencies = [ + "anyhow", + "chrono", + "envmnt 0.9.0", + "flate2", + "openssh", + "regex", + "reqenv", + "rfm", + "serde", + "serde_derive", + "serde_json", + "serde_yaml", + "tar", + "tempfile", + "tera", + "tokio", +] + +[[package]] +name = "concurrent-queue" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30ed07550be01594c6026cff2a1d7fe9c8f683caa798e12b68694ac9e88286a3" +dependencies = [ + "cache-padded", +] + +[[package]] +name = "constant_time_eq" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" + +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + +[[package]] +name = "core-foundation" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a89e2ae426ea83155dccf10c0fa6b1463ef6d5fcb44cee0b224a408fa640a62" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b" + +[[package]] +name = "cpufeatures" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66c99696f6c9dd7f35d486b9d04d7e6e202aa3e8c40d553f2fdf5e7e0c6a71ef" +dependencies = [ + "libc", +] + +[[package]] +name = "crc32fast" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "cron" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "628a3464535cee4e75af89e8c293bab926deaddfa166553b75029066c846be3f" +dependencies = [ + "chrono", + "nom", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-utils", + "lazy_static", + "memoffset", + "scopeguard", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" +dependencies = [ + "cfg-if 1.0.0", + "lazy_static", +] + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "crypto-mac" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" +dependencies = [ + "generic-array 0.14.4", + "subtle", +] + +[[package]] +name = "ctor" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e98e2ad1a782e33928b96fc3948e7c355e5af34ba4de7670fe8bac2a3b2006d" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "ctr" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea" +dependencies = [ + "cipher", +] + +[[package]] +name = "darling" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f2c43f534ea4b0b049015d00269734195e6d3f0f6635cb692251aca6f9f8b3c" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e91455b86830a1c21799d94524df0845183fa55bafd9aa137b01c7d1065fa36" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim 0.10.0", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29b5acf0dea37a7f66f7b25d2c5e93fd46f8f6968b1a5d7a3e02e97768afc95a" +dependencies = [ + "darling_core", + "quote", + "syn", +] + +[[package]] +name = "derive_more" +version = "0.99.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40eebddd2156ce1bb37b20bbe5151340a31828b1f2d22ba4141f3531710e38df" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version", + "syn", +] + +[[package]] +name = "deunicode" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "850878694b7933ca4c9569d30a34b55031b9b139ee1fc7b94a527c4ef960d690" + +[[package]] +name = "diff" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e25ea47919b1560c4e3b7fe0aaab9becf5b84a10325ddf7db0f0ba5e1026499" + +[[package]] +name = "digest" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +dependencies = [ + "generic-array 0.12.4", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array 0.14.4", +] + +[[package]] +name = "dotenv" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" + +[[package]] +name = "downcast-rs" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" + +[[package]] +name = "dtoa" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0" + +[[package]] +name = "either" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" + +[[package]] +name = "enc_file" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "776f0d8efca36d47ee4fca2142eeb723cdfdd7c695287d2127ed1781961196f3" +dependencies = [ + "aes-gcm-siv", + "bincode", + "blake3 1.0.0", + "chacha20poly1305", + "rand 0.8.4", + "serde", + "sha2", +] + +[[package]] +name = "encoding_rs" +version = "0.8.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80df024fbc5ac80f87dfef0d9f5209a252f2a497f7f42944cff24d8253cac065" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "env_logger" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" +dependencies = [ + "atty", + "humantime", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "envmnt" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2d328fc287c61314c4a61af7cfdcbd7e678e39778488c7cb13ec133ce0f4059" +dependencies = [ + "fsio 0.1.3", + "indexmap", +] + +[[package]] +name = "envmnt" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbfac51e9996e41d78a943227b7f313efcebf545b21584a0e213b956a062e11e" +dependencies = [ + "fsio 0.2.0", + "indexmap", +] + +[[package]] +name = "error-chain" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc" +dependencies = [ + "backtrace", + "version_check", +] + +[[package]] +name = "event-listener" +version = "2.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7531096570974c3a9dcf9e4b8e1cede1ec26cf5046219fb3b9d897503b9be59" + +[[package]] +name = "failure" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86" +dependencies = [ + "backtrace", + "failure_derive", +] + +[[package]] +name = "failure_derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "fake-simd" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" + +[[package]] +name = "fastrand" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b394ed3d285a429378d3b384b9eb1285267e7df4b166df24b7a6939a04dc392e" +dependencies = [ + "instant", +] + +[[package]] +name = "filetime" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d34cfa13a63ae058bfa601fe9e313bbdb3746427c1459185464ce0fcf62e1e8" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "redox_syscall", + "winapi", +] + +[[package]] +name = "flate2" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd3aec53de10fe96d7d8c565eb17f2c687bb5518a2ec453b5b1252964526abe0" +dependencies = [ + "cfg-if 1.0.0", + "crc32fast", + "libc", + "miniz_oxide", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" +dependencies = [ + "matches", + "percent-encoding", +] + +[[package]] +name = "fsio" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1fd087255f739f4f1aeea69f11b72f8080e9c2e7645cd06955dad4a178a49e3" + +[[package]] +name = "fsio" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a50045aa8931ae01afbc5d72439e8f57f326becb8c70d07dfc816778eff3d167" + +[[package]] +name = "futures" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678" + +[[package]] +name = "futures" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1adc00f486adfc9ce99f77d717836f0c5aa84965eb0b4f051f4e83f7cab53f8b" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74ed2411805f6e4e3d9bc904c95d5d423b89b3b25dc0250aa74729de20629ff9" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af51b1b4a7fdff033703db39de8802c673eb91855f2e0d47dcf3bf2c0ef01f99" + +[[package]] +name = "futures-cpupool" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" +dependencies = [ + "futures 0.1.31", + "num_cpus", +] + +[[package]] +name = "futures-executor" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d0d535a57b87e1ae31437b892713aee90cd2d7b0ee48727cd11fc72ef54761c" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b0e06c393068f3a6ef246c75cdca793d6a46347e75286933e5e75fd2fd11582" + +[[package]] +name = "futures-lite" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48" +dependencies = [ + "fastrand", + "futures-core", + "futures-io", + "memchr", + "parking", + "pin-project-lite", + "waker-fn", +] + +[[package]] +name = "futures-macro" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c54913bae956fb8df7f4dc6fc90362aa72e69148e3f39041fbe8742d21e0ac57" +dependencies = [ + "autocfg", + "proc-macro-hack", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0f30aaa67363d119812743aa5f33c201a7a66329f97d1a887022971feea4b53" + +[[package]] +name = "futures-task" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbe54a98670017f3be909561f6ad13e810d9a51f3f061b902062ca3da80799f2" + +[[package]] +name = "futures-util" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67eb846bfd58e44a8481a00049e82c43e0ccb5d61f8dc071057cb19249dd4d78" +dependencies = [ + "autocfg", + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "proc-macro-hack", + "proc-macro-nested", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" +dependencies = [ + "typenum", +] + +[[package]] +name = "generic-array" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi 0.10.0+wasi-snapshot-preview1", +] + +[[package]] +name = "gimli" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0a01e0497841a3b2db4f8afa483cce65f7e96a3498bd6c541734792aeac8fe7" + +[[package]] +name = "glob" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" + +[[package]] +name = "globset" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10463d9ff00a2a068db14231982f5132edebad0d7660cd956a1c30292dbcbfbd" +dependencies = [ + "aho-corasick", + "bstr", + "fnv", + "log", + "regex", +] + +[[package]] +name = "globwalk" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93e3af942408868f6934a7b85134a3230832b9977cf66125df2f9edcfce4ddcc" +dependencies = [ + "bitflags", + "ignore", + "walkdir", +] + +[[package]] +name = "gloo-timers" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47204a46aaff920a1ea58b11d03dec6f704287d27561724a4631e450654a891f" +dependencies = [ + "futures-channel", + "futures-core", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "gql_playground" +version = "0.1.0" +dependencies = [ + "serde", + "serde_derive", + "serde_json", +] + +[[package]] +name = "h2" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "825343c4eef0b63f541f8903f395dc5beb362a979b5799a84062527ef1e37726" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" + +[[package]] +name = "headers" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0b7591fb62902706ae8e7aaff416b1b0fa2c0fd0878b46dc13baa3712d8a855" +dependencies = [ + "base64", + "bitflags", + "bytes", + "headers-core", + "http", + "mime", + "sha-1 0.9.7", + "time", +] + +[[package]] +name = "headers-core" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429" +dependencies = [ + "http", +] + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "http" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "527e8c9ac747e28542699a951517aa9a6945af506cd1f2e1b53a576c17b6cc11" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60daa14be0e0786db0f03a9e57cb404c9d756eed2b6c62b9ea98ec5743ec75a9" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3a87b616e37e93c22fb19bcd386f02f3af5ea98a25670ad0fce773de23c5e68" + +[[package]] +name = "httpdate" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6456b8a6c8f33fee7d958fcd1b60d55b11940a79e63ae87013e6d22e26034440" + +[[package]] +name = "humansize" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02296996cb8796d7c6e3bc2d9211b7802812d36999a51bb754123ead7d37d026" + +[[package]] +name = "humantime" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" +dependencies = [ + "quick-error", +] + +[[package]] +name = "hyper" +version = "0.14.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b61cf2d1aebcf6e6352c97b81dc2244ca29194be1b276f5d8ad5c6330fffb11" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "idna" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "ignore" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "713f1b139373f96a2e0ce3ac931cd01ee973c3c5dd7c40c0c2efe96ad2b6751d" +dependencies = [ + "crossbeam-utils", + "globset", + "lazy_static", + "log", + "memchr", + "regex", + "same-file", + "thread_local", + "walkdir", + "winapi-util", +] + +[[package]] +name = "indexmap" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" +dependencies = [ + "autocfg", + "hashbrown", +] + +[[package]] +name = "input_buffer" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f97967975f448f1a7ddb12b0bc41069d09ed6a1c161a92687e057325db35d413" +dependencies = [ + "bytes", +] + +[[package]] +name = "instant" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bee0328b1209d157ef001c94dd85b4f8f64139adb0eac2659f4b08382b2f474d" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "ipnet" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68f2d64f2edebec4ce84ad108148e67e1064789bee435edc5b60ad398714a3a9" + +[[package]] +name = "itoa" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" + +[[package]] +name = "js-sys" +version = "0.3.51" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83bdfbace3a0e81a4253f73b49e960b053e396a11012cbd49b9b74d6a2b67062" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "json" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "078e285eafdfb6c4b434e0d31e8cfcb5115b651496faca5749b88fafd4f23bfd" + +[[package]] +name = "key_of_life" +version = "0.1.0" +dependencies = [ + "base64", + "envmnt 0.8.4", + "os_info", + "reqwest", + "tkdr", +] + +[[package]] +name = "kloud" +version = "0.1.0" +dependencies = [ + "anyhow", + "app_env", + "app_tools", + "async-graphql", + "envmnt 0.9.0", + "json", + "parking_lot", + "serde", + "serde_derive", + "serde_json", + "serde_yaml", + "tempfile", + "toml", + "uuid", +] + +[[package]] +name = "kloud_entries_macro_derive" +version = "0.1.0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "kv-log-macro" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f" +dependencies = [ + "log", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "320cfe77175da3a483efed4bc0adc1968ca050b098ce4f2f1c13a56626128790" + +[[package]] +name = "librecloud_kloud" +version = "0.1.0" +dependencies = [ + "anyhow", + "async-graphql", + "kloud", + "kloud_entries_macro_derive", + "serde", + "serde_derive", + "serde_json", + "serde_yaml", + "toml", +] + +[[package]] +name = "linked-hash-map" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" + +[[package]] +name = "lock_api" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0382880606dff6d15c9476c416d18690b72742aa7b605bb6dd6ec9030fbf07eb" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +dependencies = [ + "cfg-if 1.0.0", + "value-bag", +] + +[[package]] +name = "maplit" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" + +[[package]] +name = "matches" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" + +[[package]] +name = "memchr" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc" + +[[package]] +name = "memoffset" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" +dependencies = [ + "autocfg", +] + +[[package]] +name = "mime" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" + +[[package]] +name = "mime_guess" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2684d4c2e97d99848d30b324b00c8fcc7e5c897b7cbb5819b09e7c90e8baf212" +dependencies = [ + "mime", + "unicase", +] + +[[package]] +name = "miniz_oxide" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" +dependencies = [ + "adler", + "autocfg", +] + +[[package]] +name = "mio" +version = "0.7.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c2bdb6314ec10835cd3293dd268473a835c02b7b352e788be788b3c6ca6bb16" +dependencies = [ + "libc", + "log", + "miow", + "ntapi", + "winapi", +] + +[[package]] +name = "miow" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" +dependencies = [ + "winapi", +] + +[[package]] +name = "multer" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fdd568fea4758b30d6423f013f7171e193c34aa97828d1bd9f924fb3af30a8c" +dependencies = [ + "bytes", + "derive_more", + "encoding_rs", + "futures-util", + "http", + "httparse", + "log", + "mime", + "spin 0.9.2", + "twoway 0.2.2", + "version_check", +] + +[[package]] +name = "multipart" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d050aeedc89243f5347c3e237e3e13dc76fbe4ae3742a57b94dc14f69acf76d4" +dependencies = [ + "buf_redux", + "httparse", + "log", + "mime", + "mime_guess", + "quick-error", + "rand 0.7.3", + "safemem", + "tempfile", + "twoway 0.1.8", +] + +[[package]] +name = "native-tls" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8d96b2e1c8da3957d58100b09f102c6d9cfdfced01b7ec5a8974044bb09dbd4" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "nom" +version = "4.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c349f68f25f596b9f44cf0e7c69752a5c633b0550c3ff849518bfba0233774a" +dependencies = [ + "memchr", +] + +[[package]] +name = "ntapi" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" +dependencies = [ + "winapi", +] + +[[package]] +name = "num-integer" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "object" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c55827317fb4c08822499848a14237d2874d6f139828893017237e7ab93eb386" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" + +[[package]] +name = "opaque-debug" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "openssh" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a63cf640fd0e87026b72442a4e92dacbad9aaed69b42caa54729e46058898ce" +dependencies = [ + "shell-escape", + "tempfile", + "tokio", +] + +[[package]] +name = "openssl" +version = "0.10.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "549430950c79ae24e6d02e0b7404534ecf311d94cc9f861e9e4020187d13d885" +dependencies = [ + "bitflags", + "cfg-if 1.0.0", + "foreign-types", + "libc", + "once_cell", + "openssl-sys", +] + +[[package]] +name = "openssl-probe" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28988d872ab76095a6e6ac88d99b54fd267702734fd7ffe610ca27f533ddb95a" + +[[package]] +name = "openssl-sys" +version = "0.9.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a7907e3bfa08bb85105209cdfcb6c63d109f8f6c1ed6ca318fff5c1853fbc1d" +dependencies = [ + "autocfg", + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "os_info" +version = "3.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3d2536ab8ff7605e8dc7044ec2f3eb0d49750cb559af9e5373c4564a3706cdd" +dependencies = [ + "log", + "winapi", +] + +[[package]] +name = "output_vt100" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53cdc5b785b7a58c5aad8216b3dfa114df64b0b06ae6e1501cef91df2fbdf8f9" +dependencies = [ + "winapi", +] + +[[package]] +name = "parking" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" + +[[package]] +name = "parking_lot" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018" +dependencies = [ + "cfg-if 1.0.0", + "instant", + "libc", + "redox_syscall", + "smallvec", + "winapi", +] + +[[package]] +name = "parse-zoneinfo" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c705f256449c60da65e11ff6626e0c16a0a0b96aaa348de61376b249bc340f41" +dependencies = [ + "regex", +] + +[[package]] +name = "percent-encoding" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" + +[[package]] +name = "pest" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" +dependencies = [ + "ucd-trie", +] + +[[package]] +name = "pest_derive" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "833d1ae558dc601e9a60366421196a8d94bc0ac980476d0b67e1d0988d72b2d0" +dependencies = [ + "pest", + "pest_generator", +] + +[[package]] +name = "pest_generator" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55" +dependencies = [ + "pest", + "pest_meta", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pest_meta" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54be6e404f5317079812fc8f9f5279de376d8856929e21c184ecf6bbd692a11d" +dependencies = [ + "maplit", + "pest", + "sha-1 0.8.2", +] + +[[package]] +name = "pin-project" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "576bc800220cc65dac09e99e97b08b358cfab6e17078de8dc5fee223bd2d0c08" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e8fe8163d14ce7f0cdac2e040116f22eac817edabff0be91e8aff7e9accf389" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" + +[[package]] +name = "polling" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92341d779fa34ea8437ef4d82d440d5e1ce3f3ff7f824aa64424cd481f9a1f25" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "log", + "wepoll-ffi", + "winapi", +] + +[[package]] +name = "poly1305" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fcffab1f78ebbdf4b93b68c1ffebc24037eedf271edaca795732b24e5e4e349" +dependencies = [ + "cpufeatures", + "opaque-debug 0.3.0", + "universal-hash", +] + +[[package]] +name = "polyval" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6ba6a405ef63530d6cb12802014b22f9c5751bd17cdcddbe9e46d5c8ae83287" +dependencies = [ + "cfg-if 1.0.0", + "cpufeatures", + "opaque-debug 0.3.0", + "universal-hash", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" + +[[package]] +name = "pretty_assertions" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cab0e7c02cf376875e9335e0ba1da535775beb5450d21e1dffca068818ed98b" +dependencies = [ + "ansi_term 0.12.1", + "ctor", + "diff", + "output_vt100", +] + +[[package]] +name = "pretty_env_logger" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "926d36b9553851b8b0005f1275891b392ee4d2d833852c417ed025477350fb9d" +dependencies = [ + "env_logger", + "log", +] + +[[package]] +name = "proc-macro-crate" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41fdbd1df62156fbc5945f4762632564d7d038153091c3fcf1067f6aef7cff92" +dependencies = [ + "thiserror", + "toml", +] + +[[package]] +name = "proc-macro-hack" +version = "0.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" + +[[package]] +name = "proc-macro-nested" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" + +[[package]] +name = "proc-macro2" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c7ed8b8c7b886ea3ed7dde405212185f423ab44682667c8c6dd14aa1d9f6612" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + +[[package]] +name = "quote" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc 0.2.0", +] + +[[package]] +name = "rand" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.3", + "rand_hc 0.3.1", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.3", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", +] + +[[package]] +name = "rand_core" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" +dependencies = [ + "getrandom 0.2.3", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "rand_hc" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7" +dependencies = [ + "rand_core 0.6.3", +] + +[[package]] +name = "rayon" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90" +dependencies = [ + "autocfg", + "crossbeam-deque", + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e" +dependencies = [ + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-utils", + "lazy_static", + "num_cpus", +] + +[[package]] +name = "redox_syscall" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ab49abadf3f9e1c4bc499e8845e152ad87d2ad2d30371841171169e9d75feee" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" + +[[package]] +name = "reject_filters" +version = "0.1.0" +dependencies = [ + "app_env", + "serde", + "serde_derive", + "warp", +] + +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi", +] + +[[package]] +name = "reqenv" +version = "0.1.0" +dependencies = [ + "anyhow", + "app_auth", + "app_env", + "app_errors", + "app_tools", + "base64", + "casbin", + "chrono", + "dotenv", + "envmnt 0.9.0", + "error-chain", + "glob", + "json", + "once_cell", + "parking_lot", + "rand 0.8.4", + "regex", + "reqtasks", + "serde", + "serde_derive", + "serde_json", + "serde_yaml", + "slab", + "tempfile", + "tera", + "thiserror", + "tokio", + "toml", + "url", + "uuid", + "warp", + "yaml-rust", +] + +[[package]] +name = "reqtasks" +version = "0.1.0" +dependencies = [ + "anyhow", + "app_auth", + "app_env", + "app_errors", + "app_tools", + "base64", + "casbin", + "chrono", + "dotenv", + "envmnt 0.9.0", + "error-chain", + "glob", + "json", + "once_cell", + "parking_lot", + "rand 0.8.4", + "regex", + "serde", + "serde_derive", + "serde_json", + "serde_yaml", + "slab", + "tempfile", + "tera", + "thiserror", + "tokio", + "toml", + "url", + "uuid", + "warp", + "yaml-rust", +] + +[[package]] +name = "reqwest" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "246e9f61b9bb77df069a947682be06e31ac43ea37862e244a69f177694ea6d22" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "http", + "http-body", + "hyper", + "hyper-tls", + "ipnet", + "js-sys", + "lazy_static", + "log", + "mime", + "native-tls", + "percent-encoding", + "pin-project-lite", + "serde", + "serde_urlencoded", + "tokio", + "tokio-native-tls", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + +[[package]] +name = "rfm" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e3561b82ad64cc977b5d04da33e289353f20221f5fb267d95b502407c13eead" + +[[package]] +name = "rhai" +version = "0.19.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e39f22e6f2e7ecf283d206eb5fcfae2652b05c43f9956f79341fd87f7a4234b9" +dependencies = [ + "ahash", + "instant", + "num-traits", + "rhai_codegen", + "serde", + "smallvec", + "smartstring", +] + +[[package]] +name = "rhai_codegen" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "643fd67d19aafd45a9e335afe4183dc58ba0cc6a1f43fbe34c7d92c041cdcafc" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ring" +version = "0.16.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +dependencies = [ + "cc", + "libc", + "once_cell", + "spin 0.5.2", + "untrusted", + "web-sys", + "winapi", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dead70b0b5e03e9c814bcb6b01e03e68f7c57a80aa48c72ec92152ab3e818d49" + +[[package]] +name = "rustc_version" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" +dependencies = [ + "semver", +] + +[[package]] +name = "rustls" +version = "0.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7" +dependencies = [ + "base64", + "log", + "ring", + "sct", + "webpki", +] + +[[package]] +name = "ryu" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" + +[[package]] +name = "safemem" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "schannel" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" +dependencies = [ + "lazy_static", + "winapi", +] + +[[package]] +name = "scoped-tls" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "sct" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "security-framework" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23a2ac85147a3a11d77ecf1bc7166ec0b92febfa4461c37944e180f319ece467" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e4effb91b4b8b6fb7732e670b6cee160278ff8e6bf485c7805d9e319d76e284" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "semver" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver-parser" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +dependencies = [ + "pest", +] + +[[package]] +name = "serde" +version = "1.0.126" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.126" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "963a7dbc9895aeac7ac90e74f34a5d5261828f79df35cbed41e10189d3804d43" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28c5e91e4240b46c4c19219d6cc84784444326131a4210f496f948d5cc827a29" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edfa57a7f8d9c1d260a549e7224100f6c43d43f9103e06dd8b4095a9b2b43ce9" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_yaml" +version = "0.8.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15654ed4ab61726bf918a39cb8d98a2e2995b002387807fa6ba58fdf7f59bb23" +dependencies = [ + "dtoa", + "linked-hash-map", + "serde", + "yaml-rust", +] + +[[package]] +name = "sha-1" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" +dependencies = [ + "block-buffer 0.7.3", + "digest 0.8.1", + "fake-simd", + "opaque-debug 0.2.3", +] + +[[package]] +name = "sha-1" +version = "0.9.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a0c8611594e2ab4ebbf06ec7cbbf0a99450b8570e96cbf5188b5d5f6ef18d81" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if 1.0.0", + "cpufeatures", + "digest 0.9.0", + "opaque-debug 0.3.0", +] + +[[package]] +name = "sha1" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" + +[[package]] +name = "sha2" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b362ae5752fd2137731f9fa25fd4d9058af34666ca1966fb969119cc35719f12" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if 1.0.0", + "cpufeatures", + "digest 0.9.0", + "opaque-debug 0.3.0", +] + +[[package]] +name = "shell-escape" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45bb67a18fa91266cc7807181f62f9178a6873bfad7dc788c42e6430db40184f" + +[[package]] +name = "signal-hook-registry" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +dependencies = [ + "libc", +] + +[[package]] +name = "slab" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f173ac3d1a7e3b28003f40de0b5ce7fe2710f9b9dc3fc38664cebee46b3b6527" + +[[package]] +name = "slug" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3bc762e6a4b6c6fcaade73e77f9ebc6991b676f88bb2358bddb56560f073373" +dependencies = [ + "deunicode", +] + +[[package]] +name = "smallvec" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" + +[[package]] +name = "smartstring" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31aa6a31c0c2b21327ce875f7e8952322acfcfd0c27569a6e18a647281352c9b" +dependencies = [ + "static_assertions", +] + +[[package]] +name = "socket2" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "765f090f0e423d2b55843402a07915add955e7d60657db13707a159727326cad" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "spin" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "511254be0c5bcf062b019a6c89c01a664aa359ded62f78aa72c6fc137c0590e5" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "sthash" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4509a39fb29cd0945f66b16eb18bad528a62a33dd495cf6764e5cf7f27f39ce2" +dependencies = [ + "byteorder", + "tiny-keccak", +] + +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + +[[package]] +name = "syn" +version = "1.0.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1873d832550d4588c3dbc20f01361ab00bfe741048f71e3fecf145a7cc18b29c" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "synstructure" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "474aaa926faa1603c40b7885a9eaea29b444d1cb2850cb7c0e37bb1a4182f4fa" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "unicode-xid", +] + +[[package]] +name = "tar" +version = "0.4.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d779dc6aeff029314570f666ec83f19df7280bb36ef338442cfa8c604021b80" +dependencies = [ + "filetime", + "libc", + "xattr", +] + +[[package]] +name = "tempfile" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "rand 0.8.4", + "redox_syscall", + "remove_dir_all", + "winapi", +] + +[[package]] +name = "tera" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf95b0d8a46da5fe3ea119394a6c7f1e745f9de359081641c99946e2bf55d4f2" +dependencies = [ + "chrono", + "chrono-tz", + "globwalk", + "humansize", + "lazy_static", + "percent-encoding", + "pest", + "pest_derive", + "rand 0.8.4", + "regex", + "serde", + "serde_json", + "slug", + "unic-segment", +] + +[[package]] +name = "termcolor" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "thiserror" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93119e4feac1cbe6c798c34d3a53ea0026b0b1de6a120deef895137c0529bfe2" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "060d69a0afe7796bf42e9e2ff91f5ee691fb15c53d38b4b62a9a53eb23164745" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thread_local" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8018d24e04c95ac8790716a5987d0fec4f8b27249ffa0f7d33f1369bdfb88cbd" +dependencies = [ + "once_cell", +] + +[[package]] +name = "time" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +dependencies = [ + "libc", + "wasi 0.10.0+wasi-snapshot-preview1", + "winapi", +] + +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + +[[package]] +name = "tinyvec" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "848a1e1181b9f6753b5e96a092749e29b11d19ede67dfbbd6c7dc7e0f49b5338" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + +[[package]] +name = "tkdr" +version = "0.1.0" +dependencies = [ + "anyhow", + "base64", + "blake3 0.3.8", + "chrono", + "dotenv", + "enc_file", + "envmnt 0.8.4", + "failure", + "futures 0.3.16", + "futures-cpupool", + "json", + "rand 0.8.4", + "regex", + "reqwest", + "serde", + "serde_derive", + "serde_json", + "serde_yaml", + "tera", + "toml", + "uuid", +] + +[[package]] +name = "tokio" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b7b349f11a7047e6d1276853e612d152f5e8a352c61917887cc2169e2366b4c" +dependencies = [ + "autocfg", + "bytes", + "libc", + "memchr", + "mio", + "num_cpus", + "once_cell", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "tokio-macros", + "winapi", +] + +[[package]] +name = "tokio-cron-scheduler" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6af42ec81010dbf80a8762206e4cf5273ef291b91f203b48e250130ca4289392" +dependencies = [ + "chrono", + "cron", + "tokio", + "uuid", +] + +[[package]] +name = "tokio-macros" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54473be61f4ebe4efd09cec9bd5d16fa51d70ea0192213d754d2d500457db110" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-rustls" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6" +dependencies = [ + "rustls", + "tokio", + "webpki", +] + +[[package]] +name = "tokio-stream" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b2f3f698253f03119ac0102beaa64f67a67e08074d03a22d18784104543727f" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-tungstenite" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1a5f475f1b9d077ea1017ecbc60890fda8e54942d680ca0b1d2b47cfa2d861b" +dependencies = [ + "futures-util", + "log", + "pin-project", + "tokio", + "tungstenite", +] + +[[package]] +name = "tokio-util" +version = "0.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1caa0b0c8d94a049db56b5acf8cba99dc0623aab1b26d5b5f5e2d945846b3592" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "log", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "toml" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" +dependencies = [ + "serde", +] + +[[package]] +name = "tower-service" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" + +[[package]] +name = "tracing" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09adeb8c97449311ccd28a427f96fb563e7fd31aabf994189879d9da2394b89d" +dependencies = [ + "cfg-if 1.0.0", + "log", + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9ff14f98b1a4b289c6248a023c1c2fa1491062964e9fed67ab29c4e4da4a052" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "try-lock" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" + +[[package]] +name = "tungstenite" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ada8297e8d70872fa9a551d93250a9f407beb9f37ef86494eb20012a2ff7c24" +dependencies = [ + "base64", + "byteorder", + "bytes", + "http", + "httparse", + "input_buffer", + "log", + "rand 0.8.4", + "sha-1 0.9.7", + "url", + "utf-8", +] + +[[package]] +name = "twoway" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59b11b2b5241ba34be09c3cc85a36e56e48f9888862e19cedf23336d35316ed1" +dependencies = [ + "memchr", +] + +[[package]] +name = "twoway" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c57ffb460d7c24cd6eda43694110189030a3d1dfe418416d9468fd1c1d290b47" +dependencies = [ + "memchr", + "unchecked-index", +] + +[[package]] +name = "typenum" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" + +[[package]] +name = "ucd-trie" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" + +[[package]] +name = "unchecked-index" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eeba86d422ce181a719445e51872fa30f1f7413b62becb52e95ec91aa262d85c" + +[[package]] +name = "unic-char-property" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8c57a407d9b6fa02b4795eb81c5b6652060a15a7903ea981f3d723e6c0be221" +dependencies = [ + "unic-char-range", +] + +[[package]] +name = "unic-char-range" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0398022d5f700414f6b899e10b8348231abf9173fa93144cbc1a43b9793c1fbc" + +[[package]] +name = "unic-common" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d7ff825a6a654ee85a63e80f92f054f904f21e7d12da4e22f9834a4aaa35bc" + +[[package]] +name = "unic-segment" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4ed5d26be57f84f176157270c112ef57b86debac9cd21daaabbe56db0f88f23" +dependencies = [ + "unic-ucd-segment", +] + +[[package]] +name = "unic-ucd-segment" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2079c122a62205b421f499da10f3ee0f7697f012f55b675e002483c73ea34700" +dependencies = [ + "unic-char-property", + "unic-char-range", + "unic-ucd-version", +] + +[[package]] +name = "unic-ucd-version" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96bd2f2237fe450fcd0a1d2f5f4e91711124f7857ba2e964247776ebeeb7b0c4" +dependencies = [ + "unic-common", +] + +[[package]] +name = "unicase" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" +dependencies = [ + "version_check", +] + +[[package]] +name = "unicode-bidi" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eeb8be209bb1c96b7c177c7420d26e04eccacb0eeae6b980e35fcb74678107e0" +dependencies = [ + "matches", +] + +[[package]] +name = "unicode-normalization" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-width" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" + +[[package]] +name = "unicode-xid" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" + +[[package]] +name = "universal-hash" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05" +dependencies = [ + "generic-array 0.14.4", + "subtle", +] + +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + +[[package]] +name = "url" +version = "2.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" +dependencies = [ + "form_urlencoded", + "idna", + "matches", + "percent-encoding", +] + +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" +dependencies = [ + "getrandom 0.2.3", + "serde", + "sha1", +] + +[[package]] +name = "value-bag" +version = "1.0.0-alpha.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd320e1520f94261153e96f7534476ad869c14022aee1e59af7c778075d840ae" +dependencies = [ + "ctor", + "version_check", +] + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + +[[package]] +name = "version_check" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" + +[[package]] +name = "waker-fn" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" + +[[package]] +name = "walkdir" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +dependencies = [ + "same-file", + "winapi", + "winapi-util", +] + +[[package]] +name = "want" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +dependencies = [ + "log", + "try-lock", +] + +[[package]] +name = "warp" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "332d47745e9a0c38636dbd454729b147d16bd1ed08ae67b3ab281c4506771054" +dependencies = [ + "async-compression", + "bytes", + "futures 0.3.16", + "headers", + "http", + "hyper", + "log", + "mime", + "mime_guess", + "multipart", + "percent-encoding", + "pin-project", + "scoped-tls", + "serde", + "serde_json", + "serde_urlencoded", + "tokio", + "tokio-rustls", + "tokio-stream", + "tokio-tungstenite", + "tokio-util", + "tower-service", + "tracing", +] + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "wasi" +version = "0.10.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" + +[[package]] +name = "wasm-bindgen" +version = "0.2.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d54ee1d4ed486f78874278e63e4069fc1ab9f6a18ca492076ffb90c5eb2997fd" +dependencies = [ + "cfg-if 1.0.0", + "serde", + "serde_json", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b33f6a0694ccfea53d94db8b2ed1c3a8a4c86dd936b13b9f0a15ec4a451b900" +dependencies = [ + "bumpalo", + "lazy_static", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fba7978c679d53ce2d0ac80c8c175840feb849a161664365d1287b41f2e67f1" +dependencies = [ + "cfg-if 1.0.0", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "088169ca61430fe1e58b8096c24975251700e7b1f6fd91cc9d59b04fb9b18bd4" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be2241542ff3d9f241f5e2cb6dd09b37efe786df8851c54957683a49f0987a97" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7cff876b8f18eed75a66cf49b65e7f967cb354a7aa16003fb55dbfd25b44b4f" + +[[package]] +name = "web-sys" +version = "0.3.51" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e828417b379f3df7111d3a2a9e5753706cae29c41f7c4029ee9fd77f3e09e582" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki" +version = "0.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "wepoll-ffi" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d743fdedc5c64377b5fc2bc036b01c7fd642205a0d96356034ae3404d49eb7fb" +dependencies = [ + "cc", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "winreg" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69" +dependencies = [ + "winapi", +] + +[[package]] +name = "xattr" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "244c3741f4240ef46274860397c7c74e50eb23624996930e484c16679633a54c" +dependencies = [ + "libc", +] + +[[package]] +name = "yaml-rust" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" +dependencies = [ + "linked-hash-map", +] + +[[package]] +name = "zeroize" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd" + +[[package]] +name = "zterton" +version = "0.1.0" +dependencies = [ + "anyhow", + "app_auth", + "app_auth_filters", + "app_auth_handlers", + "app_env", + "app_errors", + "app_file_filters", + "app_file_handlers", + "app_tools", + "async-graphql", + "async-graphql-warp", + "async-jobs", + "async-std", + "base64", + "bytes", + "casbin", + "chrono", + "clds", + "envmnt 0.9.0", + "futures-util", + "gql_playground", + "http", + "key_of_life", + "kloud", + "librecloud_kloud", + "log", + "once_cell", + "parking_lot", + "pretty_assertions", + "pretty_env_logger", + "reject_filters", + "reqenv", + "reqtasks", + "serde", + "serde_derive", + "serde_json", + "serde_yaml", + "slab", + "tera", + "thiserror", + "tokio", + "tokio-cron-scheduler", + "toml", + "url", + "uuid", + "warp", + "zterton 0.1.1", +] + +[[package]] +name = "zterton" +version = "0.1.1" +dependencies = [ + "anyhow", + "app_auth", + "app_auth_handlers", + "app_env", + "app_errors", + "app_tools", + "async-std", + "async-trait", + "base64", + "clap", + "dotenv", + "envmnt 0.9.0", + "glob", + "json", + "kloud", + "once_cell", + "parking_lot", + "pretty_env_logger", + "serde", + "serde_derive", + "serde_json", + "serde_yaml", + "tempfile", + "thiserror", + "toml", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..bd87494 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,79 @@ +[package] +name = "zterton" +version = "0.1.0" +authors = ["JesusPerez "] +edition = "2018" +publish = false + +[profile.dev] +opt-level = 0 + +[profile.release] +opt-level = 3 + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] + +anyhow = "1.0.40" +async-graphql = "2.8.4" +async-graphql-warp = "2.8.4" +async-jobs = "0.2.0" +async-std = "1.9.0" +tokio-cron-scheduler = "0.2.1" +base64 = "0.13.0" +bytes = "1.0.1" +casbin = "2.0.7" +chrono = "0.4.19" +envmnt = "0.9.0" +futures-util = "0.3.14" +http = "0.2.4" +#job_scheduler = "1.2.1" +# lazy_static = "1.4.0" +log = "0.4.14" +once_cell = "1.7.2" + +parking_lot = "0.11.1" +pretty_env_logger = "0.4" +serde = { version = "1.0.125", features = ["derive"] } +serde_derive = "1.0.125" +serde_json = "1.0.64" +serde_yaml = "0.8.17" +slab = "0.4.3" +tera = "1.8.0" +thiserror = "1.0.24" + +warp = { version = "0.3.1", features = ["default","websocket","tls","compression"] } +# salvo = { version = "0.5.5", features = ["full"] } +# salvo_extra = "0.5.5" +# salvo_macros = "0.5.5" +toml = "0.5.8" + +uuid = { version = "0.8.2", features = ["serde", "v5"] } +url = "2.2.1" +tokio = { version = "1.5.0", features = ["full"] } +#zterton = { path = "../../karyo/osmosys" } +zterton = { version = "0.1.1", path = "../lib/zterton" } + +app_tools = { version = "0.1.0", path = "../lib/utils/app_tools" } +app_env = { version = "0.1.0", path = "../lib/defs/app_env" } +app_auth = { version = "0.1.0", path = "../lib/defs/app_auth" } +app_errors = { version = "0.1.0", path = "../lib/defs/app_errors" } +kloud = { version = "0.1.0", path = "../lib/defs/kloud" } +gql_playground = { version = "0.1.0", path = "../lib/graphql/gql_playground" } +app_auth_handlers = { version = "0.1.0", path = "../lib/handlers/app_auth_handlers" } +app_file_filters = { version = "0.1.0", path = "../lib/filters/app_file_filters" } +app_file_handlers = { version = "0.1.0", path = "../lib/handlers/app_file_handlers" } +reqtasks = { version = "0.1.0", path = "../lib/handlers/reqtasks" } +reqenv = { version = "0.1.0", path = "../lib/handlers/reqenv" } +app_auth_filters = { version = "0.1.0", path = "../lib/filters/app_auth_filters" } +reject_filters = { version = "0.1.0", path = "../lib/filters/reject_filters" } + #kloud_entries_macro_derive = { path = "../lib/macros/kloud_entries_macro_derive" } +librecloud_kloud = { version = "0.1.0", path = "../lib/defs/librecloud/kloud" } +clds = { version = "0.1.0", path = "../lib/clds" } +#topographic_anatomy = { version = "0.1.0", path = "../lib/defs/bm/topographic_anatomy" } +#tracking_point = { version = "0.1.0", path = "../lib/defs/bm/tracking_point" } +key_of_life = { path = "../lib/key_of_life" } + +[dev-dependencies] +pretty_assertions = "0.7.2" diff --git a/src/defs.rs b/src/defs.rs new file mode 100644 index 0000000..d2b14f8 --- /dev/null +++ b/src/defs.rs @@ -0,0 +1,104 @@ +use std::collections::{BTreeMap}; +use app_env::{appenv::AppEnv, AppStore}; +use app_auth::{AuthStore}; +use kloud::{defs::KloudStore, datacontext::DataContext}; +use kloud::utils::load_from_module; + +use clds::clouds::defs::{ + CloudEnv, + Cloud, +}; +use librecloud_kloud::Kloud; +//use topographic_anatomy::TopographicAnatomy; +//use tracking_point::TrackingPoint; + +#[derive(Clone,Default)] +pub struct CollsData { + pub klouds: KloudStore, +// pub ta: KloudStore, +// pub tp: KloudStore, +} + +impl CollsData { + pub fn new(env: AppEnv) -> Self { + // dbg!(&env.contexts); + let (klouds_frmt, klouds_content) = load_from_module(env.to_owned(),"klouds"); + // let (ta_frmt, ta_content) = load_from_module(env.to_owned(),"ta"); + // let (tp_frmt, tp_content) = load_from_module(env.to_owned(),"tp"); + Self { + klouds: KloudStore::new( + Kloud::entries(&klouds_content,&klouds_frmt), + "klouds".to_owned(), + DataContext::default() + ), +/* + ta: KloudStore::new( + TopographicAnatomy::entries(&ta_content,&ta_frmt), + "ta".to_owned(), + DataContext::default() + ), + tp: KloudStore::new( + TrackingPoint::entries(&tp_content,&tp_frmt), + "tp".to_owned(), DataContext::default()) +*/ + } + } + pub async fn get_klouds_entries(coll_map: CollsData) -> BTreeMap { + let mut result = BTreeMap::new(); + let cur = coll_map.klouds.entries.read(); + for (key,value) in cur.iter() { + result.insert(key.to_owned(), value.to_owned()); + } + result + } +/* + pub async fn get_ta_entries(coll_map: CollsData) -> BTreeMap { + let mut result = BTreeMap::new(); + let cur = coll_map.ta.entries.read(); + for (key,value) in cur.iter() { + result.insert(key.to_owned(), value.to_owned()); + } + result + } + pub async fn get_tp_entries(coll_map: CollsData) -> BTreeMap { + let mut result = BTreeMap::new(); + let cur = coll_map.tp.entries.read(); + for (key,value) in cur.iter() { + result.insert(key.to_owned(), value.to_owned()); + } + result + } +*/ +} + +#[derive(Clone)] +pub struct AppDBs { + pub colls: CollsData, + pub app: AppStore, +} + +#[derive(Clone)] +pub struct DataDBs { + pub colls: CollsData, + pub app: AppStore, + pub auth: AuthStore, +} + +pub async fn load_cloud_env(cloud: &mut Cloud) { + let force: u8 = "-f".as_bytes()[0]; + cloud.env = CloudEnv::new(force,load_key().await); + cloud.providers = Cloud::load_providers().await; +} + +pub const KEY_PATH: &str = ".k"; +use key_of_life::get_key; + +pub async fn load_key() -> String { + let key_path = envmnt::get_or("KEY_PATH", KEY_PATH); + let key = get_key(&key_path,None).await; + if key.is_empty() { + std::process::exit(0x0100); + } + key +} + diff --git a/src/filters.rs b/src/filters.rs new file mode 100644 index 0000000..e2817a1 --- /dev/null +++ b/src/filters.rs @@ -0,0 +1,411 @@ +//use app_auth::{UserCtx}; +use kloud::{ + defs::{ + KloudQueryFilters, + KloudQueryDefsFilters, + KloudQueryLangFilters, +// KloudReqData, + KloudQueryConfigFilters, + }, +}; +use crate::defs::DataDBs; +use crate::handlers; +use clds::clouds::defs::{Cloud}; + +use warp::{ + filters::header::headers_cloned, + filters::method::method, + filters::BoxedFilter, + Filter, +}; + +/// The 4 ta filters combined. +// #[must_use] +// pub fn hello ( +// //) -> impl Filter + Clone { +// ) -> impl Filter + Clone { +// warp::any().map(move|| "Hola, World!") +// } + +/* + +let default_auth = warp::any().map(|| { + // something default +}); + +let auth = warp::header("authorization") + .map(|token: String| { + // something with token + }) + .or(default_auth) + .unify(); + + let context_extractor = warp::any().and( + warp::header::("authorization") + .map(|token: String| -> Context { + let token_data = match verify_jwt(token) { + Ok(t) => t, + Err(_) => return Context { user_id: 0 }, + }; + + Context { + user_id: token_data.claims.user_id, + } + }) + .or(warp::any().map(|| Context { user_id: 0 })) + .unify(), +); +*/ + +#[derive(Clone,Debug,Default)] +pub struct CollFilters { + pub prfx: String, // &'static str, +} +impl CollFilters { + pub fn new(prfx: &str) -> Self { + Self { + prfx: String::from(prfx), + } + } + pub fn filters_defs( + &self, + db: DataDBs, + cors: warp::cors::Builder, + //) -> impl Filter + Clone { + ) -> BoxedFilter<(impl warp::Reply,)> { + let defs_path: &'static str = Box::leak(format!("{}defs",&self.prfx).into_boxed_str()); + let lang_path: &'static str = Box::leak(format!("{}lang",&self.prfx).into_boxed_str()); + + self.list(db.clone(),defs_path,cors.clone()) + .or(self.langs(db.clone(),lang_path,cors.clone())) + .boxed() + } + pub fn filters_data( + &self, + db: DataDBs, + cors: warp::cors::Builder, + //) -> impl Filter + Clone { + ) -> BoxedFilter<(impl warp::Reply,)> { + let list_path: &'static str = Box::leak(format!("{}data",&self.prfx).into_boxed_str()); + // let table_path: &'static str = Box::leak(format!("{}table",&self.prfx).into_boxed_str()); + let defs_path: &'static str = Box::leak(format!("{}defs",&self.prfx).into_boxed_str()); + let lang_path: &'static str = Box::leak(format!("{}lang",&self.prfx).into_boxed_str()); + let insert_path: &'static str = Box::leak(format!("{}insert",&self.prfx).into_boxed_str()); + let delete_path: &'static str = Box::leak(format!("{}delete",&self.prfx).into_boxed_str()); + + self.list(db.clone(),list_path,cors.clone()) + // .or(self.table(db.clone(),table_path,cors.clone())) + .or(self.defs(db.clone(),defs_path,cors.clone())) + .or(self.langs(db.clone(),lang_path,cors.clone())) + // for others use "x" with path! macro + .or(self.insert(db.clone(),insert_path,cors.clone())) +// .or(self.update(db.clone())) + .or(self.delete(db.clone(),delete_path,cors.clone())) + .boxed() + } + pub fn filters_config( + &self, + db: DataDBs, + cloud: Cloud, + cors: warp::cors::Builder, + //) -> impl Filter + Clone { + ) -> BoxedFilter<(impl warp::Reply,)> { + let defs_path: &'static str = Box::leak(format!("{}defs",&self.prfx).into_boxed_str()); + let lang_path: &'static str = Box::leak(format!("{}lang",&self.prfx).into_boxed_str()); + let config_path: &'static str = Box::leak(format!("{}config",&self.prfx).into_boxed_str()); + let provision_path: &'static str = Box::leak(format!("{}provision",&self.prfx).into_boxed_str()); + let status_path: &'static str = Box::leak(format!("{}status",&self.prfx).into_boxed_str()); + let liveness_path: &'static str = Box::leak(format!("{}liveness",&self.prfx).into_boxed_str()); + self.config(db.clone(),cloud.clone(),config_path,cors.clone()) + .or(self.defs(db.clone(),defs_path,cors.clone())) + .or(self.langs(db.clone(),lang_path,cors.clone())) + .or(self.provision(db.clone(),cloud.clone(),provision_path,cors.clone())) + .or(self.status(db.clone(),cloud.clone(),status_path,cors.clone())) + .or(self.liveness(db.clone(),cloud.clone(),liveness_path,cors.clone())) + .boxed() + } + /// GET /ta?offset=3&limit=5 + pub fn list( + &self, + db: DataDBs, + path: &'static str, + cors: warp::cors::Builder, + //) -> impl Filter + Clone { + ) -> BoxedFilter<(impl warp::Reply,)> { + let prfx = self.prfx.to_owned(); + warp::path(path) + .and(warp::get()) + .and(warp::query::()) + .and(headers_cloned()) + .and(method()) + // .and_then(user_authentication) + // .and(warp::header::optional::("authorization")) + // .and(warp::header::optional::("accept-language")) + .and(self.with_db(db)) + .and(warp::any().map(move || prfx.to_owned())) + // and(self.with_auth(db.app.clone(),db.auth.clone())) + //.and(warp::any().map(move || &self.clone().db)) + // .map(|method: warp::http::Method, path: warp::path::FullPath, headers: warp::http::HeaderMap, opts: TaQueryFilters, db: AppDB | { + // dbg!(&headers); + // dbg!(&path); + // let mut req = warp::http::Request::builder() + // .method(method) + // .uri(path.as_str()) + // ; + // // // .body(body) + // // .expect("request builder"); + // // { *req.headers_mut() = headers; } + // req + // }) + .and_then(handlers::h_data::list) + .with(cors) + .boxed() + } + +/* + /// GET /ta?offset=3&limit=5 + pub fn table( + &self, + db: DataDBs, + path: &'static str, + cors: warp::cors::Builder, + //) -> impl Filter + Clone { + ) -> BoxedFilter<(impl warp::Reply,)> { + let prfx = self.prfx.to_owned(); + warp::path(path) + .and(warp::get()) + .and(warp::query::()) + .and(headers_cloned()) + .and(method()) + .and(self.with_db(db)) + .and(warp::any().map(move || prfx.to_owned())) + .and_then(handlers::h_data::table) + .with(cors) + .boxed() + } +*/ + + /// GET /ta?offset=3&limit=5 + pub fn defs( + &self, + db: DataDBs, + path: &'static str, + cors: warp::cors::Builder, + //) -> impl Filter + Clone { + ) -> BoxedFilter<(impl warp::Reply,)> { + let prfx = self.prfx.to_owned(); + warp::path(path) + .and(warp::get()) + .and(warp::query::()) + .and(headers_cloned()) + .and(method()) + .and(self.with_db(db)) + .and(warp::any().map(move || prfx.to_owned())) + .and_then(handlers::h_defs::defs) + .with(cors) + .boxed() + } + + /// POST /ta with JSON body + pub fn langs( + &self, + db: DataDBs, + path: &'static str, + cors: warp::cors::Builder, + //) -> impl Filter + Clone { + ) -> BoxedFilter<(impl warp::Reply,)> { + // warp::any().and( + let prfx = self.prfx.to_owned(); + warp::path(path) + .and(warp::get()) + // .and(warp::query::()) + // .and(warp::filters::query::raw()) + // .or(warp::any().map(|| String::default())) + // .unify() + .and(warp::query::()) + .and(headers_cloned()) + .and(method()) + // .and(with_auth(db.app.clone(),db.auth.clone())) + .and(self.with_db(db)) + .and(warp::any().map(move || prfx.to_owned())) + .and_then(handlers::h_defs::langs) + .with(cors) + .boxed() + } + + /// POST /ta with JSON body + pub fn insert( + &self, + db: DataDBs, + path: &'static str, + cors: warp::cors::Builder, + //) -> impl Filter + Clone { + ) -> BoxedFilter<(impl warp::Reply,)> { + let prfx = self.prfx.to_owned(); + warp::path(path) + .and(warp::post()) + .and(warp::body::json()) + .and(headers_cloned()) + .and(method()) + .and(self.with_db(db)) + .and(warp::any().map(move || prfx.to_owned())) + .and_then(handlers::h_data::insert) + .with(cors) + .boxed() + } + + // /// PUT /ta/:id with JSON body + // pub fn update( + // &self, + // db: DataDBs, + // //) -> impl Filter + Clone { + // ) -> BoxedFilter<(impl warp::Reply,)> { + // let prfx = self.prfx.to_owned(); + // warp::path(prfx.to_owned()) // , String) + // .and(warp::path::param()) + // .and(warp::put()) + // .and(self.json_body()) + // .and(self.with_db(db)) + // .and(warp::any().map(move || prfx.to_owned())) + // .and_then(handlers::h_data::update) + // .boxed() + // } + + /// DELETE /ta/:id + pub fn delete( + &self, + db: DataDBs, + path: &'static str, + cors: warp::cors::Builder, + //) -> impl Filter + Clone { + ) -> BoxedFilter<(impl warp::Reply,)> { + // We'll make one of our endpoints admin-only to show how authentication filters are used + // let admin_only = warp::header::exact("authorization", "Bearer admin"); + let prfx = self.prfx.to_owned(); + warp::path(path) + // .and(warp::path::param()) + // It is important to put the auth check _after_ the path filters. + // If we put the auth check before, the request `PUT /ta/invalid-string` + // would try this filter and reject because the authorization header doesn't match, + // rather because the param is wrong for that other path. + // .and(admin_only) + // .and(warp::delete()) + .and(warp::post()) + .and(warp::body::json()) + .and(headers_cloned()) + .and(method()) + .and(self.with_db(db)) + .and(warp::any().map(move || prfx.to_owned())) + .and_then(handlers::h_data::delete) + .with(cors) + .boxed() + } + /// GET /config?offset=3&limit=5 + pub fn config( + &self, + db: DataDBs, + cloud: Cloud, + path: &'static str, + cors: warp::cors::Builder, + //) -> impl Filter + Clone { + ) -> BoxedFilter<(impl warp::Reply,)> { + let prfx = self.prfx.to_owned(); + warp::path(path) + .and(warp::get()) + .and(warp::query::()) + .and(headers_cloned()) + .and(method()) + // .and_then(user_authentication) + // .and(warp::header::optional::("authorization")) + // .and(warp::header::optional::("accept-language")) + .and(self.with_db(db)) + .and(warp::any().map(move || cloud.to_owned())) + .and(warp::any().map(move || prfx.to_owned())) + .and_then(handlers::h_config::config) + .with(cors) + .boxed() + } + /// GET /provision?offset=3&limit=5 + pub fn provision( + &self, + db: DataDBs, + cloud: Cloud, + path: &'static str, + cors: warp::cors::Builder, + //) -> impl Filter + Clone { + ) -> BoxedFilter<(impl warp::Reply,)> { + let prfx = self.prfx.to_owned(); + warp::path(path) + .and(warp::get()) + .and(warp::query::()) + .and(headers_cloned()) + .and(method()) + // .and_then(user_authentication) + // .and(warp::header::optional::("authorization")) + // .and(warp::header::optional::("accept-language")) + .and(self.with_db(db)) + .and(warp::any().map(move || cloud.to_owned())) + .and(warp::any().map(move || prfx.to_owned())) + .and_then(handlers::h_config::provision) + .with(cors) + .boxed() + } + /// GET /status?offset=3&limit=5 + pub fn status( + &self, + db: DataDBs, + cloud: Cloud, + path: &'static str, + cors: warp::cors::Builder, + //) -> impl Filter + Clone { + ) -> BoxedFilter<(impl warp::Reply,)> { + let prfx = self.prfx.to_owned(); + warp::path(path) + .and(warp::get()) + .and(warp::query::()) + .and(headers_cloned()) + .and(method()) + // .and_then(user_authentication) + // .and(warp::header::optional::("authorization")) + // .and(warp::header::optional::("accept-language")) + .and(self.with_db(db)) + .and(warp::any().map(move || cloud.to_owned())) + .and(warp::any().map(move || prfx.to_owned())) + .and_then(handlers::h_config::status) + .with(cors) + .boxed() + } + /// GET /status?offset=3&limit=5 + pub fn liveness( + &self, + db: DataDBs, + cloud: Cloud, + path: &'static str, + cors: warp::cors::Builder, + //) -> impl Filter + Clone { + ) -> BoxedFilter<(impl warp::Reply,)> { + let prfx = self.prfx.to_owned(); + warp::path(path) + .and(warp::get()) + .and(warp::query::()) + .and(headers_cloned()) + .and(method()) + // .and_then(user_authentication) + // .and(warp::header::optional::("authorization")) + // .and(warp::header::optional::("accept-language")) + .and(self.with_db(db)) + .and(warp::any().map(move || cloud.to_owned())) + .and(warp::any().map(move || prfx.to_owned())) + .and_then(handlers::h_config::liveness) + .with(cors) + .boxed() + } + fn with_db(&self, db: DataDBs) -> impl Filter + Clone { + warp::any().map(move || db.clone()) + } + // fn json_body(&self) -> impl Filter + Clone { + // // When accepting a body, we want a JSON body + // // (and to reject huge payloads)... + // warp::body::content_length_limit(1024 * 16).and(warp::body::json()) + // } +} \ No newline at end of file diff --git a/src/graphql.rs b/src/graphql.rs new file mode 100644 index 0000000..461157c --- /dev/null +++ b/src/graphql.rs @@ -0,0 +1,172 @@ +/* +//! Async-graphql integration with Warp + +#![allow(clippy::type_complexity)] +#![forbid(unsafe_code)] + +pub mod batch_request; +pub mod errors; +pub mod requests; +pub mod subscriptions; +pub mod filters; + +pub use batch_request::{graphql_batch, graphql_batch_opts, BatchResponse}; +pub use errors::BadRequest; +pub use requests::{graphql, graphql_opts, Response}; +// pub use subscriptions::{graphql_subscription, graphql_subscription_with_data}; +*/ + +use async_graphql::scalar; +use async_graphql::{EmptyMutation, EmptySubscription, MergedObject, Schema, Enum}; +// use async_graphql_warp::{BadRequest, Response}; +use async_graphql_warp::{Response}; +use serde::{Serialize,Deserialize}; +//use http::StatusCode; +use std::convert::Infallible; +use warp::{ + filters::header::headers_cloned, + filters::method::method, + http::{method::Method, HeaderMap, HeaderValue}, + // http::{header::AUTHORIZATION, method::Method, HeaderMap, HeaderValue}, + // filters::path::{full, FullPath}, + http::Response as HttpResponse, + Filter, filters::BoxedFilter +}; + +use gql_playground::{playground_source,GraphQLPlaygroundConfig}; + //use async_graphql::http::{playground_source, GraphQLPlaygroundConfig}; + //use crate::topographic_anatomy::graphql::{QueryRoot as TaQueryRoot}; +// use crate::topographic_anatomy::{TopographicAnatomyQuery,TopographicAnatomyMutation}; // TopographicAnatomyChanged}; +// use crate::tracking_point::{TrackingPointQuery,TrackingPointMutation}; // TrackingPointChanged}; + // use zterton::auth::defs::{AuthStore}; + // use zterton::auth::filters::{with_auth}; +use crate::defs::{DataDBs}; +use reqenv::ReqEnv; + +#[derive(Enum, Eq, PartialEq, Copy, Clone)] +pub enum MutationType { + Created, + Updated, + Deleted, +} +impl Default for MutationType { + fn default() -> Self { MutationType::Updated } +} + +pub type JsonMap = serde_json::Map; + +#[derive(MergedObject, Default)] +struct Query( +// TopographicAnatomyQuery, +// TrackingPointQuery, +); + +#[derive(MergedObject, Default)] +struct Mutation( +// // TopographicAnatomyChanged, +// TopographicAnatomyMutation, +// // TrackingPointChanged, +// TrackingPointMutation, +); + +#[derive(Clone, Default, Debug, Serialize, Deserialize)] +pub struct Map { + pub data: JsonMap, +} +scalar!(Map); + +pub async fn graphiql( + path: &'static str, + giql_path: &'static str, + data_dbs: DataDBs, +) -> BoxedFilter<(impl warp::Reply,)> { +// ) -> impl Filter + Clone { + if giql_path.is_empty() { + warp::path(path) + .and(warp::get()) + .map(move || { + HttpResponse::builder() + .header("content-type", "text/html") + .body("".into()) + }) + .boxed() + } else { + warp::path(path) + .and(warp::get()) + .and(headers_cloned()) + .and(method()) + .and(with_db(data_dbs)) + // TODO check auth here + .map(move |_headers: HeaderMap, _method: Method, _db: DataDBs| { + let gql_playground_config: GraphQLPlaygroundConfig = GraphQLPlaygroundConfig::new(giql_path); + HttpResponse::builder() + .header("content-type", "text/html") + .body(playground_source(gql_playground_config)) +// .body(playground_source(GraphQLPlaygroundConfig::new("/gql"))) + }) + .boxed() + } + +// graphql_playground +// .or(graphql_post) + // .recover(|err: Rejection| async move { + // if let Some(BadRequest(err)) = err.find() { + // return Ok::<_, Infallible>(warp::reply::with_status( + // err.to_string(), + // StatusCode::BAD_REQUEST, + // )); + // } + // Ok(warp::reply::with_status( + // "INTERNAL_SERVER_ERROR".to_string(), + // StatusCode::INTERNAL_SERVER_ERROR, + // )) + // }) +} + + +pub async fn graphql( +// config: &Config, + path: &'static str, + data_dbs: DataDBs, + cors: warp::cors::Builder, +) -> BoxedFilter<(impl warp::Reply,)> { +// ) -> impl Filter + Clone { + + let schema = Schema::build( Query::default(), Mutation::default(), EmptySubscription) + .data(data_dbs.clone()) + .finish(); + + // warp::path!("gql").and(async_graphql_warp::graphql(schema)).and_then( + warp::path(path) + .and(headers_cloned()) + .and(method()) + .and(with_db(data_dbs)) + .and(async_graphql_warp::graphql(schema)).and_then( + | headers: HeaderMap, method: Method, db: DataDBs, + (schema, request): ( + Schema, + async_graphql::Request, + )| async move { + let reqenv = ReqEnv::new(db.app, db.auth, headers, method, "/gql", "gql", "gql"); + match reqenv.user_authentication().await { + Ok(_auth) => { + // dbg!("auth: {}",&auth); + Ok::<_, Infallible>(Response::from(schema.execute(request).await)) + }, + Err(e) => { + let result = format!("Error: no credentials found"); + println!("gql:{} {}",&result,e); + let empty_schema = Schema::build( Query::default(), EmptyMutation, EmptySubscription) + .finish(); + Ok::<_, Infallible>(Response::from(empty_schema.execute(request).await)) + } + } + } + ) + .with(cors) + .boxed() +} + +fn with_db(db: DataDBs) -> impl Filter + Clone { + warp::any().map(move || db.clone()) +} \ No newline at end of file diff --git a/src/handlers.rs b/src/handlers.rs new file mode 100644 index 0000000..2601400 --- /dev/null +++ b/src/handlers.rs @@ -0,0 +1,3 @@ +pub mod h_config; +pub mod h_data; +pub mod h_defs; \ No newline at end of file diff --git a/src/handlers/h_config.rs b/src/handlers/h_config.rs new file mode 100644 index 0000000..580d491 --- /dev/null +++ b/src/handlers/h_config.rs @@ -0,0 +1,564 @@ +// use std::convert::Infallible; +// use std::collections::HashMap; +use warp::{ + // http::{StatusCode}, + http::{method::Method, HeaderMap, HeaderValue}, + Reply, Rejection, +}; +use reqenv::ReqEnv; +// use app_env::profile::Profile; +// use app_env::config::Config; +use kloud::{ + defs::{ + KloudQueryConfigFilters, + }, +}; +use clds::clouds::defs::{Cloud}; +use crate::defs::{DataDBs}; // ,CollsData}; +use clds::clouds::on_clouds::{on_cloud_req,on_cloud_name_req}; + +pub async fn cloud_req(reqname: &str,cloud: &Cloud,reqenv: &ReqEnv,opts: &KloudQueryConfigFilters) -> String { + let result: String; + if opts.grp.is_empty() { + result = on_cloud_req(&reqname,&cloud,&reqenv,&opts.tsksrvcs,&opts.srvrs,&opts.cld).await; + } else if opts.name.is_empty() { + let source = format!("{}/{}",&opts.cld,&opts.grp); + result = on_cloud_name_req(&reqname,&cloud,&reqenv,&opts.tsksrvcs,&opts.srvrs,&source).await; + } else { + let source = format!("{}/{}/{}",&opts.cld,&opts.grp,&opts.name); + result = on_cloud_name_req(&reqname,&cloud,&reqenv,&opts.tsksrvcs,&opts.srvrs,&source).await; + } + match reqname { + "config" => { + result.to_owned() + }, + "status" => { + result.to_owned() + }, + "provision" => { + result.to_owned() + }, + "liveness" => { + result.to_owned() + }, + _ => { + result.to_owned() + } + } +} +pub async fn config ( + opts: KloudQueryConfigFilters, + header: HeaderMap, + method: Method, +// user: UserCtx, + db: DataDBs, + cloud: Cloud, + prfx: String, +// path: warp::path::FullPath, headers: warp::http::HeaderMap +) -> Result { + // dbg!("{:#?}",&db); + // dbg!("{:#?}",&header); + // dbg!("{:#?}",&opts); + let reqenv = ReqEnv::new(db.app, db.auth, header, method, "/config", "config", &prfx); + // get_pkgs_vers(&mut cloud).await?; + + // cloud.env.listhosts = String::from(listhosts); + // if let Some(lang_str) = header.get("accept-language") { + // println!("{:?}",&lang_str); + // } +// println!("User: {} | {}",&user.user_id,&user.token); + + // println!("LANG: {}",language); + // if prfx.as_str() == "ta" { + // let cur = db.colls.ta.entries.read(); + // } + // let allow_origin = reqenv.config().allow_origin; + // let result = cloud_req("config",&cloud,&reqenv,&opts).await; + // println!("Result: {}",&result); + // return Ok(warp::http::Response::builder() + // .body(result.to_string()) + // .into_response()) + // ; + match reqenv.user_authentication().await { + Ok(_auth) => { + // dbg!("auth: {}",&auth); + match prfx.as_str() { + "kloud" => { + let result = cloud_req("config",&cloud,&reqenv,&opts).await; + // println!("Result: {}",&result); + Ok(warp::http::Response::builder() + .body(result.to_string()) + .into_response()) + }, + "ta" => { +/* let data = CollsData::get_ta_entries(db.colls.clone()).await; + let data_out: Vec = data.iter().enumerate().filter(|(idx,(itm,_))|{ + let mut skip = false; + if !opts.id.is_empty() && !itm.contains(&opts.id) { skip = true; } + if opts.start > 0 && idx < &(opts.start as usize) { skip = true; } + if opts.end > 0 && idx > &(opts.end as usize) { skip = true; } + !skip + }).map(|(_,(_,value))| value).cloned().collect(); +*/ + let data_out: Vec = Vec::new(); + let result = serde_json::to_string(&data_out).unwrap_or_else(|_| String::from("")); + Ok(warp::http::Response::builder() + .body(result.to_string()) + .into_response()) + /* + Ok(warp::reply::with_header( + // warp::reply::json(&CollsData::get_ta_entries(db.colls.clone()).await), + warp::http::Response::new(result), + // warp::http::Response::new(body), + "Access-Control-Allow-Origin", + &allow_origin)) + // Ok(warp::reply::json(&result)) + */ + }, + "tp" => { + // let result = CollsData::get_tp_entries(db.colls.clone()).await; +/* let data = CollsData::get_tp_entries(db.colls.clone()).await; + let data_out: Vec = data.iter().enumerate().filter(|(idx,(itm,_))|{ + let mut skip = false; + if !opts.id.is_empty() && !itm.contains(&opts.id) { skip = true; } + if opts.start > 0 && idx < &(opts.start as usize) { skip = true; } + if opts.end > 0 && idx > &(opts.end as usize) { skip = true; } + !skip + }).map(|(_,(_,value))| value).cloned().collect(); +*/ + let data_out: Vec = Vec::new(); + let result = serde_json::to_string(&data_out).unwrap_or_else(|_| String::from("")); + Ok(warp::http::Response::builder() + .body(result.to_string()) + .into_response()) + /* + Ok(warp::reply::with_header( + // warp::reply::json(&CollsData::get_tp_entries(db.colls.clone()).await), + warp::http::Response::new(result), + // warp::http::Response::new(body), + "Access-Control-Allow-Origin", + &allow_origin)) + // Ok(warp::reply::json(&result)) + */ + }, + _ => { + //let result=""; + let result = format!("list for '{}' undefined",&prfx); + // (AuthError::UserNotFoundError.to_string()) + println!("{}",&result); + Ok(warp::http::Response::builder() + .body(result.to_string()) + .into_response()) + /* + Ok(warp::reply::with_header( + // warp::reply::json(&""), + warp::http::Response::new(result), + // warp::http::Response::new(body), + "Access-Control-Allow-Origin", + &allow_origin)) + */ + }, + } + }, + Err(e) => { + let result = format!("Error: no credentials found"); + println!("{}",e); + Ok(warp::http::Response::builder() + .body(result.to_string()) + .into_response()) + /* + Ok(warp::reply::with_header( + // warp::reply::json(&""), + warp::http::Response::new(result), + "Access-Control-Allow-Origin", + &allow_origin)) + */ + }, + } +} +pub async fn provision ( + opts: KloudQueryConfigFilters, + header: HeaderMap, + method: Method, +// user: UserCtx, + db: DataDBs, + cloud: Cloud, + prfx: String, +// path: warp::path::FullPath, headers: warp::http::HeaderMap +) -> Result { +// dbg!("{:#?}",&db); +// dbg!("{:#?}",&header); +// dbg!("{:#?}",&opts); + let reqenv = ReqEnv::new(db.app, db.auth, header, method, "/provision", "provision", &prfx); + // if let Some(lang_str) = header.get("accept-language") { + // println!("{:?}",&lang_str); + // } +// println!("User: {} | {}",&user.user_id,&user.token); + + // println!("LANG: {}",language); + // if prfx.as_str() == "ta" { + // let cur = db.colls.ta.entries.read(); + // } + // let allow_origin = reqenv.config().allow_origin; +// let test = true; +// if test == true { + let result = cloud_req("provision",&cloud,&reqenv,&opts).await; + println!("Result: {}",&result); +// return Ok(warp::http::Response::builder() +// .body(result.to_string()) +// .into_response()); +// } else { + match reqenv.user_authentication().await { + Ok(_auth) => { + // dbg!("auth: {}",&auth); + match prfx.as_str() { + "kloud" => { + let result = cloud_req("provision",&cloud,&reqenv,&opts).await; + println!("Result: {}",&result); + Ok(warp::http::Response::builder() + .body(result.to_string()) + .into_response()) + }, + "ta" => { +/* let data = CollsData::get_ta_entries(db.colls.clone()).await; + let data_out: Vec = data.iter().enumerate().filter(|(idx,(itm,_))|{ + let mut skip = false; + if !opts.id.is_empty() && !itm.contains(&opts.id) { skip = true; } + if opts.start > 0 && idx < &(opts.start as usize) { skip = true; } + if opts.end > 0 && idx > &(opts.end as usize) { skip = true; } + !skip + }).map(|(_,(_,value))| value).cloned().collect(); +*/ + let data_out: Vec = Vec::new(); + let result = serde_json::to_string(&data_out).unwrap_or_else(|_| String::from("")); + Ok(warp::http::Response::builder() + .body(result.to_string()) + .into_response()) + /* + Ok(warp::reply::with_header( + // warp::reply::json(&CollsData::get_ta_entries(db.colls.clone()).await), + warp::http::Response::new(result), + // warp::http::Response::new(body), + "Access-Control-Allow-Origin", + &allow_origin)) + // Ok(warp::reply::json(&result)) + */ + }, + "tp" => { + // let result = CollsData::get_tp_entries(db.colls.clone()).await; +/* let data = CollsData::get_tp_entries(db.colls.clone()).await; + let data_out: Vec = data.iter().enumerate().filter(|(idx,(itm,_))|{ + let mut skip = false; + if !opts.id.is_empty() && !itm.contains(&opts.id) { skip = true; } + if opts.start > 0 && idx < &(opts.start as usize) { skip = true; } + if opts.end > 0 && idx > &(opts.end as usize) { skip = true; } + !skip + }).map(|(_,(_,value))| value).cloned().collect(); +*/ + let data_out: Vec = Vec::new(); + let result = serde_json::to_string(&data_out).unwrap_or_else(|_| String::from("")); + Ok(warp::http::Response::builder() + .body(result.to_string()) + .into_response()) + /* + Ok(warp::reply::with_header( + // warp::reply::json(&CollsData::get_tp_entries(db.colls.clone()).await), + warp::http::Response::new(result), + // warp::http::Response::new(body), + "Access-Control-Allow-Origin", + &allow_origin)) + // Ok(warp::reply::json(&result)) + */ + }, + _ => { + //let result=""; + let result = format!("list for '{}' undefined",&prfx); + // (AuthError::UserNotFoundError.to_string()) + println!("{}",&result); + Ok(warp::http::Response::builder() + .body(result.to_string()) + .into_response()) + /* + Ok(warp::reply::with_header( + // warp::reply::json(&""), + warp::http::Response::new(result), + // warp::http::Response::new(body), + "Access-Control-Allow-Origin", + &allow_origin)) + */ + }, + } + }, + Err(e) => { + let result = format!("Error: no credentials found"); + println!("{}",e); + Ok(warp::http::Response::builder() + .body(result.to_string()) + .into_response()) + /* + Ok(warp::reply::with_header( + // warp::reply::json(&""), + warp::http::Response::new(result), + "Access-Control-Allow-Origin", + &allow_origin)) + */ + }, + } + // } +} +pub async fn status ( + opts: KloudQueryConfigFilters, + header: HeaderMap, + method: Method, +// user: UserCtx, + db: DataDBs, + cloud: Cloud, + prfx: String, +// path: warp::path::FullPath, headers: warp::http::HeaderMap +) -> Result { +// dbg!("{:#?}",&db); +// dbg!("{:#?}",&header); +// dbg!("{:#?}",&opts); + let reqenv = ReqEnv::new(db.app, db.auth, header, method, "/status", "status", &prfx); + // if let Some(lang_str) = header.get("accept-language") { + // println!("{:?}",&lang_str); + // } +// println!("User: {} | {}",&user.user_id,&user.token); + + // println!("LANG: {}",language); + // if prfx.as_str() == "ta" { + // let cur = db.colls.ta.entries.read(); + // } + // let allow_origin = reqenv.config().allow_origin; +// let result = cloud_req("status",&cloud,&reqenv,&opts).await; +// println!("Result: {}",&result); +// return Ok(warp::http::Response::builder() +// .body(result.to_string()) +// .into_response()); + match reqenv.user_authentication().await { + Ok(_auth) => { + // dbg!("auth: {}",&auth); + match prfx.as_str() { + "kloud" => { + let result = cloud_req("status",&cloud,&reqenv,&opts).await; + println!("Result: {}",&result); + Ok(warp::http::Response::builder() + .body(result.to_string()) + .into_response()) + }, + "ta" => { +/* let data = CollsData::get_ta_entries(db.colls.clone()).await; + let data_out: Vec = data.iter().enumerate().filter(|(idx,(itm,_))|{ + let mut skip = false; + if !opts.id.is_empty() && !itm.contains(&opts.id) { skip = true; } + if opts.start > 0 && idx < &(opts.start as usize) { skip = true; } + if opts.end > 0 && idx > &(opts.end as usize) { skip = true; } + !skip + }).map(|(_,(_,value))| value).cloned().collect(); +*/ + let data_out: Vec = Vec::new(); + let result = serde_json::to_string(&data_out).unwrap_or_else(|_| String::from("")); + Ok(warp::http::Response::builder() + .body(result.to_string()) + .into_response()) + /* + Ok(warp::reply::with_header( + // warp::reply::json(&CollsData::get_ta_entries(db.colls.clone()).await), + warp::http::Response::new(result), + // warp::http::Response::new(body), + "Access-Control-Allow-Origin", + &allow_origin)) + // Ok(warp::reply::json(&result)) + */ + }, + "tp" => { + // let result = CollsData::get_tp_entries(db.colls.clone()).await; +/* let data = CollsData::get_tp_entries(db.colls.clone()).await; + let data_out: Vec = data.iter().enumerate().filter(|(idx,(itm,_))|{ + let mut skip = false; + if !opts.id.is_empty() && !itm.contains(&opts.id) { skip = true; } + if opts.start > 0 && idx < &(opts.start as usize) { skip = true; } + if opts.end > 0 && idx > &(opts.end as usize) { skip = true; } + !skip + }).map(|(_,(_,value))| value).cloned().collect(); +*/ + let data_out: Vec = Vec::new(); + let result = serde_json::to_string(&data_out).unwrap_or_else(|_| String::from("")); + Ok(warp::http::Response::builder() + .body(result.to_string()) + .into_response()) + /* + Ok(warp::reply::with_header( + // warp::reply::json(&CollsData::get_tp_entries(db.colls.clone()).await), + warp::http::Response::new(result), + // warp::http::Response::new(body), + "Access-Control-Allow-Origin", + &allow_origin)) + // Ok(warp::reply::json(&result)) + */ + }, + _ => { + //let result=""; + let result = format!("list for '{}' undefined",&prfx); + // (AuthError::UserNotFoundError.to_string()) + println!("{}",&result); + Ok(warp::http::Response::builder() + .body(result.to_string()) + .into_response()) + /* + Ok(warp::reply::with_header( + // warp::reply::json(&""), + warp::http::Response::new(result), + // warp::http::Response::new(body), + "Access-Control-Allow-Origin", + &allow_origin)) + */ + }, + } + }, + Err(e) => { + let result = format!("Error: no credentials found"); + println!("{}",e); + Ok(warp::http::Response::builder() + .body(result.to_string()) + .into_response()) + /* + Ok(warp::reply::with_header( + // warp::reply::json(&""), + warp::http::Response::new(result), + "Access-Control-Allow-Origin", + &allow_origin)) + */ + }, + } +} +pub async fn liveness ( + opts: KloudQueryConfigFilters, + header: HeaderMap, + method: Method, +// user: UserCtx, + db: DataDBs, + cloud: Cloud, + prfx: String, +// path: warp::path::FullPath, headers: warp::http::HeaderMap +) -> Result { +// dbg!("{:#?}",&db); +// dbg!("{:#?}",&header); +// dbg!("{:#?}",&opts); + let reqenv = ReqEnv::new(db.app, db.auth, header, method, "/liveness", "liveness", &prfx); + // if let Some(lang_str) = header.get("accept-language") { + // println!("{:?}",&lang_str); + // } +// println!("User: {} | {}",&user.user_id,&user.token); + + // println!("LANG: {}",language); + // if prfx.as_str() == "ta" { + // let cur = db.colls.ta.entries.read(); + // } + // let allow_origin = reqenv.config().allow_origin; +// let test = true; +// if test == true { +// let result = cloud_req("liveness",&cloud,&reqenv,&opts).await; +// println!("Result: {}",&result); +// return Ok(warp::http::Response::builder() +// .body(result.to_string()) +// .into_response()); +// } else { + match reqenv.user_authentication().await { + Ok(_auth) => { + // dbg!("auth: {}",&auth); + match prfx.as_str() { + "kloud" => { + let result = cloud_req("liveness",&cloud,&reqenv,&opts).await; + println!("Result: {}",&result); + Ok(warp::http::Response::builder() + .body(result.to_string()) + .into_response()) + }, + "ta" => { +/* let data = CollsData::get_ta_entries(db.colls.clone()).await; + let data_out: Vec = data.iter().enumerate().filter(|(idx,(itm,_))|{ + let mut skip = false; + if !opts.id.is_empty() && !itm.contains(&opts.id) { skip = true; } + if opts.start > 0 && idx < &(opts.start as usize) { skip = true; } + if opts.end > 0 && idx > &(opts.end as usize) { skip = true; } + !skip + }).map(|(_,(_,value))| value).cloned().collect(); +*/ + let data_out: Vec = Vec::new(); + let result = serde_json::to_string(&data_out).unwrap_or_else(|_| String::from("")); + Ok(warp::http::Response::builder() + .body(result.to_string()) + .into_response()) + /* + Ok(warp::reply::with_header( + // warp::reply::json(&CollsData::get_ta_entries(db.colls.clone()).await), + warp::http::Response::new(result), + // warp::http::Response::new(body), + "Access-Control-Allow-Origin", + &allow_origin)) + // Ok(warp::reply::json(&result)) + */ + }, + "tp" => { + // let result = CollsData::get_tp_entries(db.colls.clone()).await; +/* let data = CollsData::get_tp_entries(db.colls.clone()).await; + let data_out: Vec = data.iter().enumerate().filter(|(idx,(itm,_))|{ + let mut skip = false; + if !opts.id.is_empty() && !itm.contains(&opts.id) { skip = true; } + if opts.start > 0 && idx < &(opts.start as usize) { skip = true; } + if opts.end > 0 && idx > &(opts.end as usize) { skip = true; } + !skip + }).map(|(_,(_,value))| value).cloned().collect(); +*/ + let data_out: Vec = Vec::new(); + let result = serde_json::to_string(&data_out).unwrap_or_else(|_| String::from("")); + Ok(warp::http::Response::builder() + .body(result.to_string()) + .into_response()) + /* + Ok(warp::reply::with_header( + // warp::reply::json(&CollsData::get_tp_entries(db.colls.clone()).await), + warp::http::Response::new(result), + // warp::http::Response::new(body), + "Access-Control-Allow-Origin", + &allow_origin)) + // Ok(warp::reply::json(&result)) + */ + }, + _ => { + //let result=""; + let result = format!("list for '{}' undefined",&prfx); + // (AuthError::UserNotFoundError.to_string()) + println!("{}",&result); + Ok(warp::http::Response::builder() + .body(result.to_string()) + .into_response()) + /* + Ok(warp::reply::with_header( + // warp::reply::json(&""), + warp::http::Response::new(result), + // warp::http::Response::new(body), + "Access-Control-Allow-Origin", + &allow_origin)) + */ + }, + } + }, + Err(e) => { + let result = format!("Error: no credentials found"); + println!("{}",e); + Ok(warp::http::Response::builder() + .body(result.to_string()) + .into_response()) + /* + Ok(warp::reply::with_header( + // warp::reply::json(&""), + warp::http::Response::new(result), + "Access-Control-Allow-Origin", + &allow_origin)) + */ + }, + } + // } +} \ No newline at end of file diff --git a/src/handlers/h_data.rs b/src/handlers/h_data.rs new file mode 100644 index 0000000..9c28ffe --- /dev/null +++ b/src/handlers/h_data.rs @@ -0,0 +1,442 @@ +// use std::convert::Infallible; +// use std::collections::HashMap; +use warp::{ + // http::{StatusCode}, + http::{method::Method, HeaderMap, HeaderValue}, + Reply, Rejection, +}; +use reqenv::ReqEnv; +/* +use crate::topographic_anatomy::defs::{TaStore,TaData,TaQueryFilters,TopographicAnatomy}; +use zterton::kloud::utils::{lng_t,get_lang_items_str,load_lang}; +//use zterton::models::{AppStore, AppData}; + +use crate::defs::AppDB; +use crate::auth::defs::{ + AuthError, + Sessions, + UserCtx, + UserMap, + WebResult, + SharedEnforcer, + BEARER_PREFIX, + custom_reject +}; +*/ +// use ::topographic_anatomy::{TopographicAnatomy}; +// use ::tracking_point::{TrackingPoint}; +// use crate::tracking_point::defs::{TrackingPoint}; +//use app_auth::{UserCtx}; +use kloud::{ + defs::{ + KloudQueryFilters, + KloudReqData, + }, +}; +use crate::defs::{DataDBs}; // ,CollsData}; +/* +|method: http::Method, path: warp::path::FullPath, headers: http::HeaderMap, body| { + let mut reqenv = http::Request::builder() + .method(method) + .uri(path.as_str()) + .body(body) + .expect("request builder"); + { *reqenv.headers_mut() = headers; } + req +*/ +/* +pub async fn table( + opts: KloudQueryFilters, + header: HeaderMap, + method: Method, + db: DataDBs, + prfx: String, +) -> Result { + let reqenv = ReqEnv::new(db.app, db.auth, header, method, "", "table", &prfx); + let lang = reqenv.lang(); + let mut ctx = reqenv.ctx(); + let req_context = ""; + let app_ctx: &str; + if ! req_context.is_empty() && req_context != reqenv.config().default_module.as_str() { + app_ctx = req_context; + } else { + app_ctx = ""; + } + let lang_items = serde_json::to_string(&LangItems::new("langs/ta","es","yaml")) + .unwrap_or_else(|_| String::from("")); + let mut data_hash: HashMap = HashMap::new(); + data_hash.insert("lang".to_string(), lang.to_owned()); + data_hash.insert("lang_txt".to_string(), lang_items.to_owned()); + + // let allow_origin = reqenv.config().allow_origin; + match reqenv.user_authentication().await { + Ok(auth) => { + dbg!("auth: {}",&auth); + // let mut res = String::from(""); + // let res = if let Some(name) = query.get("name") { + // submitted form + match reqenv.req + .render_page( + &mut ctx, + reqenv.config().templates_path.as_str(), + "ta_table/index.html", + "index.html", + format!("ta_table/{}.toml", lang.to_owned()) + .to_owned() + .as_str(), + &mut data_hash, + app_ctx, + ) + .await { + Ok(page) => + Ok(warp::http::Response::builder() + .body(page) + .into_response()), + /* + Ok(warp::reply::with_header( + warp::http::Response::new(page), + "Access-Control-Allow-Origin", + &allow_origin)), + */ + Err(err) => + Ok(warp::http::Response::builder() + .body(err.to_string()) + .into_response()), + /* + Ok(warp::reply::with_header( + warp::http::Response::new(err.to_string()), + "Access-Control-Allow-Origin", + &allow_origin)), + */ + } + }, + Err(e) => { + let result = format!("Error: no credentials found"); + println!("{}",e); + Ok(warp::http::Response::builder() + .body(result.to_string()) + .into_response()) + /* + Ok(warp::reply::with_header( + warp::http::Response::new(result), + "Access-Control-Allow-Origin", + &allow_origin)) + */ + }, + } +} +*/ +pub async fn list( + _opts: KloudQueryFilters, + header: HeaderMap, + method: Method, +// user: UserCtx, + db: DataDBs, + prfx: String, +// path: warp::path::FullPath, headers: warp::http::HeaderMap +) -> Result { +// dbg!("{:#?}",&db); +// dbg!("{:#?}",&header); +// dbg!("{:#?}",&opts); + let reqenv = ReqEnv::new(db.app, db.auth, header, method, "/list", "list", &prfx); + // if let Some(lang_str) = header.get("accept-language") { + // println!("{:?}",&lang_str); + // } +// println!("User: {} | {}",&user.user_id,&user.token); + + // println!("LANG: {}",language); + // if prfx.as_str() == "ta" { + // let cur = db.colls.ta.entries.read(); + // } + // let allow_origin = reqenv.config().allow_origin; + match reqenv.user_authentication().await { + Ok(_auth) => { + // dbg!("auth: {}",&auth); + match prfx.as_str() { + "ta" => { +/* let data = CollsData::get_ta_entries(db.colls.clone()).await; + let data_out: Vec = data.iter().enumerate().filter(|(idx,(itm,_))|{ + let mut skip = false; + if !opts.id.is_empty() && !itm.contains(&opts.id) { skip = true; } + if opts.start > 0 && idx < &(opts.start as usize) { skip = true; } + if opts.end > 0 && idx > &(opts.end as usize) { skip = true; } + !skip + }).map(|(_,(_,value))| value).cloned().collect(); +*/ + let data_out: Vec = Vec::new(); + let result = serde_json::to_string(&data_out).unwrap_or_else(|_| String::from("")); + Ok(warp::http::Response::builder() + .body(result.to_string()) + .into_response()) + /* + Ok(warp::reply::with_header( + // warp::reply::json(&CollsData::get_ta_entries(db.colls.clone()).await), + warp::http::Response::new(result), + // warp::http::Response::new(body), + "Access-Control-Allow-Origin", + &allow_origin)) + // Ok(warp::reply::json(&result)) + */ + }, + "tp" => { + // let result = CollsData::get_tp_entries(db.colls.clone()).await; +/* let data = CollsData::get_tp_entries(db.colls.clone()).await; + let data_out: Vec = data.iter().enumerate().filter(|(idx,(itm,_))|{ + let mut skip = false; + if !opts.id.is_empty() && !itm.contains(&opts.id) { skip = true; } + if opts.start > 0 && idx < &(opts.start as usize) { skip = true; } + if opts.end > 0 && idx > &(opts.end as usize) { skip = true; } + !skip + }).map(|(_,(_,value))| value).cloned().collect(); +*/ + let data_out: Vec = Vec::new(); + let result = serde_json::to_string(&data_out).unwrap_or_else(|_| String::from("")); + Ok(warp::http::Response::builder() + .body(result.to_string()) + .into_response()) + /* + Ok(warp::reply::with_header( + // warp::reply::json(&CollsData::get_tp_entries(db.colls.clone()).await), + warp::http::Response::new(result), + // warp::http::Response::new(body), + "Access-Control-Allow-Origin", + &allow_origin)) + // Ok(warp::reply::json(&result)) + */ + }, + _ => { + //let result=""; + let result = format!("list for '{}' undefined",&prfx); + // (AuthError::UserNotFoundError.to_string()) + println!("{}",&result); + Ok(warp::http::Response::builder() + .body(result.to_string()) + .into_response()) + /* + Ok(warp::reply::with_header( + // warp::reply::json(&""), + warp::http::Response::new(result), + // warp::http::Response::new(body), + "Access-Control-Allow-Origin", + &allow_origin)) + */ + }, + } + }, + Err(e) => { + let result = format!("Error: no credentials found"); + println!("{}",e); + Ok(warp::http::Response::builder() + .body(result.to_string()) + .into_response()) + /* + Ok(warp::reply::with_header( + // warp::reply::json(&""), + warp::http::Response::new(result), + "Access-Control-Allow-Origin", + &allow_origin)) + */ + }, + } + /* + let db_appdata = get_db_appdata().await; + let reqtasks = ReqEnv::new(&db_appdata, req, "data"); + + // if init at request + //if let Err(e) = set_ta_data().await { + if set_ta_data(&reqtasks.env()).await.is_err() { + res.render_html_text("Error"); + } +*/ +// warp::reply::json(&result), +// let body: String = "".to_string(); + + // Ok(warp::reply::with_header( + // warp::reply::json(&result), + // // warp::http::Response::new(body), + // "Access-Control-Allow-Origin", + // &allow_origin)) + // Ok(warp::reply::json(&result)) +} +// warp::generic::Either<(std::string::String,), (std::string::String,)> +// pub async fn create( +// create: TopographicAnatomy, +// db: DataDBs, +// prfx: String, +// ) -> Result { +// /* +// log::debug!("create_ta: {:?}", create); + +// let mut vec = db.ta.lock().await; + +// for ta in vec.iter() { +// if ta.id == create.id { +// log::debug!(" -> id already exists: {}", create.id); +// // ta with id already exists, return `400 BadRequest`. +// return Ok(StatusCode::BAD_REQUEST); +// } +// } + +// // No existing ta with id, so insert and return `201 Created`. +// vec.push(create); +// */ +// Ok(StatusCode::CREATED) +// } + +pub async fn insert( + _data: KloudReqData, + header: HeaderMap, + method: Method, + db: DataDBs, + prfx: String, +) -> Result { + #[allow(unused_mut)] + let mut result = String::from(""); + let reqenv = ReqEnv::new(db.app, db.auth, header, method, "/insert", "insert", &prfx); + match reqenv.user_authentication().await { + Ok(_auth) => { + // dbg!("auth: {}",&auth); +/* + match prfx.as_str() { + "ta" => { + match serde_json::from_str::(&data.str_data) { + Ok(item) => { + if db.colls.ta.entries.read().contains_key(&data.id) { + if data.id != item.id { + db.colls.ta.entries.write().remove(&data.id); + println!("DELETE topographic_anatomy id: {}",&data.id); + } + db.colls.ta.entries.write().insert(item.id.to_owned(), item.to_owned()); + println!("UPDATED topographic_anatomy id: {}",&item.id); + result = format!("UPDATED: {}",&item.id); + } else { + db.colls.ta.entries.write().insert(item.id.to_owned(), item.to_owned()); + println!("CREATED topographic_anatomy id: {}",&item.id); + result = format!("CREATED: {}",&item.id); + } + // TODO create a job + /* + let ta_data = CollsData::get_ta_entries(db.colls.clone()).await; + let ta_data_dump = serde_yaml::to_string(&ta_data).unwrap_or_else(|_| String::from("")); + if ta_data_dump != "" { + let module = reqenv.module(); + let ta_path = format!("{}/{}.{}",&module.store_root,&module.store_path,&module.store_frmt); + let _fs_res = tokio::fs::write(&ta_path, ta_data_dump).await.map_err(|e| { + eprint!("error writing file: {}", e); + }); + } + */ + }, + Err(e) => { + println!("Error parse insert topographic_anatomy: {}",e); + result = format!("Error parse ta: {}",&e); + } + } + }, + "tp" => { + // let result = CollsData::get_tp_entries(db.colls.clone()).await; + match serde_json::from_str::(&data.str_data) { + Ok(item) => { + if db.colls.tp.entries.read().contains_key(&data.id) { + db.colls.tp.entries.write().insert(item.id.to_owned(), item.to_owned()); + println!("UPDATED tracking_point id: {}",&item.id); + result = format!("UPDATED: {}",&item.id); + } else { + db.colls.tp.entries.write().insert(item.id.to_owned(), item.to_owned()); + println!("CREATED tracking_point id: {}",&item.id); + result = format!("CREATED: {}",&item.id); + } + }, + Err(e) => { + println!("Error {} parse insert : {}",&prfx,e); + result = format!("ERROR: {} parse insert: '{}'",&prfx,e); + } + } + }, + _ => { + result = format!("ERROR: list for '{}' undefined",&prfx); + // (AuthError::UserNotFoundError.to_string()) + println!("{}",&result); + } + }; +*/ + }, + Err(e) => { + let result = format!("Error: no credentials found"); + println!("{}: {}",&result,e); + }, + } + let json_res = format!("{{ \"res\": \"{}\"}}", result); + Ok(warp::http::Response::builder() + .body(json_res.to_string()) + .into_response()) + // If the for loop didn't return OK, then the ID doesn't exist... + // Ok(StatusCode::NOT_FOUND) +} + +pub async fn delete( + data: KloudReqData, + header: HeaderMap, + method: Method, + db: DataDBs, + prfx: String, +) -> Result { + if data.id.is_empty() { + return Ok(warp::http::Response::builder() + .body("ERROR: no data".to_string()) + .into_response()); + } + let result: String; + let reqenv = ReqEnv::new(db.app, db.auth, header, method, "/delete", "delete", &prfx); + match reqenv.user_authentication().await { + Ok(_auth) => { + result = String::from("DONE"); + // dbg!("auth: {}",&auth); +/* + match prfx.as_str() { + "ta" => { + if db.colls.ta.entries.read().contains_key(&data.id) { + db.colls.ta.entries.write().remove(&data.id); + if db.colls.ta.entries.read().contains_key(&data.id) { + println!("NOT DELETED topographic_anatomy id: {}",&data.id); + result = format!("ERROR: topographic_anatomy NOT deleted: '{}'",&data.id); + } else { + println!("DELETED topographic_anatomy id: {}",&data.id); + result = format!("DELETED: topographic_anatomy: '{}'",&data.id); + } + } else { + result = format!("ERROR: topographic_anatomy NOT found: '{}'",&data.id); + } + }, + "tp" => { + if db.colls.tp.entries.read().contains_key(&data.id) { + db.colls.tp.entries.write().remove(&data.id); + if db.colls.tp.entries.read().contains_key(&data.id) { + println!("NOT DELETED tracking_point id: {}",&data.id); + result = format!("ERROR: tracking_point NOT deleted: '{}'",&data.id); + } else { + println!("DELETED tracking_point id: {}",&data.id); + result = format!("DELETED: tracking_point: '{}'",&data.id); + } + } else { + result = format!("ERROR: topographic_anatomy NOT found: '{}'",&data.id); + } + }, + _ => { + result = format!("ERROR: list for '{}' undefined",&prfx); + // (AuthError::UserNotFoundError.to_string()) + println!("{}",&result); + } + }; +*/ + }, + Err(e) => { + result = format!("Error: no credentials found"); + println!("{}",e); + }, + } + let json_res = format!("{{ \"res\": \"{}\"}}", result); + Ok(warp::http::Response::builder() + .body(json_res.to_string()) + .into_response()) +} \ No newline at end of file diff --git a/src/handlers/h_defs.rs b/src/handlers/h_defs.rs new file mode 100644 index 0000000..cd64988 --- /dev/null +++ b/src/handlers/h_defs.rs @@ -0,0 +1,162 @@ +// use std::convert::Infallible; +// use std::collections::HashMap; +use warp::{ + // http::{StatusCode}, + http::{method::Method, HeaderMap, HeaderValue}, + Reply, Rejection, +}; +use reqenv::ReqEnv; +use app_env::profile::Profile; +/* +use crate::topographic_anatomy::defs::{TaStore,TaData,TaQueryFilters,TopographicAnatomy}; +use zterton::kloud::utils::{lng_t,get_lang_items_str,load_lang}; +//use zterton::models::{AppStore, AppData}; + +use crate::defs::AppDB; +use crate::auth::defs::{ + AuthError, + Sessions, + UserCtx, + UserMap, + WebResult, + SharedEnforcer, + BEARER_PREFIX, + custom_reject +}; +*/ +// use ::topographic_anatomy::{TopographicAnatomy}; +// use ::tracking_point::{TrackingPoint}; +// use crate::tracking_point::defs::{TrackingPoint}; +//use app_auth::{UserCtx}; +use kloud::{ + defs::{ + KloudQueryDefsFilters, + KloudQueryLangFilters, + }, + lang::LangItems, +}; + +use crate::defs::{DataDBs}; // ,CollsData}; + +// warp::generic::Either<(std::string::String,), (std::string::String,)> +pub async fn langs( + opts: KloudQueryLangFilters, + header: HeaderMap, + method: Method, +// user: UserCtx, + db: DataDBs, + prfx: String, +// headers: warp::http::HeaderMap +// path: warp::path::FullPath, headers: warp::http::HeaderMap +) -> Result { + let reqenv = ReqEnv::new(db.app, db.auth, header, method, "/langs", "langs", &prfx); +// println!("User: {} | {}",&user.user_id,&user.token); + // if let Some(lang) = reqtasks.params().get("lang") { + // res.render_json_text(&get_lang_items_str("langs",req_lang,"yaml")) + // } else { + // res.render_json_text(&get_lang_items_str("langs",&reqtasks.lang(),"yaml")) + // } + // log::debug!("LANG: {} - {}",language, lang); +// dbg!("LANG: {} - {}",language, lang); + // let allow_origin = reqenv.config().allow_origin; + + match reqenv.user_authentication().await { + Ok(_auth) => { + // dbg!("auth: {}",&auth); + let lang = opts.lang.unwrap_or_else(|| String::from("es")); + let section = opts.section.unwrap_or_else(|| String::from("")); + let lang_items = LangItems::new("langs/ta",&lang,"yaml"); + let result = lang_items.get_items_str(§ion); + Ok(warp::http::Response::builder() + .body(result.to_string()) + .into_response()) + /* + Ok(warp::reply::with_header( + warp::http::Response::new(result), + "Access-Control-Allow-Origin", + &allow_origin)) + // Ok(warp::reply::json(&result)) + */ + }, + Err(e) => { + let result = format!("Error: no credentials found"); + println!("{}",e); + Ok(warp::http::Response::builder() + .body(result.to_string()) + .into_response()) + /* + Ok(warp::reply::with_header( + warp::http::Response::new(result), + "Access-Control-Allow-Origin", + &allow_origin)) + */ + } + } +} +// warp::generic::Either<(std::string::String,), (std::string::String,)> +pub async fn defs( + _opts: KloudQueryDefsFilters, + header: HeaderMap, + method: Method, +// user: UserCtx, + db: DataDBs, + prfx: String, +// headers: warp::http::HeaderMap +// path: warp::path::FullPath, headers: warp::http::HeaderMap +) -> Result { + let reqenv = ReqEnv::new(db.app, db.auth, header, method, "/defs", "defs", &prfx); + // let allow_origin = reqenv.config().allow_origin; + match reqenv.user_authentication().await { + Ok(auth) => { + // dbg!("auth: {}",&auth); + // println!("User: {} | {}",&user.user_id,&user.token); + // if let Some(lang) = reqtasks.params().get("lang") { + // res.render_json_text(&get_lang_items_str("langs",req_lang,"yaml")) + // } else { + // res.render_json_text(&get_lang_items_str("langs",&reqtasks.lang(),"yaml")) + // } + // log::debug!("LANG: {} - {}",language, lang); + // dbg!("LANG: {} - {}",language, lang); + + let mut path = format!("{}/profiles/{}/{}/defs.yaml",reqenv.config().resources_path,&prfx,&auth.user_id); + if ! std::path::Path::new(&path).exists() { + path = format!("{}/profiles/{}/defs.yaml",reqenv.config().resources_path,&prfx); + } + let content = Profile::load_fs_content(path.into()); + // let lang = opts.lang.unwrap_or_else(|| String::from("es")); + // let section = opts.section.unwrap_or_else(|| String::from("")); + // let lang_items = LangItems::new("langs/ta",&lang,"yaml"); + // let result = lang_items.get_items_str(§ion); + let res = Profile::to_yaml(content); // String::from(""); + let result = serde_json::to_string(&res).unwrap_or_else(|_| String::from("")); + Ok(warp::http::Response::builder() + .body(result.to_string()) + .into_response()) + /* + Ok(warp::reply::with_header( + warp::http::Response::new(result), + "Access-Control-Allow-Origin", + &allow_origin)) + */ + // warp::reply::json(&res), + // Ok(warp::reply::with_header( + // warp::http::Response::new(result), + // "Access-Control-Allow-Origin", + // &allow_origin)) + // Ok(warp::reply::json(&result)) + }, + Err(e) => { + let result = format!("Error: no credentials found"); + println!("{}",e); + Ok(warp::http::Response::builder() + .body(result.to_string()) + .into_response()) + /* + Ok(warp::reply::with_header( + warp::http::Response::new(result), + "Access-Control-Allow-Origin", + &allow_origin)) + */ + } + } +} diff --git a/src/klouds.rs b/src/klouds.rs new file mode 100644 index 0000000..3fe6224 --- /dev/null +++ b/src/klouds.rs @@ -0,0 +1,95 @@ +use async_graphql::{Context, Object, Result}; + +use crate::defs::DataDBs; +use crate::graphql::{Map,MutationType}; + +use klouds::Kloud; +use crate::filters::CollFilters; + +pub fn load_klouds_filters() -> CollFilters { + CollFilters { + prfx: String::from("klouds"), + } +} + +#[derive(Clone,Default)] +pub struct KloudMainQuery; + +#[Object] +impl KloudMainQuery { + async fn klouds(&self, ctx: &Context<'_>) -> Vec { + let data_dbs = ctx.data_unchecked::(); + let cur = data_dbs.colls.klouds.entries.read(); + // let mut result: Vec = Vec::new(); + // for (_,value) in cur.iter() { + // result.push(value.to_owned()); + // } + cur.values().cloned().collect() + // for (_,value) in cur.iter() { + // result.push(value.to_owned()); + // } + + //result + // books.iter().map(|(_, book)| book).cloned().collect() + } +} + +#[derive(Clone,Default)] +pub struct KloudMainChanged { + pub mutation_type: MutationType, + pub id: String, + pub objmap: Map, +} + +#[Object] +impl KloudMainChanged { + async fn mutation_type(&self) -> MutationType { + self.mutation_type + } + async fn id(&self) -> &String { + &self.id + } + async fn objmap(&self) -> &Map { + &self.objmap + } + async fn klouds(&self, ctx: &Context<'_>) -> Result> { + let data_dbs = ctx.data_unchecked::(); + // TODO Parse self.objmap + match self.mutation_type { + MutationType::Created => + data_dbs.colls.klouds.entries.write() + .insert(self.id.to_owned(), Kloud::default()), + MutationType::Updated => + data_dbs.colls.klouds.entries.write() + .insert(self.id.to_owned(), Kloud::default()), + MutationType::Deleted => + data_dbs.colls.klouds.entries.write().remove(&self.id), + }; + // let entry = data_dbs.data.ta.ta_entries. + // let entry = d + // let id = &self.id; // .parse::()?; + // for (_,value) in cur.iter() { + // result.push(value.to_owned()); + // } + // let books = ctx.data_unchecked::().lock().await; + // let id = self.id.parse::()?; + // Ok(books.get(id).cloned()) + Ok(Some(Kloud::default())) + } +} +/* +https://github.com/async-graphql/examples/blob/b36b5c44543b7323cb199ed229ea247e83b85d18/models/books/src/lib.rs + +https://blog.logrocket.com/creating-a-rest-api-in-rust-with-warp/ + + store.grocery_list.write().insert(item.name, item.quantity); + Ok(warp::reply::with_status( + "Added items to the grocery list", + http::StatusCode::CREATED, + )) + store.grocery_list.write().remove(&id.name); + Ok(warp::reply::with_status( + "Removed item from grocery list", + http::StatusCode::OK, + )) +*/ \ No newline at end of file diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..8984ba2 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,349 @@ +use std::sync::atomic::{AtomicUsize, Ordering}; +use app_env::{ + AppStore, + appenv::AppEnv, + appinfo::AppInfo, + appdata::AppData, + config::Config, +}; +use app_auth::AuthStore; +use reject_filters::{handle_rejection}; +// use zterton::models::{Terton}; +//use std::fs; //, io}; +// use std::fs::OpenOptions; +// use std::io::Write; +//use std::path::Path; +// use serde_yaml::Value; +use anyhow::{Result}; +// use std::env; +//use warp::{http::Response as HttpResponse, Filter, filters::BoxedFilter}; +use warp::{ + // http::{StatusCode}, + http::{method::Method, HeaderMap}, + Filter, +}; +// use warp::filters::header::headers_cloned; +// use warp::path::FullPath; +// use warp::http::{Uri, HeaderMap, HeaderValue}; + +//use crate::utils::set_ta_data; +use crate::defs::{DataDBs,CollsData,load_cloud_env}; +use clds::clouds::defs::{ + Cloud, +}; +// use clds::app_env::config::Config; +use clds::clouds::on_clouds::{make_cloud_cache,run_clouds_check}; +use reqenv::ReqEnv; + +// #[macro_use] +// extern crate kloud_entries_macro_derive; + +static WEBSERVER: AtomicUsize = AtomicUsize::new(0); +const VERSION: &'static str = env!("CARGO_PKG_VERSION"); +// const VERSION: Option<&'static str> = option_env!("CARGO_PKG_VERSION"); +const AUTHORS: &'static str = env!("CARGO_PKG_AUTHORS"); + +pub mod defs; +pub mod graphql; +pub mod filters; +pub mod handlers; + +// pub const MODEL_PATH: &String = String::from("./auth/auth_model.conf"); +// pub const POLICY_PATH: &String = String::from("./auth/policy.csv"); + +async fn create_auth_store(app_env: &AppEnv,verbose: &str) -> AuthStore { + let model_path = app_env.config.st_auth_model_path(); + let policy_path = app_env.config.st_auth_policy_path(); + AuthStore::new(&app_env.config,AuthStore::create_enforcer(model_path,policy_path).await,&verbose) +} +async fn up_web_server() -> Result<()> { + let webserver_status = WEBSERVER.load(Ordering::Relaxed); + let zterton_env = envmnt::get_or("ZTERTON", "UNKNOWN"); + let verbose = envmnt::get_or("WEB_SERVER_VERBOSE", ""); + if webserver_status != 0 { + if verbose != "quiet" { + println!("ZTerton web services at {}",&zterton_env); + } + // envmnt::set("ZTERTON", "WEBSERVER"); + return Ok(()); + /* + let app = Zterton::new( + app_env.config.srv_protocol.to_owned(), + app_env.config.srv_host.to_owned(), + app_env.config.srv_port, + ); + let serverstring = format!("{}:{}",&srv_host,&srv_port); + match std::net::TcpStream::connect(&serverstring) { + Ok(_serverstream) => { + Ok(()) + Err(anyhow!("Source {}: Connection to '{}' for tsksrvc '{}' failed: {}",&source,&serverstring,&tsk_name,&e)) + }, + Err(e) => { + // handle_input(serverstream); + } + } + */ + } + WEBSERVER.store(1,Ordering::Relaxed); + let mut app_env = AppEnv::default(); + app_env.info = AppInfo::new( + "Zterton", + format!("version: {}",VERSION), + format!("Authors: {}",AUTHORS), + ).await; + println!("Web services: init {} ___________ ", chrono::Utc::now().timestamp()); + zterton::init_app(&mut app_env,"").await?; + // TODO pass root file-name frmt from AppEnv Config + // if init at load + // set_ta_data(&app_env).await?; + + let (app, socket) = zterton::start_web(&mut app_env).await; + + println!("Load app store ..."); + let app_store = AppStore::new(AppData::new(app_env.to_owned())); + + // As static casbin + println!("Load auth store ..."); + let auth_store = create_auth_store(&app_env,"").await; + // dbg!(&auth_store.users.read().await); + // dbg!(&auth_store.shadows.read().await); + + println!("Load data store ..."); + + let data_dbs = DataDBs { + colls: CollsData::new(app_env.to_owned()), + app: app_store.to_owned(), + auth: auth_store.to_owned(), + }; + println!("Load web filters ..."); + // let store = warp::any().map(move || ta_store.clone()); + //let routes = warp::any().map(|| "Hello, World!"); + + // let us get some static boxes from config values: + let log_name = app_env.config.st_log_name(); + // Path for static files + let html_path = app_env.config.st_html_path(); + // If not graphQL comment/remove next line + let gql_path = app_env.config.st_gql_req_path(); + // If not graphiQL comment/remove next line Interface GiQL + let giql_path = app_env.config.st_giql_req_path(); + + let origins: Vec<&str> = app_env.config.allow_origin.iter().map(AsRef::as_ref).collect(); + let cors = warp::cors() + //.allow_any_origin() + .allow_origins(origins) + //.allow_origins(vec![app_env.config.allow_origin.as_str(), "https://localhost:8000"]) + .allow_credentials(true) + .allow_header("content-type") + .allow_header("Authorization") + .allow_methods(&[Method::GET, Method::POST, Method::DELETE]); + + let auth_api = + // Auth routes for login & logout REQUIRED + app_auth_filters::auth(app_store.clone(),auth_store.clone(),cors.clone()); // .with(cors.clone()); + + let gqli_api = + // // If not graphiQL comment/remove next line Interface GiQL MUST BEFORE graphql post with schema + // app_api.to_owned() + graphql::graphiql(gql_path, giql_path, data_dbs.clone()).await; + if giql_path.len() > 0 { + println!( + "GraphiQL url: {}://{}:{}/{}", + &app.protocol, &app.host, &app.port, &giql_path + ); + } + let mut cloud = Cloud::default(); + load_cloud_env(&mut cloud).await; + // app_api.to_owned() + // If not graphQL comment/remove next line + let gql_api=graphql::graphql(gql_path, data_dbs.clone(),cors.clone()).await; //.with(cors.clone()); + + // // Add ALL ENTITIES to work with here + let kloud_api = filters::CollFilters::new("kloud") + .filters_config(data_dbs.clone(),cloud.clone(),cors.clone()); + + // let ta_api = + // filters::CollFilters::new("ta").filters(&app_env.config, data_dbs.clone(),cors.clone()); + +// let tp_api = filters::CollFilters::new("tp").filters(&app_env.config, data_dbs.clone(),cors.clone()); +// .or(tracking_point::load_tp_filters().filters(&app_env.config, data_dbs.clone())) +// .or(topographic_anatomy::filters::ta(&app_env.config, data_dbs.clone())) +// .or(tracking_point::filters::tp(&app_env.config, data_dbs.clone())) + + let file_api = app_file_filters::files(app_store.clone(),auth_store.clone()).with(cors.clone()); + // Path for static files, better to be LAST + let fs_api = warp::fs::dir(html_path).with(warp::compression::gzip()); + // Recover and handle errors + let app_api = auth_api + .or(gqli_api).or(gql_api) + .or(kloud_api) + // .or(ta_api) + // .or(tp_api) + .or(file_api) + .or(fs_api) + .recover(move | error: warp::Rejection| handle_rejection(error, app_store.clone())) + .boxed(); + // Wrap routes with log to get info + let routes = app_api.with(warp::log(log_name)); +// let routes = app_api.with(cors).with(warp::log(log_name)); + + println!( + "Starting http server: {}://{}:{}", + &app.protocol, &app.host, &app.port + ); + envmnt::set("ZTERTON", format!("{}:{}",&app.host,&app.port)); + println!("Web services: done {} __________ ",chrono::Utc::now().timestamp()); + if app.protocol.clone().as_str() == "http" { + warp::serve(routes.to_owned()) + .run(socket) + .await; + } else { + let cert_pem = format!("{}/ssl/{}", app_env.config.resources_path, "cert.pem"); + let key_pem = format!("{}/ssl/{}", &app_env.config.resources_path, "key.pem"); + warp::serve(routes) + .tls() + .cert_path(cert_pem) + .key_path(key_pem) + .run(socket) + .await; + } + Ok(()) +} +pub async fn run_cache_clouds() { + let args: Vec = std::env::args().collect(); + let mut arg_cfg_path = String::from(""); + let mut arg_env_path = String::from(""); + args.iter().enumerate().for_each(|(idx,arg)| { + if arg == "-c" { + arg_cfg_path=args[idx+1].to_owned(); + } else if arg == "-e" { + arg_env_path=args[idx+1].to_owned(); + } + }); + println!("Cache service on Clouds: run {} __________ {} / {} ",chrono::Utc::now().timestamp(),&arg_cfg_path,&arg_env_path); + let mut cloud = Cloud::default(); + load_cloud_env(&mut cloud).await; + let mut app_env = AppEnv::default(); + let config_content = Config::load_file_content("quiet", &arg_cfg_path); + if ! config_content.contains("run_mode") { + return; + } + app_env.config = Config::new(config_content,"quiet"); + let app_store = AppStore::new(AppData::new(app_env.to_owned())); + let auth_store = create_auth_store(&app_env,"quiet").await; + + let mut headers = HeaderMap::new(); + headers.insert(http::header::HOST, "localhost".parse().unwrap()); + let reqenv = ReqEnv::new( + app_store, auth_store, + headers, + Method::GET, + "/config", "config", "kloud" + ); + let _ = make_cloud_cache(&reqenv,&cloud).await; + println!("Cache service on Clouds: done {} __________ ",chrono::Utc::now().timestamp()); +} + +pub async fn run_check_clouds() { + let args: Vec = std::env::args().collect(); + let mut arg_cfg_path = String::from(""); + let mut arg_env_path = String::from(""); + args.iter().enumerate().for_each(|(idx,arg)| { + if arg == "-c" { + arg_cfg_path=args[idx+1].to_owned(); + } else if arg == "-e" { + arg_env_path=args[idx+1].to_owned(); + } + }); + println!("Check Cloud services: run {} __________ {} / {} ",chrono::Utc::now().timestamp(),&arg_cfg_path,&arg_env_path); + let mut cloud = Cloud::default(); + load_cloud_env(&mut cloud).await; + let mut app_env = AppEnv::default(); + let config_content = Config::load_file_content("quiet",&arg_cfg_path); + if ! config_content.contains("run_mode") { + return; + } + app_env.config = Config::new(config_content,"quiet"); + let app_store = AppStore::new(AppData::new(app_env.to_owned())); + let auth_store = create_auth_store(&app_env,"quiet").await; + + let mut headers = HeaderMap::new(); + headers.insert(http::header::HOST, "localhost".parse().unwrap()); + let reqenv = ReqEnv::new( + app_store, auth_store, + headers, + Method::GET, + "/config", "config", "kloud" + ); + let _ = run_clouds_check(&reqenv,&cloud).await; + println!("Check Cloud service: done {} __________ ",chrono::Utc::now().timestamp()); +} +// for standalone server & async use +// #[tokio::main] +// pub async fn main() -> Result<()> { + +pub fn main() -> Result<()> { + let args: Vec = std::env::args().collect(); + // println!("I got {:?} arguments: {:?}.", args.len() - 1, &args[1..]); + if args.len() > 1 && ( args[1] == "-h" || args[1] == "--help") { + println!("{} USAGE: -c config-toml -e env.file",&args[0]); + } + let mut arg_cfg_path = String::from(""); + let mut arg_env_path = String::from(""); + args.iter().enumerate().for_each(|(idx,arg)| { + if arg == "-c" { + arg_cfg_path=args[idx+1].to_owned(); + } else if arg == "-e" { + arg_env_path=args[idx+1].to_owned(); + } + }); +// assert!(output.is_ok()); + let loop_duration: u64; + let run_cache: bool; + let run_check: bool; + { + let config_content = Config::load_file_content("quiet", &arg_cfg_path); + if config_content.contains("run_mode") { + let config = Config::new(config_content,"quiet"); + loop_duration = config.loop_duration; + // loop_duration = 10; + run_cache = config.run_cache; + run_check = config.run_check; + if run_cache { + println!("Running 'cloud_cache' every {} seconds in LOOP",&loop_duration); + } + if run_check { + println!("Running 'cloud_check' every {} seconds in LOOP",&loop_duration); + } + } else { + loop_duration = 0; + run_cache = false; + run_check = false; + } + } + // println!("content: {}",&config_content); + let rt = tokio::runtime::Runtime::new().unwrap_or_else(|e| + panic!("Error create tokio runtime {}",e) + ); + loop { + rt.block_on(async move { + tokio::spawn(async move {up_web_server().await }); + tokio::time::sleep(tokio::time::Duration::from_secs(5)).await; + if run_check { + tokio::spawn(async {run_check_clouds().await }); // For async task + tokio::time::sleep(tokio::time::Duration::from_secs(5)).await; + } + // { + // // For blocking task: + // let join_handle = tokio::task::spawn_blocking(|| do_my_task()); + // tokio::spawn(async { do_my_task().await; }); + // join_handle.await; // TODO: should handle error here + // } + if run_cache { + tokio::spawn(async {run_cache_clouds().await }); // For async task + } + println!("LOOP: {} __________",chrono::Utc::now().timestamp()); + tokio::time::sleep(tokio::time::Duration::from_secs(loop_duration)).await; + }); + } +} diff --git a/src/reqenv.rs b/src/reqenv.rs new file mode 100644 index 0000000..ee2d8ca --- /dev/null +++ b/src/reqenv.rs @@ -0,0 +1,114 @@ +//use std::collections::HashMap; +use std::fmt; +//use std::str::from_utf8; +//use tera::Tera; + +use warp::{ + http::{method::Method, HeaderMap, HeaderValue}, +// Filter, +}; + +use reqtasks::ReqTasks; +use app_env::{ + appenv::AppEnv, + config::Config, + module::Module, + AppStore, + // AppData, +}; +use app_auth::{ + AuthStore, + UserCtx, + LoginRequest, + // BEARER_PREFIX, + // AuthError, +}; + +/// `ReqEnv` includes ReqTasks as core type +/// it is a kind of wrapping type +/// to declare: +/// - auth methods locally +/// - other attributes +/// - other request tasks methods +/// +#[derive(Clone)] +pub struct ReqEnv { + pub req: ReqTasks, + +} + +impl fmt::Display for ReqEnv { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{} {} {}", &self.req.path, &self.req.origin, &self.req.key_module) + } +} + +impl ReqEnv { + pub fn new( + app_db: AppStore, + auth_store: AuthStore, + header: HeaderMap, + method: Method, + path: &str, + origin: &str, + key_module: &str + ) -> Self { + let app_data = app_db.app_data.read(); + // let auth_store: &'a AuthStore = &AuthStore { + // users: auth_db.users.clone(), + // sessions: auth_db.sessions.clone(), + // enforcer: auth_db.enforcer.clone(), + // }; + Self { + req: ReqTasks { + app_data: app_data.to_owned(), + auth_store: auth_store.to_owned(), + header, + method, + path: format!("{}{}",key_module,path).to_string(), + origin: format!("{}{}",key_module,origin).to_string(), + key_module: key_module.to_string(), + }, + } + } + /// Get `AppEnv` + #[must_use] + pub fn env(&self) -> AppEnv { + self.req.env() + } + /// Get Tera + #[must_use] + pub fn tera(&self) -> tera::Tera { + self.req.tera() + } + /// Get Context (ctx) + #[must_use] + pub fn ctx(&self) -> tera::Context { + self.req.ctx() + } + /// Get `AppEnv` Config + #[must_use] + pub fn config(&self) -> Config { + self.req.config() + } + #[must_use] + pub fn module(&self) -> Module { + self.req.module() + } + #[must_use] + pub fn lang(&self) -> String { + self.req.lang() + } + #[allow(clippy::missing_errors_doc)] + pub fn token_from_header(&self) -> anyhow::Result { + self.req.token_from_header() + } + #[allow(clippy::missing_errors_doc)] + pub async fn token_session(&self, login: &LoginRequest) -> anyhow::Result { + self.req.token_session(login).await + } + #[allow(clippy::missing_errors_doc)] + pub async fn user_authentication(&self) -> anyhow::Result { + self.req.user_authentication().await + } +} \ No newline at end of file