diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..fabe43a --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,1838 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "aho-corasick" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba" +dependencies = [ + "memchr", +] + +[[package]] +name = "anyhow" +version = "1.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" + +[[package]] +name = "assert-json-diff" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47e4f2b81832e72834d7518d8487a0396a28cc408186a2e8854c0f98011faf12" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bitflags" +version = "2.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b588b76d00fde79687d7646a9b5bdf3cc0f655e0bbd080335a95d7e96f3587da" + +[[package]] +name = "bumpalo" +version = "3.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" + +[[package]] +name = "bytes" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" + +[[package]] +name = "cc" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "509591b7bcd67f4ef775afad7662703b4935daaa6ec0e5605cfb1090b32a2b6d" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "colored" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faf9468729b8cbcea668e36183cb69d317348c2e08e994829fb56ebfdfbaac34" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "displaydoc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.3", +] + +[[package]] +name = "encoding_rs" +version = "0.8.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "fastrand" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" + +[[package]] +name = "find-msvc-tools" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d45db016d36b838f563236e9193d0ee6ce38f3f68b6c94e914b4929c96bbb890" + +[[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.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" + +[[package]] +name = "futures-sink" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1944426bf7d03f1d14f708785e4b33efd750b36d48a157b836b3efc15ede8e1d" + +[[package]] +name = "futures-task" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" + +[[package]] +name = "futures-util" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "slab", +] + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi 5.3.0", + "wasip2", +] + +[[package]] +name = "getrandom" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +dependencies = [ + "cfg-if", + "libc", + "r-efi 6.0.0", +] + +[[package]] +name = "h2" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6cb093c84e8bd9b188d4c4a8cb6579fc016968d14c99882163cd3ff402a4f155" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hagfish" +version = "0.1.0" +dependencies = [ + "anyhow", + "mockito", + "reqwest", + "serde", + "serde_json", + "thiserror", + "tokio", + "tokio-test", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "hashbrown" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" + +[[package]] +name = "http" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "918d3568bebf352712bc2ef3d46a8bcf1a75b373be6539de198e9105cbbf9ce0" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2a8f2913ee65f60facd6a5905613afaa448497a0230cc41ce022d93290bc2c" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23169fe34a5fbcdd3f3862e78fb9b6fccd5f02a6dc6f732547005d45631ce71c" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d22053281f852e11534f5198498373cbb59295120a20771d90f7ed1897490a72" +dependencies = [ + "atomic-waker", + "bytes", + "futures-channel", + "futures-core", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ca68d021ef39cf6463ab54c1d0f5daf03377b70561305bb89a8f83aab66e0f" +dependencies = [ + "http", + "hyper", + "hyper-util", + "rustls", + "tokio", + "tokio-rustls", + "tower-service", +] + +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96547c2556ec9d12fb1578c4eaf448b04993e7fb79cbaad930a656880a6bdfa0" +dependencies = [ + "base64", + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "hyper", + "ipnet", + "libc", + "percent-encoding", + "pin-project-lite", + "socket2", + "system-configuration", + "tokio", + "tower-service", + "tracing", + "windows-registry", +] + +[[package]] +name = "icu_collections" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa68d21081c4a05d5a901a1c62add574c77048b6a1c67be3b50ce0b60d4ca513" +dependencies = [ + "displaydoc", + "potential_utf", + "utf8_iter", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d56e28588da92eee5c3201a6eff33fabdd49b62269c8938d4ff050ce4d900deb" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12f9cf5f235641ed274641dd81c3f28d870e276763d0797aeeab72317b1c646f" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1563da1ed3e0b3bf3d74c9b85917ac9c56464d2f57242270c09c9e752f8021a0" + +[[package]] +name = "icu_properties" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e7ca276ad3145661a65914e6daf131ca5120cd3dcee8f8f3214b8875184a148" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e590f038c1464a96894fd6d10127e90a8be4509f56ff7ecef851b15cee0b7caa" + +[[package]] +name = "icu_provider" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92a7ed671a6aad807a8651a2e1782a6598fda9ce5185dd8158549e95a91c6428" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "2.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "ipnet" +version = "2.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a756c3fac73139e83f14c2d742155dd2b78d3ee56597b419a0579b7bdd6dd78" + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "js-sys" +version = "0.3.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e0c1080212aad755ea003d18543e8768dd432c48819efd73a7bf1e39b7a5a3a" +dependencies = [ + "cfg-if", + "futures-util", + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.189" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2" + +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + +[[package]] +name = "litemap" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad" + +[[package]] +name = "matchers" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9" +dependencies = [ + "regex-automata", +] + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "mio" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30d65c71f1ce40ab09135ce117d742b9f8a19ff91a41a8b57ed50bc2de59c427" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.61.2", +] + +[[package]] +name = "mockito" +version = "1.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90820618712cab19cfc46b274c6c22546a82affcb3c3bdf0f29e3db8e1bb92c0" +dependencies = [ + "assert-json-diff", + "bytes", + "colored", + "futures-core", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-util", + "log", + "pin-project-lite", + "rand", + "regex", + "serde_json", + "serde_urlencoded", + "similar", + "tokio", +] + +[[package]] +name = "native-tls" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "465500e14ea162429d264d44189adc38b199b62b1c21eea9f69e4b73cb03bbf2" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "nu-ansi-term" +version = "0.50.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "openssl" +version = "0.10.81" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77823a27f0babb03091cb9ed9ef80af3b39dbc82f97e8fa530374b7dafd87a45" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "openssl-probe" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" + +[[package]] +name = "openssl-sys" +version = "0.9.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b47e7e6bb2c38cd930d25a23b40fa52e068c10e85f3e03a7f5ba5aaca5713695" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-link", +] + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "pkg-config" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548" + +[[package]] +name = "potential_utf" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661" +dependencies = [ + "zerovec", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "rand" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ef1d0d795eb7d84685bca4f72f3649f064e6641543d3a8c415898726a57b41" +dependencies = [ + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" +dependencies = [ + "getrandom 0.3.4", +] + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" + +[[package]] +name = "reqwest" +version = "0.12.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-core", + "h2", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-tls", + "hyper-util", + "js-sys", + "log", + "mime", + "native-tls", + "percent-encoding", + "pin-project-lite", + "rustls-pki-types", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tokio-native-tls", + "tower", + "tower-http", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.17", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustix" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls" +version = "0.23.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0283386ce02abc0151e1761d08802dfe86c173b0b494af5cbc086574e453da06" +dependencies = [ + "once_cell", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pki-types" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f4925028c7eb5d1fcdaf196971378ed9d2c1c4efc7dc5d011256f76c99c0a96" +dependencies = [ + "zeroize", +] + +[[package]] +name = "rustls-webpki" +version = "0.103.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0527518605e68109d875e248ea259b6758801cf165e4b2c2733ae3b51f12535a" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + +[[package]] +name = "rustversion" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" + +[[package]] +name = "ryu" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" + +[[package]] +name = "schannel" +version = "0.1.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91c1b7e4904c873ef0710c1f407dde2e6287de2bebc1bbbf7d430bb7cbffd939" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "security-framework" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" +dependencies = [ + "bitflags", + "core-foundation 0.10.1", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.3", +] + +[[package]] +name = "serde_json" +version = "1.0.151" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "signal-hook-registry" +version = "1.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" +dependencies = [ + "errno", + "libc", +] + +[[package]] +name = "similar" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa" + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90" + +[[package]] +name = "socket2" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "2.0.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53e9bae58849f64dfa4f5d5ae372c8341f7305f82a3868709269343628b659a3" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +dependencies = [ + "futures-core", +] + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "system-configuration" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a13f3d0daba03132c0aa9767f98351b3488edc2c100cda2d2ec2b04f3d8d3c8b" +dependencies = [ + "bitflags", + "core-foundation 0.9.4", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "tempfile" +version = "3.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" +dependencies = [ + "fastrand", + "getrandom 0.4.3", + "once_cell", + "rustix", + "windows-sys 0.61.2", +] + +[[package]] +name = "thiserror" +version = "2.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec86235f5fcc2a73650310756d2ac5b138a5780bbbdfae3eeccec992c435ba4f" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc04cd3e1236dd4a98afca4569f2deb3f120e5422a4023be2cb683f8486292af" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.3", +] + +[[package]] +name = "thread_local" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad99c4c6d32803332c548b1af0540b357b3f5fc0be8f6c6bfe8b2e6ae784070" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "tinystr" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1e27c91459209c2986af3dcf603a5a74a4368754ce37414f59acc971167f643" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tokio" +version = "1.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "202caea871b69668250d242070849eb495be178ed697a3e98aebce5bc81a0bed" +dependencies = [ + "bytes", + "libc", + "mio", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.61.2", +] + +[[package]] +name = "tokio-macros" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78773a2a397f451582ce068015985c33193cf6dea8b74d2a639fe457b2f07b0e" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.3", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1729aa945f29d91ba541258c8df89027d5792d85a8841fb65e8bf0f4ede4ef61" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tokio-stream" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3d06f0b082ba57c26b79407372e57cf2a1e28124f78e9479fe80322cf53420b" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-test" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f6d24790a10a7af737693a3e8f1d03faef7e6ca0cc99aae5066f533766de545" +dependencies = [ + "futures-core", + "tokio", + "tokio-stream", +] + +[[package]] +name = "tokio-util" +version = "0.7.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "494815d09bf52b5548659851081238f0ca39ff638363907596da739561c62c52" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "libc", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tower" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-http" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cfcf7e2740e6fc6d4d688b4ef00650406bb94adf4731e43c096c3a19fe40840" +dependencies = [ + "bitflags", + "bytes", + "futures-util", + "http", + "http-body", + "pin-project-lite", + "tower", + "tower-layer", + "tower-service", + "url", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7f578e5945fb242538965c2d0b04418d38ec25c79d160cd279bf0731c8d319" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex-automata", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "valuable" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasip2" +version = "1.0.4+wasi-0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.127" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b70935747edd64d89de3efa29d73789b806c15798f8e7dca4d8ac356b50ce70" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b7777d5cc23d0e91404e53ce2d5e8ec7acae3026b16233dba62cd3246457950" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.127" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77775f8f3f7217702089053b94958f8f54061a3f663417df76e19cbdcca29bc1" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.127" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e11d33f857dc2fb11b8bc75aee111aa9cbeb12cd9f25efd3d4c2a3dd4e235284" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn 2.0.119", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.127" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef64dbcc55df09c7e5a46182d181c2cfa3e925f3da937ea764728b4bbb9dcbf" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "web-sys" +version = "0.3.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c435338968042f4f59a557f690a253676d47ce13ceb55d70100e7facf6620a30" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-registry" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02752bf7fbdcce7f2a27a742f798510f3e5ad88dbe84871e5168e2120c3d5720" +dependencies = [ + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "wit-bindgen" +version = "0.57.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" + +[[package]] +name = "writeable" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc" + +[[package]] +name = "yoke" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "709fe23a0424b6a435d82152b1bd3fdfb0833487d5fa90d05d42762a9891fef5" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de844c262c8848816172cef550288e7dc6c7b7814b4ee56b3e1553f275f1858e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", + "synstructure", +] + +[[package]] +name = "zerocopy" +version = "0.8.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "556764e583adb45a9f8d413c2a147fa7e8d821e48e12b14fd560b607998b75eb" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2ab42fc20575779bd240faa45f94a74256f755c0fa9e89f0ede20d91d0cdfc1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "zerofrom" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11532158c46691caf0f2593ea8358fed6bbf68a0315e80aae9bd41fbade684a1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13c156562582aa81c60cb29407084cdb54c4164760106ab78e6c5b0858cf64e" + +[[package]] +name = "zerotrie" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea269c3bd32f0a32c321907a2ae912ba6f4649bb0fc764a15627e99a7095a3f" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94b5c6b5976d66c1d703c4fd17d3f5e43c8cedaacf604961b171adc7130896d8" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47402523226a02bfe5230160dc3ccc089aa6f6f19e7fcbb4e6f824bbb1b4aa62" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.3", +] + +[[package]] +name = "zmij" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" diff --git a/docs/API.md b/docs/API.md new file mode 100644 index 0000000..e12be6d --- /dev/null +++ b/docs/API.md @@ -0,0 +1,192 @@ + +# API Documentation + +This document describes the PX-Web API used by hagfish to fetch Faroese fisheries statistics from the official Statbank. + +## EndpointBase URL: https://statbank.hagstova.fo/api/v1/fo/H2/VV/VV01/fisknv_md.px +- **GET**: Returns metadata (table structure, dimension codes, labels) +- **POST**: Returns data in JSON-stat2 format + +## Metadata Request (GET) + +### Requestbash +curl -s "https://statbank.hagstova.fo/api/v1/fo/H2/VV/VV01/fisknv_md.px" +### Response Structurejson +{ +"title": "AVR01010 Avreiðingar í nøgd og virði...", +"variables": [ +{ +"code": "measure", +"text": "mát", +"role": null, +"values": ["MASS", "VALUE"], +"valueTexts": ["Nøgd", "Virði"] +} +] +} +### Fields + +| Field | Type | Description | +|-------|------|-------------| +| `title` | string | Table name in Faroese | +| `variables[].code` | string | Dimension identifier (used in queries) | +| `variables[].text` | string | Human-readable label in Faroese | +| `variables[].role` | null/string | Classification (always `null` on this endpoint) | +| `variables[].values` | string[] | Valid dimension codes | +| `variables[].valueTexts` | string[] | Display labels (parallel with `values`) | + +### Verified Dimension Codes + +| Variable Code | Faroese Label | Values | +|---------------|---------------|--------| +| `measure` | mát | `MASS`, `VALUE` | +| `Species (ASFIS2022)` | Fiskaslag (ASFIS2022) | `TOTAL`, `148XXXXXXX00000`, ... (72 total) | +| `Fishing Gear (ISSCFG2016)` | Reiðskapur (ISSCFG2016) | `TOTAL`, ... (12 total) | +| `Economic Zone (GEONOM2023)` | Búskapar øki (GEONOM2023) | `TOTAL`, ... (10 total) | +| `Processing (EUMOFAPresentation)` | Virking (EUMOFAPresentation) | `TOTAL`, ... (6 total) | +| `Preservation (EUMOFAPreservation)` | Viðgerð (EUMOFAPreservation) | `TOTAL`, ... (9 total) | +| `Shipsize` | Skipastødd | `TOTAL`, ... (11 total) | +| `month` | mánaður | `2015M01` through `2026M05` (137 months) | + +**Note**: `role` is always `null`. Time dimension identification must use `code == "month"`. + +--- + +## Data Request (POST) + +### Request Body Formatjson +{ +"query": [ +{ +"code": "dimension_code", +"selection": { +"filter": "item", +"values": ["value1", "value2"] +} +} +], +"response": { +"format": "json-stat2" +} +} +### Filter Types + +| Filter | Values | Description | +|--------|--------|-------------| +| `item` | explicit codes | Select specific values | +| `all` | `["*"]` | Wildcard — select all values | +| `top` | `["TOP_N"]` | Top N values by magnitude | + +### Example Querybash +curl -s -X POST +-H "Content-Type: application/json" +-d '{ +"query": [ +{"code": "month", "selection": {"filter": "item", "values": ["2024M01", "2024M02"]}}, +{"code": "Species (ASFIS2022)", "selection": {"filter": "all", "values": [""]}}, +{"code": "Fishing Gear (ISSCFG2016)", "selection": {"filter": "all", "values": [""]}}, +{"code": "Economic Zone (GEONOM2023)", "selection": {"filter": "all", "values": ["*"]}}, +{"code": "Processing (EUMOFAPresentation)", "selection": {"filter": "item", "values": ["TOTAL"]}}, +{"code": "Preservation (EUMOFAPreservation)", "selection": {"filter": "item", "values": ["TOTAL"]}}, +{"code": "Shipsize", "selection": {"filter": "item", "values": ["TOTAL"]}}, +{"code": "measure", "selection": {"filter": "item", "values": ["MASS", "VALUE"]}} +], +"response": {"format": "json-stat2"} +}' +"https://statbank.hagstova.fo/api/v1/fo/H2/VV/VV01/fisknv_md.px" +### Cell Limit + +- Maximum cells per query: ~8,000,000 +- Recommended maximum: 1,000,000 for reliability +- To fetch full dataset, paginate by month or use smaller dimension selections + +--- + +## Response Format (JSON-stat2) + +### Structurejson +{ +"class": "dataset", +"label": "...", +"id": ["measure", "Species (ASFIS2022)", ..., "month"], +"size": [2, 72, 12, 10, 1, 1, 1, 2], +"dimension": { +"measure": { +"label": "mát", +"category": { +"index": {"MASS": 0, "VALUE": 1}, +"label": {"MASS": "Nøgd", "VALUE": "Virði"} +} +} +}, +"value": [73653738, 1234567, ...] +} +### Fields + +| Field | Description | +|-------|-------------| +| `id` | Array of dimension codes in order (defines cube layout) | +| `size` | Cardinality per dimension (parallel with `id`) | +| `dimension..category.index` | Maps value code → numeric position in dimension | +| `dimension..category.label` | Maps value code → display text | +| `value` | Flattened array of measurements (row-major order) | + +### Row-Major Index Decoding + +Values are stored in row-major order: the last dimension (`month`) varies fastest. + +Given `size = [2, 72, 12, 10, 1, 1, 1, 2]`: + +- Flat index `0` → `[0,0,0,0,0,0,0,0]` = measure=MASS, species=TOTAL, ..., month=2024M01 +- Flat index `1` → `[0,0,0,0,0,0,0,1]` = measure=MASS, species=TOTAL, ..., month=2024M02 +- Flat index `2` → `[0,0,0,0,0,0,1,0]` = measure=MASS, species=SPECIES_1, ..., month=2024M01 + +Decoding algorithm (reverse modulo):rust +fn decode(flat_index: usize, sizes: &[usize]) -> Vec { +let mut indices = Vec::new(); +let mut remaining = flat_index; +for &size in sizes.iter().rev() { +indices.push(remaining % size); +remaining /= size; +} +indices.reverse(); +indices +} +### Sentinel Values + +| Value | Meaning | +|-------|---------| +| `-1.0` | Missing/no data (treated as `NULL`) | +| `null` | Missing/no data (already nullable in JSON) | + +--- + +## Known Constraints + +1. **Cell limit**: ~8 million cells per query +2. **Rate limits**: Unknown — assume reasonable backoff for large downloads +3. **Language**: API responds in requested language (`fo` or `en`) +4. **Time zone**: No timezone specified — treat timestamps as local +5. **Updates**: Data updated irregularly — metadata timestamp in response header + +--- + +## Integration Checklist + +- [x] Metadata endpoint reachable via GET +- [x] POST queries return valid JSON-stat2 +- [x] Dimension codes match `variables[].code` from metadata +- [x] Row-major index decoding verified +- [x] Sentinel value coercion (`-1.0` → `None`) implemented +- [x] Unicode (Faroese characters) handled correctly +- [ ] Incremental ingestion logic tested +- [ ] Parquet export tested +- [ ] Error handling for network timeouts implemented + +--- + +## References + +- Official PxWeb documentation: https://pxweb.github.io/docs/ +- JSON-stat2 specification: http://json-stat.org/format/ +- Hagstova Føroya: https://www.hagstova.fo/ diff --git a/TODO.md b/docs/TODO.md similarity index 92% rename from TODO.md rename to docs/TODO.md index c602830..3e4eb3d 100644 --- a/TODO.md +++ b/docs/TODO.md @@ -59,12 +59,12 @@ hagfish/ ### Phase 1: Types & Ingestion -- [ ] 1.1 Define types in types.rs: MetadataResponse, VariableMeta, DataResponse, DataRow, Query, Selection, QueryItem, Config — all with serde derives -- [ ] 1.2 Implement ingest.rs::fetch_metadata(url) — GET request, parse JSON, return HashMap<(variable_code, value_code), faroese_label> -- [ ] 1.3 Implement ingest.rs::build_query(months: &[String]) — construct POST body with all species/gear/zones set to "*", processing/preservation/shipsize set to TOTAL, measure set to both MASS and VALUE -- [ ] 1.4 Implement ingest.rs::fetch_data(url, query) — POST request, parse JSON-stat2 response, return Vec -- [ ] 1.5 Implement ingest.rs::parse_row(row, lookup_maps) — decode key[] positions into labeled Landing struct. Handle "-" → None. -- [ ] 1.6 Write unit tests: mock JSON-stat2 response, verify key-to-label mapping, verify "-" handling, verify Faroese Unicode characters in species names (ð, á, í, ý, ø, ó) +- [x] 1.1 Define types in types.rs: MetadataResponse, VariableMeta, DataResponse, DataRow, Query, Selection, QueryItem, Config — all with serde derives +- [x] 1.2 Implement ingest.rs::fetch_metadata(url) — GET request, parse JSON, return HashMap<(variable_code, value_code), faroese_label> +- [x] 1.3 Implement ingest.rs::build_query(months: &[String]) — construct POST body with all species/gear/zones set to "*", processing/preservation/shipsize set to TOTAL, measure set to both MASS and VALUE +- [x] 1.4 Implement ingest.rs::fetch_data(url, query) — POST request, parse JSON-stat2 response, return Vec +- [x] 1.5 Implement ingest.rs::parse_row(row, lookup_maps) — decode key[] positions into labeled Landing struct. Handle "-" → None. +- [x] 1.6 Write unit tests: mock JSON-stat2 response, verify key-to-label mapping, verify "-" handling, verify Faroese Unicode characters in species names (ð, á, í, ý, ø, ó) ### Phase 2: DuckDB Storage diff --git a/src/ingest.rs b/src/ingest.rs index 5541eee..c778e5f 100644 --- a/src/ingest.rs +++ b/src/ingest.rs @@ -2,177 +2,259 @@ //! //! Handles metadata fetching, query construction, data retrieval, and //! parsing of JSON-stat2 responses into structured rows. +//! +//! ## API contract (confirmed 2026-08-16) +//! +//! - GET endpoint: `https://statbank.hagstova.fo/api/v1/fo/H2/VV/VV01/fisknv_md.px` +//! - POST endpoint: same URL +//! - Dimension codes are NOT Faroese short names — they use classification +//! identifiers like "Species (ASFIS2022)", "Fishing Gear (ISSCFG2016)". +//! - `role` is null for all variables on this endpoint. +//! - Metadata uses parallel `values`/`valueTexts` string arrays. +//! - Sentinel values: -1.0 indicates missing data. use crate::types::*; use reqwest::Client; -use tracing::{debug, info, warn}; use std::collections::HashMap; +use tracing::{debug, info, warn}; -const PX_WEB_LANGUAGE: &str = "fo"; // Faroese labels +/// Language code for PX-Web queries. +const PX_WEB_LANGUAGE: &str = "fo"; + +/// Dimension codes — confirmed against live API on 2026-08-16. +/// These are the `code` field values from the metadata response. +const DIM_MONTH: &str = "month"; +const DIM_SPECIES: &str = "Species (ASFIS2022)"; +const DIM_GEAR: &str = "Fishing Gear (ISSCFG2016)"; +const DIM_ZONE: &str = "Economic Zone (GEONOM2023)"; +const DIM_PROCESSING: &str = "Processing (EUMOFAPresentation)"; +const DIM_PRESERVATION: &str = "Preservation (EUMOFAPreservation)"; +const DIM_SHIPSIZE: &str = "Shipsize"; +const DIM_MEASURE: &str = "measure"; + +/// Sentinel f64 values that indicate missing data, coerced to None. +const SENTINEL_VALUES: [f64; 2] = [-1.0, f64::NAN]; + +/// Checks whether a numeric value is a sentinel. +fn is_sentinel(v: f64) -> bool { + SENTINEL_VALUES + .iter() + .any(|s| v.total_cmp(s) == std::cmp::Ordering::Equal) +} /// Fetches metadata from PX-Web API endpoint. /// -/// Returns a HashMap mapping variable_id → code → label mappings. -/// This lookup is used to decode opaque codes in data responses. +/// Returns a `LookupMap` mapping dimension code → (value code → label). pub async fn fetch_metadata(client: &Client, url: &str) -> Result { info!("Fetching metadata from {}", url); - + let resp = client .get(url) .header("Accept", "application/json") .send() .await?; - + if !resp.status().is_success() { + let body = resp.text().await.unwrap_or_default(); return Err(IngestError::HttpError(reqwest::Error::from( std::io::Error::new( std::io::ErrorKind::Other, - format!("API returned status: {}", resp.status()), + format!("API returned error: {}", body), ), ))); } - + let meta: MetadataResponse = resp.json().await?; debug!("Received {} variables from metadata", meta.variables.len()); - - // Build lookup map from metadata - let mut lookup_map: LookupMap = HashMap::new(); - + for var in &meta.variables { - let codes = meta.values.get(&var.id); - if let Some(codes) = codes { - let labels: HashMap = codes - .iter() - .map(|vm| (vm.code.clone(), vm.text.clone())) - .collect(); - lookup_map.insert(var.id.clone(), labels); - info!("Loaded {} codes for variable '{}'", labels.len(), var.id); - } else { - warn!("No codes found for variable '{}'", var.id); - } + info!( + "Variable: code='{}' text='{}' role={:?} values={}", + var.code, + var.text, + var.role, + var.values.len() + ); } - + + let mut lookup_map: LookupMap = HashMap::with_capacity(meta.variables.len()); + + for var in &meta.variables { + if var.values.is_empty() { + debug!("Variable '{}' has no values", var.code); + continue; + } + + let lookup = var.lookup_map(); + info!("Loaded {} codes for '{}'", lookup.len(), var.code); + lookup_map.insert(var.code.clone(), lookup); + } + Ok(lookup_map) } +/// Extracts all available months from metadata. +/// +/// Uses the "month" dimension code since `role` is null on this endpoint. +pub fn extract_available_months(meta: &MetadataResponse) -> Vec { + meta.variables + .iter() + .find(|v| v.code == DIM_MONTH) + .map(|v| v.values.clone()) + .unwrap_or_default() +} + /// Constructs a query body for fetching all landing data. /// -/// Sets all categorical dimensions to "*" (all values) and measures to MASS+VALUE. -/// Used for full backfill ingestion. +/// Sets categorical dimensions to wildcard ("all" filter), time to explicit +/// months, and measure to MASS + VALUE. +/// +/// # Panics +/// Panics if `all_months` is empty. pub fn build_query(all_months: &[String]) -> Query { + assert!( + !all_months.is_empty(), + "build_query requires at least one month" + ); + Query { query: vec![ QueryItem { - id: "Tid".to_string(), // Month - values: all_months.to_vec(), + code: DIM_MONTH.to_string(), + selection: Selection { + filter: "item".to_string(), + values: all_months.to_vec(), + }, }, QueryItem { - id: "Art".to_string(), // Species - values: vec!["*".to_string()], + code: DIM_SPECIES.to_string(), + selection: Selection { + filter: "all".to_string(), + values: vec!["*".to_string()], + }, }, QueryItem { - id: "Redskab".to_string(), // Gear - values: vec!["*".to_string()], + code: DIM_GEAR.to_string(), + selection: Selection { + filter: "all".to_string(), + values: vec!["*".to_string()], + }, }, QueryItem { - id: "Økonomisk zone".to_string(), - values: vec!["*".to_string()], + code: DIM_ZONE.to_string(), + selection: Selection { + filter: "all".to_string(), + values: vec!["*".to_string()], + }, }, QueryItem { - id: "Tilstand".to_string(), // Processing - values: vec!["TOTAL".to_string()], + code: DIM_PROCESSING.to_string(), + selection: Selection { + filter: "all".to_string(), + values: vec!["*".to_string()], + }, }, QueryItem { - id: "Konservering".to_string(), // Preservation - values: vec!["TOTAL".to_string()], + code: DIM_PRESERVATION.to_string(), + selection: Selection { + filter: "all".to_string(), + values: vec!["*".to_string()], + }, }, QueryItem { - id: "Skibsstørrelse".to_string(), // Vessel size - values: vec!["TOTAL".to_string()], + code: DIM_SHIPSIZE.to_string(), + selection: Selection { + filter: "all".to_string(), + values: vec!["*".to_string()], + }, }, QueryItem { - id: "Måleenhed".to_string(), // Measure - values: vec!["MASS".to_string(), "VALUE".to_string()], + code: DIM_MEASURE.to_string(), + selection: Selection { + filter: "item".to_string(), + values: vec!["MASS".to_string(), "VALUE".to_string()], + }, }, ], - language: PX_WEB_LANGUAGE.to_string(), + response: QueryResponse::default(), } } /// Fetches data from PX-Web API using the provided query. pub async fn fetch_data(client: &Client, url: &str, query: &Query) -> Result { - info!("Sending data query for {} month(s)", query.query[0].values.len()); - - let resp = client - .post(url) - .json(query) - .send() - .await?; - + let month_count = query + .query + .iter() + .find(|q| q.code == DIM_MONTH) + .map(|q| q.selection.values.len()) + .unwrap_or(0); + + info!("Sending data query for {} month(s)", month_count); + + let resp = client.post(url).json(query).send().await?; + if !resp.status().is_success() { let body = resp.text().await.unwrap_or_default(); warn!("API error response: {}", body); return Err(IngestError::HttpError(reqwest::Error::from( std::io::Error::new( std::io::ErrorKind::Other, - format!("API returned status: {}", resp.status()), + format!("API returned error: {}", body), ), ))); } - + let data: DataResponse = resp.json().await?; - + if data.dataset.value.is_empty() { return Err(IngestError::EmptyDataset); } - - info!( - "Retrieved {} data points from API", - data.dataset.value.len() - ); - + + info!("Retrieved {} data points", data.dataset.value.len()); + Ok(data) } -/// Extracts dimension codes from a flat row index in JSON-stat2 format. +/// Decodes a flat row-major index into per-dimension indices. /// -/// JSON-stat2 uses a flattened array where each element corresponds to a unique -/// combination of dimension values. The dimension.keys array tells us how many -/// values exist per dimension. We decode the flat index into per-dimension indices. -fn decode_key_indices(flat_index: usize, key_counts: &[usize]) -> Vec { - let mut indices = Vec::with_capacity(key_counts.len()); +/// JSON-stat2 uses row-major order: the last dimension varies fastest. +fn decode_key_indices(flat_index: usize, key_sizes: &[usize]) -> Vec { + let mut indices = Vec::with_capacity(key_sizes.len()); let mut remaining = flat_index; - - // Process dimensions in reverse (last dimension varies fastest) - for count in key_counts.iter().rev() { - indices.push((remaining % count) as usize); - remaining /= count; + + for &size in key_sizes.iter().rev() { + indices.push(remaining % size); + remaining /= size; } - - indices.reverse(); // Restore original order + + indices.reverse(); indices } -/// Parses a single row from JSON-stat2 format into a DataRow. +/// Parses a single row from a JSON-stat2 response into a `DataRow`. /// -/// # Arguments -/// * `row_index` - Index into the dataset's value array -/// * `dataset` - The complete dataset response -/// * `lookup_maps` - Code → label mappings for each dimension +/// Dimension order in the response `id` array determines positional mapping. +/// The expected order (from API metadata) is: +/// measure, species, gear, zone, processing, preservation, shipsize, month /// -/// # Errors -/// Returns an error if the row_index exceeds bounds or required lookups are missing. +/// However, JSON-stat2 `dimension.id` defines the actual order — we read it +/// dynamically and map by dimension code, not by position assumption. pub fn parse_row( row_index: usize, dataset: &DataResponse, lookup_maps: &LookupMap, ) -> Result { let dim_info = &dataset.dataset.dimension; - let categories = &dim_info.category; - let keys = &dim_info.keys; - let value = dataset.dataset.value.get(row_index).copied().flatten(); - - // Validate bounds + let dim_order = &dim_info.id; + + if dim_order.len() != 8 { + return Err(IngestError::MissingDimension(format!( + "Expected 8 dimensions, got {}. Dimensions: {:?}", + dim_order.len(), + dim_order + ))); + } + if row_index >= dataset.dataset.value.len() { return Err(IngestError::InvalidValueCode(format!( "Row index {} out of bounds (max {})", @@ -180,83 +262,109 @@ pub fn parse_row( dataset.dataset.value.len() ))); } - - // Get category label lists for each dimension (in key order) - let category_lists: Vec> = keys + + // Build ordered category lists: for each dimension, extract (code, label) + // pairs sorted by their JSON-stat2 index position. + let category_lists: Vec> = dim_order .iter() - .filter_map(|k| { - categories.label.get(k).map(|labels| { - labels.iter().map(|s| s.as_str()).collect::>() - }) + .map(|dim_code| { + let dim = dim_info.dimensions.get(dim_code).ok_or_else(|| { + IngestError::MissingDimension(format!( + "Dimension '{}' not found in response", + dim_code + )) + })?; + + let mut entries: Vec<(String, usize)> = dim + .category + .index + .iter() + .map(|(code, &pos)| (code.clone(), pos)) + .collect(); + entries.sort_by_key(|(_, pos)| *pos); + + let list: Vec<(String, String)> = entries + .into_iter() + .map(|(code, _)| { + let label = dim.category.label.get(&code).cloned().unwrap_or_else(|| { + lookup_maps + .get(dim_code) + .and_then(|m| m.get(&code)) + .cloned() + .unwrap_or_else(|| code.clone()) + }); + (code, label) + }) + .collect(); + + Ok(list) }) - .collect(); - - if category_lists.len() != keys.len() { - return Err(IngestError::MissingDimension( - format!( - "Category count mismatch: {} keys vs {} category lists", - keys.len(), - category_lists.len() - ) - )); - } - - // Decode flat index into per-dimension indices - let key_counts: Vec = category_lists.iter().map(|c| c.len()).collect(); - let indices = decode_key_indices(row_index, &key_counts); - - // Map indices back to actual dimension values - let dimension_values: Vec<&str> = indices + .collect::>>()?; + + let key_sizes: Vec = category_lists.iter().map(|c| c.len()).collect(); + let indices = decode_key_indices(row_index, &key_sizes); + + let dimension_values: Vec<(String, String)> = indices .into_iter() .zip(category_lists.iter()) - .map(|(idx, list)| list[idx]) + .map(|(idx, list)| list[idx].clone()) .collect(); - - // Expected 8 dimensions: [month, species, gear, zone, processing, preservation, shipsize, measure] - const EXPECTED_DIMS: usize = 8; - if dimension_values.len() != EXPECTED_DIMS { - return Err(IngestError::MissingDimension(format!( - "Expected {} dimensions, got {}", - EXPECTED_DIMS, - dimension_values.len() - ))); + + // Build a lookup from dimension code → (code, label) for this row + let mut dim_map: HashMap<&str, (String, String)> = HashMap::with_capacity(8); + for (dim_code, values) in dim_order.iter().zip(dimension_values.iter()) { + dim_map.insert(dim_code.as_str(), values.clone()); } - - let [month_code, species_code, gear_code, zone_code, processing_code, preservation_code, shipsize_code, measure_code]: [&str; 8] = - dimension_values.try_into().unwrap(); - - // Helper to safely get label from lookup map - fn get_label<'a>(maps: &'a LookupMap, var_name: &str, code: &str) -> &'a str { - maps.get(var_name) - .and_then(|m| m.get(code)) - .map(|s| s.as_str()) - .unwrap_or(code) - } - - let data_row = DataRow { - month: month_code.to_string(), - species_code: species_code.to_string(), - species_label: get_label(lookup_maps, "Art", species_code).to_string(), - gear_code: gear_code.to_string(), - gear_label: get_label(lookup_maps, "Redskab", gear_code).to_string(), - zone_code: zone_code.to_string(), - zone_label: get_label(lookup_maps, "Økonomisk zone", zone_code).to_string(), - processing_code: processing_code.to_string(), - processing_label: get_label(lookup_maps, "Tilstand", processing_code).to_string(), - preservation_code: preservation_code.to_string(), - preservation_label: get_label(lookup_maps, "Konservering", preservation_code).to_string(), - shipsize_code: shipsize_code.to_string(), - shipsize_label: get_label(lookup_maps, "Skibsstørrelse", shipsize_code).to_string(), - measure_code: measure_code.to_string(), - measure_label: get_label(lookup_maps, "Måleenhed", measure_code).to_string(), - value, // Already handled None case above + + let get = |code: &str| -> (String, String) { + dim_map + .get(code) + .cloned() + .unwrap_or_else(|| ("".to_string(), "".to_string())) }; - - Ok(data_row) + + let (month_code, month_label) = get(DIM_MONTH); + let (species_code, species_label) = get(DIM_SPECIES); + let (gear_code, gear_label) = get(DIM_GEAR); + let (zone_code, zone_label) = get(DIM_ZONE); + let (processing_code, processing_label) = get(DIM_PROCESSING); + let (preservation_code, preservation_label) = get(DIM_PRESERVATION); + let (shipsize_code, shipsize_label) = get(DIM_SHIPSIZE); + let (measure_code, measure_label) = get(DIM_MEASURE); + + // Coerce sentinel values to None + let raw_value = dataset.dataset.value[row_index]; + let value = match raw_value { + Some(v) if is_sentinel(v) => None, + other => other, + }; + + debug!( + "Row {}: month={} species={} ({}) measure={} value={:?}", + row_index, month_code, species_code, species_label, measure_code, value + ); + + Ok(DataRow { + month: month_code, + species_code, + species_label, + gear_code, + gear_label, + zone_code, + zone_label, + processing_code, + processing_label, + preservation_code, + preservation_label, + shipsize_code, + shipsize_label, + measure_code, + measure_label, + value, + }) } -/// Converts DataRow to Landing struct for database insertion. -/// Removes redundant fields that aren't needed in the fact table. +/// Converts a `DataRow` to a `Landing` struct for database insertion. pub fn data_row_to_landing(row: &DataRow) -> Landing { Landing { month: row.month.clone(), @@ -272,183 +380,233 @@ pub fn data_row_to_landing(row: &DataRow) -> Landing { } } -/// Collects all months available in the metadata response. -/// Used for building incremental ingestion queries. -pub fn extract_available_months(meta: &MetadataResponse) -> Vec { - meta.values - .get("Tid") - .map(|codes| codes.iter().map(|c| c.code.clone()).collect()) - .unwrap_or_default() -} - #[cfg(test)] mod tests { use super::*; - use std::sync::OnceLock; - static CLIENT: OnceLock = OnceLock::new(); - - fn client() -> &'static Client { - CLIENT.get_or_init(Client::new) - } - - /// Test fixture: mock JSON-stat2 response with Faroese Unicode characters. - /// Simulates a response with 2 months × 2 species × 2 measures = 8 values. fn mock_dataset_response() -> DataResponse { + let mut dimensions = HashMap::new(); + + dimensions.insert( + DIM_MONTH.to_string(), + Dimension { + label: "Mánaður".to_string(), + category: CategoryInfo { + index: HashMap::from([("2015M01".to_string(), 0), ("2015M02".to_string(), 1)]), + label: HashMap::from([ + ("2015M01".to_string(), "Januar 2015".to_string()), + ("2015M02".to_string(), "Februar 2015".to_string()), + ]), + }, + }, + ); + + dimensions.insert( + DIM_SPECIES.to_string(), + Dimension { + label: "Fiskaslag".to_string(), + category: CategoryInfo { + index: HashMap::from([ + ("148XXXXXXX00000".to_string(), 0), + ("183XXXXXXX00000".to_string(), 1), + ]), + label: HashMap::from([ + ("148XXXXXXX00000".to_string(), "Sild".to_string()), + ("183XXXXXXX00000".to_string(), "Þorskur".to_string()), + ]), + }, + }, + ); + + for dim_code in [ + DIM_GEAR, + DIM_ZONE, + DIM_PROCESSING, + DIM_PRESERVATION, + DIM_SHIPSIZE, + ] { + dimensions.insert( + dim_code.to_string(), + Dimension { + label: dim_code.to_string(), + category: CategoryInfo { + index: HashMap::from([("TOTAL".to_string(), 0)]), + label: HashMap::from([("TOTAL".to_string(), "Total".to_string())]), + }, + }, + ); + } + + dimensions.insert( + DIM_MEASURE.to_string(), + Dimension { + label: "Mát".to_string(), + category: CategoryInfo { + index: HashMap::from([("MASS".to_string(), 0), ("VALUE".to_string(), 1)]), + label: HashMap::from([ + ("MASS".to_string(), "Nøgd".to_string()), + ("VALUE".to_string(), "Virði".to_string()), + ]), + }, + }, + ); + + // Dimension order: measure, species, gear, zone, processing, + // preservation, shipsize, month + // Sizes: 2, 2, 1, 1, 1, 1, 1, 2 = 8 values DataResponse { dataset: Dataset { - // Keys specify cardinality per dimension (2 months, 2 species, ..., 2 measures) - keys: vec![ - "2".to_string(), // Time (2 months) - "2".to_string(), // Art (2 species) - "1".to_string(), // Redskab (1 gear - TOTAL) - "1".to_string(), // Zone (1 zone - TOTAL) - "1".to_string(), // Tilstand (1 - TOTAL) - "1".to_string(), // Konservering (1 - TOTAL) - "1".to_string(), // Skibsstørrelse (1 - TOTAL) - "2".to_string(), // Måleenhed (2 - MASS, VALUE) - ], - category: CategoryInfo { - label: HashMap::from([ - ( - "0".to_string(), - vec!["2015M01".to_string(), "2015M02".to_string()], - ), - ( - "1".to_string(), - vec!["Sild".to_string(), "Þorskur".to_string()], - ), - ("2".to_string(), vec!["TOTAL".to_string()]), - ("3".to_string(), vec!["TOTAL".to_string()]), - ("4".to_string(), vec!["TOTAL".to_string()]), - ("5".to_string(), vec!["TOTAL".to_string()]), - ("6".to_string(), vec!["TOTAL".to_string()]), - ( - "7".to_string(), - vec!["MASS".to_string(), "VALUE".to_string()], - ), - ]), - index: None, + dimension: DimInfo { + id: vec![ + DIM_MEASURE.to_string(), + DIM_SPECIES.to_string(), + DIM_GEAR.to_string(), + DIM_ZONE.to_string(), + DIM_PROCESSING.to_string(), + DIM_PRESERVATION.to_string(), + DIM_SHIPSIZE.to_string(), + DIM_MONTH.to_string(), + ], + size: vec![2, 2, 1, 1, 1, 1, 1, 2], + dimensions, }, value: vec![ - Some(1234.5), // 2015M01, Sild, TOTAL..., MASS - Some(2345.6), // 2015M01, Sild, TOTAL..., VALUE - Some(-1.0), // 2015M01, Þorskur, TOTAL..., MASS (marker) - Some(3456.7), // 2015M01, Þorskur, TOTAL..., VALUE - Some(4567.8), // 2015M02, Sild, TOTAL..., MASS - Some(5678.9), // 2015M02, Sild, TOTAL..., VALUE - None, // 2015M02, Þorskur, TOTAL..., MASS (missing) - Some(6789.0), // 2015M02, Þorskur, TOTAL..., VALUE + Some(1234.5), // MASS, Sild, ..., 2015M01 + Some(2345.6), // MASS, Sild, ..., 2015M02 + Some(-1.0), // MASS, Þorskur, ..., 2015M01 (sentinel) + Some(3456.7), // MASS, Þorskur, ..., 2015M02 + Some(4567.8), // VALUE, Sild, ..., 2015M01 + Some(5678.9), // VALUE, Sild, ..., 2015M02 + None, // VALUE, Þorskur, ..., 2015M01 (null) + Some(6789.0), // VALUE, Þorskur, ..., 2015M02 ], + status: vec![], }, } } - /// Test fixture: mock lookup maps with Faroese labels. fn mock_lookup_maps() -> LookupMap { let mut maps = LookupMap::new(); maps.insert( - "0".to_string(), + DIM_MONTH.to_string(), HashMap::from([ ("2015M01".to_string(), "Januar 2015".to_string()), ("2015M02".to_string(), "Februar 2015".to_string()), ]), ); maps.insert( - "1".to_string(), + DIM_SPECIES.to_string(), HashMap::from([ - ("Sild".to_string(), "Sild".to_string()), - ("Þorskur".to_string(), "Þorskur".to_string()), + ("148XXXXXXX00000".to_string(), "Sild".to_string()), + ("183XXXXXXX00000".to_string(), "Þorskur".to_string()), ]), ); maps.insert( - "7".to_string(), + DIM_MEASURE.to_string(), HashMap::from([ - ("MASS".to_string(), "Kilo".to_string()), - ("VALUE".to_string(), "Krónur".to_string()), + ("MASS".to_string(), "Nøgd".to_string()), + ("VALUE".to_string(), "Virði".to_string()), ]), ); maps } - #[tokio::test] - async fn test_build_query_all_wildcards() { + #[test] + fn test_build_query_uses_correct_dimension_codes() { let months = vec!["2015M01".to_string(), "2015M02".to_string()]; let query = build_query(&months); - - assert_eq!(query.language, PX_WEB_LANGUAGE); - assert_eq!(query.query.len(), 8); // All 8 dimensions - - // Check that species is wildcard - let species_query = query.query.iter().find(|q| q.id == "Art").unwrap(); - assert_eq!(species_query.values, vec!["*".to_string()]); - - // Check that measures includes both MASS and VALUE - let measure_query = query.query.iter().find(|q| q.id == "Måleenhed").unwrap(); - assert!(measure_query.values.contains(&"MASS".to_string())); - assert!(measure_query.values.contains(&"VALUE".to_string())); + + assert_eq!(query.response.format, "json-stat2"); + assert_eq!(query.query.len(), 8); + + assert_eq!(query.query[0].code, DIM_MONTH); + assert_eq!(query.query[0].selection.filter, "item"); + assert_eq!(query.query[0].selection.values.len(), 2); + + assert_eq!(query.query[1].code, DIM_SPECIES); + assert_eq!(query.query[1].selection.filter, "all"); + + assert_eq!(query.query[7].code, DIM_MEASURE); + assert!( + query.query[7] + .selection + .values + .contains(&"MASS".to_string()) + ); + assert!( + query.query[7] + .selection + .values + .contains(&"VALUE".to_string()) + ); } #[test] fn test_decode_key_indices_basic() { - // 2 × 2 × 2 = 8 combinations - let key_counts = vec![2, 2, 2]; - - // Index 0 should give [0, 0, 0] - let indices = decode_key_indices(0, &key_counts); - assert_eq!(indices, vec![0, 0, 0]); - - // Index 7 should give [1, 1, 1] - let indices = decode_key_indices(7, &key_counts); - assert_eq!(indices, vec![1, 1, 1]); - - // Index 3 should give [0, 1, 1] (middle combination) - let indices = decode_key_indices(3, &key_counts); - assert_eq!(indices, vec![0, 1, 1]); + let key_sizes = vec![2, 2, 2]; + assert_eq!(decode_key_indices(0, &key_sizes), vec![0, 0, 0]); + assert_eq!(decode_key_indices(7, &key_sizes), vec![1, 1, 1]); + assert_eq!(decode_key_indices(3, &key_sizes), vec![0, 1, 1]); + } + + #[test] + fn test_decode_key_indices_single_dim() { + let key_sizes = vec![5]; + assert_eq!(decode_key_indices(0, &key_sizes), vec![0]); + assert_eq!(decode_key_indices(4, &key_sizes), vec![4]); } #[test] fn test_parse_row_faroese_unicode() { let dataset = mock_dataset_response(); let lookup_maps = mock_lookup_maps(); - - // Parse first row (index 0) - let row = parse_row(0, &dataset, &lookup_maps).expect("Failed to parse row"); - - // Verify Faroese characters survive intact + + let row = parse_row(0, &dataset, &lookup_maps).expect("parse failed"); + assert_eq!(row.month, "2015M01"); - assert_eq!(row.species_code, "Sild"); - assert!(row.species_label.contains("Sild")); + assert_eq!(row.species_code, "148XXXXXXX00000"); + assert_eq!(row.species_label, "Sild"); assert_eq!(row.measure_code, "MASS"); - - // Verify value is preserved - assert!(row.value.is_some()); - assert_eq!(row.value.unwrap(), 1234.5); + assert_eq!(row.measure_label, "Nøgd"); + assert_eq!(row.value, Some(1234.5)); } #[test] - fn test_parse_row_second_species() { + fn test_parse_row_thorn_character() { let dataset = mock_dataset_response(); let lookup_maps = mock_lookup_maps(); - - // Row index 2 should be Þorskur (second species, first time, MASS) - let row = parse_row(2, &dataset, &lookup_maps).expect("Failed to parse row"); - - // Verify the special character survives - assert_eq!(row.species_code, "Þorskur"); - assert!(row.species_label.contains("Þ")); - assert!(row.species_label.contains("orskur")); + + // Row 2: MASS, Þorskur, ..., 2015M01 + let row = parse_row(2, &dataset, &lookup_maps).expect("parse failed"); + + assert_eq!(row.species_code, "183XXXXXXX00000"); + assert_eq!(row.species_label, "Þorskur"); + assert!(row.species_label.contains('Þ')); } #[test] - fn test_parse_row_missing_value_handling() { + fn test_parse_row_sentinel_coerced_to_none() { let dataset = mock_dataset_response(); let lookup_maps = mock_lookup_maps(); - - // Row index 6 has None value (missing data for 2015M02, Þorskur, MASS) - let row = parse_row(6, &dataset, &lookup_maps).expect("Failed to parse row"); - - // Missing values should become None, not panic + + // Row 2 has -1.0 sentinel + let row = parse_row(2, &dataset, &lookup_maps).expect("parse failed"); + + assert!( + row.value.is_none(), + "Sentinel -1.0 must be None, got {:?}", + row.value + ); + } + + #[test] + fn test_parse_row_explicit_null() { + let dataset = mock_dataset_response(); + let lookup_maps = mock_lookup_maps(); + + // Row 6 has None + let row = parse_row(6, &dataset, &lookup_maps).expect("parse failed"); + assert!(row.value.is_none()); } @@ -456,54 +614,128 @@ mod tests { fn test_parse_row_out_of_bounds() { let dataset = mock_dataset_response(); let lookup_maps = mock_lookup_maps(); - - // Requesting out-of-bounds index should return error + let result = parse_row(100, &dataset, &lookup_maps); assert!(result.is_err()); - - if let Err(IngestError::InvalidValueCode(msg)) = result { - assert!(msg.contains("out of bounds")); - } else { - panic!("Expected InvalidValueCode error"); + + match result { + Err(IngestError::InvalidValueCode(msg)) => assert!(msg.contains("out of bounds")), + _ => panic!("Expected InvalidValueCode"), } } + #[test] + fn test_parse_row_wrong_dimension_count() { + let mut dataset = mock_dataset_response(); + dataset.dataset.dimension.id.pop(); + dataset.dataset.dimension.size.pop(); + + let lookup_maps = mock_lookup_maps(); + let result = parse_row(0, &dataset, &lookup_maps); + assert!(result.is_err()); + } + #[test] fn test_data_row_to_landing() { let dataset = mock_dataset_response(); let lookup_maps = mock_lookup_maps(); - - let row = parse_row(0, &dataset, &lookup_maps).expect("Failed to parse row"); + + let row = parse_row(0, &dataset, &lookup_maps).expect("parse failed"); let landing = data_row_to_landing(&row); - - // Verify core fields are copied + assert_eq!(landing.month, row.month); assert_eq!(landing.species_code, row.species_code); + assert_eq!(landing.species_label, row.species_label); assert_eq!(landing.measure_code, row.measure_code); assert_eq!(landing.value, row.value); - - // Verify lookup fields are preserved - assert_eq!(landing.species_label, row.species_label); - assert_eq!(landing.gear_code, row.gear_code); - assert_eq!(landing.zone_code, row.zone_code); + } + + #[test] + fn test_faroese_unicode_all_rows() { + let dataset = mock_dataset_response(); + let lookup_maps = mock_lookup_maps(); + + for i in 0..8 { + let row = parse_row(i, &dataset, &lookup_maps); + assert!(row.is_ok(), "Row {} failed", i); + + if let Ok(r) = row { + assert!( + !r.species_label.contains('\u{FFFD}'), + "Replacement char in row {}", + i + ); + } + } + } + + #[test] + fn test_is_sentinel() { + assert!(is_sentinel(-1.0)); + assert!(is_sentinel(f64::NAN)); + assert!(!is_sentinel(0.0)); + assert!(!is_sentinel(1234.5)); + assert!(!is_sentinel(0.001)); } #[test] fn test_extract_available_months() { let meta = MetadataResponse { - variables: vec![], - values: HashMap::from([( - "Tid".to_string(), - vec![ - ValueMeta { code: "2015M01".to_string(), text: "Jan 2015".to_string() }, - ValueMeta { code: "2015M02".to_string(), text: "Feb 2015".to_string() }, - ], - )]), + title: Some("test".to_string()), + variables: vec![VariableMeta { + code: DIM_MONTH.to_string(), + text: "Mánaður".to_string(), + role: None, + values: vec!["2015M01".to_string(), "2015M02".to_string()], + value_texts: vec!["Jan 2015".to_string(), "Feb 2015".to_string()], + extra: HashMap::new(), + }], }; - + let months = extract_available_months(&meta); assert_eq!(months.len(), 2); assert!(months.contains(&"2015M01".to_string())); assert!(months.contains(&"2015M02".to_string())); } + + #[test] + fn test_extract_available_months_no_month_var() { + let meta = MetadataResponse { + title: None, + variables: vec![VariableMeta { + code: DIM_SPECIES.to_string(), + text: "Fiskaslag".to_string(), + role: None, + values: vec!["TOTAL".to_string()], + value_texts: vec!["Tils.".to_string()], + extra: HashMap::new(), + }], + }; + + let months = extract_available_months(&meta); + assert!(months.is_empty()); + } + + #[test] + #[should_panic(expected = "requires at least one month")] + fn test_build_query_empty_panics() { + let _ = build_query(&[]); + } + + #[test] + fn test_variable_meta_lookup_map() { + let var = VariableMeta { + code: "measure".to_string(), + text: "mát".to_string(), + role: None, + values: vec!["MASS".to_string(), "VALUE".to_string()], + value_texts: vec!["Nøgd".to_string(), "Virði".to_string()], + extra: HashMap::new(), + }; + + let map = var.lookup_map(); + assert_eq!(map.get("MASS"), Some(&"Nøgd".to_string())); + assert_eq!(map.get("VALUE"), Some(&"Virði".to_string())); + assert_eq!(map.len(), 2); + } } diff --git a/src/main.rs b/src/main.rs index e7a11a9..ec562c9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,3 @@ fn main() { - println!("Hello, world!"); + println!("hagfish — not yet wired. Run tests with: cargo test"); } diff --git a/src/types.rs b/src/types.rs index f42c1bb..fdd5a78 100644 --- a/src/types.rs +++ b/src/types.rs @@ -20,63 +20,132 @@ impl Default for Config { Self { duckdb_path: "hagfish.db".to_string(), bind_address: "127.0.0.1:8090".to_string(), - data_source_url: "https://statbank.hagstova.fo/data/api/table/fisknv_md".to_string(), + data_source_url: "https://statbank.hagstova.fo/api/v1/fo/H2/VV/VV01/fisknv_md.px" + .to_string(), log_file_path: Some("hagfish.log".to_string()), } } } +// --------------------------------------------------------------------------- +// Metadata types (GET response) +// --------------------------------------------------------------------------- + /// Metadata response from PX-Web API GET request. -/// Contains variable definitions and value codes with labels. +/// +/// Confirmed structure from live API: +/// ```json +/// { +/// "title": "AVR01010 ...", +/// "variables": [ +/// { +/// "code": "measure", +/// "text": "mát", +/// "role": null, +/// "values": ["MASS", "VALUE"], +/// "valueTexts": ["Nøgd", "Virði"] +/// } +/// ] +/// } +/// ``` #[derive(Debug, Clone, Deserialize, Serialize)] pub struct MetadataResponse { + #[serde(default)] + pub title: Option, pub variables: Vec, - pub values: HashMap>, } /// Variable metadata describing a dimension in the PX-Web table. +/// +/// PxWeb v1 uses parallel string arrays for codes and labels. +/// The `role` field is null on this endpoint — do not rely on it. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct VariableMeta { - pub id: String, + /// Variable identifier used in queries (e.g. "month", "measure", + /// "Species (ASFIS2022)") + pub code: String, + /// Human-readable label in the queried language + #[serde(default)] pub text: String, - pub role: String, - /// Position in the key array (0-indexed) - #[serde(rename = "keyPosition", skip_serializing_if = "Option::is_none")] - pub key_position: Option, + /// Role classification — null on this endpoint + #[serde(default)] + pub role: Option, + /// Code values for this variable (parallel with valueTexts) + #[serde(default)] + pub values: Vec, + /// Display labels for each value (parallel with values) + #[serde(default, rename = "valueTexts")] + pub value_texts: Vec, + /// Catch-all for unknown fields + #[serde(flatten)] + pub extra: HashMap, } -/// Value metadata: code → display label mapping for a variable. -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct ValueMeta { - pub code: String, - pub text: String, +impl VariableMeta { + /// Build a code→label lookup map from the parallel arrays. + pub fn lookup_map(&self) -> HashMap { + self.values + .iter() + .zip(self.value_texts.iter()) + .map(|(code, label)| (code.clone(), label.clone())) + .collect() + } } +// --------------------------------------------------------------------------- +// Query types (POST request body) +// --------------------------------------------------------------------------- + /// Query body sent to PX-Web API POST endpoint. +/// +/// Confirmed format: +/// ```json +/// { +/// "query": [{"code": "month", "selection": {"filter": "item", "values": [...]}}], +/// "response": {"format": "json-stat2"} +/// } +/// ``` #[derive(Debug, Clone, Serialize)] pub struct Query { pub query: Vec, - pub language: String, + pub response: QueryResponse, } /// Single query item representing a dimension selection. #[derive(Debug, Clone, Serialize)] pub struct QueryItem { - pub id: String, + pub code: String, + pub selection: Selection, +} + +/// Selection within a query item. +#[derive(Debug, Clone, Serialize)] +pub struct Selection { + /// "item" for explicit values, "all" for wildcard, "top" for top-N + pub filter: String, + /// Values to select. For "all" filter, use ["*"]. pub values: Vec, } -/// Selection helper for building queries programmatically. -#[derive(Debug, Clone)] -pub struct Selection { - /// Dimension name (matches variable.id from metadata) - pub dimension: String, - /// Codes to include, or "*" for all - pub codes: Vec, +/// Response format specification. +#[derive(Debug, Clone, Serialize)] +pub struct QueryResponse { + pub format: String, } +impl Default for QueryResponse { + fn default() -> Self { + Self { + format: "json-stat2".to_string(), + } + } +} + +// --------------------------------------------------------------------------- +// Data response types (JSON-stat2) +// --------------------------------------------------------------------------- + /// Raw data response from PX-Web API POST request. -/// JSON-stat2 format with metadata and data sections. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct DataResponse { pub dataset: Dataset, @@ -87,24 +156,52 @@ pub struct DataResponse { pub struct Dataset { pub dimension: DimInfo, pub value: Vec>, + /// Status codes per value (optional) + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub status: Vec, } -/// Dimension metadata describing key layout. +/// Dimension metadata in JSON-stat2 format. +/// +/// Uses a flat `id` array for ordering and a `size` array for cardinality. +/// Each dimension is keyed by its code in the `dimensions` map. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct DimInfo { - #[serde(rename = "key")] - pub keys: Vec, + /// Ordered dimension IDs (defines cube layout) + #[serde(default)] + pub id: Vec, + /// Size of each dimension + #[serde(default)] + pub size: Vec, + /// One entry per dimension, keyed by dimension code + #[serde(flatten)] + pub dimensions: HashMap, +} + +/// A single dimension in the JSON-stat2 response. +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct Dimension { + /// Display label + #[serde(default)] + pub label: String, + /// Category info with index and label maps pub category: CategoryInfo, } -/// Category info containing value lists for each dimension. +/// Category info containing index and label maps. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct CategoryInfo { - pub label: HashMap>, - #[serde(skip_serializing_if = "Option::is_none")] - pub index: Option>>, + /// Maps category code → numeric position in the dimension + pub index: HashMap, + /// Maps category code → display label + #[serde(default)] + pub label: HashMap, } +// --------------------------------------------------------------------------- +// Internal data models +// --------------------------------------------------------------------------- + /// Decoded row of landing data with labeled dimensions. #[derive(Debug, Clone)] pub struct DataRow { @@ -126,7 +223,7 @@ pub struct DataRow { pub value: Option, } -/// Structured representation of a single landing record. +/// Structured representation of a single landing record for DB insertion. #[derive(Debug, Clone)] pub struct Landing { pub month: String, @@ -141,6 +238,10 @@ pub struct Landing { pub value: Option, } +// --------------------------------------------------------------------------- +// Errors +// --------------------------------------------------------------------------- + /// Error types for ingestion module. #[derive(Debug, thiserror::Error)] pub enum IngestError { @@ -153,18 +254,21 @@ pub enum IngestError { #[error("Missing dimension in response: {0}")] MissingDimension(String), - #[error("Invalid value code: {0}")] + #[error("Invalid value: {0}")] InvalidValueCode(String), #[error("API returned empty data set")] EmptyDataset, - #[error("Unicode decode error: {0}")] - UnicodeError(String), + #[error("Dimension '{0}' not found in metadata")] + DimensionNotFound(String), } -/// Lookup map for decoding key arrays into labeled values. -/// Keyed by dimension name, contains code → label mappings. +// --------------------------------------------------------------------------- +// Type aliases +// --------------------------------------------------------------------------- + +/// Lookup map: dimension_code → (value_code → display_label). pub type LookupMap = HashMap>; /// Result alias using custom error type.