load("@rules_proto//proto:defs.bzl", "proto_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@com_github_grpc_ecosystem_grpc_gateway_v2//protoc-gen-openapiv2:defs.bzl", "protoc_gen_openapiv2")
load("@openapi_tools_generator_bazel//:defs.bzl", "openapi_generator")

proto_library(
    name = "obsidianpb_proto",
    srcs = ["obsidian.proto"],
    visibility = ["//visibility:public"],
    deps = [
        "@com_envoyproxy_protoc_gen_validate//validate:validate_proto",
        "@go_googleapis//google/api:annotations_proto",
    ],
)

go_proto_library(
    name = "obsidianpb_go_proto",
    compilers = [
        "//:go_apiv2",
        "//:go_grpc",
        "//:go_validate",
        "@com_github_grpc_ecosystem_grpc_gateway_v2//protoc-gen-grpc-gateway:go_gen_grpc_gateway",
    ],
    importpath = "peridot.resf.org/obsidian/pb",
    proto = ":obsidianpb_proto",
    visibility = ["//visibility:public"],
    deps = [
        "@com_envoyproxy_protoc_gen_validate//validate:validate_go_proto",
        "@go_googleapis//google/api:annotations_go_proto",
    ],
)

go_library(
    name = "pb",
    embed = [":obsidianpb_go_proto"],
    importpath = "peridot.resf.org/obsidian/pb",
    visibility = ["//visibility:public"],
)

protoc_gen_openapiv2(
    name = "openapi",
    proto = ":obsidianpb_proto",
    simple_operation_ids = True,
    single_output = True,
)

openapi_generator(
    name = "client_typescript",
    generator = "typescript-fetch",
    spec = ":openapi",
    visibility = ["//visibility:public"],
)