型を公開する練習として、 pt-query-digest *1 で --output json
したときに出力される JSON の型を書いてみた。 JSON.parse()
したものにつける型を想定している。
index.d.ts とかを書いて、 package.json に types
として指定しておくと完成らしい。 npm に公開しなくても、とりあえず yarn add -D https://github.com/hogashi/types-pt-query-digest-output-json
とかやるとインストールできるのでさっと作ってみるには気楽。
値としては数値なはずだけどプロパティによって number だったり string だったりすることがあってちょっと難しい。ちゃんとコード読んでるわけでもないので、意外と null になるじゃんみたいなものもあったりしそう。あと pt-query-digest の v3.0 時点でもまだ開発中ということなので急に変わったりもしそうではある。
https://www.percona.com/doc/percona-toolkit/3.0/pt-query-digest.html#options&:~:text=json%20output%20was%20introduced%20in%202.2.1%20and%20is%20still%20in%20development
json
output was introduced in 2.2.1 and is still in development, so the data structure may change in future versions.