The worked example: a periodic table, in five languages and Bash#
Claims about extensibility are cheap. So we built the demo and published the repo: voxgig-elementdemo-sdk.
It is an SDK for a periodic-table API, elements, isotopes, groups and series, generated in TypeScript, Go, Python and Java. Then it customizes everything this page talks about, from inside its own repo, without touching sdkgen:
An entirely custom target: the same model that emits the four SDKs also emits a Bash library, curl for transport and jq for data, with one generated function per entity operation, an offline test mode, and a thin CLI.
$ source bash/elementdemo.sh
$ elementdemo_element_load id=fe | jq -r .name
Iron
$ echo '{"charge":3}' | elementdemo_element_ionize id=fe
{"ok":true,"ion":"Fe3+"}
A custom feature, elementcard, that renders any element-shaped result as an ASCII periodic-table tile. One model file, one implementation per language, hooked into the same pipeline stage in all five:
$ bash/bin/elementdemo element card id=fe
+---------+
|26 Fe|
| Iron |
| 55.845 |
+---------+
And the part that proves it: the feature's behaviour is asserted by language-neutral corpus cases in the project's own test data. The exact card string above is checked, byte for byte, by the TypeScript, Go, Python, Java and Bash test suites, from one file of cases.
# .sdk/test/feature/elementcard.aon
{
name: 'renders an element-shaped result and records it'
feature: [ { name: 'elementcard', active: true } ]
res: [ { status: 200, body: {
id: 'fe', name: 'Iron', symbol: 'Fe', number: 26, mass: 55.845 } } ]
op: [ { op: '#OP1' } ]
out: {
count: 1
last: "+---------+\n|26 Fe|\n| Iron |\n| 55.845 |\n+---------+"
}
}
Both the target and the feature come from the repo's own sdkgen package, ext/, installed with one command:
cd .sdk
npx voxgig-sdkgen package add ../ext
npm run generate