Funcs
Funcs : Funcs
Read from database the first record which matches filter
Read a record from database by id
Given record id, read only the persistent tags from Folio
Given record id, read only the transient tags from Folio
Read a record Dict by its id for hyperlinking in a UI
Read a list of record ids into a grid
Reall all records from the database which match the filter
Read a list of ids as a stream of Dict records
Reall all records which match filter as stream of Dict records
Return the intersection of all tag names used by all the records matching the given filter
Return the range of all the values mapped to a given tag name used by all the records matching the given filter
Return the number of records which match the given filter expression
Construct a modification "diff" used by commit
Commit one or more diffs to the folio database
Store a password key/val pair into current project's password store
Strip any tags which cannot be persistently committed to Folio
Coerce a value to a Ref identifier
Coerce a value to a list of Ref identifiers
Coerce a value to a record Dict
Coerce a value to a list of record Dicts
Return system meta as dict
Return current project meta as dict
Return grid of runtime xeto libs and current status
Reload all the xeto libraries in project
Enable one or more Xeto libs by name
Disable or more Xeto libs by name
Return grid of exts
Return ext settings dict for given dotted lib name
Update ext settings for given dotted lib name
Read a companion spec or instance by name - see ProjCompanion.readByName
Add new spec or instance to companion lib - see ProjCompanion.add
Update existing spec or instance in companion lib - see ProjCompanion.update
Remove a spec or instance from companion lib - see ProjCompanion.remove
Parse xeto source to its companion lib AST representation - see ProjCompanion.parse
Print companion AST rec representation back a Xeto string - see ProjCompanion.print
Create func companion lib AST representation - see ProjCompanion.parseAxon
Return if given record is under at least one watch
Open a new watch on a grid of records
Poll an open watch and return all the records which have changed since the last poll
Add a grid of recs to an existing watch and return the grid passed in
Remove a grid of recs from an existing watch and return grid passed in
Close an open watch by id
Return Runtime.isSteadyState
Get the current context as a Dict with the following tags
Return list of installed Fantom pods
Return the installed timezone database as Grid with following columns
Return the installed unit database as Grid with following columns
(filter: Filter, checked: Bool) => Dict?
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
(id: Ref?, checked: Bool) => Dict?
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
(id: Ref, checked: Bool) => Dict?
Given record id, read only the persistent tags from Folio. Also see readByIdTransientTags and readById.
(id: Ref, checked: Bool) => Dict?
Given record id, read only the transient tags from Folio. Also see readByIdPersistentTags and readById.
(id: Ref?) => Dict?
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.
(ids: List <of:Ref>, checked: Bool) => Grid
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)
(filter: Filter, opts: Dict?) => Grid
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 returnsort: 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
(ids: List <of:Ref>, checked: Bool) => Obj
Read a list of ids as a stream of Dict records. If checked if false, then records not found are skipped. See Streams.
(filter: Filter) => Obj
Reall all records which match filter as stream of Dict records. See Streams.
(filter: Filter) => Grid
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 tagkind: 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)
(filter: Filter, tagName: Str) => 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")
(filter: Filter) => Number
Return the number of records which match the given filter expression.
Examples:
readCount(point) // return number of recs with point tag
(orig: Dict?, changes: Dict?, flags: Dict?) => Obj
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 recordremove: indicates diff is removing record (in general you should addtrashtag 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})
(diffs: Obj) => Obj? <admin>
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
(key: Obj, val: Str?) => Obj? <admin>
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 Folio.
passwordSet(@abc-123, "password")
passwordSet(@abc-123, null)
(val: Obj, opts: Obj?) => Obj
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})
(val: Obj?) => Ref
Coerce a value to a Ref identifier:
Refreturns itselfRoworDict, returnidtagGridreturn first row id
(val: Obj?) => List
Coerce a value to a list of Ref identifiers:
Refreturns itself as list of oneRef[]returns itselfDictreturnidtagDict[]returnidtagsGridreturnidcolumn
(val: Obj?) => Dict
Coerce a value to a record Dict:
RoworDictreturns itselfGridreturns first rowListreturns first row (can be either Ref or Dict)Refwill make a call to read database
(val: Obj?) => List
Coerce a value to a list of record Dicts:
nullreturn empty listReforRef[](will make a call to read database)RoworRow[]returns itselfDictorDict[]returns itselfGridis mapped to list of rows
() => Dict
Return system meta as dict
() => Dict
Return current project meta as dict
(opts: Dict?) => Grid
Return grid of runtime xeto libs and current status:
- name: library dotted name string
- libBasis: basis enumeration string
- libStatus: status enumeration string
- other cols subject to change
() => Obj? <su>
Reload all the xeto libraries in project
(names: Obj, opts: Dict?) => Obj <admin>
Enable one or more Xeto libs by name:
libAdd("ph.points")
libAdd(["ph.points", "ph.equips"])
(names: Obj, opts: Dict?) => Obj <admin>
Disable or more Xeto libs by name:
libRemove("ph.points")
libRemove(["ph.points", "ph.equips"])
(opts: Dict?) => Grid
Return grid of exts:
- name: library dotted name string
- libBasis: basis enumeration string
- extStatus: status enumeration string
- other cols subject to change
(name: Str, checked: Bool) => Dict
Return ext settings dict for given dotted lib name:
extSettings("hx.task")
(name: Str, changes: Dict) => Dict <admin>
Update ext settings for given dotted lib name:
extSettingsUpdate("hx.task", {maxThreads:20})
(name: Str, checked: Bool) => Dict? <admin>
Read a companion spec or instance by name - see ProjCompanion.readByName. Examples:
companionReadByName("MySpec")
companionReadByName("my-instance")
(rec: Dict) => Dict <admin>
Add new spec or instance to companion lib - see ProjCompanion.add. Examples:
companionAdd({rt:"spec", name:"MySpec", base:@sys::Dict, spec:@sys::Spec})
companionParse("MySpec: Dict { dis: Str }").companionAdd
(rec: Dict) => Dict <admin>
Update existing spec or instance in companion lib - see ProjCompanion.update. Examples:
companionReadByName("MySpec").merge({base:@sys::Scalar}).companionUpdate
companionReadByName("myFunc").merge({axon:"(x)=>x"}).companionUpdate
(id: Obj) => Obj? <admin>
Remove a spec or instance from companion lib - see ProjCompanion.remove. The id argument can be any value accepted by toRecId(). Examples:
companionRemove(@123)
companionReadByName("MySpec").companionRemove
(xeto: Str, meta: Dict?) => Dict
Parse xeto source to its companion lib AST representation - see ProjCompanion.parse. Pipe to companionAdd() or companionUpdate() to update from Xeto source. Examples:
companionParse("MySpec: Dict { dis: Str }")
companionParse("@my-instance: Dict {}")
(rec: Dict) => Str
Print companion AST rec representation back a Xeto string - see ProjCompanion.print. Examples:
companionRead("MySpec").companionPrint
(name: Str, axon: Str, meta: Dict?) => Dict <admin>
Create func companion lib AST representation - see ProjCompanion.parseAxon. Pipe to companionAdd() or companionUpdate() to update from Xeto source. Examples:
companionParseAxon("myFunc", "(a)=>a*2")
companionParseAxon("myFunc", "(a)=>a*2", {admin})
(rec: Obj) => Bool
Return if given record is under at least one watch. The rec argument can be any value accepted by toRecId().
(grid: Grid, dis: Str) => Grid
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 RuntimeWatches.open
and Watches.
Example:
readAll(myPoints).watchOpen("MyApp|Points")
(watchId: Obj) => 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 Watch.poll and Watches.
(watchId: Str, grid: Grid) => Grid
Add a grid of recs to an existing watch and return the grid passed in.
(watchId: Str, grid: Grid) => Grid
Remove a grid of recs from an existing watch and return grid passed in.
(watchId: Str) => Obj?
Close an open watch by id. If the watch does not exist or has expired then this is a no op. Also see Watch.close and Watches.
() => Bool
Return Runtime.isSteadyState
() => Dict
Get the current context as a Dict with the following tags:
usernamefor current useruserRefid for current userlocalecurrent locale
SkySpark tags:
projNameif evaluating in context of a projectnodeIdlocal cluster node idruleRefif evaluating in context of a rule engineruleTuningif evaluating in context of rule engine
() => Grid <admin>
Return list of installed Fantom pods
() => Grid
Return the installed timezone database as Grid with following columns:
- name: name of the timezone
- fullName: qualified name used by Olson database
() => 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