Class HNamespace

Haystack namespace.

A namespace holds a collection of normalized defs.

Hierarchy

  • HNamespace

Constructors

Accessors

  • get defs(): Defs
  • Returns a defs lookup map.

    Since defs are keyed by a symbol this map provides fast look up.

    Returns Defs

    A object with key to value defs.

Methods

  • Returns a flattened list of all the supertypes in the whole supertype chain.

    Parameters

    • name: string | HSymbol

      The def name.

    Returns HDict[]

    A list of supertypes.

  • Return an array of defs for the given association on the parent.

    Parameters

    • parent: string | HSymbol

      The parent def.

    • association: string | HSymbol

      The association.

    Returns HDict[]

    An array of associated defs.

  • Return an array of dicts via their names. If a name can't be found then throw an error.

    Parameters

    • Rest ...names: (string | string[] | HSymbol | HSymbol[])[]

      The names of the defs to look up.

    Returns HDict[]

    A array of defs.

    Throws

    An error if the def can't be found.

  • Return a def via its name or undefined if it can't be found.

    Parameters

    • name: string | HSymbol

      The name of the def to look up.

    Returns undefined | HDict

    The def or undefined if it can't be found.

  • Decomposes a conjunct into its respective defs and returns them.

    If the def is not a conjunct then it will just return itself.

    Parameters

    • name: string | HSymbol

      The conjunct def to breakdown.

    Returns HDict[]

    The defs the conjunct references.

    Throws

    An error if any of the defs are invalid.

  • Match the most specific marker entity type for the specified dict.

    Parameters

    • subject: HDict

      The subject dict.

    Returns HDict

    The entity def or dict if one cannot be found.

  • Return the Haystack kind value from the def. If the def is invalid or a kind cannot be ascertained then return undefined.

    Please note, curVal and writeVal are scalars but don't extend a def that could relate to a concrete type (i.e. number or bool). This implies these values can be any scalar and hence match multiple kinds. In this case undefined will be returned for the kind.

    Parameters

    • name: string | HSymbol

      The name of the def to get the kind for.

    Returns undefined | Kind

    The kind or undefined it one cannot be found.

  • Return true if the specified def fits the base def.

    If true this means that def is assignable to types of base. This is effectively the same as checking if inheritance(def) contains base.

    Parameters

    • name: string | HSymbol

      The def name.

    • base: string | HSymbol

      The name of the base def.

    Returns boolean

    True if the def fits.

  • Return true if the specified def is a choice.

    Parameters

    • name: string | HSymbol

      The def name.

    Returns boolean

    True if the def is a choice.

  • Return true if the specified def is a entity.

    Parameters

    • name: string | HSymbol

      The def name.

    Returns boolean

    True if the def is a entity.

  • Return true if the specified def is a marker.

    Parameters

    • name: string | HSymbol

      The def name.

    Returns boolean

    True if the def is a marker.

  • Return true if the specified def is a val.

    Parameters

    • name: string | HSymbol

      The def name.

    Returns boolean

    True if the def is a val.

  • Return a def via its name or undefined if it can't be found.

    This method is a duplicate of byName.

    Parameters

    • name: string | HSymbol

      The name of the def to look up.

    Returns undefined | HDict

    The def or undefined if it can't be found.

  • Return true if the def exists in the namespace.

    This method is a duplicate of hasName.

    Parameters

    • name: string | HSymbol

      The name of the def to look up.

    Returns boolean

    True if the def exists.

  • Return true if the def exists in the namespace.

    Parameters

    • name: string | HSymbol

      The name of the def to look up.

    Returns boolean

    True if the def exists.

  • Query a subject's relationship.

    Relationships model how entities are related to one another via instance to instance relationships versus def to def associations.

    https://project-haystack.dev/doc/docHaystack/Relationships#querying

    Parameters

    • __namedParameters: {
          queried?: Set<string>;
          ref?: HRef;
          relName: string | HSymbol;
          relTerm?: string | HSymbol;
          resolve?: ((ref) => undefined | HDict);
          subject: HDict;
      }
      • Optional queried?: Set<string>
      • Optional ref?: HRef
      • relName: string | HSymbol
      • Optional relTerm?: string | HSymbol
      • Optional resolve?: ((ref) => undefined | HDict)
          • (ref): undefined | HDict
          • Parameters

            Returns undefined | HDict

      • subject: HDict

    Returns boolean

    True if a match is made.

  • Returns true if the def has subtypes.

    Parameters

    • name: string | HSymbol

      The def name.

    Returns boolean

    True if the def has subtypes.

  • Return the tags that should be added for implementation.

    Parameters

    • name: string | HSymbol

      The def name.

    Returns HDict[]

    An array of defs to be added.

  • Return an array of defs for the is association on the parent.

    Parameters

    • parent: string | HSymbol

      The parent def.

    Returns HDict[]

    An array of associated defs.

  • Return true if the dict is valid for the specified tag.

    Parameters

    • name: string | HSymbol

      The tag name.

    • dict: unknown

      The dict to validate against.

    Returns boolean

    true if the dict is valid.

  • Create a new dict with all the default required tags.

    Parameters

    • names: (string | HSymbol)[]

      The names of the tags to add.

    Returns HDict

    The new dict with all the default requirement tags.

  • Returns the supertypes of a def or an empty array if it can't be found.

    Parameters

    • name: string | HSymbol

      The def name.

    Returns HDict[]

    The supertype defs.

  • Return an array of defs for the tagOn association on the parent.

    Parameters

    • parent: string | HSymbol

      The parent def.

    Returns HDict[]

    An array of associated defs.

  • Return an array of defs for the tags association on the parent.

    Parameters

    • parent: string | HSymbol

      The parent def.

    Returns HDict[]

    An array of associated defs.

  • Returns a new dict with any implied tags that don't already exist on the dict.

    Parameters

    • dict: HDict

      The dict to look up the implied tags on.

    Returns HDict

    An implied tag dict.

  • Validates a dict for a tag.

    try {
    namespace.validate('site', new HDict({ site: HMarker.make() }))
    }
    catch(err) {
    console.error(err)
    }

    Parameters

    • name: string | HSymbol

      The name of the tag to validate.

    • dict: unknown

      The dict to validate against.

    Returns void

    Throws

    An error if the tags on the dict are not valid.

  • Validates all of the tags on the dict. Any tags that don't exist in the namespcae will be skipped.

    try {
    namespace.validateAll(new HDict({ site: HMarker.make() }))
    }
    catch(err) {
    console.error(err)
    }

    Parameters

    • dict: unknown

      The dict to validate.

    Returns void

    Throws

    An error if the tags on the dict are not valid.

  • Return the feature from the feature key. An empty string is returned if no feature can be found.

    For example, lib:foo would return lib.

    Parameters

    • name: string | HSymbol

      The name to parse.

    Returns string

    The feature.

  • Return the feature name from the feature key. An empty string is returned if no feature name can be found.

    For example, lib:foo would return foo.

    Parameters

    • name: string | HSymbol

      The name to parse.

    Returns string

    The feature name.

  • Return true if the name is for a conjunct.

    Parameters

    • name: string | HSymbol

      The name to test.

    Returns boolean

    True if the name is for a conjunct.

  • Return true if the name is for a feature.

    Parameters

    • name: string | HSymbol

      The name to test.

    Returns boolean

    True if the name is for a feature.

  • Split the conjunct name into its component parts.

    Parameters

    • name: string | HSymbol

      The name to split.

    Returns string[]

    The split marker tag names for the conjunct.

Generated using TypeDoc