Skip to content

BaseReadItem

Presents one Item as the active principal sees it inside one Workspace.

Property values pass through the principal’s Grants: Properties the principal is not granted are absent from properties and propertyValues, and a stored value that no longer fits its definition reads as invalid. Sudo and system contexts see every Property. Items the principal holds no Grant on are not returned at all.

readonly createdAt: Date

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


readonly definition: TemplateDefinition

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


readonly id: string

The Item identifier, a UUID.


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


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


readonly relations: Record<string, ReadRelationInstance>

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

ReadRelationInstance


readonly state: ReadStateInstance<string | null> | null

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


readonly templatePrn: string

The PRN of the Template the Item was created from.


readonly workspaceId: string

The identifier of the Workspace holding the Item.

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.


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>


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


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.


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.


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.