npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@launchql/proto-cli

v1.26.0

Published

The LaunchQL PG Proto parser

Downloads

111

Readme

@launchql/proto-cli

@launchql/proto-cli is a command-line interface to facilitate the parsing of pganalyze/libpg_query PostgreSQL query protobufs into structured TypeScript definitions and utilities. Designed to work with launchql/pgsql-parser for maintainable upgrades.

Installation

npm install -g @launchql/proto-cli

Getting Started

First, download the latest protobuf definition from libpg_query:

wget https://raw.githubusercontent.com/pganalyze/libpg_query/16-latest/protobuf/pg_query.proto

Run the CLI to parse the protobuf file and generate TypeScript outputs:

pg-proto-parser --inFile pg_query.proto --outDir out

Features

  • Converts PostgreSQL protobuf files to TypeScript definitions.
  • Automatically generates enums, interfaces, and utility functions from protobufs.
  • Supports custom output directories for generated files.

Usage

After installation, you can run the pg-proto-parser command for code generation as follows:

codegen

pg-proto-parser codegen --inFile <path-to-proto> --outDir <output-directory> \
                        [--enums] [--enumsJSON] [--typeUnion] \
                        [--header] [--types] [--utils] \
                        [--case] [--optional] [--removeUndefined]

Options for codegen

| Option | Description | Default Value | |---------------------|---------------------------------------------------------------------------------------------------------------------------|---------------| | --inFile | Path to the .proto file to be parsed. | Required | | --outDir | Directory to save the generated TypeScript files. | Required | | --enums | Generate TypeScript enum types for PostgreSQL enums. | false | | --enumsJSON | Generate JSON files mapping enum names to values. | false | | --typeUnion | Generate TypeScript unions from enum types. | false | | --header | Include a header in the generated TypeScript files to aid in integration. | false | | --types | Generate TypeScript interfaces for protobuf messages. | false | | --utils | Generate TypeScript utility functions for enums. | false | | --case | Keep field casing as defined in the protobuf file. If false, fields will be converted to camelCase. | false | | --optional | Generate TypeScript interfaces with optional fields. | false | | --removeUndefined | Remove the 'UNDEFINED' enum entry if it exists. | false | | --help, -h | Show this help message and exit. | | | --version, -v | Show the version number and exit. | |

To explicitly set a boolean option to false, prepend the option with --no-. For example, to disable JSON enum mapping, use --no-enumsJSON.

protogen

You can also generate code using the protogen command:

pg-proto-parser protogen --protoUrl <URL to proto file> \
                         --inFile <path to proto file> \
                         --outFile <path to output JS file> \
                         --originalPackageName <original package name> \
                         --newPackageName <new package name>

Options for protogen

| Option | Description | Default Value | |-------------------------|-------------------------------------------------------------------------------------|---------------| | --protoUrl | Full URL to download the proto file (optional). | | | --inFile | Path where the proto file will be saved or path to an existing proto file. | Required | | --outFile | Path where the generated JavaScript file will be saved. | Required | | --originalPackageName | Original package name to be replaced in the JS file. | protobufjs/minimal | | --newPackageName | New package name to replace in the JS file. | @launchql/protobufjs/minimal | | --help, -h | Show this help message. | | | --version, -v | Show the version number. | |

Related

  • launchql/pgsql-parser: A node.js PostgreSQL parser/deparser that interprets and converts PostgresSQL syntax.
  • launchql/libpg-query-node: Node.js bindings for the libpg_query library, allowing parsing of PostgreSQL queries into parse trees.
  • @pgsql/enums: Provides PostgreSQL AST enums in TypeScript, enhancing type safety and usability in projects interacting with PostgreSQL AST nodes.
  • @pgsql/types: Offers TypeScript type definitions for PostgreSQL AST nodes, facilitating type-safe construction, analysis, and manipulation of ASTs.
  • @pgsql/utils: A comprehensive utility library for PostgreSQL, offering type-safe AST node creation and enum value conversions, simplifying the construction and manipulation of PostgreSQL ASTs.

Disclaimer

AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED “AS IS”, AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.

No developer or entity involved in creating Software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the Software code or Software CLI, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.