package selection_queries

import "context"

type Querier interface {
	Query(ctx context.Context, query string) ([]byte, error)
}

type NodeRef struct {
	ID       uint32
	TermType string // "uri" | "bnode"
	IRI      string
}

type Index struct {
	IDToNode         map[uint32]NodeRef
	KeyToID          map[string]uint32
	PredicateIDByIRI map[string]uint32
}

type Meta struct {
	ID    string `json:"id"`
	Label string `json:"label"`
}

type TripleTerm struct {
	Type  string `json:"type"`
	Value string `json:"value"`
	Lang  string `json:"lang,omitempty"`
}

type Triple struct {
	S           TripleTerm `json:"s"`
	P           TripleTerm `json:"p"`
	O           TripleTerm `json:"o"`
	SubjectID   *uint32    `json:"subject_id,omitempty"`
	ObjectID    *uint32    `json:"object_id,omitempty"`
	PredicateID *uint32    `json:"predicate_id,omitempty"`
}

type Result struct {
	NeighborIDs []uint32 `json:"neighbor_ids"`
	Triples     []Triple `json:"triples"`
}

type Definition struct {
	Meta Meta
	Run  func(ctx context.Context, q Querier, idx Index, selectedIDs []uint32, includeBNodes bool) (Result, error)
}
