mendraw/synthetic

Synthetic Mendix data objects for external API data.

Creates fake ListValue, ObjectItem, ListAttributeValue etc. that satisfy the interface expected by Mendix chart/grid widgets, allowing external API data (e.g. CoinGecko) to be rendered through real Mendix marketplace widgets.

let items = synthetic.object_items(3)
let lv = synthetic.list_value(items)
let attr = synthetic.list_attribute(items, [1.0, 2.0, 3.0], float.to_string, "Decimal")

Types

Represents a synthetic association value.

pub type Association

Represents a synthetic chart series configuration.

pub type ChartSeries

Represents a JavaScript array containing a known Gleam value type.

pub type JsArray(value)

Represents a synthetic static text template.

pub type TextTemplate

Values

pub fn association(
  items items: List(mendix.ObjectItem),
  targets targets: List(mendix.ObjectItem),
) -> Association

Create a synthetic association linking items to target items. get(sourceItem) returns { value: targetItem }. Used for DynamicDataGrid referenceRow/referenceColumn.

pub fn chart_series_static(
  data_source data_source: list_value.ListValue,
  x_attr x_attr: list_attribute.ListAttributeValue,
  y_attr y_attr: list_attribute.ListAttributeValue,
  name name: TextTemplate,
  aggregation aggregation: String,
  interpolation interpolation: String,
  line_style line_style: String,
  line_color line_color: String,
  bar_color bar_color: String,
) -> ChartSeries

Build a static chart series config object for Line/Area/Column/TimeSeries. Returns a JS object with { dataSet:“static”, staticDataSource, … }.

pub fn list_attribute(
  items items: List(mendix.ObjectItem),
  values values: List(a),
  display_fn display_fn: fn(a) -> String,
  attr_type attr_type: String,
) -> list_attribute.ListAttributeValue

Create a synthetic ListAttributeValue. get(item) returns an EditableValue with the corresponding value.

  • items: ObjectItems (must match list_value items)
  • values: parallel list of values, one per item
  • display_fn: converts a value to display string
  • attr_type: Mendix attribute type (“Decimal”, “String”, “DateTime”, etc.)
pub fn list_expression(
  items items: List(mendix.ObjectItem),
  values values: List(a),
) -> list_attribute.ListExpressionValue

Create a list-bound expression value. get(item) returns { status: “available”, value: val }.

pub fn list_text_template(
  items items: List(mendix.ObjectItem),
  values values: List(String),
) -> list_attribute.ListExpressionValue

Create a list-bound text template. get(item) returns { status: “available”, value: “text for this item” }.

pub fn list_value(
  items items: List(mendix.ObjectItem),
) -> list_value.ListValue

Create a synthetic ListValue from a list of ObjectItems. Status is “available”, mutation methods are no-ops.

pub fn object_item(id id: String) -> mendix.ObjectItem

Create a single synthetic ObjectItem with the given id

pub fn object_items(count count: Int) -> List(mendix.ObjectItem)

Create N synthetic ObjectItems with ids “synth_0”, “synth_1”, …

pub fn text_template(value value: String) -> TextTemplate

Create a static text template (not bound to a datasource). Returns { value: text } matching Mendix textTemplate shape.

pub fn to_js_array(items items: List(value)) -> JsArray(value)

Convert a Gleam List to a JS Array. Needed for chart widget lines/series props which expect JS arrays.

Search Document