pgdesign v0.26.0 /internal/parse
On this page

Package parse provides a lenient TOML parser for pgdesign schema files, extracting structure without enforcing semantic rules into a RawSchema.

#internal/parse

#internal/parse

Package parse turns pgdesign schema TOML into a RawSchema. Entry points (File/Bytes/Files/Dir) first run a strictspec-generated document-shape gate (see gate.go and pgschema/): strictspec is the single authority for shape — well-formedness, closed records (unknown keys), base-type conformance, required fields, and the identifier/pgtype/sql-expression custom-scalar lexemes. Only shape-valid documents are walked into a RawSchema; semantic rules (type existence, reference/enum-value resolution, SQL grammaticality, normal form) remain native in model/validate. Every schema document must carry a top-level format_version.

Column order is preserved via AST walking (not map iteration).

#RawSchema

Go go
type RawSchema struct

RawSchema is the top-level result of parsing one or more TOML schema files.

#RawMeta

Go go
type RawMeta struct

RawMeta holds the [meta] section values.

#RawSMState

Go go
type RawSMState struct

RawSMState holds a state in a state machine type from [types..states.].

#RawSMTransition

Go go
type RawSMTransition struct

RawSMTransition holds a transition in a state machine type from [[types.*.transitions]].

#RawCompositeField

Go go
type RawCompositeField struct

RawCompositeField holds one composite type field from [types.*.fields].

#RawType

Go go
type RawType struct

RawType holds a user-defined type from [types.*].

#RawView

Go go
type RawView struct

RawView holds a view definition from [views.*].

#RawMaterializedView

Go go
type RawMaterializedView struct

RawMaterializedView holds a materialized view definition from [materialized_views.*].

#RawSequence

Go go
type RawSequence struct

RawSequence holds a sequence definition from [sequences.*].

#RawTable

Go go
type RawTable struct

RawTable holds a table definition from [tables.*].

#RawColumn

Go go
type RawColumn struct

RawColumn holds a column definition from [tables..columns.].

#RawFK

Go go
type RawFK struct

RawFK holds a foreign key constraint from [tables..fks.].

#RawIndex

Go go
type RawIndex struct

RawIndex holds an index definition from [tables..indexes.].

#RawUnique

Go go
type RawUnique struct

RawUnique holds a unique constraint from [tables..unique.].

#RawCheck

Go go
type RawCheck struct

RawCheck holds a check constraint from [tables..checks.].

#RawExclusion

Go go
type RawExclusion struct

RawExclusion holds an exclusion constraint from [tables..exclusions.].

#RawPolicy

Go go
type RawPolicy struct

RawPolicy holds a row-level security policy from [tables..policies.].

#RawTrigger

Go go
type RawTrigger struct

RawTrigger holds a trigger definition from [tables..triggers.].

#RawPartitioning

Go go
type RawPartitioning struct

RawPartitioning holds partition configuration from [tables.*.partitioning].

#RawDependency

Go go
type RawDependency struct

RawDependency holds a functional dependency from [[tables.*.dependencies]].

#RawMaintenance

Go go
type RawMaintenance struct

RawMaintenance holds maintenance configuration from [tables.*.maintenance].

#RawFunctionArg

Go go
type RawFunctionArg struct

RawFunctionArg holds a function argument from [[functions.*.args]].

#RawFunction

Go go
type RawFunction struct

RawFunction holds a function or procedure definition from [functions.*].

#CollectUserTypes

Go go
func CollectUserTypes(raw *RawSchema) []semtype.UserTypeDef

CollectUserTypes converts a RawSchema's user-defined types into UserTypeDefs suitable for loading into a semtype.Registry. This is the single canonical conversion point — all callers should use this instead of inline conversion.

#File

Go go
func File(path string) (*RawSchema, []diagnostic.Diagnostic)

File parses a single TOML schema file and returns a RawSchema with diagnostics. It continues past errors, returning partial results even on failure.

#Bytes

Go go
func Bytes(data []byte) (*RawSchema, []diagnostic.Diagnostic)

Bytes parses TOML bytes and returns a RawSchema with diagnostics. Like File but operates on in-memory bytes instead of reading from disk.

#Files

Go go
func Files(paths []string) ([]*RawSchema, []diagnostic.Diagnostic)

Files parses multiple TOML schema files and returns all schemas with aggregated diagnostics.

#Dir

Go go
func Dir(dirPath string) ([]*RawSchema, []diagnostic.Diagnostic)

Dir finds all .toml schema files in a directory (excluding pgdesign.toml), parses each, and returns all schemas with aggregated diagnostics.

Search