Versions in this module Expand all Collapse all v0 v0.271.0 Nov 11, 2026 v0.270.0 Nov 6, 2026 v0.269.0 Nov 5, 2026 v0.268.0 Oct 28, 2026 Changes in this version + const DefaultFile + const EvalTimeout + const MaxIteratorItems + const MaxRules + const MaxTuples + const Version + var ErrChangedOnDisk = errors.New("changed on disk since it was loaded; reload it before saving") + var ErrLayout = errors.New("the saved file would differ from the edit") + var ErrNoEvent = errors.New("no event") + func AppliedSoFar(p *Plan, applied int) string + func ApplyQuestion(writes, deletes int, name, id string) string + func ChangeLine(t language.Tuple, field func(string) string) string + func CheckTuple(t language.Tuple) error + func Compile(d *Document) ([]byte, *mapper.Mapping, mapper.Diagnostics, error) + func CompileSource(src []byte) (*mapper.Mapping, mapper.Diagnostics, error) + func DecodeEvent(data []byte) (map[string]any, error) + func EvalExpr(ctx context.Context, vars []Variable, expr string, event map[string]any) (any, error) + func Execute(ctx context.Context, p *Plan, w TupleWriter, progress func(done, total int)) (int, error) + func FieldInRule(field string) string + func IteratorItem(ctx context.Context, r Rule, event map[string]any) (any, bool) + func Lookup(event map[string]any, expr string) (any, bool) + func Marshal(d *Document) ([]byte, error) + func MissingTypes(d *Document, ix *ModelIndex) []string + func ParseEvents(r io.Reader, source string) ([]map[string]any, error) + func PlanSummary(p *Plan) string + func PlanText(p *Plan, field func(string) string) []string + func Plural(n int, noun string) string + func SampleKey(event map[string]any) (string, error) + func SamplesFromTests(ctx context.Context, d *Document) + func SentLine(p *Plan, label string) string + func TupleText(t language.Tuple, field func(string) string) string + func UniqueTestName(tests []TestCase, name string) string + type ContextEntry struct + Key string + Template string + type Document struct + Rules []Rule + Tests []TestCase + type Event struct + Label string + Payload map[string]any + func Events(d *Document) []Event + type EventPlan struct + Atomic bool + Changes []language.Tuple + Index int + Matched bool + Type string + func (e EventPlan) Requests() int + type File struct + Doc *Document + Editable bool + Invalid mapper.Diagnostics + Path string + Reason string + Src []byte + func Create(path string, doc *Document) (*File, error) + func Load(path string) (*File, error) + func LoadBytes(path string, data []byte) (*File, error) + func LoadDraft(path string) (*File, error) + func LoadDraftBytes(path string, data []byte) (*File, error) + func (f *File) ChangedOnDisk() (bool, error) + func (f *File) Overwrite(doc *Document) (bool, error) + func (f *File) ProblemPos(p Problem) (line, col int) + func (f *File) Render(doc *Document) ([]byte, bool, error) + func (f *File) RuleLine(i int) (line, col int) + func (f *File) Save(doc *Document) (bool, error) + func (f *File) SaveReformatted(doc *Document) (bool, error) + func (f *File) TestLine(i int) (line, col int) + type Finding struct + Column int + Field string + Line int + Message string + Rule int + Section string + func Check(f *File, ix *ModelIndex) []Finding + func FindingsFrom(diags mapper.Diagnostics) []Finding + type Iterator struct + As string + Source string + Tuples []Tuple + type LoadError struct + Diagnostics mapper.Diagnostics + Path string + func (e *LoadError) Error() string + type ModelIndex struct + Conditions map[string][]string + Types map[string][]string + UserConditions map[string][]string + UserTypes map[string][]string + func IndexModel(m *openfga.AuthorizationModel) *ModelIndex + func (ix *ModelIndex) AllRelations() []string + func (ix *ModelIndex) ConditionNames() []string + func (ix *ModelIndex) ConditionParams(name string) []string + func (ix *ModelIndex) Empty() bool + func (ix *ModelIndex) RelationsFor(typ string) []string + func (ix *ModelIndex) TypeNames() []string + func (ix *ModelIndex) UserConditionsFor(typ, relation, userType string) []string + func (ix *ModelIndex) UserTypesFor(typ, relation string) []string + func (ix *ModelIndex) UserTypesForRelation(relation string) []string + type Path struct + Example string + Expr string + IsArray bool + Kind string + func Paths(root string, v any) []Path + type Plan struct + Deletes int + Events []EventPlan + Unmatched int + Writes int + func PlanEvents(ctx context.Context, m *mapper.Mapping, events []map[string]any, from int, ...) (*Plan, error) + type Preview struct + Diagnostics mapper.Diagnostics + EvalErr error + Evaluated bool + Filters []mapper.TupleFilterOperation + OverBudget bool + Rules []mapper.RuleTrace + Tuples []language.Tuple + YAML []byte + func Evaluate(ctx context.Context, d *Document, event map[string]any) Preview + func (p Preview) OK() bool + func (p Preview) Problems() []Problem + func (p Preview) TupleCount() int + type Problem struct + Field string + Item int + Message string + Rule int + Section string + Warning bool + func Blocking(ps []Problem) []Problem + func CheckSamples(ctx context.Context, d *Document) []Problem + func Lint(d *Document, ix *ModelIndex) []Problem + func Warnings(ps []Problem) []Problem + type Requirement struct + DSL string + Relation string + Type string + UserTypes []string + type RequirementStatus struct + Checked bool + RelationOK bool + Requirement Requirement + TypeOK bool + UserTypesOK bool + func CheckRequirements(ix *ModelIndex, reqs []Requirement) []RequirementStatus + func (s RequirementStatus) Satisfied() bool + type Rule struct + Action string + AutoName string + AutoWhen string + Filters []TupleFilter + Iterator *Iterator + Name string + New bool + Sample *Sample + Tuples []Tuple + Variables []Variable + When string + func (r Rule) WritesTuples() bool + type Sample struct + Event map[string]any + Label string + type TestCase struct + AssertWritesCoveredByFilter bool + ExpectTupleFilters []language.TupleFilter + ExpectTuples []language.Tuple + Input map[string]any + Name string + func BuildTests(ctx context.Context, d *Document) []TestCase + func NewTest(ctx context.Context, d *Document, name string, event map[string]any) (TestCase, error) + func SavedTests(ctx context.Context, d *Document) []TestCase + func SavedTestsAndOrigins(ctx context.Context, d *Document) ([]TestCase, map[string]int) + type TestOutcome struct + Actual []language.Tuple + ActualFilters []language.TupleFilter + Duration time.Duration + Err error + Expected []language.Tuple + ExpectedFilters []language.TupleFilter + Fired []string + Line int + Missing []language.Tuple + MissingFilters []language.TupleFilter + Name string + Passed bool + Uncovered []language.Tuple + Unexpected []language.Tuple + UnexpectedFilters []language.TupleFilter + type TestRun struct + Filtered int + Skipped int + Tests []TestOutcome + func RunTests(ctx context.Context, f *File, filter string, failFast bool) (*TestRun, error) + func RunTestsWithTimeout(ctx context.Context, f *File, filter string, failFast bool, ...) (*TestRun, error) + func (r TestRun) Failed() int + type Tuple struct + Action string + Condition string + Context []ContextEntry + Object string + Relation string + User string + When string + type TupleFilter struct + Action string + Object string + Relation string + User string + type TupleReader interface + ReadTuples func(ctx context.Context, filter language.TupleFilter) ([]language.Tuple, error) + type TupleWriter interface + Write func(ctx context.Context, writes, deletes []language.Tuple) error + type Variable struct + Expr string + Name string