Builtin Library
README.md
target
The declarer a preset's values are for: resolved by the guid its target
envelope names (pinned in the preset's .refs) or by the identity string a
hand-written target names, checked against that declarer's current schema,
and compared with the checksum the pin recorded.
Exports
Target.literalFor(ref) -> string— the guid a preset pins forref.Target.describe(ref) -> string—ref's identity.Target.envelopeFor(ref) -> Envelope—{ __ref, type, name }forref.Target.resolve(presetRef, doc) -> ResolvedTarget.resolveLiteral(literal: string) -> ResolvedTarget.declarerOfAsset(ref) -> (declarer, schema)Target.isComponentTarget(v) -> boolean— true for{ entity = <id>, component = <name> }.Target.declarerOfComponent(t) -> (component, schema, proxy)— the component asset governing a component on an entity, its schema, and the live component.Target.check(schema, values) -> (valid, rejected)Target.valuesOf(presetRef, doc) -> (values, report, resolved?)— whatpreset.valuesanswers, from a document already read.Target.merge(schema, current, patch) -> valuesTarget.refuse(prefix: string, violations)— raises.
Types:
Resolved = { literal: string, name: string, ref: any?, guid: string?, schema: any?, pinned: boolean, changed: boolean }Violation = { path: string, message: string }Report = { format, target, targetGuid?, pinned, targetChanged, rejected }
Usage
local Target = require("@builtin::modules.preset.target")
local declarer, schema = Target.declarerOfAsset(texRef)