Class

RenderingEngine

RenderingEngine(flavour)

Constructor

# new RenderingEngine(flavour)

The RenderingEngine class provides a framework for converting model metadata into UI field definitions. It handles the translation of model properties to UI elements, applies validation rules, and manages different rendering flavors. This class is designed to be extended by specific rendering implementations.

Abstract class for rendering UI components based on model metadata.

Parameters:
Name Type Description
flavour string

The flavor of the rendering engine.

View Source ui/Rendering.ts, line 8

Members

# initialized

Flag indicating whether the rendering engine has been initialized.

Flag indicating whether the rendering engine has been initialized.

View Source ui/Rendering.ts, line 38

boolean

# protected initialized

Flag indicating whether the rendering engine has been initialized.

Flag indicating whether the rendering engine has been initialized.

View Source ui/Rendering.ts, line 393

Methods

# abstract initialize(…args) → {Promise.<void>}

Abstract method to be implemented by subclasses for specific initialization logic.

Initializes the rendering engine.

Parameters:
Name Type Attributes Description
args Array.<any> <repeatable>

Any additional arguments needed for initialization.

View Source ui/Rendering.ts, line 405

A promise that resolves when initialization is complete.

Promise.<void>

# protected isValidatableByAttribute(key) → {boolean}

Determines if a given UI key represents a validation that can be applied as an attribute.

Checks if a type is validatable by attribute.

Parameters:
Name Type Description
key string

The UI key to check.

View Source ui/Rendering.ts, line 435

True if the type is validatable by attribute, false otherwise.

boolean

# protected isValidatableByType(key) → {boolean}

Determines if a given UI key represents a type that is inherently validatable.

Checks if a type is validatable by its nature.

Parameters:
Name Type Description
key string

The UI key to check.

View Source ui/Rendering.ts, line 425

True if the type is validatable, false otherwise.

boolean

# abstract render(model, globalProps, …args) → {R}

Abstract method to be implemented by subclasses to define specific rendering behavior.

Renders a model with global properties and additional arguments.

Parameters:
Name Type Attributes Description
model M

The model to be rendered.

globalProps Record.<string, unknown>

Global properties to be applied to all elements during rendering.

args Array.<any> <repeatable>

Additional arguments that may be required for specific rendering implementations.

View Source ui/Rendering.ts, line 497

The rendered result, type depends on the specific implementation.

R

# protected toAttributeValue(key, value) → {string|number|boolean}

Transforms validation metadata into a value suitable for use as an HTML attribute.

Converts validation metadata to an attribute value.

Parameters:
Name Type Description
key string

The validation key.

value ValidationMetadata

The validation metadata.

View Source ui/Rendering.ts, line 447

If the given key is not validatable by attribute.

Error

The converted attribute value.

string | number | boolean

# protected toFieldDefinition(model, globalPropsopt, generateIdopt) → {FieldDefinition.<T>}

Processes a model instance, extracting UI-related metadata and validation rules to create a field definition.

Converts a model to a field definition.

sequenceDiagram participant C as Client participant RE as RenderingEngine participant R as Reflection participant M as Model C->>RE: toFieldDefinition(model, globalProps) RE->>R: getMetadata(UIKeys.UIMODEL, model.constructor) R-->>RE: UIModelMetadata RE->>R: getAllPropertyDecorators(model, UIKeys.REFLECT) R-->>RE: Record RE->>R: getAllPropertyDecorators(model, ValidationKeys.REFLECT) R-->>RE: Record[]> loop For each property RE->>RE: Process UI decorators RE->>RE: Apply validation rules end RE-->>C: FieldDefinition
Parameters:
Name Type Attributes Default Description
model M

The model instance to convert.

globalProps Record.<string, unknown> <optional>
{}

Global properties to apply to all child elements.

generateId boolean <optional>
true

Flag indicating whether to populate the rendererId property.

View Source ui/Rendering.ts, line 481

If no UI definitions are set for the model or if there are invalid decorators.

A field definition object representing the UI structure of the model.

FieldDefinition.<T>

# translate(key, toViewopt) → {string}

Converts model data types to appropriate HTML input types and vice versa.

Translates between model types and HTML input types.

Parameters:
Name Type Attributes Default Description
key string

The key to translate.

toView boolean <optional>
true

Direction of translation (true for model to view, false for view to model).

View Source ui/Rendering.ts, line 415

The translated type.

string

# static get(flavouropt) → {RenderingEngine.<O>}

Gets the current rendering engine or a specific one by flavor.

Retrieves a rendering engine by flavor.

Parameters:
Name Type Attributes Description
flavour string <optional>

The flavor of the rendering engine to retrieve.

View Source ui/Rendering.ts, line 535

If the requested flavor does not exist.

InternalError

The requested rendering engine.

RenderingEngine.<O>

# static key(key) → {string}

Prefixes a given key with the UI reflection prefix.

Generates a metadata key for UI-related properties.

Parameters:
Name Type Description
key string

The key to prefix.

View Source ui/Rendering.ts, line 560

The prefixed key.

string

# static register(engine)

Adds a rendering engine to the static cache and sets it as the current engine.

Registers a rendering engine instance.

Parameters:
Name Type Description
engine RenderingEngine.<unknown, unknown>

The rendering engine to register.

View Source ui/Rendering.ts, line 508

If an engine with the same flavor already exists.

InternalError

# static render(model, …args) → {any}

Determines the correct rendering engine for a model and invokes its render method.

Renders a model using the appropriate rendering engine.

Parameters:
Name Type Attributes Description
model M

The model to render.

args Array.<any> <repeatable>

Additional arguments to pass to the render method.

View Source ui/Rendering.ts, line 549

If no registered model is found.

InternalError

The result of the rendering process.

any