Skip to content

Instantly share code, notes, and snippets.

@scarabaeus
Last active February 23, 2023 20:19
Show Gist options
  • Save scarabaeus/b9f77921df87a6cf5d2bbd96e2be4ce3 to your computer and use it in GitHub Desktop.
Save scarabaeus/b9f77921df87a6cf5d2bbd96e2be4ce3 to your computer and use it in GitHub Desktop.
Typed value transformation for writing UI transformation to core transformation
/* Expression to be executed on the FE to create a serialized expression to be evaluated by Core (SQL as the example) */
{
"typedValues": [
{
"value": "John",
"type": "string"
},
{
"value": "Doe",
"type": "string"
},
{
"value": "$number($.amount)",
"type": "number"
},
{
"value": "Company Name",
"type": "string"
}
]
}
[
"John",
"Doe",
$number($.amount),
"Company Name"
]
"[\"John\",\"Doe\",$number($.amount),\"Company Name\"]"
(
$values := function($acc, $item, $index, $entireArray) {
$acc & ($item.type = "number" ? $item.value : "\"" & $item.value & "\"") & ($count($entireArray) != ($index + 1) ? "," : "")
};
"[" & $reduce($.typedValues, $values, "") & "]"
)
@scarabaeus
Copy link
Author

This would be used in the "Save Transformation" portion of a Third-Party FE node schema.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment