npm.io
1.0.0 • Published 11 years agoCLI

protobufit

Licence
ISC
Version
1.0.0
Deps
4
Vulns
0
Weekly
0
Stars
2

protobufit

Converts various schema types into Protocol Buffers format (v2).

Supports:

Yes, this handles:

  • Multiple schema definitions in a single file
  • Tries to auto-detect the given schema format if not specified
  • required and repeated
npm install -g protobufit

CLI usage

protobufit [input-file] [-f <format>]
  <format>: 'sql' or 'jsonschema'

Example

protobufit schema.sql -f sql > schema.proto

schema.sql

CREATE TABLE "pluto" (
  "boroughtext" text,
  "block" integer,
  "lot" bigint,
  "cd" date NOT NULL,
);

schema.proto

syntax = "proto2";

message pluto {
  optional string boroughtext = 1;
  optional int32 block = 2;
  optional int64 lot = 3;
  required string cd = 4;
JS usage
var protobufit = require('protobufit')
var data = fs.readFileSync('schema.sql').toString()
var opts = {format: 'sql'}
console.log(protobufit(data, opts))
TODO
  • datapackage.json
  • Rdata?