codesql

package module
v0.0.0-...-722397a Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CachePath

func CachePath(name, root, cacheDir string) (string, error)

CachePath returns config/codesql/<database-name>-<source-root-hash>.sqlite.

func ManagedCacheTables

func ManagedCacheTables() []string

ManagedCacheTables returns the CodeSQL tables whose cached GraphQL query results must be invalidated after source reconciliation.

func ManagedMutationTables

func ManagedMutationTables() []string

ManagedMutationTables returns CodeSQL's service-managed mutation tables.

func OpenManaged

func OpenManaged(ctx context.Context, opts Options) (*Managed, *Stats, error)

OpenManaged opens or creates the managed SQLite cache, reconciles it with the source root, and optionally starts the runtime watcher.

func RefreshPublicGraph

func RefreshPublicGraph(ctx context.Context, db *sql.DB) error

Types

type DBRefTarget

type DBRefTarget struct {
	DatabaseName string
	SchemaName   string
	TableName    string
	Columns      []string
}

type Managed

type Managed struct {
	DB        *sql.DB
	CachePath string
	Root      string
	// contains filtered or unexported fields
}

Managed is a live SQLite-backed source-code database.

func (*Managed) Close

func (m *Managed) Close() error

Close stops the watcher, if any, and closes the SQLite database.

func (*Managed) ExecuteManagedMutation

func (m *Managed) ExecuteManagedMutation(ctx context.Context, req MutationRequest) (json.RawMessage, error)

ExecuteManagedMutation handles CodeSQL preview/apply/lock GraphQL mutations.

func (*Managed) RefreshPublicGraph

func (m *Managed) RefreshPublicGraph(ctx context.Context) error

RefreshPublicGraph refreshes the public gj_code facade while serializing against other managed CodeSQL writes.

func (*Managed) SetDBRefTargets

func (m *Managed) SetDBRefTargets(ctx context.Context, targets []DBRefTarget) error

func (*Managed) SetSourceChangeHook

func (m *Managed) SetSourceChangeHook(fn func())

SetSourceChangeHook registers a callback fired after a successful reconcile that changes the indexed source view.

type MutationField

type MutationField struct {
	Name   string
	Column string
}

MutationField describes a selected return field.

type MutationRequest

type MutationRequest struct {
	Database  string
	Operation string
	Roots     []MutationRoot
}

MutationRequest describes GraphQL roots routed to the CodeSQL mutation bridge.

type MutationRoot

type MutationRoot struct {
	FieldName string
	Table     string
	Operation string
	Input     map[string]interface{}
	Fields    []MutationField
}

MutationRoot describes one managed mutation root.

type Options

type Options struct {
	// Name is the GraphJin database config key. It is used as the cache file
	// prefix under CacheDir.
	Name string
	// Root is the source tree to index.
	Root string
	// CacheDir is normally <graphjin-config>/codesql.
	CacheDir string
	// Watch starts the runtime fsnotify reconciler after the initial scan.
	Watch bool
	// InferDBRefs enables best-effort code-to-database reference extraction.
	InferDBRefs bool
	// RefTargets is an optional database metadata catalog used to resolve refs.
	RefTargets []DBRefTarget
}

Options configures a managed CodeSQL index.

type Stats

type Stats struct {
	FilesIndexed int
	FilesAdded   int
	FilesChanged int
	FilesDeleted int
	FilesSkipped int
	ParseErrors  int
	Duration     time.Duration
}

Stats describes the latest reconciliation run.

Jump to

Keyboard shortcuts

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