{"id":18639,"library":"ord-schema-protobufjs","title":"Open Reaction Database Schema (JavaScript)","description":"Compiled protobuf definitions for the Open Reaction Database, a structured format for capturing organic reaction data. This npm package (v0.5.1) provides the generated protobuf messages (e.g., Reaction, Compound) for Node.js and browser via protobuf.js. Updated irregularly alongside the ORD schema. Key differentiator: enables programmatic access to the standardized ORD schema for reaction data interchange, supporting datasets, conditions, outcomes, and analyses. Used for reading/writing reaction records, validating against the ORD spec, and integrating with ORD-compatible datasets. Ships TypeScript declarations.","status":"active","version":"0.5.1","language":"javascript","source_language":"en","source_url":"https://github.com/open-reaction-database/ord-schema","tags":["javascript","typescript"],"install":[{"cmd":"npm install ord-schema-protobufjs","lang":"bash","label":"npm"},{"cmd":"yarn add ord-schema-protobufjs","lang":"bash","label":"yarn"},{"cmd":"pnpm add ord-schema-protobufjs","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Runtime dependency for protobuf message serialization/deserialization","package":"protobufjs","optional":false},{"reason":"Needed for 64-bit integer support in protobuf.js in certain environments","package":"long","optional":true}],"imports":[{"note":"Package uses protobuf.js static code generation; ESM import is preferred in Node 12+.","wrong":"const { Reaction } = require('ord-schema-protobufjs')","symbol":"Reaction","correct":"import { Reaction } from 'ord-schema-protobufjs'"},{"note":"Named exports are available directly; no need for namespace import.","wrong":"import * as ord from 'ord-schema-protobufjs'; const Compound = ord.Compound","symbol":"Compound","correct":"import { Compound } from 'ord-schema-protobufjs'"},{"note":"Default export gives access to the root protobuf object; use for loading descriptors or custom usage.","wrong":"const ordSchema = require('ord-schema-protobufjs')","symbol":"ordSchema","correct":"import ordSchema from 'ord-schema-protobufjs'"}],"quickstart":{"code":"import { Reaction, Compound } from 'ord-schema-protobufjs';\n\n// Create a new Reaction message\nconst reaction = Reaction.create({\n  identifiers: [{ value: 'OCCO', type: Compound.CompoundIdentifier.SMILES }],\n  inputs: {\n    'substrate': {\n      components: [{\n        substance: {\n          identifiers: [{ value: 'CCO', type: Compound.CompoundIdentifier.SMILES }]\n        }\n      }]\n    }\n  },\n  conditions: {\n    temperature: { setpoint: { value: 80, units: 'CELSIUS' } },\n    time: { duration: { value: 2, units: 'HOUR' } }\n  }\n});\n\n// Verify the message\nconst err = Reaction.verify(reaction);\nif (err) throw Error(err);\n\n// Encode to binary\nconst buffer = Reaction.encode(reaction).finish();\nconsole.log('Encoded length:', buffer.length);\n\n// Decode back\nconst decoded = Reaction.decode(buffer);\nconsole.log('Decoded reaction temperature:', decoded.conditions?.temperature?.setpoint?.value);","lang":"typescript","description":"Creates a simple reaction with SMILES identifiers, conditions, and demonstrates encode/decode round-trip."},"warnings":[{"fix":"Update calls to write_dataset(..., { format: 'parquet' }) to match new signature.","message":"In v0.5.0, the 'write_dataset' function signature changed from (dataset, path) to (dataset, path, options).","severity":"breaking","affected_versions":">=0.5.0"},{"fix":"Migrate to DatasetView and write_dataset for Parquet support.","message":"The 'Dataset' message may be replaced by 'DatasetView' in future versions; use DatasetView for new code.","severity":"deprecated","affected_versions":">=0.5.0"},{"fix":"Always reference enum fields like Compound.CompoundIdentifier.SMILES instead of 'SMILES'.","message":"Compound.CompoundIdentifier enumeration values are integers; using string literals will fail validation.","severity":"gotcha","affected_versions":"*"},{"fix":"Use Reaction.create() to ensure correct structure; avoid raw object assignment.","message":"The Reaction message requires nested objects to match proto schema exactly; extra fields will be ignored or throw in strict mode.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use the .create() static method to construct the message: Reaction.create(obj) instead of plain obj.","cause":"Passing a plain JavaScript object to a method that expects a protobuf message instance.","error":"Error: Invalid type: expected Message, got Object"},{"fix":"Use named import: import { Reaction } from 'ord-schema-protobufjs'.","cause":"Importing the package incorrectly (e.g., using namespace import instead of named import).","error":"TypeError: Reaction.verify is not a function"},{"fix":"Use the numeric enum value from the generated constants, e.g., Temperature.TemperatureUnit.CELSIUS.","cause":"Using a string that does not match the exact enum value (e.g., 'CELSIUS' vs 'CELCIUS' typo).","error":"Error: Value for field 'units' is not a valid enum value."},{"fix":"Run: npm install ord-schema-protobufjs --save","cause":"Missing dependency or incorrect npm install.","error":"Module not found: Can't resolve 'ord-schema-protobufjs'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}