dari
Every member of the dari object a Script action binds, with its signature, as the code declares it. How the pieces fit together, and what a script hands to a Content Edit Save, is under Content API.
Everything dari exports
| Member | Kind | What it is |
|---|---|---|
Record | class | A content asset: one of the content model's types, with its field values. |
RecordRef | class | A pointer to content stored separately, which must already exist: the value of a reference field. |
Location | class | A point on the earth, as a latitude and a longitude in degrees, for a location field. |
Region | class | An area, as circles and polygons, for a region field. |
StorageItem | class | A reference to a file the CMS can already reach, for a file field. |
LocalDate | class | A calendar date with no time or zone, stored as 2026-08-14. |
LocalTime | class | A time of day with no date or zone, stored as 09:30, with seconds and a fraction only when they are not zero. |
LocalDateTime | class | A date and time with no zone, stored as 2026-08-14T09:30. |
ZonedDateTime | class | A date and time in a named zone, stored as 2026-08-14T09:30-04:00[America/New_York]. |
OffsetDateTime | class | A date and time with an offset from UTC, stored as 2026-08-14T09:30-04:00. |
OffsetTime | class | A time of day with an offset from UTC, stored as 09:30-04:00. |
ZoneId | class | A time zone, stored by its name, such as America/New_York. |
ZoneOffset | class | An offset from UTC, stored as -04:00, or Z for UTC. |
Year | class | A year. |
YearMonth | class | A year and month, stored as 2026-08. |
Duration | class | An amount of time: days, hours, minutes and seconds. |
Period | class | An amount of calendar time: years, months and days. |
MonthDay | class | A month and day with no year, stored as --08-14. |
RichText | class | The editor's stored markup, which is not HTML: paragraphs are separated by two <br/> rather than wrapped in <p>, and anything richer than a mark or a list is a registered element addressed by tag name. |
RichTextElement | class | One rich text element, found in stored markup or built to add: its tag name, its attributes and its body. |
InlineText | class | Inline content: the marks the editor writes, and nothing it does not. |
Differences | class | The field changes between two states, keyed by record id: the shape a Content Edit Save's Differences field takes. |
DariError | class | Everything this SDK throws, so a script can tell an SDK complaint from a bug in its own code with error instanceof dari.DariError. |
dari.diff | function | What changed between two states, keyed by record id, for a Content Edit Save's Differences field. |
dari.uuid | function | A fresh id for a record about to be built: time-ordered, so ids minted here sort beside ids the CMS minted itself. |
dari.type | function | The named type as the content model describes it: its id, its fields, and what may be named in as(). |
dari.timeZone | property | The zone a plain Date is read in when a field wants a calendar date, a wall-clock time or an offset. |
The classes below them, TypeInfo from dari.type() and ModificationView from record.as(), are reached through a return value rather than named on dari.
Record
A content asset: one of the content model's types, with its field values. Every value set through record.put() is checked against the type and converted to the field's stored form, so a misspelled field name, a value of the wrong type, or a reference where the field embeds an object fails on the line that caused it.
| Property | Type | Description |
|---|---|---|
id | string | The asset's id, minted when the record is built unless one was given. |
type | string or null | The type's id as the content model knows it, or null for a record built without a type. |
typeInfo | TypeInfo or null | The type as the content model describes it, or null for a record built without a type. |
new Record(type, [id])
A record of the named type, with a fresh id unless one is given.
| Parameter | Type | Description |
|---|---|---|
type | string | The type's full internal name, its last part when that is unique across the content model, or its id. |
id | string | Optional. The id to build under, for a record that must take a known id. Omitted, a fresh time-ordered id is minted. |
Record.fromState(state)
Reads a record from its stored form, such as the values a Content Fetch returns, keeping its id and type. Embedded records inside it come back as records, references as a RecordRef, and lists as arrays.
| Parameter | Type | Description |
|---|---|---|
state | Object or null | The stored form. |
Returns Record or null: The record, or null for a null state.
Record.fromStateJson(json)
Reads a record from its stored form as JSON text.
| Parameter | Type | Description |
|---|---|---|
json | string | The stored form, as JSON. |
Returns Record or null: The record, or null when the JSON is null.
record.as(className)
This record's fields as the named modification class declares them, addressed by their Java field names, with the stored prefix worked out for you. Fails when the class does not modify this type, naming the ones that do.
| Parameter | Type | Description |
|---|---|---|
className | string | The modification's full class name, such as com.psddev.cms.db.Content$ObjectModification. |
Returns ModificationView: The same record, seen through that class.
record.get(name)
Reads a field's value.
| Parameter | Type | Description |
|---|---|---|
name | string | The field's internal name. |
Returns *: The value as it was set or read: a record, an array, a value object, or a plain value. Undefined when the field is not set.
record.put(name, value)
Sets a field, converting the value to the field's stored form. Fails, naming the field, when the type has no such field, the value does not suit it, or undefined is given; put null to clear a field.
| Parameter | Type | Description |
|---|---|---|
name | string | The field's internal name. |
value | * | The value: a plain value, a Date, a Record for an embedded field, a RecordRef or an id for a reference, or one of the value classes. |
Returns Record: This record, so calls chain.
record.putRaw(name, value)
Writes a value under an internal name with no checking or conversion: the escape hatch for a field type this SDK does not write, or a record built without a type.
| Parameter | Type | Description |
|---|---|---|
name | string | The internal name to store under. |
value | * | The value, in its stored form. |
Returns Record: This record.
record.putAll(values)
Sets several fields at once, each as record.put() would.
| Parameter | Type | Description |
|---|---|---|
values | Object<string, *> | Values by internal field name. |
Returns Record: This record.
record.remove(name)
Removes a field, so the stored form no longer carries it. To keep the field and clear its value, put null.
| Parameter | Type | Description |
|---|---|---|
name | string | The field's internal name. |
Returns Record: This record.
record.has(name)
Whether a field is set, even to null.
| Parameter | Type | Description |
|---|---|---|
name | string | The field's internal name. |
Returns boolean: True when the field is set.
record.keys()
Every field name that is set, in the order the fields were set.
Returns string[]: The internal names.
record.entries()
Every set field with its value, as [name, value] pairs.
Returns Array[]: The pairs, in the order the fields were set.
record.list(name)
The array at a field, creating an empty one when the field is not set or holds something else, so an item can be pushed without checking first.
| Parameter | Type | Description |
|---|---|---|
name | string | The field's internal name. |
Returns Array: The array the field holds.
record.toRef()
A pointer to this record, for a reference field elsewhere. Only content that already exists can be pointed at, so a new record has to be saved before another record references it.
Returns RecordRef: The reference, carrying this record's id and type.
record.descendants()
Every record reachable from this one, including itself, in document order: the record, then each embedded record as it is met.
Returns Record[]: The records.
record.toState()
The stored form: every field's value with _id and _type, embedded records serialized inside it. Fails when one record appears twice in the tree; point at it from the second place with record.toRef() instead.
Returns Object: The stored form.
record.toStateJson([indent])
The stored form as JSON text.
| Parameter | Type | Description |
|---|---|---|
indent | number or string | Optional. Indentation, as JSON.stringify takes it. |
Returns string: The JSON.
record.toDifferences()
Every field on this record and on each record inside it, keyed by record id: the shape a Content Edit Save takes for content being created. For content that already exists, dari.diff() reports only what changed.
Returns Differences: The differences.
RecordRef
A pointer to content stored separately, which must already exist: the value of a reference field. Carries the content's id and, when known, its type, and no field values.
| Property | Type | Description |
|---|---|---|
id | string | The content's id. |
type | string or null | The content's type id, or null when it isn't known. |
new RecordRef(id, [type])
Points at existing content by id.
| Parameter | Type | Description |
|---|---|---|
id | string | The content's id. Anything but a UUID is refused. |
type | string | Optional. The content's type id, when known. |
RecordRef.fromState(state)
Reads a reference from its stored form, { _ref, _type }.
| Parameter | Type | Description |
|---|---|---|
state | Object or null | The stored form. |
Returns RecordRef or null: The reference, or null for a null state.
recordRef.toState()
The stored form: { _ref: id }, with _type when the type is known.
Returns Object: The stored form.
Location
A point on the earth, as a latitude and a longitude in degrees, for a location field.
| Property | Type | Description |
|---|---|---|
latitude | number | The latitude. |
longitude | number | The longitude. |
new Location(latitude, longitude)
A point from its coordinates, latitude first. Both must be numbers.
| Parameter | Type | Description |
|---|---|---|
latitude | number | The latitude, in degrees. |
longitude | number | The longitude, in degrees. |
Location.fromState(state)
Reads a point from its stored form, { x: latitude, y: longitude }.
| Parameter | Type | Description |
|---|---|---|
state | Object or null | The stored form. |
Returns Location or null: The point, or null for a null state.
location.toState()
The stored form: { x: latitude, y: longitude }.
Returns Object: The stored form.
location.toString()
The point as latitude, longitude.
Returns string: The text.
Region
An area, as circles and polygons, for a region field. Build one with Region.circle() or Region.polygon(), and add shapes with region.addCircle() and region.addPolygon(). Points go in latitude first and radii in metres; the stored form is read back the same way through region.circleList.
| Property | Type | Description |
|---|---|---|
polygons | Array | The polygons in their stored form: rings of [longitude, latitude] pairs. |
circles | Array | The circles in their stored form: [longitude, latitude, radiusInDegrees] triples. |
Region.circle(center, radiusInMeters)
A region of one circle.
| Parameter | Type | Description |
|---|---|---|
center | Location or Object | The centre: a Location, or anything with latitude and longitude. |
radiusInMeters | number | The radius, in metres. |
Returns Region: The region.
Region.polygon(ring)
A region of one polygon.
| Parameter | Type | Description |
|---|---|---|
ring | Array<(Location|Object)> | The corners in order. The ring is closed for you if it isn't already. |
Returns Region: The region.
Region.fromState(state)
Reads a region from its stored form.
| Parameter | Type | Description |
|---|---|---|
state | Object or null | The stored form. |
Returns Region or null: The region, or null for a null state.
region.addCircle(center, radiusInMeters)
Adds a circle.
| Parameter | Type | Description |
|---|---|---|
center | Location or Object | The centre: a Location, or anything with latitude and longitude. |
radiusInMeters | number | The radius, in metres. |
Returns Region: This region.
region.addPolygon(ring)
Adds a polygon from a ring of locations. The ring is closed for you if it isn't already.
| Parameter | Type | Description |
|---|---|---|
ring | Array<(Location|Object)> | The corners in order. |
Returns Region: This region.
region.circleList
The circles as centres and radii in metres, rather than as the stored longitude-first degree triples.
Type: Array<{center: Location, radiusInMeters: number}>
region.toState()
The stored form: polygons, circles, and the x, y and radius keys Dari still writes.
Returns Object: The stored form.
StorageItem
A reference to a file the CMS can already reach, for a file field. A script cannot upload, since it has no network, so this points at something that exists rather than putting it there.
| Property | Type | Description |
|---|---|---|
storage | string | The storage the file is in: _url for a file at a URL. |
path | string | The file's path in that storage, or its URL. |
contentType | string or null | The file's media type, such as image/png, when known. |
metadata | Object or null | The file's metadata, such as its width and height, when known. |
new StorageItem(storage, path, [contentType], [metadata])
A file in a named storage. For a file at a URL, StorageItem.url() is shorter.
| Parameter | Type | Description |
|---|---|---|
storage | string | The storage's name. |
path | string | The file's path in that storage. |
contentType | string | Optional. The file's media type. |
metadata | Object | Optional. The file's metadata. |
StorageItem.url(url)
A file at a URL. The only kind a script can create, until the platform has first-class file support.
| Parameter | Type | Description |
|---|---|---|
url | string | The file's URL. |
Returns StorageItem: The item.
StorageItem.fromState(state)
Reads any stored item, whatever its storage, so one can be copied from one record to another.
| Parameter | Type | Description |
|---|---|---|
state | Object or null | The stored form. |
Returns StorageItem or null: The item, or null for a null state.
storageItem.withContentType(contentType)
Sets the media type.
| Parameter | Type | Description |
|---|---|---|
contentType | string | The media type, such as image/png. |
Returns StorageItem: This item.
storageItem.withMetadata(metadata)
Merges into the metadata: width, height, original file name, focus points, crops.
| Parameter | Type | Description |
|---|---|---|
metadata | Object | The entries to add or replace. |
Returns StorageItem: This item.
storageItem.toState()
The stored form: storage, path, contentType and metadata.
Returns Object: The stored form.
LocalDate
A calendar date with no time or zone, stored as 2026-08-14.
LocalDate.parse(text)
Parses the text form the field stores, refusing anything java.time would.
| Parameter | Type | Description |
|---|---|---|
text | string | The value as java.time prints it, such as 2026-08-14 for a LocalDate. |
Returns LocalDate: The value.
LocalDate.from(value, [zone])
The value an instant has in a zone: the same moment is a different calendar date or wall-clock time depending on where it is read.
| Parameter | Type | Description |
|---|---|---|
value | Date or number or string | An instant: a Date, epoch milliseconds, or ISO text. |
zone | string | Optional. The zone to read it in. Omitted, dari.timeZone. |
Returns LocalDate: The value.
LocalDate.of(year, month, day)
A date from its parts.
| Parameter | Type | Description |
|---|---|---|
year | number | The year. |
month | number | The month, 1 to 12. |
day | number | The day of the month. |
Returns LocalDate: The date.
localDate.toState()
The stored form: the text java.time prints for this value.
Returns string: The text.
localDate.toString()
The same text as the stored form.
Returns string: The text.
LocalTime
A time of day with no date or zone, stored as 09:30, with seconds and a fraction only when they are not zero.
LocalTime.parse(text)
Parses the text form the field stores, refusing anything java.time would.
| Parameter | Type | Description |
|---|---|---|
text | string | The value as java.time prints it, such as 2026-08-14 for a LocalDate. |
Returns LocalTime: The value.
LocalTime.from(value, [zone])
The value an instant has in a zone: the same moment is a different calendar date or wall-clock time depending on where it is read.
| Parameter | Type | Description |
|---|---|---|
value | Date or number or string | An instant: a Date, epoch milliseconds, or ISO text. |
zone | string | Optional. The zone to read it in. Omitted, dari.timeZone. |
Returns LocalTime: The value.
LocalTime.of(hour, minute, [second])
A time from its parts.
| Parameter | Type | Description |
|---|---|---|
hour | number | The hour, 0 to 23. |
minute | number | The minute. |
second | number | Optional. The second. Omitted or zero, the time is stored without seconds. |
Returns LocalTime: The time.
localTime.toState()
The stored form: the text java.time prints for this value.
Returns string: The text.
localTime.toString()
The same text as the stored form.
Returns string: The text.
LocalDateTime
A date and time with no zone, stored as 2026-08-14T09:30.
LocalDateTime.parse(text)
Parses the text form the field stores, refusing anything java.time would.
| Parameter | Type | Description |
|---|---|---|
text | string | The value as java.time prints it, such as 2026-08-14 for a LocalDate. |
Returns LocalDateTime: The value.
LocalDateTime.from(value, [zone])
The value an instant has in a zone: the same moment is a different calendar date or wall-clock time depending on where it is read.
| Parameter | Type | Description |
|---|---|---|
value | Date or number or string | An instant: a Date, epoch milliseconds, or ISO text. |
zone | string | Optional. The zone to read it in. Omitted, dari.timeZone. |
Returns LocalDateTime: The value.
localDateTime.toState()
The stored form: the text java.time prints for this value.
Returns string: The text.
localDateTime.toString()
The same text as the stored form.
Returns string: The text.
ZonedDateTime
A date and time in a named zone, stored as 2026-08-14T09:30-04:00[America/New_York].
ZonedDateTime.parse(text)
Parses the text form the field stores, refusing anything java.time would.
| Parameter | Type | Description |
|---|---|---|
text | string | The value as java.time prints it, such as 2026-08-14 for a LocalDate. |
Returns ZonedDateTime: The value.
ZonedDateTime.from(value, [zone])
The value an instant has in a zone: the same moment is a different calendar date or wall-clock time depending on where it is read.
| Parameter | Type | Description |
|---|---|---|
value | Date or number or string | An instant: a Date, epoch milliseconds, or ISO text. |
zone | string | Optional. The zone to read it in. Omitted, dari.timeZone. |
Returns ZonedDateTime: The value.
zonedDateTime.toState()
The stored form: the text java.time prints for this value.
Returns string: The text.
zonedDateTime.toString()
The same text as the stored form.
Returns string: The text.
OffsetDateTime
A date and time with an offset from UTC, stored as 2026-08-14T09:30-04:00.
OffsetDateTime.parse(text)
Parses the text form the field stores, refusing anything java.time would.
| Parameter | Type | Description |
|---|---|---|
text | string | The value as java.time prints it, such as 2026-08-14 for a LocalDate. |
Returns OffsetDateTime: The value.
OffsetDateTime.from(value, [zone])
The value an instant has in a zone: the same moment is a different calendar date or wall-clock time depending on where it is read.
| Parameter | Type | Description |
|---|---|---|
value | Date or number or string | An instant: a Date, epoch milliseconds, or ISO text. |
zone | string | Optional. The zone to read it in. Omitted, dari.timeZone. |
Returns OffsetDateTime: The value.
offsetDateTime.toState()
The stored form: the text java.time prints for this value.
Returns string: The text.
offsetDateTime.toString()
The same text as the stored form.
Returns string: The text.
OffsetTime
A time of day with an offset from UTC, stored as 09:30-04:00.
OffsetTime.parse(text)
Parses the text form the field stores, refusing anything java.time would.
| Parameter | Type | Description |
|---|---|---|
text | string | The value as java.time prints it, such as 2026-08-14 for a LocalDate. |
Returns OffsetTime: The value.
OffsetTime.from(value, [zone])
The value an instant has in a zone: the same moment is a different calendar date or wall-clock time depending on where it is read.
| Parameter | Type | Description |
|---|---|---|
value | Date or number or string | An instant: a Date, epoch milliseconds, or ISO text. |
zone | string | Optional. The zone to read it in. Omitted, dari.timeZone. |
Returns OffsetTime: The value.
offsetTime.toState()
The stored form: the text java.time prints for this value.
Returns string: The text.
offsetTime.toString()
The same text as the stored form.
Returns string: The text.
ZoneId
A time zone, stored by its name, such as America/New_York. from gives the zone the instant was read in.
ZoneId.parse(text)
Parses the text form the field stores, refusing anything java.time would.
| Parameter | Type | Description |
|---|---|---|
text | string | The value as java.time prints it, such as 2026-08-14 for a LocalDate. |
Returns ZoneId: The value.
ZoneId.from(value, [zone])
The value an instant has in a zone: the same moment is a different calendar date or wall-clock time depending on where it is read.
| Parameter | Type | Description |
|---|---|---|
value | Date or number or string | An instant: a Date, epoch milliseconds, or ISO text. |
zone | string | Optional. The zone to read it in. Omitted, dari.timeZone. |
Returns ZoneId: The value.
zoneId.toState()
The stored form: the text java.time prints for this value.
Returns string: The text.
zoneId.toString()
The same text as the stored form.
Returns string: The text.
ZoneOffset
An offset from UTC, stored as -04:00, or Z for UTC.
ZoneOffset.parse(text)
Parses the text form the field stores, refusing anything java.time would.
| Parameter | Type | Description |
|---|---|---|
text | string | The value as java.time prints it, such as 2026-08-14 for a LocalDate. |
Returns ZoneOffset: The value.
ZoneOffset.from(value, [zone])
The value an instant has in a zone: the same moment is a different calendar date or wall-clock time depending on where it is read.
| Parameter | Type | Description |
|---|---|---|
value | Date or number or string | An instant: a Date, epoch milliseconds, or ISO text. |
zone | string | Optional. The zone to read it in. Omitted, dari.timeZone. |
Returns ZoneOffset: The value.
zoneOffset.toState()
The stored form: the text java.time prints for this value.
Returns string: The text.
zoneOffset.toString()
The same text as the stored form.
Returns string: The text.
Year
A year. Stored as a number rather than as text, unlike every other date and time value.
| Property | Type | Description |
|---|---|---|
value | number | The year. |
new Year(value)
A year from a whole number.
| Parameter | Type | Description |
|---|---|---|
value | number | The year. |
Year.of(value)
A year from a whole number.
| Parameter | Type | Description |
|---|---|---|
value | number | The year. |
Returns Year: The year.
Year.parse(text)
A year from its text.
| Parameter | Type | Description |
|---|---|---|
text | string | The year, such as 2026. |
Returns Year: The year.
Year.from(value, [zone])
The year an instant falls in, read in a zone.
| Parameter | Type | Description |
|---|---|---|
value | Date or number or string | An instant: a Date, epoch milliseconds, or ISO text. |
zone | string | Optional. The zone to read it in. Omitted, dari.timeZone. |
Returns Year: The year.
year.toState()
The stored form: the number.
Returns number: The year.
year.toString()
The year as text.
Returns string: The text.
YearMonth
A year and month, stored as 2026-08.
YearMonth.parse(text)
Parses the text form the field stores, refusing anything java.time would.
| Parameter | Type | Description |
|---|---|---|
text | string | The value as java.time prints it, such as 2026-08-14 for a LocalDate. |
Returns YearMonth: The value.
YearMonth.from(value, [zone])
The value an instant has in a zone: the same moment is a different calendar date or wall-clock time depending on where it is read.
| Parameter | Type | Description |
|---|---|---|
value | Date or number or string | An instant: a Date, epoch milliseconds, or ISO text. |
zone | string | Optional. The zone to read it in. Omitted, dari.timeZone. |
Returns YearMonth: The value.
YearMonth.of(year, month)
A year and month from their parts.
| Parameter | Type | Description |
|---|---|---|
year | number | The year. |
month | number | The month, 1 to 12. |
Returns YearMonth: The value.
yearMonth.toState()
The stored form: the text java.time prints for this value.
Returns string: The text.
yearMonth.toString()
The same text as the stored form.
Returns string: The text.
Duration
An amount of time: days, hours, minutes and seconds. Not derivable from a Date, which is one instant rather than a span, so this is one of the few date-shaped values a script has to build.
Duration.of(spec)
A span from its parts.
| Parameter | Type | Description |
|---|---|---|
spec | Object | The parts: days, hours, minutes and seconds, each optional. |
Returns Duration: The span, such as PT4M30S for { minutes: 4, seconds: 30 }.
Duration.ofSeconds(seconds)
A span of so many seconds, normalized to hours, minutes and seconds, which is how java.time prints the same span back.
| Parameter | Type | Description |
|---|---|---|
seconds | number | The seconds. A fraction is dropped. |
Returns Duration: The span.
Duration.ofMinutes(minutes)
A span of so many minutes.
| Parameter | Type | Description |
|---|---|---|
minutes | number | The minutes. |
Returns Duration: The span.
Duration.parse(text)
A span from the ISO-8601 text java.time accepts.
| Parameter | Type | Description |
|---|---|---|
text | string | The text, such as PT4M30S. |
Returns Duration: The span.
Duration.between(from, to)
The span between two instants, to the second.
| Parameter | Type | Description |
|---|---|---|
from | Date or number or string | The earlier instant. |
to | Date or number or string | The later instant. |
Returns Duration: The span.
duration.toState()
The stored form: the ISO-8601 text, such as PT4M30S.
Returns string: The text.
duration.toString()
The same text as the stored form.
Returns string: The text.
Period
An amount of calendar time: years, months and days. Like Duration, a span rather than an instant.
Period.of(spec)
An amount from its parts.
| Parameter | Type | Description |
|---|---|---|
spec | Object | The parts: years, months and days, each optional. |
Returns Period: The amount, such as P1Y6M for { years: 1, months: 6 }.
Period.parse(text)
An amount from the ISO-8601 text java.time accepts.
| Parameter | Type | Description |
|---|---|---|
text | string | The text, such as P1Y6M. |
Returns Period: The amount.
period.toState()
The stored form: the ISO-8601 text, such as P1Y6M.
Returns string: The text.
period.toString()
The same text as the stored form.
Returns string: The text.
MonthDay
A month and day with no year, stored as --08-14.
MonthDay.parse(text)
Parses the text form the field stores, refusing anything java.time would.
| Parameter | Type | Description |
|---|---|---|
text | string | The value as java.time prints it, such as 2026-08-14 for a LocalDate. |
Returns MonthDay: The value.
MonthDay.from(value, [zone])
The value an instant has in a zone: the same moment is a different calendar date or wall-clock time depending on where it is read.
| Parameter | Type | Description |
|---|---|---|
value | Date or number or string | An instant: a Date, epoch milliseconds, or ISO text. |
zone | string | Optional. The zone to read it in. Omitted, dari.timeZone. |
Returns MonthDay: The value.
MonthDay.of(month, day)
A month and day from their parts.
| Parameter | Type | Description |
|---|---|---|
month | number | The month, 1 to 12. |
day | number | The day of the month. |
Returns MonthDay: The value.
monthDay.toState()
The stored form: the text java.time prints for this value.
Returns string: The text.
monthDay.toString()
The same text as the stored form.
Returns string: The text.
RichText
The editor's stored markup, which is not HTML: paragraphs are separated by two <br/> rather than wrapped in <p>, and anything richer than a mark or a list is a registered element addressed by tag name. Build one a block at a time, convert plain prose with RichText.fromPlainText(), or read existing markup with RichText.from().
new RichText([markup])
Starts from existing markup, or from nothing.
| Parameter | Type | Description |
|---|---|---|
markup | string | Optional. Stored markup to start from. |
RichText.from(markup)
Existing stored markup, for reading or rewriting.
| Parameter | Type | Description |
|---|---|---|
markup | string or null | The markup, such as the value of a rich text field. |
Returns RichText: The value.
RichText.fromPlainText(text)
Plain text as the editor would have stored it: blank lines become paragraph breaks, single newlines become soft line breaks, and the text itself is escaped. For prose that arrived with no idea it was destined for a rich text field, such as a model's answer or an imported description, whose newlines would otherwise be lost and whose < and & would become markup.
| Parameter | Type | Description |
|---|---|---|
text | string | The prose. |
Returns RichText: The value, ready to build on.
richText.html(markup)
Markup written unchanged, after the paragraph break a preceding paragraph left pending.
| Parameter | Type | Description |
|---|---|---|
markup | string | The markup. |
Returns RichText: This value.
richText.paragraph(value)
A block of text, separated from the next block by two <br/>. The separator is written lazily, so the last paragraph carries no trailing break.
| Parameter | Type | Description |
|---|---|---|
value | string or InlineText or function | The text, a built InlineText, or a function given an InlineText to build on. |
Returns RichText: This value.
richText.line(value)
A line inside the current block, ending in a single <br/>: the editor's soft break.
| Parameter | Type | Description |
|---|---|---|
value | string or InlineText or function | The text, a built InlineText, or a function given an InlineText to build on. |
Returns RichText: This value.
richText.list(items)
A bulleted list.
| Parameter | Type | Description |
|---|---|---|
items | Array<(string|InlineText|function())> | One entry per item, each as richText.paragraph() takes. |
Returns RichText: This value.
richText.orderedList(items)
A numbered list.
| Parameter | Type | Description |
|---|---|---|
items | Array<(string|InlineText|function())> | One entry per item, each as richText.paragraph() takes. |
Returns RichText: This value.
richText.element(tagName, [options])
A registered rich text element, by the tag name the CMS knows it under. Where an element's data goes, in attributes, in the body, or in one attribute holding a serialized record, is that element's own design, so give it the attributes and body it expects. An attribute given a Record is written as that record's state JSON.
| Parameter | Type | Description |
|---|---|---|
tagName | string or RichTextElement | The tag name, or a built RichTextElement. |
options | Object | Optional. attributes and body, as RichTextElement takes. |
Returns RichText: This value.
richText.elements(tagName)
Every occurrence of the named element in this markup, in document order.
| Parameter | Type | Description |
|---|---|---|
tagName | string | The tag name. |
Returns RichTextElement[]: The elements.
richText.rewrite(tagName, visitor)
Rewrites every occurrence of the named element. Markup outside the elements visited is left byte for byte as it was.
| Parameter | Type | Description |
|---|---|---|
tagName | string | The tag name. |
visitor | function | Given each element in turn. Return the element to keep it, a different one to replace it, or null to remove it. |
Returns RichText: This value.
richText.toPlainText()
The readable text: every tag but an inline mark becomes a space, and runs of whitespace collapse.
Returns string: The text.
richText.isEmpty
Whether the markup holds no readable text.
Type: boolean
richText.toHtml()
The markup.
Returns string: The markup.
richText.toState()
The stored form: the markup.
Returns string: The markup.
richText.toString()
The markup.
Returns string: The markup.
RichTextElement
One rich text element, found in stored markup or built to add: its tag name, its attributes and its body. Nothing here interprets what those mean. An element decides for itself whether a value belongs in an attribute, in the body, or in one attribute holding its whole serialized state, and that decision lives in Java code this SDK cannot run. So the element is what it literally is, with richTextElement.record() for the common case where one attribute holds a record.
| Property | Type | Description |
|---|---|---|
tagName | string | The element's tag name, such as bsp-pull-quote. |
attributes | Object<string, *> | The attributes, by name. |
body | string | The body text. |
new RichTextElement(tagName, [options])
An element to add to a RichText.
| Parameter | Type | Description |
|---|---|---|
tagName | string | The tag name the CMS knows the element by. |
options | Object | Optional. attributes, the attribute values by name, and body, the body text. |
richTextElement.attribute(name, [value])
Reads an attribute with one argument, writes it with two. A Record is written as its state JSON.
| Parameter | Type | Description |
|---|---|---|
name | string | The attribute's name. |
value | * | Optional. The value to write. |
Returns *: The attribute's value when reading, or this element when writing.
richTextElement.record(name)
The named attribute parsed as a record, for an element that stores its fields as serialized state.
| Parameter | Type | Description |
|---|---|---|
name | string | The attribute's name. |
Returns Record or null: The record, or null when the attribute is empty.
richTextElement.toHtml()
The element as markup, its attributes escaped and a Record-valued attribute written as that record's state JSON.
Returns string: The markup.
InlineText
Inline content: the marks the editor writes, and nothing it does not. Given to a RichText block as a function, t => t.text("The ").bold("harbor"), so formatting can be mixed into a paragraph, a line or a list item.
new InlineText()
An empty run of inline content.
inlineText.text(value)
Plain text, escaped so that markup characters in it stay text.
| Parameter | Type | Description |
|---|---|---|
value | string | The text. |
Returns InlineText: This run.
inlineText.bold(value)
Text in bold.
| Parameter | Type | Description |
|---|---|---|
value | string | The text. |
Returns InlineText: This run.
inlineText.italic(value)
Text in italics.
| Parameter | Type | Description |
|---|---|---|
value | string | The text. |
Returns InlineText: This run.
inlineText.underline(value)
Underlined text.
| Parameter | Type | Description |
|---|---|---|
value | string | The text. |
Returns InlineText: This run.
inlineText.strikethrough(value)
Struck-through text.
| Parameter | Type | Description |
|---|---|---|
value | string | The text. |
Returns InlineText: This run.
inlineText.code(value)
Text as code.
| Parameter | Type | Description |
|---|---|---|
value | string | The text. |
Returns InlineText: This run.
inlineText.wrap(tag, value)
Text inside one inline mark, by its tag name, for a mark the named methods don't cover, such as sup.
| Parameter | Type | Description |
|---|---|---|
tag | string | The mark's tag name. |
value | string | The text. |
Returns InlineText: This run.
inlineText.link(href, value)
A link.
| Parameter | Type | Description |
|---|---|---|
href | string | The URL. |
value | string | The link's text. |
Returns InlineText: This run.
inlineText.html(markup)
Markup written as it is, unescaped.
| Parameter | Type | Description |
|---|---|---|
markup | string | The markup. |
Returns InlineText: This run.
inlineText.toHtml()
The run as markup.
Returns string: The markup.
Differences
The field changes between two states, keyed by record id: the shape a Content Edit Save's Differences field takes. Produced by dari.diff() and record.toDifferences().
| Property | Type | Description |
|---|---|---|
byRecord | Object<string, Object> | Every change, keyed by record id, each an object of the changed fields in their stored form: the value the Save's Differences field wants. |
differences.isEmpty
Whether nothing changed.
Type: boolean
differences.recordIds
The ids of the records that changed.
Type: string[]
differences.forRecord(id)
One record's changed fields.
| Parameter | Type | Description |
|---|---|---|
id | string | The record's id. |
Returns Object: The changed fields, empty when that record didn't change.
differences.embeddedFor(id)
Every changed record except the one named, as a Save's embedded-object rows.
| Parameter | Type | Description |
|---|---|---|
id | string | The root record's id. |
Returns Array<{objectId: string, fields: Object}>: The other records' changes.
differences.toJson([indent])
The changes as JSON text, for logging while working out why something is or isn't changing.
| Parameter | Type | Description |
|---|---|---|
indent | number or string | Optional. Indentation, as JSON.stringify takes it. |
Returns string: The JSON.
DariError
Everything this SDK throws, so a script can tell an SDK complaint from a bug in its own code with error instanceof dari.DariError. The message names the field or value and what was expected.
| Property | Type | Description |
|---|---|---|
name | string | Always DariError. |
new DariError(message)
An error of this SDK's kind, for a script that wants its own checks to fail the same way.
| Parameter | Type | Description |
|---|---|---|
message | string | What went wrong. |
dari.diff(before, after, [options])
What changed between two states, keyed by record id, for a Content Edit Save's Differences field. Compares as Dari does: null equals false and every empty value, a field missing on one side counts as null, and lists compare in order unless named in unorderedFields.
| Parameter | Type | Description |
|---|---|---|
before | Object or Record | The earlier state, such as a Content Fetch's values, or an empty object for content being created. |
after | Object or Record | The later state, or the record itself. |
options | Object | Optional. unorderedFields: the names of fields whose lists compare as sets, for a list whose order carries no meaning. |
Returns Differences: The changes.
dari.uuid()
A fresh id for a record about to be built: time-ordered, so ids minted here sort beside ids the CMS minted itself.
Returns string: The id.
dari.type(identifier)
The named type as the content model describes it: its id, its fields, and what may be named in as(). Fails when there is no such type.
| Parameter | Type | Description |
|---|---|---|
identifier | string | The type's full internal name, its last part when that is unique across the content model, or its id. |
Returns TypeInfo: The type.
dari.timeZone
The zone a plain Date is read in when a field wants a calendar date, a wall-clock time or an offset. Defaults to UTC. Set it once at the top of a script that cares, to a name the runtime knows, such as America/New_York.
Type: string
TypeInfo
One content type as the content model describes it: what dari.type returns. Its fields are described as objects with a name, a type such as text, number, date, record or list/text, the permittedValues of a fixed list, and isEmbedded for a record field that holds its value inside the parent.
| Property | Type | Description |
|---|---|---|
id | string | The type's id. |
name | string | The type's full internal name, such as com.example.Article. |
displayName | string | The type's display name. |
isEmbedded | boolean | Whether content of this type lives inside its parent rather than on its own. |
isAbstract | boolean | Whether the type only exists to be extended. |
isConcrete | boolean | Whether content of exactly this type can exist. |
modifications | string[] | The modification classes that apply to the type, which record.as() may name. |
typeInfo.field(internalName)
The field stored under an internal name, the type's own or a global one.
| Parameter | Type | Description |
|---|---|---|
internalName | string | The name the field is stored under. |
Returns Object or null: The field's description, or null when the type has no such field.
typeInfo.fieldOf(declaringClassName, javaFieldName)
The field a modification class declares under a Java field name.
| Parameter | Type | Description |
|---|---|---|
declaringClassName | string | The modification's full class name. |
javaFieldName | string | The field's name in that class. |
Returns Object or null: The field's description, or null when that class declares no such field.
typeInfo.fieldNames()
Every field's internal name, the type's own and the global ones.
Returns string[]: The names.
typeInfo.declares(className)
Whether as(className) is meaningful here: the class modifies this type, or declares a global field.
| Parameter | Type | Description |
|---|---|---|
className | string | The class's full name. |
Returns boolean: True when the class may be named.
typeInfo.javaFieldNamesOf(className)
The Java field names a modification class declares on this type.
| Parameter | Type | Description |
|---|---|---|
className | string | The class's full name. |
Returns string[]: The names, empty for a class that declares none.
typeInfo.modificationNames()
Every class that may be named in record.as() on this type.
Returns string[]: The full class names.
ModificationView
A record's fields as one modification class declares them, addressed by their Java field names: what record.as() returns. Reads and writes go to the record itself, under the prefixed names the fields are stored under.
modificationView.get(javaFieldName)
Reads a field's value.
| Parameter | Type | Description |
|---|---|---|
javaFieldName | string | The field's name in the modification class. |
Returns *: The value, or undefined when the field is not set.
modificationView.put(javaFieldName, value)
Sets a field, converting the value as record.put() does.
| Parameter | Type | Description |
|---|---|---|
javaFieldName | string | The field's name in the modification class. |
value | * | The value. |
Returns ModificationView: This view.
modificationView.putAll(values)
Sets several fields at once.
| Parameter | Type | Description |
|---|---|---|
values | Object<string, *> | Values by Java field name. |
Returns ModificationView: This view.
modificationView.remove(javaFieldName)
Removes a field.
| Parameter | Type | Description |
|---|---|---|
javaFieldName | string | The field's name in the modification class. |
Returns ModificationView: This view.
modificationView.has(javaFieldName)
Whether a field is set.
| Parameter | Type | Description |
|---|---|---|
javaFieldName | string | The field's name in the modification class. |
Returns boolean: True when the field is set.
modificationView.internalName(javaFieldName)
The internal name this modification's field is stored under: the prefix applied, ready for a state map or record.putRaw().
| Parameter | Type | Description |
|---|---|---|
javaFieldName | string | The field's name in the modification class. |
Returns string: The stored name.