A12 Document Model to TypeScript Code

Dear A12 community,
we’ve indentified a repetitive task for our development team which is to create typescript code (interfaces) from A12 document models. Our primary usecase is to work with the data of a Form-Engine in our custom code. We favor compile time over runtime errors. Basically operations not solvable by UI modelling.
So far we did not tackle the task to write an automated tool ourselfs.
Is there some project that developed something suitable and would like to share?

Thanks,
Björn from Leipzig

Hello,

I don’t know of any projects that have developed something to handle this task. However, I have used online tools such as JSON to TypeScript<!-- --> • quicktype which when given some JSON, generate typescript types. In this case you’d need to give it an example document, rather than your model and the resulting type does require some tweaking, but it gets you most of the way there.

For me this type of thing has always been a one off, so the above method was sufficient. Nevertheless, I can see the benefit of a tool that takes care of it, so would be interested to know if you decide to create something yourself.

Cheers
Cameron

In the <PROJECT_NAME> project, we had developed a Node script that does exactly this. The code was written for the old XML models however, it would need to be updated for the new JSON format. I’ll enclose the script (as *.txt since *.ts files are disallowed).
scratch_169.txt (13.3 KB)

If you still need it, we from <PROJECT_NAME> Project have a gradle-plugin for that.

It is JSON and compatible with the 2022.06 Release.