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")

Values

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

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: list_value.ListValue,
  x_attr: list_attribute.ListAttributeValue,
  y_attr: list_attribute.ListAttributeValue,
  name: a,
  aggregation: String,
  interpolation: String,
  line_style: String,
  line_color: String,
  bar_color: String,
) -> b

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: List(mendix.ObjectItem),
  values: List(a),
  display_fn: fn(a) -> String,
  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: List(mendix.ObjectItem),
  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: List(mendix.ObjectItem),
  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: 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: String) -> mendix.ObjectItem

Create a single synthetic ObjectItem with the given id

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

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

pub fn text_template(value: String) -> a

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

pub fn to_js_array(items: List(a)) -> b

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

Search Document