Skip to content

EventBuilder

Declares an Event’s payload, Listeners, child Events and schedules.

The payload is declared with the InputBuilder methods this interface exposes, such as addProperty. Registering a Listener declares behavior; the Runtime executes it when the Event is published or invoked immediately.

readonly children: EventBuilder[]

Events this Event’s Listeners may publish, in the order they were added.


readonly input: InputBuilder

Payload declaration of the Event.


readonly key: string

Event key within its Template, Union or App.


readonly prn: string

Platform Resource Name of the declared resource, derived from the App key and resource key.

BaseBuilder.prn

addArray(key): ArrayInputBuilder

Declares an array value; declare its element type on the returned builder.

string

Input key.

ArrayInputBuilder

InputBuilder.addArray


addChildEvent(event): this

Declares an Event that this Event’s Listeners may publish.

EventBuilder

Event that Listeners of this Event publish.

this

This builder for chaining.

Declared children let the Builder reject cycles at build time; the Runtime separately bounds the depth of Event chains. Adding the same child twice adds it once.

When adding event would create a cycle of declared child Events.

Declaring a follow-up Event

const refresh = app.addEvent('refresh');
const refreshed = app.addEvent('refreshed');
refresh.addChildEvent(refreshed);

Circular references


addJson(key, parser): JsonInputBuilder

Declares a JSON value parsed by a Zod type or parse function.

string

Input key.

ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>> | JsonParse<any>

Zod type or parse function that parses the value.

JsonInputBuilder

InputBuilder.addJson


addListener(key, handler): EventListenerBuilder

Registers a Listener that the Runtime runs when this Event is processed.

string

Listener key within the Event.

EventListener

Listener to run.

EventListenerBuilder

The Listener builder.

The Listener receives the Event, the target Item, the declaring App as current and a write context as ctx. Execution and failure semantics depend on whether the Event was published or invoked immediately.


addObject(key): ObjectInputBuilder

Declares a nested object value; declare its members on the returned builder.

string

Input key.

ObjectInputBuilder

InputBuilder.addObject


addProperty(key, type): DataTypeInputBuilder

Declares a primitive or temporal value such as 'id', 'string' or 'date'.

string

Input key.

PrimitiveDataType | TemporalDataType

Data type of the value.

DataTypeInputBuilder

InputBuilder.addProperty

addProperty(key, type, options?): SelectInputBuilder

Declares a single-select or multi-select value; declare its options on the returned builder, or resolve them from a well-known format via options.format.

string

Input key.

SelectDataType

Select data type.

SelectInputOptions

Select options, such as the format the options are resolved from.

SelectInputBuilder

InputBuilder.addProperty

addProperty(key, type): JsonInputBuilder

Declares a JSON value parsed by a Zod type.

string

Input key.

ZodType

Zod type of the value.

JsonInputBuilder

InputBuilder.addProperty

addProperty(key, type, options?): JsonInputBuilder

Declares a value of any supported type and returns the matching builder.

string

Input key.

PrimitiveDataType | TemporalDataType | SelectDataType | ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>

Data type name or Zod type.

SelectInputOptions

Select options, only applicable to a select data type.

JsonInputBuilder

InputBuilder.addProperty


addSchedule(key, crontab): EventSchedulerBuilder

Publishes this Event on a crontab schedule.

string

Schedule key within the Event.

string

Crontab expression in the five-part Unix format.

EventSchedulerBuilder

The schedule builder.

The crontab uses the standard five-part Unix format. An App-level Event is published against the Workspace Item; a Template Event is published against every active Item of the Template, or only Items in the states given with EventSchedulerBuilder.state. Schedules run on a best-effort basis: precise timing is not guaranteed and ticks of frequent schedules may be skipped.

A daily schedule

leaveExpiryDue.addSchedule('daily', '30 2 * * *');

Schedules


setDescription(description): this

Sets the description emitted into the definition and rendered in generated reference and application assets.

string

Human-readable description of the resource.

this

This builder for chaining.

BaseBuilder.setDescription


toDefinition(): EventDefinition

Emits the Definition of this Event, including its payload, Listeners, child Event PRNs and schedules.

EventDefinition