base

package
v0.3.42 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CatalogDirectiveName       = "catalog"
	DependencyDirectiveName    = "dependency"
	ModuleCatalogDirectiveName = "module_catalog"
)
View Source
const (
	ObjectTableDirectiveName = "table"
	ObjectViewDirectiveName  = "view"
)

Object-level directive names.

View Source
const (
	FieldPrimaryKeyDirectiveName           = "pk"
	FieldGeometryInfoDirectiveName         = "geometry_info"
	FieldSqlDirectiveName                  = "sql"
	FieldExtraFieldDirectiveName           = "extra_field"
	FieldDefaultDirectiveName              = "default"
	FieldDefaultDirectiveInsertExprArgName = "insert_exp"
	FieldDefaultDirectiveUpdateExprArgName = "update_exp"
	FieldMeasurementDirectiveName          = "measurement"
	FieldMeasurementFuncArgName            = "measurement_func"
	FieldDimDirectiveName                  = "dim"
	FieldExcludeMCPDirectiveName           = "exclude_mcp"
)

Field-level directive names.

View Source
const (
	WithDeletedDirectiveName = "with_deleted"
	StatsDirectiveName       = "stats"
	UnnestDirectiveName      = "unnest"
	NoPushdownDirectiveName  = "no_pushdown"
	AtDirectiveName          = "at"
)

Query-side directive names.

View Source
const (
	QueryDirectiveName                 = "query"
	MutationDirectiveName              = "mutation"
	FunctionDirectiveName              = "function"
	ArgDefaultDirectiveName            = "arg_default"
	FunctionCallDirectiveName          = "function_call"
	FunctionCallTableJoinDirectiveName = "table_function_call_join"
	JoinDirectiveName                  = "join"
	ReferencesDirectiveName            = "references"
	SubscriptionDirectiveName          = "subscription"
	FieldReferencesDirectiveName       = "field_references"
	ReferencesQueryDirectiveName       = "references_query"
	FieldAggregationQueryDirectiveName = "aggregation_query"
	ModuleDirectiveName                = "module"
	ModuleRootDirectiveName            = "module_root"
	ViewArgsDirectiveName              = "args"
	OriginalNameDirectiveName          = "original_name"
	DeprecatedDirectiveName            = "deprecated"
	FilterInputDirectiveName           = "filter_input"
	FilterListInputDirectiveName       = "filter_list_input"
	DataInputDirectiveName             = "data_input"
)

Query/mutation directive names.

View Source
const (
	CacheDirectiveName           = "cache"
	NoCacheDirectiveName         = "no_cache"
	InvalidateCacheDirectiveName = "invalidate_cache"
)

Cache directive names.

View Source
const (
	AddH3DirectiveName          = "add_h3"
	H3QueryFieldName            = "h3"
	H3QueryTypeName             = "_h3_query"
	H3DataQueryTypeName         = "_h3_data_query"
	H3DataFieldName             = "data"
	DistributionFieldName       = "distribution_by"
	DistributionTypeName        = "_distribution_by"
	BucketDistributionFieldName = "distribution_by_bucket"
	BucketDistributionTypeName  = "_distribution_by_bucket"
)

H3 directive and type names.

View Source
const (
	GisFeatureDirectiveName    = "feature"
	GisWFSDirectiveName        = "wfs"
	GisWFSFieldDirectiveName   = "wfs_field"
	GisWFSExcludeDirectiveName = "wfs_exclude"
	GisWFSTypeName             = "_wfs_features"
)

GIS/WFS directive and type names.

View Source
const (
	QueryTimeJoinsFieldName   = "_join"
	QueryTimeJoinsTypeName    = "_join"
	QueryTimeSpatialFieldName = "_spatial"
	QueryTimeSpatialTypeName  = "_spatial"
)

Query-time join type/field names.

View Source
const (
	VectorTypeName                       = "Vector"
	VectorSearchInputName                = "VectorSearchInput"
	VectorDistanceTypeEnumName           = "VectorDistanceType"
	VectorSearchDistanceL2               = "L2"
	VectorSearchDistanceIP               = "Inner"
	VectorSearchDistanceCosine           = "Cosine"
	SimilaritySearchArgumentName         = "similarity"
	EmbeddingsDirectiveName              = "embeddings"
	SemanticSearchArgumentName           = "semantic"
	SemanticSearchInputName              = "SemanticSearchInput"
	SummaryForEmbeddedArgumentName       = "summary"
	DistanceFieldNameSuffix              = "distance"
	VectorDistanceExtraFieldName         = "VectorDistance"
	QueryEmbeddingDistanceExtraFieldName = "QueryEmbeddingDistance"
	QueryEmbeddingsDistanceFieldName     = "_distance_to_query"
)

Vector search directive and type names.

View Source
const (
	FunctionTypeName         = "Function"
	FunctionMutationTypeName = "MutationFunction"
	QueryBaseName            = "Query"
	MutationBaseName         = "Mutation"
	SubscriptionBaseName     = "Subscription"
	OperationResultTypeName  = "OperationResult"
)

Type name constants.

View Source
const (
	JSONTypeName                      = "JSON"
	TimestampTypeName                 = "Timestamp"
	DateTimeTypeName                  = "DateTime"
	DateTypeName                      = "Date"
	H3CellTypeName                    = "H3Cell"
	GeometryTypeName                  = "Geometry"
	GeometryAggregationTypeName       = "GeometryAggregation"
	GeometryMeasurementExtraFieldName = "Measurement"
	TimestampExtractExtraFieldName    = "Extract"
)

Scalar type name constants.

View Source
const (
	AggregateKeyFieldName   = "key"
	AggregateFieldName      = "aggregations"
	AggRowsCountFieldName   = "_rows_count"
	AggregationSuffix       = "_aggregation"
	BucketAggregationSuffix = "_bucket_aggregation"
)

Aggregation constants.

View Source
const (
	ListFilterInputSuffix = "_list_filter"
	FilterInputSuffix     = "_filter"
)

Input/filter constants.

View Source
const (
	MutationTypeTextInsert = "INSERT"
	MutationTypeTextUpdate = "UPDATE"
	MutationTypeTextDelete = "DELETE"
)

Mutation type text constants.

View Source
const (
	JoinSourceFieldPrefix = "source"
	JoinRefFieldPrefix    = "dest"
)

Join field name prefixes.

View Source
const (
	ObjectQueryByPKSuffix = "_by_pk"
	StubFieldName         = "_stub"
	// PlaceholderFieldName is the member introspection injects when a type
	// would otherwise expose none — the GraphQL spec requires an OBJECT type
	// to have at least one field, and a role may have been denied all of them.
	// It is synthetic: nothing can select it, so a field listing must drop it.
	PlaceholderFieldName = "_placeholder"
)

Object query constants.

View Source
const (
	QueryTypeTextSelect          = "SELECT"
	QueryTypeTextSelectOne       = "SELECT_ONE"
	QueryTypeTextAggregate       = "AGGREGATE"
	QueryTypeTextAggregateBucket = "AGGREGATE_BUCKET"
)

Query type text constants (for @query directive "type" argument).

View Source
const (
	ObjectHyperTableDirectiveName = "hypertable"
	ObjectCubeDirectiveName       = "cube"
	ObjectUniqueDirectiveName     = "unique"

	FieldReferencesQueryDirectiveName = "references_query"

	FieldTimescaleKeyDirectiveName = "timescale_key"

	InputFieldNamedArgDirectiveName = "named_arg"

	ObjectAggregationDirectiveName      = "aggregation"
	ObjectFieldAggregationDirectiveName = "field_aggregation"
)

Object-level secondary directive names.

View Source
const (
	DescFilter        = "Filter"
	DescOrderBy       = "Sort options for the result set"
	DescLimit         = "Limit the number of returned objects"
	DescOffset        = "Skip the first n objects"
	DescDistinctOn    = "Distinct on the given fields"
	DescInnerJoin     = "Apply inner join to the result set"
	DescInnerJoinRef  = "Apply inner join to reference record"
	DescArgs          = "Arguments for the view"
	DescBucketKey     = "The key of the bucket"
	DescNestedOrderBy = "Sort options for the nested result set"
	DescNestedLimit   = "Limit the number of returned nested objects"
	DescNestedOffset  = "Skip the first n nested objects"
	DescMutationData  = "The record data"
)

Query argument descriptions.

View Source
const (
	ArgName                  = "name"
	ArgType                  = "type"
	ArgSQL                   = "sql"
	ArgExp                   = "exp"
	ArgField                 = "field"
	ArgRequired              = "required"
	ArgDescription           = "description"
	ArgReferencesName        = "references_name"
	ArgSourceFields          = "source_fields"
	ArgReferencesFields      = "references_fields"
	ArgReferencesQuery       = "references_query"
	ArgReferencesDescription = "references_description"
	ArgIsM2M                 = "is_m2m"
	ArgM2MName               = "m2m_name"
	ArgIsTable               = "is_table"
	ArgIsTableFuncJoin       = "is_table_func_join"
	ArgIsBucket              = "is_bucket"
	ArgBaseField             = "base_field"
	ArgBaseType              = "base_type"
	ArgQuery                 = "query"
	ArgSoftDelete            = "soft_delete"
	ArgSoftDeleteCond        = "soft_delete_cond"
	ArgSoftDeleteSet         = "soft_delete_set"
	ArgSkipNullArg           = "skip_null_arg"
	ArgJsonCast              = "json_cast"
	ArgSequence              = "sequence"
	ArgQuerySuffix           = "query_suffix"
	ArgSkipQuery             = "skip_query"
	ArgModule                = "module"
	ArgModel                 = "model"
	ArgVector                = "vector"
	ArgDistance              = "distance"
	ArgLen                   = "len"
	ArgSRID                  = "srid"
	ArgArgs                  = "args"
	ArgValue                 = "value"
)

Directive argument name constants (shared between sdl and rules).

View Source
const (
	// Drop type, input, enum value, or field from the schema
	DropDirectiveName = "drop"
	// Replace type, input, enum value, or field in the schema with the new definition
	ReplaceDirectiveName = "replace"
	// Skip adding the definition if it already exists
	IfNotExistsDirectiveName = "if_not_exists"
	// Drop a specific directive usage from the target definition or field
	DropDirectiveDirectiveName = "drop_directive"
)

DDL directive names

View Source
const (
	MetadataSchemaQuery   = "__schema"
	MetadataTypeQuery     = "__type"
	MetadataTypeNameQuery = "__typename"

	// Logical-model introspection (catalog) meta queries. Single "_" prefix:
	// GraphQL hard-reserves "__" names (graphql-js rejects them even in
	// introspection results), so these are ordinary system fields on Query —
	// like jq/h3 — dispatched to the metadata path by name.
	MetadataCatalogQuery     = "_catalog"
	MetadataModuleQuery      = "_module"
	MetadataDataObjectQuery  = "_dataObject"
	MetadataFunctionQuery    = "_function"
	MetadataTypesQuery       = "_types"
	MetadataDataSourceQuery  = "_dataSource"
	MetadataDataSourcesQuery = "_dataSources"

	JQTransformQueryName = "jq"
)

Metadata query constants.

View Source
const (
	TableDataObject = "table"
	ViewDataObject  = "view"
)
View Source
const CatalogSystemVariableName = "$catalog"

Catalog system variable.

View Source
const FieldSourceDirectiveName = "field_source"

Variables

View Source
var SystemDirective = &ast.Directive{Name: "system", Position: CompiledPos("")}

SystemDirective is the sentinel directive marking compiler-generated definitions.

Functions

func AddH3Directive

func AddH3Directive(field string, resolution int, transformFrom int, buffer float64, divideVals bool, simplify bool, pos *ast.Position) *ast.Directive

AddH3Directive creates an @add_h3 directive with the given parameters.

func CloneArgument

func CloneArgument(arg *ast.Argument) *ast.Argument

func CloneArgumentList

func CloneArgumentList(args ast.ArgumentList) ast.ArgumentList

func CloneDefinition

func CloneDefinition(def *ast.Definition, fieldFilter func(*ast.FieldDefinition) bool) *ast.Definition

func CloneDirective

func CloneDirective(dir *ast.Directive) *ast.Directive

func CloneDirectiveList

func CloneDirectiveList(dirs ast.DirectiveList) ast.DirectiveList

func CloneEnumValueList

func CloneEnumValueList(enumValues ast.EnumValueList) ast.EnumValueList

func CloneFieldDefinition

func CloneFieldDefinition(field *ast.FieldDefinition) *ast.FieldDefinition

func CloneFieldDefinitionListWithFilter

func CloneFieldDefinitionListWithFilter(fields ast.FieldList, fieldFilter func(*ast.FieldDefinition) bool) ast.FieldList

func CloneValue

func CloneValue(value *ast.Value) *ast.Value

func CompiledPos

func CompiledPos(name string) *ast.Position

CompiledPos creates a position marker for compiled/generated AST elements.

func DefinitionCatalog

func DefinitionCatalog(def *ast.Definition) string

func DefinitionDependencies

func DefinitionDependencies(def *ast.Definition) []string

func DefinitionDirectiveArgString

func DefinitionDirectiveArgString(def *ast.Definition, dirName, argName string) string

func DerivedTypeNames

func DerivedTypeNames(name string) []string

DerivedTypeNames returns the deterministic list of all type names generated from a source type during compilation. It is the forward mapping pkg/mcp inverts to tell a generated type from a source-declared one.

func DirectiveArgString

func DirectiveArgString(dir *ast.Directive, name string) string

func DirectiveArgStrings

func DirectiveArgStrings(dir *ast.Directive, name string) []string

DirectiveArgStrings extracts a list of string values from a directive argument.

func DropDirectiveIfExists

func DropDirectiveIfExists(def *ast.Definition) bool

func DropFieldIfExists

func DropFieldIfExists(field *ast.FieldDefinition) bool

func ErrorPosf

func ErrorPosf(pos *ast.Position, format string, args ...any) *gqlerror.Error

func FieldDefCatalog

func FieldDefCatalog(field *ast.FieldDefinition) string

func FieldDefDependency

func FieldDefDependency(field *ast.FieldDefinition) string

FieldDefDependency returns the dependency name from a field's @dependency directive.

func FieldDefDirectiveArgString

func FieldDefDirectiveArgString(field *ast.FieldDefinition, dirName, argName string) string

func FieldGeometryInfoDirective

func FieldGeometryInfoDirective(geomType string, srid int) *ast.Directive

FieldGeometryInfoDirective creates a @geometry_info directive.

func FieldSourceDirective

func FieldSourceDirective(name string) *ast.Directive

FieldSourceDirective creates a @field_source directive for renamed fields.

func FieldSqlDirective

func FieldSqlDirective(sql string) *ast.Directive

FieldSqlDirective creates a @sql directive with the given expression.

func Ident

func Ident(s string) string

Ident quotes a SQL identifier if it is a reserved keyword or contains special characters.

func IsControlDirective

func IsControlDirective(name string) bool

IsControlDirective returns true for DDL control directives that should be stripped before inserting definitions into the schema.

func IsDropDefinition

func IsDropDefinition(def *ast.Definition) bool

func IsDropEnumValue

func IsDropEnumValue(ev *ast.EnumValueDefinition) bool

func IsDropField

func IsDropField(field *ast.FieldDefinition) bool

func IsIfNotExistsDefinition

func IsIfNotExistsDefinition(def *ast.Definition) bool

func IsReplaceDefinition

func IsReplaceDefinition(def *ast.Definition) bool

func IsReplaceField

func IsReplaceField(field *ast.FieldDefinition) bool

func IsValidIdentifier

func IsValidIdentifier(s string) bool

IsValidIdentifier returns true if the string is a valid unquoted SQL identifier.

func ModuleDirective

func ModuleDirective(name string, pos *ast.Position) *ast.Directive

ModuleDirective creates a @module directive with the given name.

func QuerySideDirectives

func QuerySideDirectives() []string

QuerySideDirectives returns directive names that are valid on query fields.

func SetDirectiveArg

func SetDirectiveArg(dir *ast.Directive, name, value string)

SetDirectiveArg sets or adds a string argument on a directive.

func Sources

func Sources() []*ast.Source

Sources returns the base system type SDL sources. Scalar type SDL is provided separately by the types package.

func StripControlDirectives

func StripControlDirectives(dirs ast.DirectiveList) ast.DirectiveList

StripControlDirectives returns a new directive list with all DDL control directives removed.

Types

type BatchRule

type BatchRule interface {
	Rule
	ProcessAll(ctx CompilationContext) error
}

BatchRule performs cross-cutting work after all DefinitionRules in the same phase.

type CompilationContext

type CompilationContext interface {
	Context() context.Context
	Source() DefinitionsSource
	CompileOptions() Options
	ApplyPrefix(name string) string

	// Scalar registry access
	ScalarLookup(name string) types.ScalarType
	IsScalar(name string) bool

	// Output writing. Only extensions are written now: the pipeline no longer
	// GENERATES definitions — it validates and prepares the source's own, in
	// place, for the catalog storage to persist.
	AddExtension(ext *ast.Definition)

	// PromoteToSource adds a definition to the source-level pool.
	// Definitions added here are dispatched to DefinitionRules in subsequent phases,
	// alongside source definitions. Used by PREPARE rules (e.g. InternalExtensionMerger)
	// when an extension targets a provider type not present in the source.
	PromoteToSource(def *ast.Definition)

	// PromotedDefinitions returns definitions promoted via PromoteToSource.
	// Used by PREPARE batch rules (e.g. PrefixPreparer) to also process promoted defs.
	PromotedDefinitions() []*ast.Definition

	// Type lookup: checks compilation output first, then target schema
	LookupType(name string) *ast.Definition

	// LookupExtension returns the accumulated extension for a given type name,
	// or nil if no extensions have been added for that type.
	LookupExtension(name string) *ast.Definition

	// Shared state management
	RegisterObject(name string, info *ObjectInfo)
	GetObject(name string) *ObjectInfo

	// Object iteration
	Objects() iter.Seq2[string, *ObjectInfo]

	// Output iteration (for FINALIZE rules)
	OutputExtensions() iter.Seq[*ast.Definition]

	// Dependency registration (extension compilation)
	RegisterDependency(name string)
}

CompilationContext provides rules access to source, target schema lookups, output writing, scalar registry, and shared state.

type CompiledCatalog

type CompiledCatalog interface {
	DefinitionsSource
	ExtensionsSource
}

CompiledCatalog is the DDL feed output of compilation, consumable by static.Provider.Update().

type DefinitionRule

type DefinitionRule interface {
	Rule
	Match(def *ast.Definition) bool
	Process(ctx CompilationContext, def *ast.Definition) error
}

DefinitionRule processes individual source definitions matching a predicate.

type DefinitionsSource

type DefinitionsSource interface {
	ForName(ctx context.Context, name string) *ast.Definition
	DirectiveForName(ctx context.Context, name string) *ast.DirectiveDefinition

	// iteration
	Definitions(ctx context.Context) iter.Seq[*ast.Definition]
	DirectiveDefinitions(ctx context.Context) iter.Seq2[string, *ast.DirectiveDefinition]
}

DefinitionsSource resolves types and directives with context support. A subset of Provider for functions that only need type resolution.

type DependentCompiledCatalog

type DependentCompiledCatalog interface {
	Dependencies() []string
}

DependentCompiledCatalog extends CompiledCatalog with dependency information collected from @dependency directives during extension compilation.

type DropDirectiveSpec

type DropDirectiveSpec struct {
	Name  string            // directive name to drop
	Match map[string]string // argument values to match (nil = drop all instances)
}

DropDirectiveSpec describes which directive to remove from a target.

func DropDirectiveSpecs

func DropDirectiveSpecs(def *ast.Definition) []DropDirectiveSpec

DropDirectiveSpecs extracts all @drop_directive specs from a definition's directives.

func FieldDropDirectiveSpecs

func FieldDropDirectiveSpecs(field *ast.FieldDefinition) []DropDirectiveSpec

FieldDropDirectiveSpecs extracts all @drop_directive specs from a field's directives.

type EngineCapabilities

type EngineCapabilities struct {
	General EngineGeneralCapabilities
	Insert  EngineInsertCapabilities
	Update  EngineUpdateCapabilities
	Delete  EngineDeleteCapabilities
}

EngineCapabilities declares what an engine supports.

type EngineDeleteCapabilities

type EngineDeleteCapabilities struct {
	Delete           bool
	DeleteWithoutPKs bool
}

type EngineGeneralCapabilities

type EngineGeneralCapabilities struct {
	SupportDefaultSequences       bool
	UnsupportedTypes              []string
	UnsupportStructuredTypes      bool
	UnsupportArrays               bool
	UnsupportTables               bool
	SupportCrossCatalogReferences bool
	SupportTimeTravel             bool
}

type EngineInsertCapabilities

type EngineInsertCapabilities struct {
	Insert           bool
	Returning        bool
	InsertReferences bool
}

type EngineUpdateCapabilities

type EngineUpdateCapabilities struct {
	Update           bool
	UpdatePKColumns  bool
	UpdateWithoutPKs bool
}

type ExtensionsSource

type ExtensionsSource interface {
	DefinitionsSource

	// Extensions
	DefinitionExtensions(ctx context.Context, name string) iter.Seq[*ast.Definition]
	Extensions(ctx context.Context) iter.Seq[*ast.Definition]
}

ExtensionsSource extends DefinitionsSource with support for definition extensions.

type GraphQLAnnotator

type GraphQLAnnotator interface {
	// SetDefinitionDescription curates a generated type's description (gql_type).
	SetDefinitionDescription(ctx context.Context, typeName, desc, longDesc string) error
	// SetFieldDescription curates a field's description (gql_field, key=type.field).
	SetFieldDescription(ctx context.Context, typeName, fieldName, desc, longDesc string) error
	// SetArgumentDescription curates a field argument's description
	// (gql_argument, key=type.field.arg).
	SetArgumentDescription(ctx context.Context, typeName, fieldName, argName, desc, longDesc string) error
}

GraphQLAnnotator curates human descriptions over the GENERATED GraphQL schema surface — the synthetic types (aggregations, filters, mutation inputs, module roots, shared query types), their fields and their arguments, which have no logical-model entity to hang a description on. Its keys live in a separate namespace (gql_type / gql_field / gql_argument) so they never collide with the logical annotations, and the store applies them AFTER the logical layer, so a GraphQL curation wins over a logical one.

type HugrType

type HugrType string

HugrType identifies the kind of a compiled schema definition for introspection.

const (
	HugrTypeModule     HugrType = "module"
	HugrTypeTable      HugrType = "table"
	HugrTypeView       HugrType = "view"
	HugrTypeJoin       HugrType = "join_queries"
	HugrTypeSpatial    HugrType = "spatial_queries"
	HugrTypeH3Data     HugrType = "h3_data"
	HugrTypeH3Agg      HugrType = "h3_aggregate"
	HugrTypeFilter     HugrType = "filter"
	HugrTypeFilterList HugrType = "filter_list"
	HugrTypeDataInput  HugrType = "data_input"
)

type HugrTypeField

type HugrTypeField string

HugrTypeField identifies the kind of a field within a compiled definition.

const (
	HugrTypeFieldSubmodule      HugrTypeField = "submodule"
	HugrTypeFieldSelectOne      HugrTypeField = "select_one"
	HugrTypeFieldSelect         HugrTypeField = "select"
	HugrTypeFieldAgg            HugrTypeField = "aggregate"
	HugrTypeFieldBucketAgg      HugrTypeField = "bucket_agg"
	HugrTypeFieldFunction       HugrTypeField = "function"
	HugrTypeFieldJoin           HugrTypeField = "join"
	HugrTypeFieldSpatial        HugrTypeField = "spatial"
	HugrTypeFieldH3Agg          HugrTypeField = "h3_aggregate"
	HugrTypeFieldJQ             HugrTypeField = "jq"
	HugrTypeFieldMutationInsert HugrTypeField = "mutation_insert"
	HugrTypeFieldMutationUpdate HugrTypeField = "mutation_update"
	HugrTypeFieldMutationDelete HugrTypeField = "mutation_delete"
	HugrTypeFieldExtraField     HugrTypeField = "extra_field"
	HugrTypeFieldSubscription   HugrTypeField = "subscription"
)

type LogicalAnnotator

type LogicalAnnotator interface {
	// SetModuleDescription curates a module's description (entity_kind=module).
	SetModuleDescription(ctx context.Context, module, desc, longDesc string) error
	// SetDataObjectDescription curates a data object's description
	// (entity_kind=data_object, key = compiled object type name).
	SetDataObjectDescription(ctx context.Context, name, desc, longDesc string) error
	// SetSourceTypeDescription curates a residual source-defined type's
	// description (entity_kind=type).
	SetSourceTypeDescription(ctx context.Context, name, desc, longDesc string) error
	// SetObjectFieldDescription curates a data-object field's description,
	// including relation navigation fields (entity_kind=field, key=owner.field).
	SetObjectFieldDescription(ctx context.Context, owner, field, desc, longDesc string) error
	// SetFunctionDescription curates ONE function's description. The key is
	// module.name (or name when module is empty; parent=module) and the
	// entity_kind is the function's KIND — "function", "mutation" or
	// "subscription", the value catalog.functions.kind stores — because the same
	// name in two root namespaces is two operations. Empty means "function".
	SetFunctionDescription(ctx context.Context, module, name, kind, desc, longDesc string) error
	// SetDataSourceDescription curates a data source's description
	// (entity_kind=data_source).
	SetDataSourceDescription(ctx context.Context, name, desc, longDesc string) error
}

LogicalAnnotator curates human descriptions over the LOGICAL model — the source-level entities the CoreDB entity_* views expose: modules, data objects, residual source-defined types, object fields (including relation navigation fields), functions and data sources. The keys mirror exactly how those views select their overlay from catalog.annotations, so a curation written here also feeds the vector search MCP discovery runs over the same rows. The store applies these as a description overlay at reconstruction time; callers reach it via type assertion, like SuspendableProvider.

type ModuleObjectType

type ModuleObjectType int

ModuleObjectType identifies the kind of module root object.

const (
	ModuleQuery ModuleObjectType = iota + 1
	ModuleMutation
	ModuleFunction
	ModuleMutationFunction
	ModuleSubscription
)

type ModuleRoot

type ModuleRoot struct {
	Name string
	Type ModuleObjectType
}

ModuleRoot holds extracted module information from a type definition.

func ModuleRootInfo

func ModuleRootInfo(def *ast.Definition) *ModuleRoot

ModuleRootInfo extracts module root information from @module_root directive or by well-known type name (Query, Mutation, Function, MutationFunction).

type ObjectInfo

type ObjectInfo struct {
	Name         string
	OriginalName string
	TableName    string
	Module       string
	IsReplace    bool
	IsView       bool
	IsM2M        bool
	IsCube       bool
	IsHypertable bool
	PrimaryKey   []string

	// Parameterized views (@args)
	InputArgsName string // input type name from @args(name: "...")
	RequiredArgs  bool   // true if any field in input type is NonNull or @args(required: true)
}

ObjectInfo caches shared metadata about a data object during compilation.

type ObjectMutationType

type ObjectMutationType int

ObjectMutationType represents the kind of mutation generated for a data object.

const (
	MutationTypeInsert ObjectMutationType = iota
	MutationTypeUpdate
	MutationTypeDelete
)

func (ObjectMutationType) String

func (m ObjectMutationType) String() string

type ObjectQueryType

type ObjectQueryType int

ObjectQueryType represents the kind of query generated for a data object.

const (
	QueryTypeSelect ObjectQueryType = iota
	QueryTypeSelectOne
	QueryTypeAggregate
	QueryTypeAggregateBucket

	SubQueryTypeReferencesData
	SubQueryTypeJoinData
	SubQueryTypeFunctionCallData
	SubQueryTypeFunctionCallTableJoinData
)

type Options

type Options struct {
	Name         string
	ReadOnly     bool
	Prefix       string
	EngineType   string
	AsModule     bool
	IsExtension  bool
	Capabilities *EngineCapabilities
}

Options configures compilation behavior.

func (*Options) ApplyPrefix

func (o *Options) ApplyPrefix(name string) string

ApplyPrefix prepends the prefix to a name with underscore separator if set.

func (*Options) IsArraysSupported

func (o *Options) IsArraysSupported() bool

func (*Options) IsCrossCatalogReferencesSupported

func (o *Options) IsCrossCatalogReferencesSupported() bool

func (*Options) IsSequenceDefaultSupported

func (o *Options) IsSequenceDefaultSupported() bool

func (*Options) IsStructuredTypesSupported

func (o *Options) IsStructuredTypesSupported() bool

func (*Options) IsTablesSupported

func (o *Options) IsTablesSupported() bool

func (*Options) IsTypeSupported

func (o *Options) IsTypeSupported(typ string) bool

func (*Options) SupportDelete

func (o *Options) SupportDelete() bool

func (*Options) SupportDeleteWithoutPKs

func (o *Options) SupportDeleteWithoutPKs() bool

func (*Options) SupportInsert

func (o *Options) SupportInsert() bool

func (*Options) SupportInsertReferences

func (o *Options) SupportInsertReferences() bool

func (*Options) SupportInsertReturning

func (o *Options) SupportInsertReturning() bool

func (*Options) SupportUpdate

func (o *Options) SupportUpdate() bool

func (*Options) SupportUpdatePKs

func (o *Options) SupportUpdatePKs() bool

func (*Options) SupportUpdateWithoutPKs

func (o *Options) SupportUpdateWithoutPKs() bool

type Phase

type Phase int

Phase represents a compilation phase.

const (
	PhaseValidate Phase = iota
	PhasePrepare
	PhaseGenerate
	PhaseAssemble
	PhaseFinalize
)

func (Phase) String

func (p Phase) String() string

type Provider

type Provider interface {
	DefinitionsSource

	Description(ctx context.Context) string

	// Root operation types
	QueryType(ctx context.Context) *ast.Definition
	MutationType(ctx context.Context) *ast.Definition
	SubscriptionType(ctx context.Context) *ast.Definition

	// Type relationships (for validator: fragment spreading, interface checks)
	PossibleTypes(ctx context.Context, name string) iter.Seq[*ast.Definition]
	Implements(ctx context.Context, name string) iter.Seq[*ast.Definition]

	// types iteration (for introspection, meta-info)
	Types(ctx context.Context) iter.Seq2[string, *ast.Definition]
}

Provider is a read-only interface to a compiled schema. All methods accept context.Context for future storage-backed implementations.

type QueryRequest

type QueryRequest struct {
	Name      string
	OrderNum  int
	QueryType QueryType
	Field     *ast.Field
	Subset    []QueryRequest
}

QueryRequest is a classified entry from an operation's selection set.

type QueryType

type QueryType int

QueryType is a bitmask for classifying operation-level query requests.

const (
	QueryTypeNone QueryType = 0
	QueryTypeMeta QueryType = 1 << iota
	QueryTypeQuery
	QueryTypeJQTransform
	QueryTypeMutation
	QueryTypeFunction
	QueryTypeFunctionMutation
	QueryTypeH3Aggregation
	QueryTypeSubscription
)

type Rule

type Rule interface {
	Name() string
	Phase() Phase
}

Rule is the base interface for all compilation rules.

Jump to

Keyboard shortcuts

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