readerbuilder

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 22, 2026 License: Apache-2.0 Imports: 21 Imported by: 4

Documentation

Overview

Package readerbuilder provides stateless, source-preserving DQL reader edits.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CodecMutation

type CodecMutation struct {
	Name string   `json:"name"`
	Args []string `json:"args,omitempty"`
}

type ColumnContract

type ColumnContract struct {
	View     string            `json:"view"`
	Column   string            `json:"column"`
	CastType string            `json:"castType,omitempty"`
	Tags     map[string]string `json:"tags,omitempty"`
}

ColumnContract is the normalized authoring projection for one view column. It lets clients render cohesive controls without parsing DQL or Go tags.

type ColumnContractMutation

type ColumnContractMutation struct {
	View       string            `json:"view"`
	Column     string            `json:"column"`
	CastType   *string           `json:"castType,omitempty"`
	Tags       map[string]string `json:"tags,omitempty"`
	RemoveTags []string          `json:"removeTags,omitempty"`
}

ColumnContractMutation applies cohesive field metadata to one compiled view column. A nil CastType preserves the current CAST; a non-nil empty value removes it. Tags are merged by key and RemoveTags removes only the named metadata, preserving unrelated authored tags.

type ColumnRoleMutation

type ColumnRoleMutation struct {
	View   string `json:"view"`
	Column string `json:"column"`
	Role   string `json:"role"`
}

type Config

type Config struct {
	Scope               string
	Name                string
	Types               *typecatalog.Catalog
	AvailableConnectors []string
	AvailableCaches     []string
	PredicateNames      []string
}

type Field

type Field struct {
	ExistingName        string         `json:"existingName,omitempty"`
	Name                string         `json:"name"`
	Type                string         `json:"type"`
	SourceKind          string         `json:"sourceKind"`
	SourceName          string         `json:"sourceName"`
	Required            *bool          `json:"required,omitempty"`
	QuerySelector       string         `json:"querySelector,omitempty"`
	UpdateQuerySelector *string        `json:"updateQuerySelector,omitempty"`
	Value               *string        `json:"value,omitempty"`
	UpdateValue         bool           `json:"updateValue,omitempty"`
	URI                 *string        `json:"uri,omitempty"`
	UpdateURI           bool           `json:"updateUri,omitempty"`
	Codec               *CodecMutation `json:"codec,omitempty"`
	UpdateCodec         bool           `json:"updateCodec,omitempty"`
	EmitOutput          *bool          `json:"emitOutput,omitempty"`
	Description         *string        `json:"description,omitempty"`
	UpdateDescription   bool           `json:"updateDescription,omitempty"`
	Example             *string        `json:"example,omitempty"`
	UpdateExample       bool           `json:"updateExample,omitempty"`
}

type FunctionMutation

type FunctionMutation struct {
	Name         string   `json:"name"`
	Args         []string `json:"args,omitempty"`
	ExpectedArgs []string `json:"expectedArgs,omitempty"`
	Occurrence   int      `json:"occurrence,omitempty"`
}

type FunctionOccurrence

type FunctionOccurrence struct {
	Name       string         `json:"name"`
	Args       []string       `json:"args,omitempty"`
	Occurrence int            `json:"occurrence"`
	SourceSpan dql.SourceSpan `json:"sourceSpan"`
}

type Operation

type Operation struct {
	Type                 OperationType                 `json:"type"`
	Reader               *ReaderMutation               `json:"reader,omitempty"`
	Package              *PackageMutation              `json:"package,omitempty"`
	Field                *Field                        `json:"field,omitempty"`
	Predicate            *PredicateMutation            `json:"predicate,omitempty"`
	PredicateGroup       *PredicateGroupMutation       `json:"predicateGroup,omitempty"`
	PredicateComposition *PredicateCompositionMutation `json:"predicateComposition,omitempty"`
	Function             *FunctionMutation             `json:"function,omitempty"`
	Setting              *SettingMutation              `json:"setting,omitempty"`
	View                 *ViewMutation                 `json:"view,omitempty"`
	Relation             *RelationMutation             `json:"relation,omitempty"`
	ColumnRole           *ColumnRoleMutation           `json:"columnRole,omitempty"`
	Column               *ColumnContractMutation       `json:"column,omitempty"`
	Operations           []Operation                   `json:"operations,omitempty"`
}

type OperationType

type OperationType string
const (
	OperationInspect                    OperationType = "inspect"
	OperationCreateReader               OperationType = "createReader"
	OperationSetPackage                 OperationType = "setPackage"
	OperationAddField                   OperationType = "addField"
	OperationUpdateField                OperationType = "updateField"
	OperationRemoveField                OperationType = "removeField"
	OperationAddFieldPredicate          OperationType = "addFieldPredicate"
	OperationUpdateFieldPredicate       OperationType = "updateFieldPredicate"
	OperationRemoveFieldPredicate       OperationType = "removeFieldPredicate"
	OperationUpdatePredicateGroup       OperationType = "updatePredicateGroup"
	OperationUpdatePredicateComposition OperationType = "updatePredicateComposition"
	OperationAddFunction                OperationType = "addFunction"
	OperationUpdateFunction             OperationType = "updateFunction"
	OperationRemoveFunction             OperationType = "removeFunction"
	OperationSetSetting                 OperationType = "setSetting"
	OperationAddView                    OperationType = "addView"
	OperationUpdateView                 OperationType = "updateView"
	OperationRemoveView                 OperationType = "removeView"
	OperationUpdateRelation             OperationType = "updateRelation"
	OperationSetColumnRole              OperationType = "setColumnRole"
	OperationSetColumnContract          OperationType = "setColumnContract"
	OperationBatch                      OperationType = "batch"
)

type PackageMutation

type PackageMutation struct {
	Path     string `json:"path"`
	Expected string `json:"expected,omitempty"`
}

type PredicateComposition

type PredicateComposition struct {
	View         string                     `json:"view"`
	Occurrence   int                        `json:"occurrence"`
	Terms        []PredicateCompositionTerm `json:"terms,omitempty"`
	BuildKeyword string                     `json:"buildKeyword"`
	SourceSpan   dql.SourceSpan             `json:"sourceSpan"`
	Editable     bool                       `json:"editable"`
	Reason       string                     `json:"reason,omitempty"`
}

PredicateComposition describes one complete Builder chain, in source order. Connector is the effective persistent And/Or state at each Combine call. The first term also records that state, although no preceding term exists.

type PredicateCompositionMutation

type PredicateCompositionMutation struct {
	View         string                     `json:"view"`
	Occurrence   int                        `json:"occurrence"`
	Terms        []PredicateCompositionTerm `json:"terms"`
	BuildKeyword string                     `json:"buildKeyword"`
}

PredicateCompositionMutation changes only outer boolean composition. Every existing expansion must occur exactly as often as before; group membership and within-group operators are managed by the predicate/group operations.

type PredicateCompositionTerm

type PredicateCompositionTerm struct {
	Operator  string `json:"operator"`
	Connector string `json:"connector"`
	Groups    []int  `json:"groups"`
}

type PredicateExpansion

type PredicateExpansion struct {
	View       string         `json:"view"`
	Method     string         `json:"method"`
	Group      int            `json:"group"`
	Operator   string         `json:"operator,omitempty"`
	SourceSpan dql.SourceSpan `json:"sourceSpan"`
}

type PredicateGroupMutation

type PredicateGroupMutation struct {
	Group    int      `json:"group"`
	Views    []string `json:"views"`
	Operator string   `json:"operator"`
}

PredicateGroupMutation updates the compiled boolean operator for every explicit expansion site of one predicate group. Views must name the complete current expansion scope so an authoring client cannot silently broaden or narrow a shared filter group.

type PredicateMutation

type PredicateMutation struct {
	Field           string   `json:"field"`
	Occurrence      int      `json:"occurrence,omitempty"`
	View            string   `json:"view"`
	Group           int      `json:"group"`
	Name            string   `json:"name,omitempty"`
	Args            []string `json:"args,omitempty"`
	ApplyWhenAbsent bool     `json:"applyWhenAbsent,omitempty"`
	ExpansionViews  []string `json:"expansionViews,omitempty"`
	GroupOperator   string   `json:"groupOperator,omitempty"`
	CombineOperator string   `json:"combineOperator,omitempty"`
}

type ReaderMutation

type ReaderMutation struct {
	Package    string `json:"package"`
	Connector  string `json:"connector"`
	Route      string `json:"route"`
	Name       string `json:"name"`
	TypeName   string `json:"typeName,omitempty"`
	OutputName string `json:"outputName,omitempty"`
	SQL        string `json:"sql"`
}

ReaderMutation defines the initial typed root graph. The reader builder owns DQL rendering and compilation; clients provide author intent, not DQL text.

type RelationMutation

type RelationMutation struct {
	Name   string `json:"name"`
	Parent string `json:"parent"`
	On     string `json:"on"`
}

type Request

type Request struct {
	DQL       string    `json:"dql"`
	Operation Operation `json:"operation"`
}

type Response

type Response struct {
	Applied     bool                     `json:"applied"`
	DQL         string                   `json:"dql"`
	Structure   *Structure               `json:"structure,omitempty"`
	Diagnostics []*transcribe.Diagnostic `json:"diagnostics,omitempty"`
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func New

func New(config Config) *Service

func (*Service) Apply

func (s *Service) Apply(ctx context.Context, request Request) Response

func (*Service) ServeHTTP

func (s *Service) ServeHTTP(writer http.ResponseWriter, request *http.Request)

ServeHTTP exposes the stateless builder contract. Decoded domain failures use the normal response envelope; malformed transport input uses HTTP 400.

type SettingMutation

type SettingMutation struct {
	Name    string             `json:"name"`
	Args    []string           `json:"args,omitempty"`
	Options []FunctionMutation `json:"options,omitempty"`
	Remove  bool               `json:"remove,omitempty"`
}

type Structure

type Structure struct {
	Status                string                      `json:"status"`
	Component             *spec.Component             `json:"component,omitempty"`
	Declarations          []dql.DeclarationOccurrence `json:"declarations,omitempty"`
	Views                 []ViewOccurrence            `json:"views,omitempty"`
	PredicateExpansions   []PredicateExpansion        `json:"predicateExpansions,omitempty"`
	PredicateCompositions []PredicateComposition      `json:"predicateCompositions,omitempty"`
	Functions             []FunctionOccurrence        `json:"functions,omitempty"`
	ColumnContracts       []ColumnContract            `json:"columnContracts,omitempty"`
	AvailableConnectors   []string                    `json:"availableConnectors,omitempty"`
	AvailablePredicates   []string                    `json:"availablePredicates,omitempty"`
	AvailableCaches       []string                    `json:"availableCaches,omitempty"`
}

type ViewMutation

type ViewMutation struct {
	Name     string            `json:"name"`
	Kind     spec.RelationKind `json:"kind,omitempty"`
	TypeExpr string            `json:"typeExpr,omitempty"`
	SQL      string            `json:"sql,omitempty"`
	Parent   string            `json:"parent,omitempty"`
	Join     string            `json:"join,omitempty"`
	On       string            `json:"on,omitempty"`
}

type ViewOccurrence

type ViewOccurrence struct {
	Name string `json:"name"`
	// SQL is the exact embedded query for this named view. It intentionally
	// excludes the outer graph projection and join wrapper so authoring clients
	// can edit a view without reverse-engineering compiled runtime SQL.
	SQL        string         `json:"sql,omitempty"`
	SourceSpan dql.SourceSpan `json:"sourceSpan"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL