@haxall/haxall
    Preparing search index...

    Class HxCoreFuncs

    Haxall core "hx" axon functions supported by all runtimes

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    type$: Type

    Methods

    • Return a negative integer, zero, or a positive integer if this object is less than, equal to, or greater than the specified object:

      this < that   =>  <0
      this == that => 0
      this > that => >0

      This method may also be accessed via the < <= <=> >= and > shortcut operators. If not overridden the default implementation compares the toStr representations. Also see docLang.

      Examples:

      3.compare(8)  =>  -1
      8.compare(3) => 1
      8.compare(8) => 0
      3 <=> 8 => -1 // shortcut for 3.compare(8)

      Parameters

      Returns number

    • Compare this object to the specified for equality. This method may be accessed via the == and != shortcut operators. If not overridden the default implementation compares for reference equality using the === operator. If this method is overridden, then hash() must also be overridden such that any two objects which return true for equals() must return the same value for hash(). This method must accept null and return false.

      Parameters

      Returns boolean

    • Return a unique hashcode for this object. If a class overrides hash() then it must ensure if equals() returns true for any two objects then they have same hash code.

      Returns number

    • Return if this Obj is immutable and safe to share between threads:

      • an instance of a const class
      • the result of toImmutable on List, Map, or Buf
      • a Func object may or may not be immutable - see sys::Func.
      • other instances are assumed mutable and return false

      Returns boolean

    • Get an immutable representation of this instance or throw NotImmutableErr if this object cannot be represented as an immutable:

      • if type is const, return this
      • if already an immutable List, Map, Buf, or Func return this
      • if a List, then attempt to perform a deep clone by calling toImmutable on all items
      • if a Map, then attempt to perform a deep clone by calling toImmutable on all values (keys are already immutable)
      • some Funcs can be made immutable - see sys::Func
      • if a Buf create immutable copy, see sys::Buf
      • any other object throws NotImmutableErr

      Returns Readonly<this>

    • Return a string representation of this object.

      Returns string

    • Trap a dynamic call for handling. Dynamic calls are invoked with the -> shortcut operator:

      a->x        a.trap("x", null)
      a->x() a.trap("x", null)
      a->x = b a.trap("x", [b])
      a->x(b) a.trap("x", [b])
      a->x(b, c) a.trap("x", [b, c])

      The default implementation provided by Obj attempts to use reflection. If name maps to a method, it is invoked with the specified arguments. If name maps to a field and args.size is zero, get the field. If name maps to a field and args.size is one, set the field and return args[0]. Otherwise throw UnknownSlotErr.

      Parameters

      Returns JsObj

    • Get the Type instance which represents this object's class. Also seeType.of or Pod.of.

      Returns Type

    • This method called whenever an it-block is applied to an object. The default implementation calls the function with this, and then returns this.

      Parameters

      • f: (arg0: this) => void

      Returns this

    • Return about dict

      Returns Dict

    • Commit one or more diffs to the folio database. The argument may be one of the following:

      If one diff is passed, return the new record. If a list of diffs is passed return a list of new records.

      This is a synchronous blocking call which will return the new record or records as the result.

      Examples:

      // add new record
      newRec: commit(diff(null, {dis:"New Rec!"}, {add}))

      // add someTag to some group of records
      readAll(filter).toRecList.map(r => diff(r, {someTag})).commit

      Parameters

      Returns JsObj

    • Get the current context as a Dict with the following tags:

      • username for current user
      • userRef id for current user
      • locale current locale

      SkySpark tags:

      • projName if evaluating in context of a project
      • nodeId local cluster node id
      • ruleRef if evaluating in context of a rule engine
      • ruleTuning if evaluating in context of rule engine

      Returns Dict

    • Construct a modification "diff" used by commit. The orig should be the instance which was read from the database, or it may be null only if the add flag is passed. Any tags to add/set/remove should be included in the changes dict.

      The following flags are supported:

      • add: indicates diff is adding new record
      • remove: indicates diff is removing record (in general you should add trash tag instead of removing)
      • transient: indicate that this diff should not be flushed to persistent storage (it may or may not be persisted).
      • force: indicating that changes should be applied regardless of other concurrent changes which may be been applied after the orig version was read (use with caution!)

      Examples:

      // create new record
      diff(null, {dis:"New Rec", someMarker}, {add})

      // create new record with explicit id like Diff.makeAdd
      diff(null, {id:151bd3c5-6ce3cb21, dis:"New Rec"}, {add})

      // set/add dis tag and remove oldTag
      diff(orig, {dis:"New Dis", -oldTag})

      // set/add val tag transiently
      diff(orig, {val:123}, {transient})

      Parameters

      Returns Diff

    • Write x.toStr to standard output followed by newline. If x is null then print "null". If no argument is provided then print an empty line.

      Parameters

      Returns void

    • Returns boolean

    • Return if given record is under at least one watch. The rec argument can be any value accepted by toRecId().

      Parameters

      Returns boolean

    • Enable a library by name in the runtime:

      libAdd("mqtt")
      

      Parameters

      • name: string
      • Optionaltags: Dict

      Returns Dict

    • Disable a library by name in the runtime:

      libRemove("mqtt")
      

      Parameters

      Returns JsObj

    • Return grid of enabled libs and their current status. Columns:

      • name: library name string
      • libStatus: status enumeration string
      • statusMsg: additional message string or null

      Returns Grid

    • Parameters

      • ...args: unknown[]

      Returns HxCoreFuncs

    • Store a password key/val pair into current project's password store. The key is typically a Ref of the associated record. If the val is null, then the password will be removed. See docHaxall::Folio#passwords.

      passwordSet(@abc-123, "password")
      passwordSet(@abc-123, null)

      Parameters

      Returns void

    • Return list of installed Fantom pods

      Returns Grid

    • Read from database the first record which matches filter. If no matches found throw UnknownRecErr or null based on checked flag. If there are multiple matches it is indeterminate which one is returned. See readAll for how filter works.

      Examples:

      read(site)                 // read any site rec
      read(site and dis=="HQ") // read site rec with specific dis tag
      read(chiller) // raise exception if no recs with chiller tag
      read(chiller, false) // return null if no recs with chiller tag

      Parameters

      Returns Dict

    • Reall all records from the database which match the filter. The filter must an expression which matches the filter structure. String values may parsed into a filter using parseFilter function.

      Options:

      • limit: max number of recs to return
      • sort: sort by display name

      Examples:

      readAll(site)                      // read all site recs
      readAll(equip and siteRef==@xyz) // read all equip in a given site
      readAll(equip, {limit:10}) // read up to ten equips
      readAll(equip, {sort}) // read all equip sorted by dis

      Parameters

      Returns Grid

    • Reall all records which match filter as stream of Dict records. See docHaxall::Streams#readAllStream.

      Parameters

      Returns JsObj

    • Return the intersection of all tag names used by all the records matching the given filter. The results are returned as a grid with following columns:

      • name: string name of the tag
      • kind: all the different value kinds separated by "|"
      • count: total number of recs with the tag Also see readAllTagVals and gridColKinds.

      Examples:

      // read statistics on all tags used by equip recs
      readAllTagNames(equip)

      Parameters

      Returns Grid

    • Return the range of all the values mapped to a given tag name used by all the records matching the given filter. This method is capped to 200 results. The results are returned as a grid with a single val column. Also see readAllTagNames.

      Examples:

      // read grid of all unique point unit tags
      readAllTagVals(point, "unit")

      Parameters

      Returns Grid

    • Read a record from database by id. If not found throw UnknownRecErr or return null based on checked flag. In Haxall all refs are relative, but in SkySpark refs may be prefixed with something like "p:projName:r:". This function will accept both relative and absolute refs.

      Examples:

      readById(@2b00f9dc-82690ed6)          // relative ref literal
      readById(@:demo:r:2b00f9dc-82690ed6) // project absolute literal
      readById(id) // read using variable
      readById(equip->siteRef) // read from ref tag

      Parameters

      • id: Ref
      • Optionalchecked: boolean

      Returns Dict

    • Given record id, read only the persistent tags from Folio. Also see readByIdTransientTags and readById.

      Parameters

      • id: Ref
      • Optionalchecked: boolean

      Returns Dict

    • Read a list of record ids into a grid. The rows in the result correspond by index to the ids list. If checked is true, then every id must be found in the database or UnknownRecErr is thrown. If checked is false, then an unknown record is returned as a row with every column set to null (including the id tag). Either relative or project absolute refs may be used.

      Examples:

      // read two relative refs
      readByIds([@2af6f9ce-6ddc5075, @2af6f9ce-2d56b43a])

      // read two project absolute refs
      readByIds([@p:demo:r:2af6f9ce-6ddc5075, @p:demo:r:2af6f9ce-2d56b43a])

      // return null for a given id if it does not exist
      readByIds([@2af6f9ce-6ddc5075, @2af6f9ce-2d56b43a], false)

      Parameters

      • ids: List<Ref>
      • Optionalchecked: boolean

      Returns Grid

    • Read a list of ids as a stream of Dict records. If checked if false, then records not found are skipped. See docHaxall::Streams#readByIdsStream.

      Parameters

      • ids: List<Ref>
      • Optionalchecked: boolean

      Returns JsObj

    • Given record id, read only the transient tags from Folio. Also see readByIdPersistentTags and readById.

      Parameters

      • id: Ref
      • Optionalchecked: boolean

      Returns Dict

    • Return the number of records which match the given filter expression.

      Examples:

      readCount(point)    // return number of recs with point tag
      

      Parameters

      Returns Number

    • Read a record Dict by its id for hyperlinking in a UI. Unlike other reads which return a Dict, this read returns the columns ordered in the same order as reads which return a Grid.

      Parameters

      Returns Dict

    • Grid of installed services. Format of the grid is subject to change.

      Returns Grid

    • Strip any tags which cannot be persistently committed to Folio. This includes special tags such as hisSize and any transient tags the record has defined. If val is Dict, then a single Dict is returned. Otherwise val must be Dict[] or Grid and Dict[] is returned. The mod tag is stripped unless the {mod} option is specified. The id tag is not stripped for cases when adding records with swizzled ids; pass {-id} in options to strip the id tag also.

      Examples:

      // strip uncommittable tags and keep id
      toCommit: rec.stripUncommittable

      // strip uncommittable tags and the id tag
      toCommit: rec.stripUncommittable({-id})

      // strip uncommittable tags, but keep id and mod
      toCommit: rec.stripUncommittable({mod})

      Parameters

      Returns JsObj

    • Coerce a value to a record Dict:

      • Row or Dict returns itself
      • Grid returns first row
      • List returns first row (can be either Ref or Dict)
      • Ref will make a call to read database

      Parameters

      Returns Dict

    • Coerce a value to a Ref identifier:

      • Ref returns itself
      • Row or Dict, return id tag
      • Grid return first row id

      Parameters

      Returns Ref

    • Coerce a value to a list of Ref identifiers:

      • Ref returns itself as list of one
      • Ref[] returns itself
      • Dict return id tag
      • Dict[] return id tags
      • Grid return id column

      Parameters

      Returns List<Ref>

    • Coerce a value to a list of record Dicts:

      • null return empty list
      • Ref or Ref[] (will make a call to read database)
      • Row or Row[] returns itself
      • Dict or Dict[] returns itself
      • Grid is mapped to list of rows

      Parameters

      Returns List<Dict>

    • Return the installed timezone database as Grid with following columns:

      • name: name of the timezone
      • fullName: qualified name used by Olson database

      Returns Grid

    • Return the installed unit database as Grid with following columns:

      • quantity: dimension of the unit
      • name: full name of the unit
      • symbol: the abbreviated Unicode name of the unit

      Returns Grid

    • Add a grid of recs to an existing watch and return the grid passed in.

      Parameters

      • watchId: string
      • grid: Grid

      Returns Grid

    • Close an open watch by id. If the watch does not exist or has expired then this is a no op. Also see hx::HxWatch.close and docHaxall::Watches#axon.

      Parameters

      • watchId: string

      Returns JsObj

    • Open a new watch on a grid of records. The dis parameter is used for the watch's debug display string. Update and return the grid with a meta watchId tag. Also see hx::HxWatchService.open and docHaxall::Watches#axon.

      Example:

      readAll(myPoints).watchOpen("MyApp|Points")
      

      Parameters

      • grid: Grid
      • dis: string

      Returns Grid

    • Poll an open watch and return all the records which have changed since the last poll. Raise exception if watchId doesn't exist or has expired. Also see hx::HxWatch.poll and docHaxall::Watches#axon.

      Parameters

      Returns Grid

    • Remove a grid of recs from an existing watch and return grid passed in.

      Parameters

      • watchId: string
      • grid: Grid

      Returns Grid

    • Reload all the Xeto libraries

      Returns JsObj