
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
resolve-protobuf-schema
Advanced tools
Read a protobuf schema from the disk, parse it and resolve all imports
The resolve-protobuf-schema npm package is used to parse and resolve Protocol Buffers (protobuf) schema definitions. It helps in converting .proto files into JavaScript objects that can be used for further processing or validation.
Parsing .proto files
This feature allows you to read and parse a .proto file into a JavaScript object. The parsed schema can then be used for various purposes such as validation or code generation.
const fs = require('fs');
const resolve = require('resolve-protobuf-schema');
const schema = resolve(fs.readFileSync('path/to/your.proto', 'utf-8'));
console.log(schema);
Resolving imports in .proto files
This feature allows you to resolve imports within .proto files. If your .proto file imports other .proto files, you can provide a custom resolveImport function to handle these imports.
const fs = require('fs');
const resolve = require('resolve-protobuf-schema');
const schema = resolve(fs.readFileSync('path/to/your.proto', 'utf-8'), {
resolveImport: (importPath) => fs.readFileSync(importPath, 'utf-8')
});
console.log(schema);
protobufjs is a comprehensive library for working with Protocol Buffers in JavaScript. It provides functionality for parsing .proto files, generating static code, and runtime message encoding/decoding. Compared to resolve-protobuf-schema, protobufjs offers a broader range of features including message serialization and deserialization.
proto-loader is a package that works with grpc and allows you to load .proto files into JavaScript objects. It supports resolving imports and is often used in conjunction with grpc libraries. While it offers similar schema resolution capabilities, it is more focused on gRPC service definitions and usage.
Read a protobuf schema from the disk, parse it and resolve all imports
npm install resolve-protobuf-schema
Store the following example protobuf schema in test.proto
message Test {
optional string test = 1;
}
Then run
var resolve = require('resolve-protobuf-schema')
console.log(resolve.sync('test.proto')) // prints the parsed schema
Schema imports will resolved as well
import "./test.proto"
message AnotherTest {
optional string test = 1;
}
console.log(resolve.sync('./another-test.proto')) // will print a combined parsed schema
resolve(path, cb)
read and resolve a schemaresolve.sync(path)
sync version of resolve
MIT
FAQs
Read a protobuf schema from the disk, parse it and resolve all imports
The npm package resolve-protobuf-schema receives a total of 1,459,359 weekly downloads. As such, resolve-protobuf-schema popularity was classified as popular.
We found that resolve-protobuf-schema 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
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.