ReadRuntimeInstance
Gives read access to one Workspace under the active principal, as passed to queries and to the read side of every execution.
Remarks
Section titled “Remarks”Item lookups return undefined for Items the principal cannot read, and Property values are filtered
by the principal’s Grants.
Extends
Section titled “Extends”Extended by
Section titled “Extended by”Properties
Section titled “Properties”
readonlyapps:Record<string,ReadAppInstance>
The Apps of the Definition, keyed by canonical App key.
readonlynow:DateTime
The execution time in UTC, fixed for the whole attempt so that every read and write within it observes the same moment; a retried attempt receives a fresh time.
principalId
Section titled “principalId”
readonlyprincipalId:string
The identifier of the principal the execution runs as; inside sudo, the principal that invoked it.
Throws
Section titled “Throws”when read in a system context, which has no principal.
readonlyroot:ReadAppInstance
The root App of the Definition.
workspaceId
Section titled “workspaceId”
readonlyworkspaceId:string
The identifier of the Workspace.
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”getItem()
Section titled “getItem()”getItem(
id):Promise<ReadItem|undefined>
Loads an Item by identifier.
Parameters
Section titled “Parameters”string
The Item identifier.
Returns
Section titled “Returns”Promise<ReadItem | undefined>
The Item, or undefined when the active principal cannot read it.
getItemByKeyPath()
Section titled “getItemByKeyPath()”getItemByKeyPath(…
parts):Promise<ReadItem|undefined>
Loads an Item by following keys down the hierarchy from the Workspace Item, one key per part.
Parameters
Section titled “Parameters”…[string, ...string[]]
The keys to follow, starting with a top-level Item’s key.
Returns
Section titled “Returns”Promise<ReadItem | undefined>
The Item at the end of the path, or undefined when any key along it does not match a readable child.
Example
Section titled “Example”Load a well-known Item
const settings = await ctx.getItemByKeyPath('settings');getWorkspaceItem()
Section titled “getWorkspaceItem()”getWorkspaceItem():
Promise<ReadWorkspaceItem|undefined>
Loads the Item at the root of the Workspace hierarchy.
Returns
Section titled “Returns”Promise<ReadWorkspaceItem | undefined>
getWorkspaceTemplate()
Section titled “getWorkspaceTemplate()”getWorkspaceTemplate():
ReadTemplate
Returns the Template of the Workspace Item.
Returns
Section titled “Returns”hashKey()
Section titled “hashKey()”hashKey(
source):Promise<string>
Hashes a string into a key of the form sha256:<hex>, for deriving stable keys from external identifiers.
Parameters
Section titled “Parameters”source
Section titled “source”string
The string to hash, at most 1,024 characters.
Returns
Section titled “Returns”Promise<string>
Throws
Section titled “Throws”when source is not a string of at most 1,024 characters.
log(
message, …optional):void
Writes a message to the Runtime log, with the same argument handling as console.log.
Parameters
Section titled “Parameters”message
Section titled “message”any
The message or value to log.
optional
Section titled “optional”…any[]
Further values to log alongside it.
Returns
Section titled “Returns”void
selectItems()
Section titled “selectItems()”selectItems():
ItemCursorSelector<ReadItem>
Starts a selection over every Item in the Workspace.
Returns
Section titled “Returns”Remarks
Section titled “Remarks”Narrow the selection with template, union, prn or only before filtering or sorting by Property.
sudo()
Section titled “sudo()”sudo<
TResult>(fn):Promise<TResult>
Runs a callback with a context that bypasses Grants while staying attributed to the active principal.
Type Parameters
Section titled “Type Parameters”TResult
Section titled “TResult”TResult
Parameters
Section titled “Parameters”(ctx) => Promise<TResult>
Receives the elevated context and returns the result of the call.
Returns
Section titled “Returns”Promise<TResult>
Whatever fn returns.
Remarks
Section titled “Remarks”From a principal or masquerade context the callback receives a sudo context whose reads ignore Grants
and whose principalId is still the invoking principal. From a sudo or system context it receives the same
level of access it already had.
template()
Section titled “template()”template(
prn):Promise<ReadTemplate<ReadItem> |undefined>
Looks up a Template by PRN.
Parameters
Section titled “Parameters”string
The Template PRN.
Returns
Section titled “Returns”Promise<ReadTemplate<ReadItem> | undefined>
The Template, or undefined when no Template in the Definition has that PRN.

