If anyone has any feedback on the design, I'd be interested in hearing it. Or if you have questions about design choices, I can answer them. Thanks for reading!
71 karma · joined March 5, 2013
Currently developing:
* radashi <https://github.com/radashi-org/radashi>
* pg-nano <https://github.com/pg-nano/pg-nano>
* alien-rpc <https://github.com/alloc/alien-rpc>
Currently maintaining:
* jumpgen <https://github.com/alloc/jumpgen>
* alien-dom <https://github.com/alloc/alien-dom>
Previously maintained:
* vite (core team from v0 til v4)
* immer (co-author)
* react-spring (co-author)
If anyone has any feedback on the design, I'd be interested in hearing it. Or if you have questions about design choices, I can answer them. Thanks for reading!
[1]: https://github.com/aleclarson/dough
P.S. If you can cope with jQuery in a medium/large app, good for you. But it's not my cup of tea.
In my case, building an RPC library with REST semantics, it's important to me to not place any restrictions on how developers pass their data to the backend. So removing that arbitrary flattening requirement is a big win. The json-qs specification does it in a way that balances readability and compactness.
I've found it helps a lot when writing a library that takes advantage of compile-time code generation. In the future, I think it could be cool to try and integrate jumpgen with bundlers, like Vite or Rollup, so your file generator can be used as a bundler plugin. Currently, jumpgen “generators” only have a programmatic API, but jumpgen will have a CLI as well, if you think that could be useful. Mostly though, jumpgen is intended as a “white label” library that is contained by your own CLI, if you have one.
# Motivation
Code generation can be useful for many tasks. I'm using code generation in my own libraries, pg-nano[1] and alien-rpc (in development). In pg-nano, I'm generating TypeScript functions that mirror Postgres functions (aka UDFs). In alien-rpc, I'm generating runtime metadata for RPC-style API routing.
I could not find a library that simplifies the task of writing a code generator, so I made jumpgen.
# What It Does
It's designed to handle the burdens of implementing a “watch mode” for your generators. It also returns an event emitter, especially useful for logging. Your generator is free to work in relative paths, since jumpgen handles path resolution according to a user-provided root directory.
It tracks which files your generator has read into memory and which directories your generator has listed. When those files/directories are changed or have files added/removed, your generator will rerun automatically (if watch mode is enabled). This even works with globs!
I've also included a "dedent" helper function so you can indent any template literal without that excess indentation carrying over into the emitted files.
# Feedback Wanted
If this sounds interesting to you, I'd love to hear any comments or criticisms about the API, the readme, or whatever else. Thanks!
edit: The creator of Terser is working on flow analysis for his new minifier, according to him[1].
[1]: https://github.com/terser/terser/issues/1410#issuecomment-17...
It also has a companion library[2] for generating TypeBox validators from TypeScript definitions, which I'm currently using in an RPC library I'm working on.
[1]: https://github.com/sinclairzx81/typebox [2]: https://github.com/sinclairzx81/typebox-codegen
I don't know if much can be done about echo chambers. People seem to like their echo chambers. For those who are sick of such environments, I've designed another system (not yet part of the product I mentioned above) that I believe has the potential to breed a place of authenticity on the internet.
There's also the DEFERRABLE constraint setting[1] for one-to-one relationships (which can usually be avoided via a joint reference table). This pattern should already work in pg-nano.
[1]: https://www.postgresql.org/docs/current/sql-set-constraints....
As far as migrations go, pg-nano is taking the same “schema diffing” approach that I assume Prisma does, where the active schema of your Postgres instance is compared to the desired schema (defined via SQL files in pg-nano's case) and a migration plan is generated from there. In the context of migrating a non-local Postgres instance, pg-nano still has some R&D to do.
It's a syntax parser that produces an AST. So only information explicitly defined in the syntax is available. To infer input/output types for an arbitrary SQL command, you need introspection (the most fool-proof way being PQdescribePrepared[1]).
> Being able to use raw SQL and get query types "for free" would be amazing.
That's basically what pg-nano does, but you need to use Postgres functions, rather than "$1" or "?" placeholder templating. Of course, some people prefer co-locating their raw SQL inside their TypeScript files, in which case, pg-nano is not for them.
[1]: https://www.postgresql.org/docs/current/libpq-exec.html#LIBP...
> do you think it's possible to use your libraries to get the return type of an arbitrary postgres query, even if it's dynamic?
Yes it is. I've solved that exact problem in pg-nano. I use the `describePrepared` feature of libpq: https://github.com/pg-nano/pg-nano/blob/4cca3dbe6be609c479e4...
It's not released yet, but give it a look :) (v0.1 is almost done)
In that sense, jury nullification can be impartial.
If they can't convince other jurors, no "harm" done. If they can, then perhaps the law is overkill. The judge seems to be overpowered here.
The more compelling use case is for clients to cache the receipts of particular transactions so they can replay them on other services. For example, if the user decides to migrate their data to a competing service.
Also, the receipts act as proof of tampering (or lack thereof), since they are signed by the Vapor node.