
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
@potygen/cli
Advanced tools
Command line tool for generating types for potygen
yarn add --dev @potygen/cli
If we had sql string templates like this:
import { sql } from '@potygen/potygen';
import { Client } from 'pg';
const db = new Client(process.env.POSTGRES_CONNECTION);
async function main() {
await db.connect();
const productsSql = sql`SELECT product FROM orders WHERE region = $region`;
const data = await productsSql(db, { region: 'Sofia' });
console.log(data);
await db.end();
}
main();
We could then run the potygen cli tool to generate types for them
yarn potygen -n postgres://localhost:5432/postgres examples/simple.ts
After that you can import the types and use them, which will type both parameters of the query as well as the results
import { sql } from '@potygen/potygen';
import { Client } from 'pg';
import { ProductsSqlQuery } from './simple-typed.queries';
const db = new Client(process.env.POSTGRES_CONNECTION);
async function main() {
await db.connect();
const productsSql = sql<ProductsSqlQuery>`SELECT product FROM orders WHERE region = $region`;
const data = await productsSql(db, { region: 'Sofia' });
console.log(data);
await db.end();
}
main();
You can define potygen.config.json or provide a json file to the --config property. The full list of parameters are:
Usage: potygen [options]
Convert postgres query files inty typescript types
Options:
-V, --version output the version number
-c, --config <config> A configuration file to load (default: "potygen.config.json")
-f, --files <files> A glob pattern to search files by (default: "**/*.sql")
-w, --watch Watch for file changes and update live
-v, --verbose Show verbose logs
-s, --silent Only show error logs
-p, --typePrefix <typePrefix> Prefix generated types
-r, --root <root> Set the root directory (default: /Users/ivank/Projects/potygen/packages/cli)
-n, --connection <connection> Connection to the postgres database. URI (default: "postgres://localhost:5432/db")
-t, --template <template> A template of the path, where to generate the typescript type files. The parameters are the response from node's path.parse function (default:
"{{dir}}/{{name}}.queries.ts")
-h, --help display help for command
FAQs
Command line interface for potygen (Postgres Typescript Generator)
The npm package @potygen/cli receives a total of 23 weekly downloads. As such, @potygen/cli popularity was classified as not popular.
We found that @potygen/cli demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.