ui

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package ui provides the admin UI page registry (TAD §9.1) and the codegen input contract consumed by the @orjanda/codegen pass (TAD §6.3).

Page registrations surface custom frontend routes in the Admin UI sidebar (PRD §18.3); the codegen types mirror the GET /api/v1/meta shape so a single field-type-to-external-representation table feeds both the agent tool JSON Schemas (TAD §10.2) and the generated TypeScript client.

Index

Constants

This section is empty.

Variables

View Source
var BaseColumns = []string{"id", "name", "owner", "created_at", "updated_at", "modified_by", "doc_status", "deleted"}

BaseColumns are the auto-field columns present on every row (TAD §1.4).

Functions

func ContentHash

func ContentHash(reg schema.Registry) (string, error)

ContentHash computes a stable hash of the codegen-relevant Registry surface: any change to a DocType's metadata that would alter the generated TypeScript (fields, types, requiredness, permissions, titles, child tables) changes the hash. `orjanda serve` (Phase 10) compares this hash across Registry recompiles to decide whether to re-run the codegen pass (TAD §6.3 step 3).

func DefaultScriptPath

func DefaultScriptPath() string

DefaultScriptPath locates the @orjanda/codegen Node script: an orjanda-codegen.mjs in the working directory when present (a vendored or workspace copy), else the one shipped in the framework module. When neither exists it falls back to the relative name so the exec error names the binary.

func MarshalInput

func MarshalInput(reg schema.Registry) ([]byte, error)

MarshalInput renders the TAD §6.3 step-1 payload exactly as Regenerate writes it (documents sorted by Name, two-space indentation) — the byte shape the committed orjanda-ui/src/generated/schema.json must match.

func Regenerate

func Regenerate(ctx context.Context, opts RegenerateOptions) (bool, error)

Regenerate runs the codegen pass if and only if the Registry's content hash differs from the recorded marker (TAD §6.3 step 3). It returns true when the pass ran. On success the marker is updated to the current hash.

func VerifyCommittedSchema

func VerifyCommittedSchema(reg schema.Registry, inputPath string) error

VerifyCommittedSchema is the node-free half of the generated-output consistency check (REVIEW-2026-08-12 finding 5): the on-disk step-1 payload must be byte-identical to a fresh CodegenInput for reg. Production `orjanda serve` fails fast on a mismatch so a stale TypeScript client cannot ship unnoticed; the UI test suite uses it as the commit-time gate on the checked-in orjanda-ui/src/generated/schema.json.

Types

type ChildTableJSON

type ChildTableJSON struct {
	FieldName string      `json:"field_name"`
	DocType   string      `json:"doc_type"`
	TypeName  string      `json:"type_name"`
	Fields    []FieldJSON `json:"fields"`
}

ChildTableJSON describes a compiled child-table embed for the codegen pass. DocType is the canonical child DocType the generated interface references.

type DocMetaJSON

type DocMetaJSON struct {
	Name        string           `json:"name"`
	App         string           `json:"app,omitempty"`
	Module      string           `json:"module,omitempty"`
	TitleField  string           `json:"title_field"`
	Searchable  bool             `json:"searchable"`
	Submittable bool             `json:"submittable"`
	Icon        string           `json:"icon,omitempty"`
	Description string           `json:"description,omitempty"`
	Fields      []FieldJSON      `json:"fields"`
	ChildTables []ChildTableJSON `json:"child_tables,omitempty"`
	Permissions PermissionsJSON  `json:"permissions"`
}

DocMetaJSON is the per-Document codegen input record.

func CodegenInput

func CodegenInput(reg schema.Registry) ([]DocMetaJSON, error)

CodegenInput builds the TAD §6.3 step-1 payload for a compiled Registry. Documents are ordered by Name for stable hashing and deterministic output.

type FieldJSON

type FieldJSON struct {
	Name       string   `json:"name"`
	Column     string   `json:"db_column"`
	Type       string   `json:"type"`
	Label      string   `json:"label"`
	Required   bool     `json:"required"`
	Options    []string `json:"options,omitempty"`
	Link       string   `json:"link,omitempty"`
	Hidden     bool     `json:"hidden"`
	Permission string   `json:"permission,omitempty"`
	ReadOnly   bool     `json:"read_only,omitempty"`
}

FieldJSON is the compiled metadata for one field. Column mirrors the REST record key; Name mirrors the REST write key.

type FieldTypeName

type FieldTypeName = string

FieldTypeName is the stable external type identifier emitted on the wire. It is the string form of schema.FieldType (PRD §10.3's Field Types table).

type Page

type Page struct {
	// Path is the client-side route (e.g. "/app/hr/org-chart").
	Path string `json:"path"`
	// Title is the page title shown in the sidebar and document head.
	Title string `json:"title"`
	// Component is the JS module path resolved by the frontend bundle loader
	// (e.g. "hr/OrgChart").
	Component string `json:"component"`
	// Icon is an optional icon identifier for the sidebar entry.
	Icon string `json:"icon,omitempty"`
	// Menu groups the page under a sidebar heading.
	Menu string `json:"menu,omitempty"`
}

Page describes a custom Admin UI page registered by an Application. See TAD §9.1 and PRD §18.3. The JSON tags fix the GET /api/v1/meta/pages wire shape consumed by the Admin UI sidebar.

type PermissionsJSON

type PermissionsJSON struct {
	CanRead   bool `json:"can_read"`
	CanWrite  bool `json:"can_write"`
	CanCreate bool `json:"can_create"`
	CanDelete bool `json:"can_delete"`
	CanSubmit bool `json:"can_submit"`
}

PermissionsJSON is the identity-independent capability summary. It answers "does ANY role grant this verb?" so the generated client only exposes methods that a non-empty role set could invoke; the server still enforces per-request checks (PRD §25.1).

type RegenerateOptions

type RegenerateOptions struct {
	// Registry is the compiled Registry to snapshot.
	Registry schema.Registry
	// ScriptPath is the absolute path to the @orjanda/codegen Node script.
	// Defaults to DefaultScriptPath.
	ScriptPath string
	// InputPath is where the TAD §6.3 step-1 payload is written. Defaults to
	// "orjanda-ui/src/generated/schema.json".
	InputPath string
	// OutputDir is where generated TypeScript is written. Defaults to
	// "orjanda-ui/src/generated".
	OutputDir string
	// MarkerPath records the last ContentHash so unchanged Registries skip
	// regeneration. Defaults to <OutputDir>/.registry-hash.
	MarkerPath string
	// NodeBin is the node binary; defaults to "node".
	NodeBin string
}

RegenerateOptions configures a codegen pass (TAD §6.3 step 2).

type Registry

type Registry interface {
	RegisterPage(p Page)
	Pages() []Page
}

Registry collects ui.Page registrations before routes mount. See TAD §9.1.

func NewRegistry

func NewRegistry() Registry

NewRegistry builds an empty page Registry. Custom pages are registered via RegisterPage; the default per-Document list/form pages are derived from the Registry metadata at render time (PRD §17.3) and are not stored here.

Jump to

Keyboard shortcuts

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