Namespace
@Js
const mixin Namespace
Library namespace is a pinned manifest of specific library versions. Namespaces may lazily load their libs, in which case not all operations are supported. Create a new namespace via XetoEnv.createNamespace.
Get an instance by the given qualified name
Get the given library by name
Get a type spec by the given qualified name
Create default instance for the given spec
Get all the mixins inherited into the given type
Get a spec by the given qualified name
Return if this namespace contains the given lib name
Iterate all the instances in libs
Compute the extended type spec by merging all meta and slots from mixins
Validate a graph of records using their configured spec tag
Base64 digest for this namespace based on its lib versions Note
Return load status for the given library name
Iterate all the direct subtypes of given type
Validate a single value against a spec
Exception for a library with lib status of err, or null otherwise
Get the effective spec metadata slots
Spec for Fantom Type or the typeof given object
Access I/O operations using this namespace
Environment used to create this namespace
Return if the given instance fits the spec via structural typing
Lookup the version info for a library name in this namespace
Iterate all top-level types in libs until callback returns non-null
List the library name and versions in this namespace
Return if given type has at least one direct subtype
Get the effective map of all functions
Return choice API for given spec
List all libraries
Iterate all the top-level types in libs
abstract SpecChoice choice(Spec spec)
Return choice API for given spec. Callers should prefer the slot over the type since the slot determines maybe and multi-choice flags. Raise exception if Spec.isChoice is false.
abstract Str digest()
Base64 digest for this namespace based on its lib versions Note: this digest only changes when the libs and/or versions are modified. It is not a digest of the lib contents.
abstract Void eachInstance(|Dict| f)
Iterate all the instances in libs
abstract Void eachSubtype(Spec base, |Spec| f)
Iterate all the direct subtypes of given type
abstract Void eachType(|Spec| f)
Iterate all the top-level types in libs.
abstract Obj? eachTypeWhile(|Spec->Obj?| f)
Iterate all top-level types in libs until callback returns non-null.
abstract XetoEnv env()
Environment used to create this namespace
abstract Bool fits(Obj? val, Spec spec, Dict? opts)
Return if the given instance fits the spec via structural typing. Options:
graph: marker to also check graph of references such as required pointsignoreRefs: marker to ignore if refs resolve to valid targethaystack: marker tag to use Haystack level data fidelity
abstract SpecMap funcs()
Get the effective map of all functions. This is semantically equivalent to specx(Funcs).slots.
abstract Bool hasLib(Str name)
Return if this namespace contains the given lib name. This is true if version will return non-null regardless of libStatus.
abstract Bool hasSubtypes(Spec base)
Return if given type has at least one direct subtype.
abstract Dict? instance(Str qname, Bool checked)
Get an instance by the given qualified name
abstract Obj? instantiate(Spec spec, Dict? opts)
Create default instance for the given spec. Raise exception if spec is abstract.
Options:
graph: marker tag to instantiate graph of recs (will auto-generate ids)abstract: marker to supress error if spec is abstractid: Ref tag to include in new instancehaystack: marker tag to use Haystack level data fidelity
abstract XetoIO io()
Access I/O operations using this namespace
abstract Lib? lib(Str name, Bool checked)
Get the given library by name. If the library is not in the namesapce or could be compiled then raise an exception unless checked is false.
abstract Err? libErr(Str name, Bool checked)
Exception for a library with lib status of err, or null otherwise. Return null/exception if library not included
abstract LibStatus? libStatus(Str name, Bool checked)
Return load status for the given library name:
ok: library is included and loaded successfullyerr: library is included but could not be loaded- null/exception if library not included
abstract Lib[] libs()
List all libraries. Any libs which cannot be compiled are excluded.
abstract SpecMap metas()
Get the effective spec metadata slots. This is semantically equivalent to specx(Spec).slots.
abstract Spec[] mixinsFor(Spec type)
Get all the mixins inherited into the given type. This operation can be expensive.
abstract Spec? spec(Str qname, Bool checked)
Get a spec by the given qualified name:
- type/mixin: "foo.bar::Baz"
- slot/global: "foo.bar::Baz.qux"
abstract Spec? specOf(Obj? val, Bool checked)
Spec for Fantom Type or the typeof given object
abstract Spec specx(Spec type)
Compute the extended type spec by merging all meta and slots from mixins. This call can be quite expensive; so cache and reuse the result for your operation.
abstract Spec? type(Str qname, Bool checked)
Get a type spec by the given qualified name.
abstract ValidateReport validate(Obj? val, Spec? spec, Dict? opts)
Validate a single value against a spec. If spec is null, then validate against specOf(val). Should be called within an XetoContext context to verify external refs.
abstract ValidateReport validateAll(Dict[] subjects, Dict? opts)
Validate a graph of records using their configured spec tag. Should be called within an XetoContext context to verify external refs.
abstract LibVersion? version(Str name, Bool checked)
Lookup the version info for a library name in this namespace.
abstract LibVersion[] versions()
List the library name and versions in this namespace.