Data Modelling SDK
Shared SDK for model operations across platforms (API, WASM, Native).
Copyright (c) 2025 Mark Olliver - Licensed under MIT
Features
- Storage Backends: File system, browser storage (IndexedDB/localStorage), and HTTP API
- Model Loading/Saving: Load and save models from various storage backends
- Import/Export: Import from SQL, ODCL, JSON Schema, AVRO, Protobuf; Export to various formats
- Validation: Table and relationship validation (naming conflicts, circular dependencies)
Usage
File System Backend (Native Apps)
use FileSystemStorageBackend;
use ModelLoader;
let storage = new;
let loader = new;
let result = loader.load_model.await?;
Browser Storage Backend (WASM Apps)
use BrowserStorageBackend;
use ModelLoader;
let storage = new;
let loader = new;
let result = loader.load_model.await?;
API Backend (Online Mode)
use ApiStorageBackend;
use ModelLoader;
let storage = new;
let loader = new;
let result = loader.load_model.await?;
WASM Bindings (Browser/Offline Mode)
The SDK exposes WASM bindings for parsing and export operations, enabling offline functionality in web applications.
Build the WASM module:
Use in JavaScript/TypeScript:
import init from './pkg/data_modelling_sdk.js';
// Initialize the module
await ;
// Parse ODCS YAML
const yaml = `apiVersion: v3.1.0
kind: DataContract
name: users
schema:
fields:
- name: id
type: bigint`;
const resultJson = ;
const result = JSON.;
console.log;
// Export to ODCS YAML
const workspace = ;
const exportedYaml = ;
console.log;
Available WASM Functions:
parseOdcsYaml(yamlContent: string): string- Parse ODCS YAML to workspace structureexportToOdcsYaml(workspaceJson: string): string- Export workspace to ODCS YAMLimportFromSql(sqlContent: string, dialect: string): string- Import from SQLimportFromAvro(avroContent: string): string- Import from AVRO schemaimportFromJsonSchema(jsonSchemaContent: string): string- Import from JSON SchemaimportFromProtobuf(protobufContent: string): string- Import from ProtobufexportToSql(workspaceJson: string, dialect: string): string- Export to SQLexportToAvro(workspaceJson: string): string- Export to AVRO schemaexportToJsonSchema(workspaceJson: string): string- Export to JSON SchemaexportToProtobuf(workspaceJson: string): string- Export to Protobuf
Development
Pre-commit Hooks
This project uses pre-commit hooks to ensure code quality. Install them with:
# Install pre-commit (if not already installed)
# Install the git hooks
# Run hooks manually on all files
The hooks will automatically run on git commit and check:
- Rust formatting (
cargo fmt) - Rust linting (
cargo clippy) - Security audit (
cargo audit) - File formatting (trailing whitespace, end of file, etc.)
- YAML/TOML/JSON syntax
CI/CD
GitHub Actions workflows automatically run on push and pull requests:
- Lint: Format check, clippy, and security audit
- Test: Unit and integration tests on Linux, macOS, and Windows
- Build: Release build verification
- Publish: Automatic publishing to crates.io on main branch (after all checks pass)
Status
The SDK structure is in place. The actual implementation of import/export/validation logic is being migrated incrementally from the parent crate. Currently, the SDK provides:
- ✅ Storage backend abstraction and implementations
- ✅ Model loader/saver structure
- ✅ Import/export module structure
- ✅ Validation module structure
- ⏳ Full implementation of parsers/exporters (in progress)