load("@crates//:defs.bzl", "aliases", "all_crate_deps")

load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library", "rust_proc_macro", "rust_test")



filegroup(

    name = "cargo_manifest",

    srcs = ["Cargo.toml"],

    visibility = ["//visibility:public"],

)



filegroup(

    name = "package_runfiles",

    srcs = glob(["Cargo.toml", "**/*"], exclude = ["BUILD", "BUILD.bazel"], allow_empty = True),

    visibility = ["//visibility:public"],

)



rust_library(
    name = "meerkat_openai",
    aliases = aliases(package_name = "meerkat-openai"),
    crate_name = "meerkat_openai",
    crate_root = "src/lib.rs",
    crate_features = [
        "oauth",
        "realtime",
    ],
    edition = "2024",
    compile_data = [
        "Cargo.toml",
    ],
    srcs = glob(["src/**/*.rs"]),
    visibility = ["//visibility:public"],
    rustc_env = {
        "CARGO_PKG_VERSION": "0.6.32",
        "CARGO_MANIFEST_DIR": "./meerkat-openai",
    },
    proc_macro_deps = all_crate_deps(
        package_name = "meerkat-openai",
        proc_macro = True,
    ),
    deps = [
        "//meerkat-auth-core:meerkat_auth_core",
        "//meerkat-contracts:meerkat_contracts",
        "//meerkat-core:meerkat_core",
        "//meerkat-llm-core:meerkat_llm_core",
    ] + all_crate_deps(
        package_name = "meerkat-openai",
        normal = True,
    ),
)

rust_library(
    name = "meerkat_openai_agent_factory_build",
    aliases = aliases(package_name = "meerkat-openai"),
    crate_name = "meerkat_openai",
    crate_root = "src/lib.rs",
    crate_features = [
        "oauth",
        "realtime",
    ],
    edition = "2024",
    compile_data = [
        "Cargo.toml",
    ],
    srcs = glob(["src/**/*.rs"]),
    visibility = [
        "//meerkat:__pkg__",
    ],
    rustc_env = {
        "CARGO_PKG_VERSION": "0.6.32",
        "CARGO_MANIFEST_DIR": "./meerkat-openai",
    },
    proc_macro_deps = all_crate_deps(
        package_name = "meerkat-openai",
        proc_macro = True,
    ),
    deps = [
        "//meerkat:meerkat_auth_core_agent_factory_build",
        "//meerkat:meerkat_contracts_agent_factory_build",
        "//meerkat:meerkat_core_agent_factory_build",
        "//meerkat:meerkat_llm_core_agent_factory_build",
    ] + all_crate_deps(
        package_name = "meerkat-openai",
        normal = True,
    ),
)

rust_test(
    name = "meerkat_openai_unit_test",
    aliases = aliases(
        package_name = "meerkat-openai",
        normal = True,
        normal_dev = True,
        proc_macro = True,
        proc_macro_dev = True,
    ),
    crate_name = "meerkat_openai",
    crate_root = "src/lib.rs",
    crate_features = [
        "oauth",
        "realtime",
    ],
    edition = "2024",
    compile_data = [
        "Cargo.toml",
    ],
    srcs = glob(["src/**/*.rs"]),
    visibility = ["//visibility:public"],
    rustc_env = {
        "CARGO_PKG_VERSION": "0.6.32",
        "CARGO_MANIFEST_DIR": "./meerkat-openai",
    },
    tags = [
        "fast",
        "unit",
    ],
    size = "small",
    data = [
        ":package_runfiles",
    ],
    env = {
        "RUST_MIN_STACK": "16777216",
    },
    proc_macro_deps = all_crate_deps(
        package_name = "meerkat-openai",
        proc_macro = True,
        proc_macro_dev = True,
    ),
    deps = [
        "//meerkat-auth-core:meerkat_auth_core",
        "//meerkat-contracts:meerkat_contracts",
        "//meerkat-core:meerkat_core",
        "//meerkat-llm-core:meerkat_llm_core",
    ] + all_crate_deps(
        package_name = "meerkat-openai",
        normal = True,
        normal_dev = True,
    ),
)

rust_test(
    name = "mock_realtime_ws_selftest_test",
    aliases = aliases(
        package_name = "meerkat-openai",
        normal = True,
        normal_dev = True,
        proc_macro = True,
        proc_macro_dev = True,
    ),
    crate_name = "mock_realtime_ws_selftest",
    crate_root = "tests/mock_realtime_ws_selftest.rs",
    crate_features = [
        "oauth",
        "realtime",
    ],
    edition = "2024",
    compile_data = [
        "Cargo.toml",
    ],
    srcs = [
        "tests/mock_realtime_ws/mod.rs",
        "tests/mock_realtime_ws/server.rs",
        "tests/mock_realtime_ws_selftest.rs",
    ],
    visibility = ["//visibility:public"],
    rustc_env = {
        "CARGO_PKG_VERSION": "0.6.32",
        "CARGO_BIN_NAME": "mock_realtime_ws_selftest",
        "CARGO_MANIFEST_DIR": "./meerkat-openai",
    },
    tags = [
        "fast",
    ],
    size = "small",
    data = [],
    env = {
        "RUST_MIN_STACK": "16777216",
    },
    proc_macro_deps = all_crate_deps(
        package_name = "meerkat-openai",
        proc_macro = True,
        proc_macro_dev = True,
    ),
    deps = [
        "//meerkat-auth-core:meerkat_auth_core",
        "//meerkat-contracts:meerkat_contracts",
        "//meerkat-core:meerkat_core",
        "//meerkat-llm-core:meerkat_llm_core",
        "//meerkat-openai:meerkat_openai",
    ] + all_crate_deps(
        package_name = "meerkat-openai",
        normal = True,
        normal_dev = True,
    ),
)

rust_test(
    name = "oauth_resolve_test",
    aliases = aliases(
        package_name = "meerkat-openai",
        normal = True,
        normal_dev = True,
        proc_macro = True,
        proc_macro_dev = True,
    ),
    crate_name = "oauth_resolve",
    crate_root = "tests/oauth_resolve.rs",
    crate_features = [
        "oauth",
        "realtime",
    ],
    edition = "2024",
    compile_data = [
        "Cargo.toml",
    ],
    srcs = [
        "tests/oauth_resolve.rs",
    ],
    visibility = ["//visibility:public"],
    rustc_env = {
        "CARGO_PKG_VERSION": "0.6.32",
        "CARGO_BIN_NAME": "oauth_resolve",
        "CARGO_MANIFEST_DIR": "./meerkat-openai",
    },
    tags = [
        "fast",
    ],
    size = "small",
    data = [],
    env = {
        "RUST_MIN_STACK": "16777216",
    },
    proc_macro_deps = all_crate_deps(
        package_name = "meerkat-openai",
        proc_macro = True,
        proc_macro_dev = True,
    ),
    deps = [
        "//meerkat-auth-core:meerkat_auth_core",
        "//meerkat-contracts:meerkat_contracts",
        "//meerkat-core:meerkat_core",
        "//meerkat-llm-core:meerkat_llm_core",
        "//meerkat-openai:meerkat_openai",
    ] + all_crate_deps(
        package_name = "meerkat-openai",
        normal = True,
        normal_dev = True,
    ),
)

test_suite(
    name = "fast_tests",
    tests = [
        ":meerkat_openai_unit_test",
        ":mock_realtime_ws_selftest_test",
        ":oauth_resolve_test",
    ],
)
