Creating and editing Anki's *.apkg and *.anki2 via SQLite

*.apkg and *.anki2 file structure is very simple, but with some quirks of incompleteness.

*.apkg file structure is a zip of at least two files.

Various Node.js sqlite packages. What is the best?

The official implementation is actually sqlite3, and there are at least 2 packages built on top of it -- sqlite and TypeORM. There are also other packages that can run SQLite including better-sqlite3 and sql.js.