Documentation
¶
Index ¶
- Constants
- func RegisterCustomType(recordType string, schemaPath string, data []byte) error
- func ResetCustomTypes()
- func ValidateAgainstSchema(data []byte, schemaPath string) error
- func ValidateCustomSchema(schemaPath string, data []byte) error
- func ValidateRecord(data []byte, recordType string) error
- func ValidateRecordWithRegistry(registry *Registry, data []byte, recordType string) error
- type RecordType
- type RecordTypeDefinition
- type RecordTypeManifest
- type Registry
- func LoadRecordTypeManifest(raw []byte, schemaFiles map[string][]byte) (*Registry, error)
- func LoadRecordTypeManifestFile(root, manifestPath string) (*Registry, error)
- func LoadRecordTypeManifestWithResources(raw []byte, schemaFiles map[string][]byte) (*Registry, error)
- func NewRegistry() *Registry
- func NewScopedRegistry() *Registry
- func (r *Registry) Definitions() []RecordTypeDefinition
- func (r *Registry) ListRecordTypes() []RecordType
- func (r *Registry) Manifest() RecordTypeManifest
- func (r *Registry) Register(def RecordTypeDefinition, data []byte) error
- func (r *Registry) RegisterCustomType(recordType, schemaID, schemaVersion, schemaPath string, data []byte) error
- func (r *Registry) RegisterCustomTypeSchema(recordType, schemaID, schemaVersion, schemaPath string) error
- func (r *Registry) RegisterFile(def RecordTypeDefinition) error
- func (r *Registry) RegisterSchema(def RecordTypeDefinition, data []byte) error
- func (r *Registry) ValidateRecord(data []byte, recordType string) error
Constants ¶
const ( RecordTypeManifestVersion = "1" RecordTypeManifestPath = "record-types.json" )
Variables ¶
This section is empty.
Functions ¶
func RegisterCustomType ¶
func ResetCustomTypes ¶
func ResetCustomTypes()
func ValidateAgainstSchema ¶
func ValidateCustomSchema ¶
func ValidateRecord ¶
Types ¶
type RecordType ¶
type RecordType struct {
Name string `json:"name"`
Description string `json:"description"`
SchemaPath string `json:"schema_path"`
}
func ListRecordTypes ¶
func ListRecordTypes() []RecordType
type RecordTypeDefinition ¶ added in v0.6.0
type RecordTypeDefinition struct {
RecordType string `json:"record_type"`
SchemaID string `json:"schema_id"`
SchemaVersion string `json:"schema_version"`
SchemaPath string `json:"schema_path"`
SHA256 string `json:"sha256"`
// Digest is an API-friendly alias for SHA256. It is not emitted as a
// second manifest field.
Digest string `json:"-"`
}
RecordTypeDefinition describes one portable custom record type. SchemaPath is always relative to the bundle root when the definition comes from a record-types.json manifest.
func (RecordTypeDefinition) MarshalJSON ¶ added in v0.6.0
func (d RecordTypeDefinition) MarshalJSON() ([]byte, error)
func (*RecordTypeDefinition) UnmarshalJSON ¶ added in v0.6.0
func (d *RecordTypeDefinition) UnmarshalJSON(raw []byte) error
type RecordTypeManifest ¶ added in v0.6.0
type RecordTypeManifest struct {
Version string `json:"version"`
RecordTypes []RecordTypeDefinition `json:"record_types"`
}
RecordTypeManifest is the portable, versioned custom type registry format.
func ParseRecordTypeManifest ¶ added in v0.6.0
func ParseRecordTypeManifest(raw []byte) (RecordTypeManifest, error)
ParseRecordTypeManifest validates and parses a record-types.json document.
type Registry ¶ added in v0.6.0
type Registry struct {
// contains filtered or unexported fields
}
Registry scopes custom type definitions to one caller or verification. A Registry is safe for concurrent validation and registration; callers should generally finish registration before sharing it with verifiers.
func LoadRecordTypeManifest ¶ added in v0.6.0
LoadRecordTypeManifest builds a scoped registry from manifest bytes and schema bytes keyed by their canonical safe manifest paths. It performs no process-global registration.
func LoadRecordTypeManifestFile ¶ added in v0.6.0
LoadRecordTypeManifestFile loads a portable manifest from a local root. Callers performing strict bundle verification should additionally enforce manifest membership before invoking this helper.
func LoadRecordTypeManifestWithResources ¶ added in v0.6.0
func LoadRecordTypeManifestWithResources(raw []byte, schemaFiles map[string][]byte) (*Registry, error)
LoadRecordTypeManifestWithResources builds a scoped registry from a manifest and an allowlisted resource set. Portable schemas must declare an exact $id and x-proof-schema-version matching their manifest definition; relative refs may resolve only to another resource in schemaFiles.
func NewRegistry ¶ added in v0.6.0
func NewRegistry() *Registry
NewRegistry creates an empty scoped registry containing only built-ins.
func NewScopedRegistry ¶ added in v0.6.0
func NewScopedRegistry() *Registry
NewScopedRegistry is an explicit alias for NewRegistry.
func (*Registry) Definitions ¶ added in v0.6.0
func (r *Registry) Definitions() []RecordTypeDefinition
Definitions returns a deterministic copy of portable custom definitions.
func (*Registry) ListRecordTypes ¶ added in v0.6.0
func (r *Registry) ListRecordTypes() []RecordType
ListRecordTypes returns built-ins and this registry's custom definitions.
func (*Registry) Manifest ¶ added in v0.6.0
func (r *Registry) Manifest() RecordTypeManifest
Manifest returns a deterministic portable manifest for the custom entries.
func (*Registry) Register ¶ added in v0.6.0
func (r *Registry) Register(def RecordTypeDefinition, data []byte) error
Register adds a portable custom definition and its schema bytes to this registry. Registration is additive: built-ins cannot be replaced and an existing name cannot be rebound to a different definition or digest.
func (*Registry) RegisterCustomType ¶ added in v0.6.0
func (r *Registry) RegisterCustomType(recordType, schemaID, schemaVersion, schemaPath string, data []byte) error
RegisterCustomType is a convenient scoped API. The supported form is RegisterCustomType(recordType, schemaID, schemaVersion, schemaPath, data).
func (*Registry) RegisterCustomTypeSchema ¶ added in v0.6.0
func (r *Registry) RegisterCustomTypeSchema(recordType, schemaID, schemaVersion, schemaPath string) error
RegisterCustomTypeSchema is a scoped file-based convenience API.
func (*Registry) RegisterFile ¶ added in v0.6.0
func (r *Registry) RegisterFile(def RecordTypeDefinition) error
RegisterFile registers a definition by reading its already validated local schema path. Portable bundle verification uses explicit bytes instead so it can bind reads to the outer bundle manifest.
func (*Registry) RegisterSchema ¶ added in v0.6.0
func (r *Registry) RegisterSchema(def RecordTypeDefinition, data []byte) error
RegisterSchema registers a schema from a portable definition. It is an alias useful to callers that prefer schema-oriented terminology.