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.
Return choice API for given spec
Base64 digest for this namespace based on its lib versions Note
Iterate all the instances in libs
Iterate all the direct subtypes of given type
Iterate all the top-level types in libs
Iterate all top-level types in libs until callback returns non-null
Environment used to create this namespace
Return if the given instance fits the spec via structural typing
Get the effective map of all functions
Return if this namespace contains the given lib name
Return if given type has at least one direct subtype
Get an instance by the given qualified name
Create default instance for the given spec
Access I/O operations using this namespace
Get the given library by name
Exception for a library with lib status of err, or null otherwise
Return load status for the given library name
List all libraries
Get the effective spec metadata slots
Get all the mixins inherited into the given type
Get only the mixins registered directly for the given type without walking the inheritance hierarchy
Get a spec by the given qualified name
Spec for Fantom Type or the typeof given object
Compute the extended type spec by merging all meta and slots from mixins
Get a type spec by the given qualified name
Validate a single value against a spec
Validate a graph of records using their configured spec tag
Lookup the version info for a library name in this namespace
List the library name and versions in this namespace
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 := null)
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 := true)
Get an instance by the given qualified name
abstract Obj? instantiate(Spec spec, Dict? opts := null)
Create default instance for the given spec. Raise exception if spec is abstract.
Options:
genIds: generate ids for entity and comp dictsgraph: marker tag to return Dict[] and generate child queriesabstract: marker to supress error if spec is abstracthaystack: 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 := true)
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 := true)
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 := true)
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[] mixinsOwn(Spec type)
Get only the mixins registered directly for the given type without walking the inheritance hierarchy.
abstract Spec? spec(Str qname, Bool checked := true)
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 := true)
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 := true)
Get a type spec by the given qualified name.
abstract ValidateReport validate(Obj? val, Spec? spec := null, Dict? opts := null)
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 := null)
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 := true)
Lookup the version info for a library name in this namespace.
abstract LibVersion[] versions()
List the library name and versions in this namespace.