#![allow(clippy::all)]
#![allow(dead_code)]

#[allow(unused)]
pub const FILE_DESCRIPTOR_SET: &[u8] = tonic::include_file_descriptor_set!("proto_descriptor");

pub mod acme {
    pub mod user {
        pub mod v1 {
            use saas_rs_sdk::storage::associations::{BelongsTo, HasMany};
            use std::collections::HashMap;
            use strum::IntoEnumIterator;
            use strum_macros::{AsRefStr, Display, EnumIter};

            include!("generated/acme.user.v1.rs");
            include!("generated/acme.user.v1.serde.rs");

            #[derive(AsRefStr, Clone, Debug, Display, EnumIter)]
            pub enum Bucket {
                #[strum(serialize = "accessTokens")]
                AccessTokens,
                #[strum(serialize = "accounts")]
                Accounts,
                #[strum(serialize = "linkedAccounts")]
                LinkedAccounts,
                #[strum(serialize = "refreshTokens")]
                RefreshTokens,
                #[strum(serialize = "typeSaladBooleanTypes")]
                TypeSaladBooleanTypes,
                #[strum(serialize = "typeSaladCharacterTypes")]
                TypeSaladCharacterTypes,
                #[strum(serialize = "typeSaladNumericArbitraryPrecisionTypes")]
                TypeSaladNumericArbitraryPrecisionTypes,
                #[strum(serialize = "typeSaladNumericFloatingPointTypes")]
                TypeSaladNumericFloatingPointTypes,
                #[strum(serialize = "typeSaladNumericIntegerTypes")]
                TypeSaladNumericIntegerTypes,
                #[strum(serialize = "typeSaladNumericSerialTypes")]
                TypeSaladNumericSerialTypes,
                #[strum(serialize = "typeSaladUuidTypes")]
                TypeSaladUuidTypes,
            }

            fn get_belongs_tos(bucket: Bucket) -> Vec<BelongsTo<Bucket>> {
                match bucket {
                    Bucket::LinkedAccounts => vec![BelongsTo {
                        remote: Bucket::Accounts,
                        local: "ownerAccountId".to_string(),
                        inverse: Some("linkedAccountIds".to_string()),
                    }],
                    _ => vec![],
                }
            }

            #[allow(unused)]
            pub fn get_belongs_tos_by_bucket() -> HashMap<String, Vec<BelongsTo<Bucket>>> {
                let mut map = HashMap::new();
                for bucket in Bucket::iter() {
                    map.insert(bucket.to_string(), get_belongs_tos(bucket));
                }
                map
            }

            fn get_has_manys(bucket: Bucket) -> Vec<HasMany<Bucket>> {
                match bucket {
                    Bucket::Accounts => vec![HasMany {
                        remote: Bucket::LinkedAccounts,
                        local: "linkedAccountIds".to_string(),
                        inverse: Some("ownerAccountId".to_string()),
                    }],
                    _ => vec![],
                }
            }

            #[allow(unused)]
            pub fn get_has_manys_by_bucket() -> HashMap<String, Vec<HasMany<Bucket>>> {
                let mut map = HashMap::new();
                for bucket in Bucket::iter() {
                    map.insert(bucket.to_string(), get_has_manys(bucket));
                }
                map
            }
        }
    }
}

#[allow(unused)]
pub fn deserialize<T: prost::Message + Default>(buf: &[u8]) -> Result<T, prost::DecodeError> {
    T::decode(&mut std::io::Cursor::new(buf))
}

#[allow(unused)]
pub fn serialize<T: prost::Message>(message: &T) -> Vec<u8> {
    let mut buf = Vec::with_capacity(message.encoded_len());
    message.encode(&mut buf).unwrap();
    buf
}
