1.26.0 • Published 1 year ago

@launchql/proto-cli v1.26.0

Weekly downloads
-
License
SEE LICENSE IN LI...
Repository
github
Last release
1 year ago

@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

OptionDescriptionDefault Value
--inFilePath to the .proto file to be parsed.Required
--outDirDirectory to save the generated TypeScript files.Required
--enumsGenerate TypeScript enum types for PostgreSQL enums.false
--enumsJSONGenerate JSON files mapping enum names to values.false
--typeUnionGenerate TypeScript unions from enum types.false
--headerInclude a header in the generated TypeScript files to aid in integration.false
--typesGenerate TypeScript interfaces for protobuf messages.false
--utilsGenerate TypeScript utility functions for enums.false
--caseKeep field casing as defined in the protobuf file. If false, fields will be converted to camelCase.false
--optionalGenerate TypeScript interfaces with optional fields.false
--removeUndefinedRemove the 'UNDEFINED' enum entry if it exists.false
--help, -hShow this help message and exit.
--version, -vShow 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

OptionDescriptionDefault Value
--protoUrlFull URL to download the proto file (optional).
--inFilePath where the proto file will be saved or path to an existing proto file.Required
--outFilePath where the generated JavaScript file will be saved.Required
--originalPackageNameOriginal package name to be replaced in the JS file.protobufjs/minimal
--newPackageNameNew package name to replace in the JS file.@launchql/protobufjs/minimal
--help, -hShow this help message.
--version, -vShow 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.

1.26.0

1 year ago

1.25.0

1 year ago

1.24.0

1 year ago

1.19.0

1 year ago

1.19.2

1 year ago

1.19.1

1 year ago

1.21.0

1 year ago

1.22.0

1 year ago

1.20.0

1 year ago

1.23.2

1 year ago

1.23.0

1 year ago

1.22.1

1 year ago

1.23.1

1 year ago

1.18.0

1 year ago

1.15.0

1 year ago

1.14.0

1 year ago

1.17.0

1 year ago

1.16.1

1 year ago

1.15.2

1 year ago

1.16.0

1 year ago

1.15.1

1 year ago

1.13.2

1 year ago

1.13.1

1 year ago

1.13.0

1 year ago

1.12.2

1 year ago

1.12.1

1 year ago

1.12.0

1 year ago

1.11.1

1 year ago

1.11.0

1 year ago

1.10.0

1 year ago

1.8.1

1 year ago

1.8.0

1 year ago

1.7.0

1 year ago

1.6.0

1 year ago

1.5.1

1 year ago

1.5.0

1 year ago

1.4.1

1 year ago

1.4.0

1 year ago

1.3.0

1 year ago

1.2.0

1 year ago

1.1.0

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.3.0

1 year ago

0.2.0

1 year ago

0.1.0

1 year ago

0.0.5

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago