Documentation
¶
Overview ¶
Package dql implements focused DQL syntax parsing for the transcribe pipeline. Production callers enter through transcribe.Compiler rather than composing these parsers directly.
Index ¶
- Constants
- Variables
- func ApplyPatch(source string, span SourceSpan, replacement string) (string, error)
- func ColumnType(expression string, context *spec.TypeContext) (spec.TypeRef, error)
- func EmbeddedSQLRefs(sql string) []*spec.EmbeddedSQLRef
- func ParsePreparedComponentSource(scope, name string, prepared *PreparedSource) (*spec.Component, error)
- func RenderPredicateOption(predicate *spec.Predicate) (string, error)
- func SetPackage(source, packagePath, expected string) (string, error)
- func UpsertSetting(source, name string, args []string) (string, error)
- func UpsertSettingTail(source, name string, args []string, tail string) (string, error)
- type DeclarationAnalysis
- type DeclarationCriteriaIn
- type DeclarationOccurrence
- type DeclarationOptionOccurrence
- type DeclarationProjection
- type DeclarationScalarProperty
- type DirectivePlan
- type PredicateOptionOccurrence
- type PreparedSource
- type RoutePlan
- type Serializer
- type SourceDiagnostic
- type SourceExport
- type SourceSpan
- type TemplateExpressions
Constants ¶
const ( DiagnosticInvalidPackage = "DQL-DIR-PACKAGE" DiagnosticInvalidImport = "DQL-DIR-IMPORT" DiagnosticInvalidSetting = "DQL-DIR-SETTING" DiagnosticInvalidDefine = "DQL-DIR-DEFINE" DiagnosticParse = "DQL-PARSE" )
Variables ¶
var ErrMissingRouteDirective = errors.New("missing #setting route directive in source")
ErrMissingRouteDirective reports a source with no #setting route directive: valid SQL, but not a component source. Callers that scan mixed SQL assets (e.g. transcribe source discovery) classify non-component files with errors.Is against this sentinel instead of re-implementing detection.
Functions ¶
func ApplyPatch ¶
func ApplyPatch(source string, span SourceSpan, replacement string) (string, error)
ApplyPatch applies one half-open byte patch to authored DQL.
func ColumnType ¶
ColumnType normalizes authored column type declarations under the component's import authority. Fluent ColumnType and projection CAST share this policy.
func EmbeddedSQLRefs ¶
func EmbeddedSQLRefs(sql string) []*spec.EmbeddedSQLRef
EmbeddedSQLRefs extracts typed resource references from one authored SQL source. Resource expansion remains a later transcribe load concern.
func ParsePreparedComponentSource ¶
func ParsePreparedComponentSource(scope, name string, prepared *PreparedSource) (*spec.Component, error)
func RenderPredicateOption ¶
RenderPredicateOption renders the canonical declaration option spelling.
func SetPackage ¶
SetPackage replaces the one authored package directive while preserving all surrounding source bytes. Expected enables revision-aware callers to verify that package authority has not changed since inspection.
func UpsertSetting ¶
UpsertSetting replaces every authored setting call with the same canonical name by one call at the first occurrence, or inserts a new call before SQL. A nil args slice removes the setting. Arguments are already-authored DQL expressions and are retained verbatim after trimming.
Types ¶
type DeclarationAnalysis ¶
type DeclarationAnalysis struct {
SQL string
FromPath string
Table string
Projection []DeclarationProjection
ProjectionComplete bool
DeclarationCriteriaIn *DeclarationCriteriaIn
DeclarationScalarProperty *DeclarationScalarProperty
DataType string
}
func AnalyzeDeclarationSQL ¶
func AnalyzeDeclarationSQL(raw string) (*DeclarationAnalysis, error)
func (*DeclarationAnalysis) NestedChildField ¶
func (a *DeclarationAnalysis) NestedChildField() string
type DeclarationCriteriaIn ¶
type DeclarationOccurrence ¶
type DeclarationOccurrence struct {
Parameter *spec.Parameter `json:"parameter"`
Span SourceSpan `json:"span"`
HeadSpan SourceSpan `json:"headSpan"`
OptionInsert int `json:"optionInsert"`
Options []DeclarationOptionOccurrence `json:"options,omitempty"`
Predicates []PredicateOptionOccurrence `json:"predicates,omitempty"`
}
DeclarationOccurrence retains one authored declaration and the source ranges needed by source-preserving editor clients. Parameter is detached metadata; Span and predicate spans address the complete authored DQL.
func DeclarationOccurrences ¶
func DeclarationOccurrences(source string) ([]DeclarationOccurrence, error)
DeclarationOccurrences parses every authored parameter declaration without applying #define-over-#set precedence. This is an authoring projection; the canonical component continues to use the normalized declaration plan.
type DeclarationOptionOccurrence ¶
type DeclarationOptionOccurrence struct {
Name string `json:"name"`
Args []string `json:"args,omitempty"`
Span SourceSpan `json:"span"`
}
type DeclarationProjection ¶
DeclarationProjection is one parser-proven StructQL destination field. Name is the result alias (or source name when no alias was authored), while Source is the selected source field used to derive its concrete Go type.
type DirectivePlan ¶
type DirectivePlan struct {
Static *spec.StaticContent
Documentation xdocs.Source
Route *RoutePlan
Settings *spec.Settings
MCP *spec.MCPExposure
MCPOnly bool
Params []*spec.Parameter
Views []*spec.View
ParamSpans map[string]SourceSpan
ConstSpans map[string]SourceSpan
// contains filtered or unexported fields
}
DirectivePlan is the normalized canonical product of one authored directive scan. Component assembly consumes this plan and never rescans the original source for routes, settings, or declarations.
type PredicateOptionOccurrence ¶
type PredicateOptionOccurrence struct {
Ordinal int `json:"ordinal"`
Predicate *spec.Predicate `json:"predicate"`
Span SourceSpan `json:"span"`
}
PredicateOptionOccurrence identifies one repeatable predicate option in its declaration. Ordinal is scoped to the declaration and follows source order.
type PreparedSource ¶
type PreparedSource struct {
Original string
DirectSQL string
SQL string
TrimPrefix int
TypeContext *spec.TypeContext
Directives *DirectivePlan
Statements statement.Statements
Diagnostics []SourceDiagnostic
}
PreparedSource is the offset-preserving output of authored DQL preprocessing. Directives carries canonical route/settings/parameter data; SQL contains only executable source and Original is retained for diagnostics.
func PrepareSource ¶
func PrepareSource(source string) *PreparedSource
PrepareSource ports the original directive-masking preprocess stage using the shared parser-backed directive scanner. Masking preserves authored byte offsets and line endings; only outer SQL whitespace is trimmed.
func (*PreparedSource) Err ¶
func (p *PreparedSource) Err() error
type Serializer ¶
type Serializer struct{}
func (Serializer) Export ¶
func (Serializer) Export(component *spec.Component, authored string) SourceExport
type SourceDiagnostic ¶
func DiagnosticForError ¶
func DiagnosticForError(err error) (SourceDiagnostic, bool)
DiagnosticForError extracts an authored-source diagnostic from a DQL parse error when the focused parser knows the failing directive span.
type SourceExport ¶
type SourceExport struct {
Source string `json:"source"`
Original bool `json:"original"`
Supported bool `json:"supported"`
Limitations []string `json:"limitations"`
}
SourceExport separates retained authorship from bounded reconstruction.
type SourceSpan ¶
type TemplateExpressions ¶
type TemplateExpressions struct{}
TemplateExpressions hands template operands to Velty while SQLParser owns the surrounding SQL. Raw nodes retain the authored bytes for later execution.
Source Files
¶
- authoring.go
- component_settings_cache.go
- component_settings_directives.go
- component_settings_model.go
- component_settings_parse.go
- component_settings_spec.go
- component_source.go
- cube_compose.go
- declaration_sql.go
- declaration_sql_hint.go
- declaration_sql_qualify.go
- declarations.go
- declarations_head.go
- declarations_options.go
- declarations_view.go
- directive_scan.go
- doc.go
- parse_primitives.go
- preprocess.go
- route_directive.go
- serialize.go
- source_error.go
- template_sql.go
- type_context.go
- type_context_edit.go
- view_embed.go