@opencdd/models
v0.1.0
Published
TypeScript value-object layer + validators for OpenCDD CDD — shared between browser and editor.
Maintainers
Readme
@opencdd/models
TypeScript value-object layer + validators for OpenCDD CDD. The shared model layer between the OpenCDD Browser and the OpenCDD Editor. A TypeScript port of the canonical Ruby cdd gem's model + validator surface.
What's in here
- Value objects —
Entity,Klass,Property,Unit,ValueList,ValueTerm,Relation,ViewControl,AliasTable,MetaClass,ClassType,PropertyDataTypeElement,ValueFormat,IRDI,DataType(withSimpleDataType,RealMeasureType,IntegerMeasureType,ClassReference,EnumStringType,EnumReferenceType). - Database — in-memory store with
finalize,merge,renameEntity,removeEntity,propertiesOf, semantic equality. - Tree walkers —
ClassTree,RelationTree,CompositionTree,EffectiveProperties. - Utilities —
Guid,InstanceRule,StructuredValues(7 parser/serializer pairs). - CDDAL — plain-text canonical format:
Lexer,Parser,Serializer,Builder,DatabaseSerializer. - Parcel — sheet schema:
ParcelMetadata,SheetSchema,Sheet,Workbook,canonicalParcelId. - Exporters —
JsonExporter,YamlExporter,MermaidExporter,CsvWriter(browser-friendly ports of the Ruby exporters). - Validators (exported as
Validators.*) — TS Runner + all Ruby rules R01–R14, including the R14 composition-cycle check.
Install
npm install @opencdd/modelsQuick example
import { Klass, Property, Database, ENTITY_CONSTRUCTORS } from "@opencdd/models";
const klass = new Klass({
irdi: "0112/2///61360_4#AAA001",
code: "AAA001",
preferredName: "Vehicle",
});
const db = new Database();
db.addEntity(klass);
db.finalize();
console.log(db.classes.size); // 1Codegen provenance
src/models/PropertyIds.generated.ts and src/models/MetaClasses.generated.ts are generated by the Ruby cdd gem's rake generate_ts task, which writes them into this repo via a git submodule of cdd-data. Do not hand-edit. See TODO.astro/02 for the codegen contract.
Versioning
Semver. The model layer mirrors the Ruby gem's semantics; breaking changes to the gem's public API surface are breaking changes here.
License
MIT. See LICENSE.
