{"library":"protocol-buffers-schema","title":"Protocol Buffers Schema Parser","description":"protocol-buffers-schema is a minimalist JavaScript library designed for parsing Protocol Buffers (.proto) schema files into a structured JavaScript object and stringifying such objects back into the .proto format. It explicitly focuses on schema definition parsing rather than binary serialization or deserialization of actual Protobuf messages. The current stable version is 3.6.1, though the last npm publication (for 3.6.0) was approximately four years ago, suggesting a maintenance mode with an infrequent release cadence, if any. Its primary differentiator is its straightforward API for schema manipulation, contrasting with more comprehensive Protobuf libraries that include code generation, runtime encoding/decoding, and gRPC support. This package serves as a foundational component for tools that need to inspect or modify Protobuf definitions programmatically.","language":"javascript","status":"maintenance","last_verified":"Sun Apr 19","install":{"commands":["npm install protocol-buffers-schema"],"cli":null},"imports":["import schema from 'protocol-buffers-schema'","import schema from 'protocol-buffers-schema'; schema.parse(protoString);","const schema = require('protocol-buffers-schema'); schema.stringify(schemaObject);"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { readFileSync } from 'fs';\nimport schema from 'protocol-buffers-schema';\n\n// Create a dummy .proto file for demonstration\nconst protoContent = `\nsyntax = \"proto2\";\n\nmessage Point {\n  required int32 x = 1;\n  required int32 y = 2;\n  optional string label = 3;\n}\n\nmessage Line {\n  required Point start = 1;\n  required Point end = 2;\n  optional string label = 3;\n}\n`;\n\n// In a real scenario, this would be fs.writeFileSync('example.proto', protoContent);\n// For this quickstart, we'll parse the string directly.\n\n// Parse the .proto schema\nconst parsedSchema = schema.parse(protoContent);\n\n// Log the parsed JavaScript object representation of the schema\nconsole.log('Parsed Protobuf Schema:');\nconsole.log(JSON.stringify(parsedSchema, null, 2));\n\n// You can also stringify it back to .proto format\nconst stringifiedSchema = schema.stringify(parsedSchema);\nconsole.log('\\nStringified Protobuf Schema (reconstructed):');\nconsole.log(stringifiedSchema);\n\n// Example of accessing elements\nconsole.log('\\nFirst message name:', parsedSchema.messages[0].name);\nconsole.log('First field of first message:', parsedSchema.messages[0].fields[0].name);","lang":"javascript","description":"Demonstrates parsing a Protobuf schema string into a JavaScript object and then stringifying it back, also showing how to access parsed schema elements.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}