A2uiCoreSurfaceModel


class A2uiCoreSurfaceModel : A2uiSurfaceModel


The root domain model for a single active surface.

It acts as the owner of that surface's A2uiCoreDataModel and A2uiCoreComponentRegistry, managing updates to these registries and propagating user actions and validation/runtime errors.

Summary

Public constructors

A2uiCoreSurfaceModel(
    id: String,
    catalog: A2uiCoreCatalog,
    dataModel: A2uiCoreDataModel,
    componentRegistry: A2uiCoreComponentRegistry,
    onDispatchAction: (A2uiUserAction) -> Unit,
    onDispatchError: (A2uiClientErrorMessage) -> Unit,
    theme: Map<StringAny?>,
    shouldSendDataModel: Boolean,
    timeProvider: () -> Long
)

Public functions

Unit
dispatchAction(componentId: String, actionDefinition: Map<StringAny?>)

Dispatches a user action from this surface to the registered action handler callback.

Unit
dispatchError(exception: A2uiException, componentId: String?)

Reports a rendering or evaluation failure to the component registry and dispatches the error to the registered error handler callback.

open operator Boolean
equals(other: Any?)
Any?
evaluatePayload(
    componentId: String,
    valueResolver: A2uiCoreValueResolver,
    dataPath: A2uiDataPath,
    payload: Any?
)

Evaluates a dynamic payload for a specific component.

open T
<T : Any> getOrCreateFunctionScopedCache(
    componentId: String,
    functionDefinition: A2uiFunctionDefinition,
    factory: () -> T
)

Gets or creates a component-scoped cache for functionDefinition.

open Int
open String

Public properties

A2uiCoreCatalog

The catalog used in this surface.

A2uiCoreComponentRegistry

The component registry backing this surface.

A2uiCoreDataModel

The storage model for this surface's data tree.

open String

The unique identifier of this surface.

Boolean

If true, indicates the data model of this surface should be appended as metadata to outgoing messages to the server.

Map<StringAny?>

An optional map of theme-specific overrides for this surface.

Public constructors

A2uiCoreSurfaceModel

A2uiCoreSurfaceModel(
    id: String,
    catalog: A2uiCoreCatalog,
    dataModel: A2uiCoreDataModel,
    componentRegistry: A2uiCoreComponentRegistry,
    onDispatchAction: (A2uiUserAction) -> Unit,
    onDispatchError: (A2uiClientErrorMessage) -> Unit,
    theme: Map<StringAny?> = emptyMap(),
    shouldSendDataModel: Boolean = false,
    timeProvider: () -> Long = { System.currentTimeMillis() }
)
Parameters
id: String

The unique identifier of this surface.

catalog: A2uiCoreCatalog

The catalog used in this surface.

dataModel: A2uiCoreDataModel

The storage model for this surface's data tree.

componentRegistry: A2uiCoreComponentRegistry

The component registry backing this surface.

onDispatchAction: (A2uiUserAction) -> Unit

Callback to handle user actions dispatched from this surface.

onDispatchError: (A2uiClientErrorMessage) -> Unit

Callback to handle errors dispatched from this surface.

theme: Map<StringAny?> = emptyMap()

An optional map of theme-specific overrides for this surface.

shouldSendDataModel: Boolean = false

If true, indicates the data model of this surface should be appended as metadata to outgoing messages to the server.

timeProvider: () -> Long = { System.currentTimeMillis() }

Provider that returns the current epoch time in milliseconds.

Public functions

dispatchAction

fun dispatchAction(componentId: String, actionDefinition: Map<StringAny?>): Unit

Dispatches a user action from this surface to the registered action handler callback.

Parameters
componentId: String

The unique identifier of the component that was interacted with.

actionDefinition: Map<StringAny?>

A map containing details about the action (e.g., name, context).

dispatchError

Added in 1.0.0-alpha01
fun dispatchError(exception: A2uiException, componentId: String? = null): Unit

Reports a rendering or evaluation failure to the component registry and dispatches the error to the registered error handler callback.

Note: The componentId is exclusively used to mark the error on the local component registry for local UI error boundary rendering. It is not appended or injected into the exception context or path sent to the server. Callers must ensure the exception itself is initialized with all the relevant information, including the component id if relevant.

Parameters
exception: A2uiException

The exception describing the failure.

componentId: String? = null

The unique identifier of the component that encountered the error. Null if the error is surface-level.

equals

open operator fun equals(other: Any?): Boolean

evaluatePayload

Added in 1.0.0-alpha01
fun evaluatePayload(
    componentId: String,
    valueResolver: A2uiCoreValueResolver,
    dataPath: A2uiDataPath,
    payload: Any?
): Any?

Evaluates a dynamic payload for a specific component.

Parameters
componentId: String

unique identifier of the UI component

valueResolver: A2uiCoreValueResolver

resolver to retrieve values from the data model

dataPath: A2uiDataPath

base path used to resolve relative paths

payload: Any?

payload to evaluate

Returns
Any?

evaluated result, or null if evaluation fails

getOrCreateFunctionScopedCache

Added in 1.0.0-alpha01
open fun <T : Any> getOrCreateFunctionScopedCache(
    componentId: String,
    functionDefinition: A2uiFunctionDefinition,
    factory: () -> T
): T

Gets or creates a component-scoped cache for functionDefinition.

Each component and functionDefinition pair gets a separate cache that persists across function invocations and data model updates. Ideal for storing the results of heavy operations that do not rely on data model values (e.g., static metadata, parsed templates, compiled regexes, etc.).

Warning: The cache does not refresh upon data model changes. Caching values that are based on the data model will result in a stale cache.

Parameters
componentId: String

unique identifier of the component

functionDefinition: A2uiFunctionDefinition

definition identifying the cache

factory: () -> T

factory function to create the cache if missing

Returns
T

cache instance

hashCode

open fun hashCode(): Int

toString

open fun toString(): String

Public properties

catalog

Added in 1.0.0-alpha01
val catalogA2uiCoreCatalog

The catalog used in this surface.

componentRegistry

Added in 1.0.0-alpha01
val componentRegistryA2uiCoreComponentRegistry

The component registry backing this surface.

dataModel

Added in 1.0.0-alpha01
val dataModelA2uiCoreDataModel

The storage model for this surface's data tree.

id

Added in 1.0.0-alpha01
open val idString

The unique identifier of this surface.

shouldSendDataModel

Added in 1.0.0-alpha01
val shouldSendDataModelBoolean

If true, indicates the data model of this surface should be appended as metadata to outgoing messages to the server.

theme

Added in 1.0.0-alpha01
val themeMap<StringAny?>

An optional map of theme-specific overrides for this surface.