Types
Contents
The shared types that flow across the Enonic libraries
Introduction
This page is the canonical reference for the cross-library types.
principals, binary streams, the content object, page components, and more. They are defined once in the @enonic-types/core package and re-exported by the individual @enonic-types/lib-* packages, so the same User, Content, or ByteSource you receive from one library is the exact type another library accepts.
Library pages name them and link here rather than redefining them. For how to install and wire the type packages, see TypeScript.
| These are the TypeScript shapes of the runtime objects. The conceptual models behind them — the content model, the query language, form schemas — are documented in the CMS and XP platform docs, linked from the relevant types below. |
Principals and keys
Principal keys are branded string templates — a User key always reads user:<idprovider>:<id>, a group key group:<idprovider>:<id>, and a role key role:<id>.
PrincipalKey
A union of the three key kinds: UserKey | GroupKey | RoleKey.
UserKey
Template string user:${string}:${string} — e.g. user:system:alice.
GroupKey
Template string group:${string}:${string} — e.g. group:system:editors.
RoleKey
Template string role:${string} — e.g. role:system.admin.
PrincipalType
One of 'user', 'group', or 'role'.
User
Properties
| Name | Type | Description |
|---|---|---|
|
type |
string |
Always |
|
key |
The principal key. |
|
|
displayName |
string |
Human-friendly name. |
|
login |
string |
Login name. |
|
idProvider |
string |
Key of the ID provider the user belongs to. |
|
hasPassword |
boolean |
Whether the user has a password set. |
|
|
string |
Optional. Email address. |
|
disabled |
boolean |
Optional. Whether the user is disabled. |
|
modifiedTime |
string |
Optional. ISO timestamp of the last modification. |
Group
Properties
| Name | Type | Description |
|---|---|---|
|
type |
string |
Always |
|
key |
The principal key. |
|
|
displayName |
string |
Human-friendly name. |
|
modifiedTime |
string |
ISO timestamp of the last modification. |
|
description |
string |
Optional. Group description. |
Binary and resources
ByteSource
An opaque handle to a binary stream. You don’t read its fields directly — you pass it to library functions (for example io.readText, io.getSize, attachment and media APIs) that consume or produce binary data. Obtain one from lib-io (newStream, a resource stream) or from content attachments.
Resource
A handle to an application resource on the classpath, returned by io.getResource.
Methods
| Name | Type | Description |
|---|---|---|
|
exists() |
boolean |
Whether the resource exists. |
|
getSize() |
number |
Size in bytes. |
|
getTimestamp() |
number |
Last-modified time, in milliseconds since the epoch. |
|
getStream() |
The resource’s binary stream. |
ResourceKey
Identifies an application resource by application key and path.
Methods
| Name | Type | Description |
|---|---|---|
|
getApplicationKey() |
string |
The owning application key. |
|
getPath() |
string |
Resource path within the application. |
|
getUri() |
string |
Full resource URI. |
|
getName() |
string |
Resource name. |
|
getExtension() |
string |
File extension. |
|
isRoot() |
boolean |
Whether the key points at the application root. |
Content model
Content
The object returned by the content APIs. The conceptual content model is documented in the CMS docs; this is its runtime shape.
Properties
| Name | Type | Description |
|---|---|---|
|
_id |
string |
Unique content id. |
|
_name |
string |
Content name (unique among siblings). |
|
_path |
string |
Full content path. |
|
type |
string |
Content type name (e.g. |
|
displayName |
string |
Human-friendly name. |
|
data |
object |
The content’s data, shaped by its content type. |
|
x |
object |
Extra data (mixins / x-data), keyed by application. |
|
attachments |
object |
Map of attachment name to Attachment. |
|
valid |
boolean |
Whether the content currently validates against its type. |
|
hasChildren |
boolean |
Whether the content has child items. |
|
creator |
Principal that created the content. |
|
|
createdTime |
string |
ISO creation timestamp. |
|
owner |
string |
Principal key of the owner. |
|
modifier |
Optional. Principal that last modified the content. |
|
|
modifiedTime |
string |
Optional. ISO timestamp of the last modification. |
|
language |
string |
Optional. Language tag of the content’s locale. |
|
childOrder |
string |
Optional. Sort order of children. |
|
page |
Optional. The page component tree (absent on fragments). |
|
|
fragment |
Optional. The fragment component (only on |
|
|
publish |
Optional. Publishing schedule and history. |
|
|
workflow |
Optional. Workflow state. |
|
|
validationErrors |
Optional. Validation errors, when the content is invalid. |
|
|
inherit |
string[] |
Optional. Which aspects are inherited in a layered project ( |
|
originProject |
string |
Optional. Project the content was inherited from. |
|
variantOf |
string |
Optional. Id of the content this is a variant of. |
|
_score |
number |
Optional. Relevance score, present on query hits. |
|
_sort |
object[] |
Optional. Sort values, present on sorted query hits. |
Attachment
A binary attached to a content item.
Properties
| Name | Type | Description |
|---|---|---|
|
name |
string |
Attachment name (unique within the content). |
|
size |
number |
Size in bytes. |
|
mimeType |
string |
Media type. |
|
label |
string |
Optional. Attachment label. |
|
sha512 |
string |
Optional. SHA-512 hash of the binary. |
PublishInfo
The publishing schedule and history of a content item. All fields are ISO-8601 timestamps.
Properties
| Name | Type | Description |
|---|---|---|
|
from |
string |
Optional. Time from which the content is published. |
|
to |
string |
Optional. Time after which the content is no longer published. |
|
first |
string |
Optional. Time the content was first published. |
WorkflowState
One of 'IN_PROGRESS', 'PENDING_APPROVAL', 'REJECTED', or 'READY'.
ValidationError
Describes a single validation failure on a content item.
Properties
| Name | Type | Description |
|---|---|---|
|
errorCode |
object |
The error code: |
|
message |
string | null |
A static, human-readable error message. |
|
i18n |
string | null |
The i18n localization key for the message. |
|
args |
array |
Optional. Values substituted into the localized message. |
Page and components
A content’s page (and a fragment’s fragment) is a tree of components. Every component carries a type discriminant — one of 'page', 'layout', 'part', 'text', or 'fragment'. There is no separate Page type: the page-level node is a PageComponent.
Component
A union of the five component kinds, discriminated by type: PageComponent | LayoutComponent | PartComponent | TextComponent | FragmentComponent.
PageComponent
Properties
| Name | Type | Description |
|---|---|---|
|
type |
string |
Always |
|
descriptor |
string |
Descriptor key of the page component (e.g. |
|
config |
object |
The component’s configuration, shaped by the descriptor. |
|
regions |
object |
Map of region name to Region. |
|
path |
string |
Component path; always |
|
template |
string |
Optional. Page template key, when the page uses a template. |
LayoutComponent
Properties
| Name | Type | Description |
|---|---|---|
|
type |
string |
Always |
|
descriptor |
string |
Descriptor key of the layout. |
|
config |
object |
The component’s configuration, shaped by the descriptor. |
|
regions |
object |
Map of region name to Region nested within the layout. |
|
path |
string |
Optional. Component path within the page. |
PartComponent
Properties
| Name | Type | Description |
|---|---|---|
|
type |
string |
Always |
|
descriptor |
string |
Descriptor key of the part. |
|
config |
object |
The component’s configuration, shaped by the descriptor. |
|
path |
string |
Optional. Component path within the page. |
TextComponent
Properties
| Name | Type | Description |
|---|---|---|
|
type |
string |
Always |
|
text |
string |
The text (HTML) content. |
|
path |
string |
Component path within the page. |
FragmentComponent
Properties
| Name | Type | Description |
|---|---|---|
|
type |
string |
Always |
|
fragment |
string |
Content id of the fragment being referenced. |
|
path |
string |
Component path within the page. |
Repository nodes
Node
A stored repository node, as returned by the lib-node connection methods (create, get, modify, move, …). A node is its system properties merged with the caller’s own data: every non-underscore property is application data, and the underscore-prefixed system properties are:
| Name | Type | Description |
|---|---|---|
|
|
string |
Generated, unique node id. |
|
|
string |
Node name, unique among its siblings. |
|
|
string |
Full path to the node. |
|
|
string |
Child order expression (for example, |
|
|
number |
Optional. Numeric value used when siblings are ordered manually. |
|
|
string |
Node type; |
|
|
object[] |
Access-control entries ( |
|
|
object |
Index configuration controlling how the node’s data is indexed. |
|
|
string |
Timestamp of the node’s current version, as an ISO-8601 instant. |
|
|
string |
Key of the node’s current version. |
All other properties are the node’s own data. See the XP platform node API for the full model.
HTTP
Other
ScriptValue
A lazy wrapper around a value crossing the Java/JavaScript boundary — used by APIs that accept arbitrary caller data (for example audit-log data, task config). Rather than fields, it exposes inspection methods: isArray(), isObject(), isValue(), isFunction(), getValue(), getKeys(), hasMember(key), getMember(key), getArray(), getMap(), getList().
Query and form types
FormItem
A single item in a content type, mixin, or form-fragment schema. FormItem is a union discriminated by formItemType, with five kinds:
| formItemType | Description |
|---|---|
|
|
A data-entry field. Properties: |
|
|
A repeatable group of nested |
|
|
A visual grouping that carries no data of its own. Properties: |
|
|
A set of selectable |
|
|
A reference to a reusable form fragment. Property: |
Every kind has a name and a label. For the full per-inputType configuration, see the CMS schema docs.
Query DSL types
QueryDsl, SortDsl, Filter, Aggregations, and Highlight model the query DSL. They are documented with the storage layer rather than duplicated here — see the XP storage and querying docs and Querying.