Documentation
¶
Overview ¶
Package framework is document types you define: describe a record once, then create, list, submit and cancel documents against it.
The DocType routes live at /v1/framework and are per org, with the engine's own permission calculus deciding every access.
The engine itself is github.com/hanzoai/framework, built on the metadata model github.com/hanzoai/doctype. Neither knows what HTTP is. This package is the ADAPTER — the "place" in the engine's layering:
doctype the VALUE — schema, coercion, naming, permission calculus.
framework the ENGINE — store, hooks, leases, operations. No transport.
this pkg the PLACE — /v1/framework/* over zip, cek-encrypted storage,
principal-derived tenancy, engine Code → HTTP status.
It does four things and nothing else:
- opens the engine with cloud's storage policy (cek, encrypted at rest);
- turns a validated request principal into an engine Caller;
- binds each engine operation to a TYPED OP and maps the error Code;
- re-exports the engine vocabulary so the app lanes (cms, erp, help, knowledge, content, guide) keep ONE import and compile unchanged.
(3) is a typed op — zip.Get[In, Out] and friends — for every route but the two document WRITES: one registry entry, and the REST route, the OpenAPI operation, the MCP tool, the CLI command and the generated SDK method all follow from it. The two exceptions are in Mount, with the reason.
The engine enforces permissions itself, so there is no authorization logic here — a second copy would be a second answer.
Index ¶
- Constants
- Variables
- func Delete(ctx context.Context, org, doctype, name string) error
- func FindByField(ctx context.Context, org, doctype, field, value string) (string, error)
- func Installed(ctx context.Context, org, doctype string) bool
- func IsValidationError(err error) bool
- func ModuleInstalled(ctx context.Context, org, module string) bool
- func Mount(app cloud.Router, deps cloud.Deps) error
- func Shutdown() error
- func UpdateData(ctx context.Context, org, doctype, name string, data map[string]any) error
- type DocField
- type DocPerm
- type DocType
- type Document
- type Event
- type Hook
- type Ingested
- type Lease
- type ListOpts
- type Role
- type Store
Constants ¶
const ( FieldData = doctype.FieldData FieldInt = doctype.FieldInt FieldFloat = doctype.FieldFloat FieldCurrency = doctype.FieldCurrency FieldCheck = doctype.FieldCheck FieldDate = doctype.FieldDate FieldDatetime = doctype.FieldDatetime FieldText = doctype.FieldText FieldSmall = doctype.FieldSmall FieldLong = doctype.FieldLong FieldRichText = doctype.FieldRichText FieldSelect = doctype.FieldSelect FieldLink = doctype.FieldLink FieldTable = doctype.FieldTable FieldAttach = doctype.FieldAttach FieldJSON = doctype.FieldJSON FieldPassword = doctype.FieldPassword )
The closed fieldtype set.
const ( RoleSystemManager = doctype.RoleSystemManager RoleAll = doctype.RoleAll )
Roles.
const ( ActionBeforeInsert = engine.ActionBeforeInsert ActionBeforeSave = engine.ActionBeforeSave ActionAfterSave = engine.ActionAfterSave ActionOnSubmit = engine.ActionOnSubmit ActionOnCancel = engine.ActionOnCancel ActionOnTrash = engine.ActionOnTrash )
Lifecycle hook actions.
Variables ¶
var ( ErrNotFound = engine.ErrNotFound ErrConflict = engine.ErrConflict ErrBadRef = engine.ErrBadRef )
Error sentinels an in-process caller classifies with errors.Is.
var ( // RegisterModule declares the DocType fixtures a module installs. RegisterModule = doctype.RegisterModule // MarkAlwaysOn makes a module's fixtures resolve for every org with no // per-org install step. MarkAlwaysOn = doctype.MarkAlwaysOn // RegisteredModules is the sorted set of registered module names. RegisteredModules = doctype.RegisteredModules // AlwaysOnModules is the sorted set of modules marked always-on. AlwaysOnModules = doctype.AlwaysOnModules // RegisterHook attaches a lifecycle handler to (doctype, action). RegisterHook = engine.RegisterHook // RegisteredHookCount is the number of (doctype, action) keys carrying a // hook — the composition root's link-guard asserts the lanes are compiled in. RegisteredHookCount = engine.RegisteredHookCount )
Registration entry points. An app lane calls these from a package init() to declare its content model and attach behaviour — the ONE way a lane extends the engine.
Functions ¶
func FindByField ¶
FindByField returns the name of the first document whose `field` equals `value`, or "" if none.
func IsValidationError ¶
IsValidationError reports whether err is a document-schema violation.
func ModuleInstalled ¶
ModuleInstalled reports whether a module's content model resolves for `org`.
Types ¶
type Document ¶
Document is a stored record: validated field data plus its lifecycle state.