I consider installing a typest instance on my private server.
Is it possible to enable the interaction with other programs, ideally establishing socks connections to running deamons or making calls to an REST API or even call (whitelisted) programs on the server.
While I understand that enabling such things (especially the last option) on a public server might lead to sever security issues, it would be great for many of my possible usecases, such as automatic report generation.
Currently I mainly use knitr/overleaf or jupyter for such usecases. I guess, for those applications it is easier, as they compile everything at once. So for typest some mechanism would be necessary, to control possibly necessary reloads.
The alternative, running scripts, creating outputs which I eventually import and display in typest just doesn’t feel to appealing.
There has been extensive discussion about this in the past, but this functionality (often referred to as “shell escape” in reference to LaTeX’s equivalent functionality) unfortunately isn’t really compatible with several of Typst’s aspects, including portability (being able to compile the same document in different environments), purity (function calls in Typst must always produce the same result to make memoization possible), security (compiling a Typst document must not produce unexpected side-effects in your system) and others.
However, you can still run non-Typst code within a Typst document through the usage of WASM plugins, which are portable. This allows you to run anything that can compile to WASM, including even languages like Python (pyrunner – Typst Universe) or JavaScript (jogs – Typst Universe). As a fun fact, this also made it possible to bring some tools from the JS ecosystem to Typst, such as charts with echarts: echarm – Typst Universe
Now, if you really do need to run an external command (because, say, your program can’t easily be compiled to WebAssembly), it will be necessary to run the command before compiling and using its output. However, you can make this process easier, and even determine which command to run from inside the Typst document, thanks to typst query, which allows fetching information from the document. Check out this package which may help: prequery – Typst Universe