package main

type ErrorResponse struct {
	Detail string `json:"detail"`
}

type HealthResponse struct {
	Status string `json:"status"`
}

type Node struct {
	ID       uint32  `json:"id"`
	TermType string  `json:"termType"` // "uri" | "bnode"
	IRI      string  `json:"iri"`
	Label    *string `json:"label"`
	X        float64 `json:"x"`
	Y        float64 `json:"y"`
}

type Edge struct {
	Source    uint32 `json:"source"`
	Target    uint32 `json:"target"`
	PredicateID uint32 `json:"predicate_id"`
}

type GraphMeta struct {
	Backend        string  `json:"backend"`
	TTLPath        *string `json:"ttl_path"`
	SparqlEndpoint string  `json:"sparql_endpoint"`
	IncludeBNodes  bool    `json:"include_bnodes"`
	GraphQueryID   string  `json:"graph_query_id"`
	Predicates     []string `json:"predicates,omitempty"` // index = predicate_id
	NodeLimit      int     `json:"node_limit"`
	EdgeLimit      int     `json:"edge_limit"`
	Nodes          int     `json:"nodes"`
	Edges          int     `json:"edges"`
}

type GraphResponse struct {
	Nodes []Node    `json:"nodes"`
	Edges []Edge    `json:"edges"`
	Meta  *GraphMeta `json:"meta"`
}

type StatsResponse struct {
	Backend        string  `json:"backend"`
	TTLPath        *string `json:"ttl_path"`
	SparqlEndpoint *string `json:"sparql_endpoint"`
	ParsedTriples  int     `json:"parsed_triples"`
	Nodes          int     `json:"nodes"`
	Edges          int     `json:"edges"`
}

type SparqlQueryRequest struct {
	Query string `json:"query"`
}

type NeighborsRequest struct {
	SelectedIDs  []uint32 `json:"selected_ids"`
	NodeLimit    *int     `json:"node_limit,omitempty"`
	EdgeLimit    *int     `json:"edge_limit,omitempty"`
	GraphQueryID  *string `json:"graph_query_id,omitempty"`
}

type NeighborsResponse struct {
	SelectedIDs []uint32 `json:"selected_ids"`
	NeighborIDs []uint32 `json:"neighbor_ids"`
}

type SelectionQueryRequest struct {
	QueryID      string   `json:"query_id"`
	SelectedIDs  []uint32 `json:"selected_ids"`
	NodeLimit    *int     `json:"node_limit,omitempty"`
	EdgeLimit    *int     `json:"edge_limit,omitempty"`
	GraphQueryID  *string `json:"graph_query_id,omitempty"`
}

type SelectionQueryResponse struct {
	QueryID     string   `json:"query_id"`
	SelectedIDs []uint32 `json:"selected_ids"`
	NeighborIDs []uint32 `json:"neighbor_ids"`
}
