Documentation
¶
Overview ¶
Package catalog is the catalog half of the smart-comments plugin: it indexes PostGraphile-style tags parsed from database COMMENTs and applies the ones with a structural representation in the introspect.Catalog — @omit on whole objects, @omit create/update/delete → privilege flags, @primaryKey / @unique / @foreignKey synthesis, @notNull / @nullable, and @filterable / @sortable as a synthetic index. Products embed the Hook and add their naming (InflectionHook) and surface (schema/API hook) halves on top of the same Index.
Index ¶
- Constants
- type Hook
- type Index
- func (ix *Index) Column(schema, table, column string) smarttags.Tags
- func (ix *Index) Constraint(schema, constraint string) smarttags.Tags
- func (ix *Index) Enum(schema, name string) smarttags.Tags
- func (ix *Index) Function(schema, name string) smarttags.Tags
- func (ix *Index) RenamedColumn(schema, table, column string) string
- func (ix *Index) RenamedColumns(schema, table string, cols []string) []string
- func (ix *Index) RenamedTable(schema, table string) string
- func (ix *Index) Table(schema, table string) smarttags.Tags
Constants ¶
const ( Name = "smart-comments" // Priority 50: the CatalogHook shapes the catalog before other plugins // read it, and the products' naming halves apply @name before naming // plugins (simple-names, 100) format. Priority = 50 )
Name and Priority of the smart-comments plugin (shared by both products' wrappers so plugins.disabled works the same everywhere).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Hook ¶
type Hook struct {
// contains filtered or unexported fields
}
Hook is the CatalogHook. The tag index is rebuilt on every TransformCatalog (watch-mode rebuilds reuse the instance) and is exposed through Index for the products' inflection/surface halves.
func (*Hook) TransformCatalog ¶
TransformCatalog applies every tag with a catalog-level representation.
type Index ¶
type Index struct {
Tables map[string]smarttags.Tags // "schema.table"
TablesBy map[string]smarttags.Tags // "table"
Columns map[string]smarttags.Tags // "schema.table.column"
ColumnsBy map[string]smarttags.Tags // "table.column"
Enums map[string]smarttags.Tags // "schema.enum"
EnumsBy map[string]smarttags.Tags // "enum"
Functions map[string]smarttags.Tags // "schema.function"
FunctionsBy map[string]smarttags.Tags // "function"
Constraints map[string]smarttags.Tags // "schema.constraint"
}
Index holds the parsed tags of every commented catalog object. The *By maps are schema-less fallbacks for call sites that don't carry the pg schema; an ambiguous name (same table name in two schemas) maps to nil. The Constraints map is also written by the Hook when a @foreignKey value carries |@fieldName / |@foreignFieldName segments.
func BuildIndex ¶
func BuildIndex(c *introspect.Catalog) *Index
BuildIndex parses and indexes the smart tags of every commented object.
func (*Index) Constraint ¶
Constraint resolves a constraint's tags; constraints are always schema-qualified. Empty name → nil.
func (*Index) RenamedColumn ¶
RenamedColumn returns the @name of a column, or the column itself.
func (*Index) RenamedColumns ¶
RenamedColumns maps RenamedColumn over cols.
func (*Index) RenamedTable ¶
RenamedTable returns the @name of a table, or the table itself.