Skip to content

ReadWorkspaceItem

Presents the Item at the root of a Workspace’s hierarchy, from which every other Item descends.

The Workspace Item has no parent, key or archive state. It is returned to every principal, though its Property values are only readable by principals holding a Grant on the Workspace Template.

Workspaces and access

readonly createdAt: Date

When the Item was created, taken from the execution time of the execution that created it.

BaseReadItem.createdAt


readonly definition: TemplateDefinition

The Template definition the Item was created from, with any extension Properties of its parent merged in.

BaseReadItem.definition


readonly id: string

The Item identifier, a UUID.

BaseReadItem.id


readonly properties: PropertyMap

Plain Property values keyed by Property key, ready for application logic.

Select values are reduced to option keys: a single-select reads as its option key or null, a multi-select as an array of option keys. instant and datetime values are Luxon DateTime objects. A Property that is unset, invalid or not granted to the principal reads as undefined.

PropertyMap

BaseReadItem.properties


readonly propertyValues: PropertyValueMap

Property values keyed by Property key, each tagged with its data type.

Use this form when the data type is significant, for example to tell an unset value from a stored value that has become invalid. Properties the principal is not granted are absent.

PropertyValue

BaseReadItem.propertyValues


readonly relations: Record<string, ReadRelationInstance>

Relations declared on the Item’s Template, keyed by Relation key and navigated from this Item’s side.

ReadRelationInstance

BaseReadItem.relations


readonly state: ReadStateInstance<string | null> | null

The Item’s current state, or null when its Template declares no states.

BaseReadItem.state


readonly templatePrn: string

The PRN of the Template the Item was created from.

BaseReadItem.templatePrn


readonly workspaceId: string

The identifier of the Workspace holding the Item.

BaseReadItem.workspaceId

assertRole(role): Promise<true>

Confirms that the active principal holds a Template Role on this Item.

TemplateRoleInstance

A Role from the Template’s roles.

Promise<true>

true when the Role is held.

AssertRoleFailedError when the active principal does not hold the Role on this Item.

BaseReadItem.assertRole


checkRole(role): Promise<boolean>

Reports whether the active principal holds a Template Role on this Item.

TemplateRoleInstance

A Role from the Template’s roles.

Promise<boolean>

BaseReadItem.checkRole


currentRoles(): Promise<BaseRoleInstance[]>

Lists the Template Roles the active principal holds on this Item.

Promise<BaseRoleInstance[]>

Sudo and system contexts hold every Role the Template declares.

Grant access

BaseReadItem.currentRoles


getAncestors(): Promise<ReadItem[]>

Loads the ancestors of this Item, nearest parent first, up to and including the Workspace Item.

Promise<ReadItem[]>

The ancestors the active principal can read, stopping at the first unreadable one; the Workspace Item has none.

BaseReadItem.getAncestors


getChildByKey(key): Promise<ReadItem | undefined>

Finds the child of this Item that carries a key.

string

The child’s key, relative to this Item.

Promise<ReadItem | undefined>

The child, or undefined when no child the active principal can read carries the key.

BaseReadItem.getChildByKey


getParent(): Promise<ReadItem | undefined>

Loads the parent of this Item.

Promise<ReadItem | undefined>

The parent, or undefined for the Workspace Item, which has no parent.

BaseReadItem.getParent


selectChildren(): ItemCursorSelector<ReadItem>

Starts a selection over the top-level Items of the Workspace.

ItemCursorSelector<ReadItem>