WriteRuntimeInstance
Gives read and write access to one Workspace for the current execution attempt, as passed to Mutations, Listeners and App Hooks.
Remarks
Section titled “Remarks”Every write returns a fresh Item; use it, or a fresh lookup, rather than an Item loaded earlier. Writable references belong to the attempt that produced them and are not for use after the execute callback has finished.
Extends
Section titled “Extends”Extended by
Section titled “Extended by”Properties
Section titled “Properties”
readonlyapps:Record<string,WriteAppInstance>
The Apps of the Definition, keyed by canonical App key, with Mutations and Event publishers.
Overrides
Section titled “Overrides”
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.
Inherited from
Section titled “Inherited from”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.
Inherited from
Section titled “Inherited from”ReadRuntimeInstance.principalId
readonlyroot:WriteAppInstance
The root App of the Definition, with Mutations and Event publishers.
Overrides
Section titled “Overrides”workspaceId
Section titled “workspaceId”
readonlyworkspaceId:string
The identifier of the Workspace.
Inherited from
Section titled “Inherited from”ReadRuntimeInstance.workspaceId
Methods
Section titled “Methods”getItem()
Section titled “getItem()”getItem(
id):Promise<WriteItem<ItemInstanceTypes> |undefined>
Loads an Item by identifier, writable in the current execution.
Parameters
Section titled “Parameters”string
The Item identifier.
Returns
Section titled “Returns”Promise<WriteItem<ItemInstanceTypes> | undefined>
The Item, or undefined when the active principal cannot read it.
Overrides
Section titled “Overrides”getItemByKeyPath()
Section titled “getItemByKeyPath()”getItemByKeyPath(…
parts):Promise<WriteItem<ItemInstanceTypes> |undefined>
Loads an Item by following keys down the hierarchy from the Workspace Item, writable in the current execution.
Parameters
Section titled “Parameters”…[string, ...string[]]
The keys to follow, starting with a top-level Item’s key.
Returns
Section titled “Returns”Promise<WriteItem<ItemInstanceTypes> | undefined>
The Item at the end of the path, or undefined when any key along it does not match a readable child.
Overrides
Section titled “Overrides”ReadRuntimeInstance.getItemByKeyPath
getWorkspaceItem()
Section titled “getWorkspaceItem()”getWorkspaceItem():
Promise<WriteWorkspaceItem>
Loads the Item at the root of the Workspace hierarchy, writable in the current execution.
Returns
Section titled “Returns”Promise<WriteWorkspaceItem>
Overrides
Section titled “Overrides”ReadRuntimeInstance.getWorkspaceItem
getWorkspaceTemplate()
Section titled “getWorkspaceTemplate()”getWorkspaceTemplate():
ReadTemplate
Returns the Template of the Workspace Item.
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”ReadRuntimeInstance.getWorkspaceTemplate
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.
Inherited from
Section titled “Inherited from”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
Inherited from
Section titled “Inherited from”selectItems()
Section titled “selectItems()”selectItems():
ItemCursorSelector<WriteItem<ItemInstanceTypes>>
Starts a selection over every Item in the Workspace, returning writable Items.
Returns
Section titled “Returns”ItemCursorSelector<WriteItem<ItemInstanceTypes>>
Overrides
Section titled “Overrides”ReadRuntimeInstance.selectItems
sudo()
Section titled “sudo()”sudo<
TResult>(fn):Promise<TResult>
Runs a callback with a context that bypasses Grants for reads and writes 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”Writes made through the elevated context are part of the same execution attempt.
Overrides
Section titled “Overrides”template()
Section titled “template()”template(
prn):Promise<WriteTemplate<WriteItem<ItemInstanceTypes>> |undefined>
Looks up a Template by PRN, returning it with Item creation.
Parameters
Section titled “Parameters”string
The Template PRN.
Returns
Section titled “Returns”Promise<WriteTemplate<WriteItem<ItemInstanceTypes>> | undefined>
The Template, or undefined when no Template in the Definition has that PRN.

