@offenedatenmodellierung/data-modelling-sdk 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +457 -0
- package/data_modelling_sdk.d.ts +1348 -0
- package/data_modelling_sdk.js +3773 -0
- package/data_modelling_sdk_bg.wasm +0 -0
- package/package.json +35 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Mark Olliver
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
# Data Modelling SDK
|
|
2
|
+
|
|
3
|
+
Shared SDK for model operations across platforms (API, WASM, Native).
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2025 Mark Olliver - Licensed under MIT
|
|
6
|
+
|
|
7
|
+
## CLI Tool
|
|
8
|
+
|
|
9
|
+
The SDK includes a command-line interface (CLI) for importing and exporting schemas. See [CLI.md](CLI.md) for detailed usage instructions.
|
|
10
|
+
|
|
11
|
+
**Quick Start:**
|
|
12
|
+
```bash
|
|
13
|
+
# Build the CLI (with OpenAPI and ODPS validation support)
|
|
14
|
+
cargo build --release --bin data-modelling-cli --features cli,openapi,odps-validation
|
|
15
|
+
|
|
16
|
+
# Run it
|
|
17
|
+
./target/release/data-modelling-cli --help
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
**Note:** The CLI now includes OpenAPI support by default in GitHub releases. For local builds, include the `openapi` feature to enable OpenAPI import/export. Include `odps-validation` to enable ODPS schema validation.
|
|
21
|
+
|
|
22
|
+
**ODPS Import/Export Examples:**
|
|
23
|
+
```bash
|
|
24
|
+
# Import ODPS YAML file
|
|
25
|
+
data-modelling-cli import odps product.odps.yaml
|
|
26
|
+
|
|
27
|
+
# Export ODCS to ODPS format
|
|
28
|
+
data-modelling-cli export odps input.odcs.yaml output.odps.yaml
|
|
29
|
+
|
|
30
|
+
# Test ODPS round-trip (requires odps-validation feature)
|
|
31
|
+
cargo run --bin test-odps --features odps-validation,cli -- product.odps.yaml --verbose
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Features
|
|
35
|
+
|
|
36
|
+
- **Storage Backends**: File system, browser storage (IndexedDB/localStorage), and HTTP API
|
|
37
|
+
- **Database Backends**: DuckDB (embedded) and PostgreSQL for high-performance queries
|
|
38
|
+
- **Model Loading/Saving**: Load and save models from various storage backends
|
|
39
|
+
- **Import/Export**: Import from SQL (PostgreSQL, MySQL, SQLite, Generic, Databricks), ODCS, ODCL, JSON Schema, AVRO, Protobuf (proto2/proto3), CADS, ODPS, BPMN, DMN, OpenAPI; Export to various formats
|
|
40
|
+
- **Decision Records (DDL)**: MADR-compliant Architecture Decision Records with full lifecycle management
|
|
41
|
+
- **Knowledge Base (KB)**: Domain-partitioned knowledge articles with Markdown content support
|
|
42
|
+
- **Business Domain Schema**: Organize systems, CADS nodes, and ODCS nodes within business domains
|
|
43
|
+
- **Universal Converter**: Convert any format to ODCS v3.1.0 format
|
|
44
|
+
- **OpenAPI to ODCS Converter**: Convert OpenAPI schema components to ODCS table definitions
|
|
45
|
+
- **Validation**: Table and relationship validation (naming conflicts, circular dependencies)
|
|
46
|
+
- **Relationship Modeling**: Crow's feet notation cardinality (zeroOrOne, exactlyOne, zeroOrMany, oneOrMany) and data flow directions
|
|
47
|
+
- **Schema Reference**: JSON Schema definitions for all supported formats in `schemas/` directory
|
|
48
|
+
- **Database Sync**: Bidirectional sync between YAML files and database with change detection
|
|
49
|
+
- **Git Hooks**: Automatic pre-commit and post-checkout hooks for database synchronization
|
|
50
|
+
|
|
51
|
+
## Decision Records (DDL)
|
|
52
|
+
|
|
53
|
+
The SDK includes full support for **Architecture Decision Records** following the MADR (Markdown Any Decision Records) format. Decisions are stored as YAML files and can be exported to Markdown for documentation.
|
|
54
|
+
|
|
55
|
+
### Decision File Structure
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
workspace/
|
|
59
|
+
├── decisions/
|
|
60
|
+
│ ├── index.yaml # Decision index with metadata
|
|
61
|
+
│ ├── 0001-use-postgresql-database.yaml # Individual decision records
|
|
62
|
+
│ ├── 0002-adopt-microservices.yaml
|
|
63
|
+
│ └── ...
|
|
64
|
+
└── decisions-md/ # Markdown exports (auto-generated)
|
|
65
|
+
├── 0001-use-postgresql-database.md
|
|
66
|
+
└── 0002-adopt-microservices.md
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Decision Lifecycle
|
|
70
|
+
|
|
71
|
+
Decisions follow a defined lifecycle with these statuses:
|
|
72
|
+
- **Draft**: Initial proposal, open for discussion
|
|
73
|
+
- **Proposed**: Formal proposal awaiting decision
|
|
74
|
+
- **Accepted**: Approved and in effect
|
|
75
|
+
- **Deprecated**: No longer recommended but still valid
|
|
76
|
+
- **Superseded**: Replaced by a newer decision
|
|
77
|
+
- **Rejected**: Not approved
|
|
78
|
+
|
|
79
|
+
### Decision Categories
|
|
80
|
+
|
|
81
|
+
- **Architecture**: System design and structure decisions
|
|
82
|
+
- **Technology**: Technology stack and tool choices
|
|
83
|
+
- **Process**: Development workflow decisions
|
|
84
|
+
- **Security**: Security-related decisions
|
|
85
|
+
- **Data**: Data modeling and storage decisions
|
|
86
|
+
- **Integration**: External system integration decisions
|
|
87
|
+
|
|
88
|
+
### CLI Commands
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
# Create a new decision
|
|
92
|
+
data-modelling-cli decision new --title "Use PostgreSQL" --domain platform
|
|
93
|
+
|
|
94
|
+
# List all decisions
|
|
95
|
+
data-modelling-cli decision list --workspace ./my-workspace
|
|
96
|
+
|
|
97
|
+
# Show a specific decision
|
|
98
|
+
data-modelling-cli decision show 1 --workspace ./my-workspace
|
|
99
|
+
|
|
100
|
+
# Filter by status or category
|
|
101
|
+
data-modelling-cli decision list --status accepted --category architecture
|
|
102
|
+
|
|
103
|
+
# Export decisions to Markdown
|
|
104
|
+
data-modelling-cli decision export --workspace ./my-workspace
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Knowledge Base (KB)
|
|
108
|
+
|
|
109
|
+
The SDK provides a **Knowledge Base** system for storing domain knowledge, guides, and documentation as structured articles.
|
|
110
|
+
|
|
111
|
+
### Knowledge Base File Structure
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
workspace/
|
|
115
|
+
├── knowledge/
|
|
116
|
+
│ ├── index.yaml # Knowledge index with metadata
|
|
117
|
+
│ ├── 0001-api-authentication-guide.yaml # Individual knowledge articles
|
|
118
|
+
│ ├── 0002-deployment-procedures.yaml
|
|
119
|
+
│ └── ...
|
|
120
|
+
└── knowledge-md/ # Markdown exports (auto-generated)
|
|
121
|
+
├── 0001-api-authentication-guide.md
|
|
122
|
+
└── 0002-deployment-procedures.md
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Article Types
|
|
126
|
+
|
|
127
|
+
- **Guide**: Step-by-step instructions and tutorials
|
|
128
|
+
- **Reference**: API documentation and technical references
|
|
129
|
+
- **Concept**: Explanations of concepts and principles
|
|
130
|
+
- **Tutorial**: Learning-focused content with examples
|
|
131
|
+
- **Troubleshooting**: Problem-solving guides
|
|
132
|
+
- **Runbook**: Operational procedures
|
|
133
|
+
|
|
134
|
+
### Article Status
|
|
135
|
+
|
|
136
|
+
- **Draft**: Work in progress
|
|
137
|
+
- **Review**: Ready for peer review
|
|
138
|
+
- **Published**: Approved and available
|
|
139
|
+
- **Archived**: No longer actively maintained
|
|
140
|
+
- **Deprecated**: Outdated, pending replacement
|
|
141
|
+
|
|
142
|
+
### CLI Commands
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
# Create a new knowledge article
|
|
146
|
+
data-modelling-cli knowledge new --title "API Authentication Guide" --domain platform --type guide
|
|
147
|
+
|
|
148
|
+
# List all articles
|
|
149
|
+
data-modelling-cli knowledge list --workspace ./my-workspace
|
|
150
|
+
|
|
151
|
+
# Show a specific article
|
|
152
|
+
data-modelling-cli knowledge show 1 --workspace ./my-workspace
|
|
153
|
+
|
|
154
|
+
# Filter by type, status, or domain
|
|
155
|
+
data-modelling-cli knowledge list --type guide --status published
|
|
156
|
+
|
|
157
|
+
# Search article content
|
|
158
|
+
data-modelling-cli knowledge search "authentication" --workspace ./my-workspace
|
|
159
|
+
|
|
160
|
+
# Export articles to Markdown
|
|
161
|
+
data-modelling-cli knowledge export --workspace ./my-workspace
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## File Structure
|
|
165
|
+
|
|
166
|
+
The SDK organizes files using a flat file naming convention within a workspace:
|
|
167
|
+
|
|
168
|
+
```
|
|
169
|
+
workspace/
|
|
170
|
+
├── .git/ # Git folder (if present)
|
|
171
|
+
├── README.md # Repository files
|
|
172
|
+
├── workspace.yaml # Workspace metadata with assets and relationships
|
|
173
|
+
├── myworkspace_sales_customers.odcs.yaml # ODCS table: workspace_domain_resource.type.yaml
|
|
174
|
+
├── myworkspace_sales_orders.odcs.yaml # Another ODCS table in sales domain
|
|
175
|
+
├── myworkspace_sales_crm_leads.odcs.yaml # ODCS table with system: workspace_domain_system_resource.type.yaml
|
|
176
|
+
├── myworkspace_analytics_metrics.odps.yaml # ODPS product file
|
|
177
|
+
├── myworkspace_platform_api.cads.yaml # CADS asset file
|
|
178
|
+
├── myworkspace_platform_api.openapi.yaml # OpenAPI specification file
|
|
179
|
+
├── myworkspace_ops_approval.bpmn.xml # BPMN process model file
|
|
180
|
+
└── myworkspace_ops_routing.dmn.xml # DMN decision model file
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### File Naming Convention
|
|
184
|
+
|
|
185
|
+
Files follow the pattern: `{workspace}_{domain}_{system}_{resource}.{type}.{ext}`
|
|
186
|
+
|
|
187
|
+
- **workspace**: The workspace name (required)
|
|
188
|
+
- **domain**: The business domain (required)
|
|
189
|
+
- **system**: The system within the domain (optional)
|
|
190
|
+
- **resource**: The resource/asset name (required)
|
|
191
|
+
- **type**: The asset type (`odcs`, `odps`, `cads`, `openapi`, `bpmn`, `dmn`)
|
|
192
|
+
- **ext**: File extension (`yaml`, `xml`, `json`)
|
|
193
|
+
|
|
194
|
+
### Workspace-Level Files
|
|
195
|
+
|
|
196
|
+
- `workspace.yaml`: Workspace metadata including domains, systems, asset references, and relationships
|
|
197
|
+
|
|
198
|
+
### Asset Types
|
|
199
|
+
|
|
200
|
+
- `*.odcs.yaml`: ODCS table/schema definitions (Open Data Contract Standard)
|
|
201
|
+
- `*.odps.yaml`: ODPS data product definitions (Open Data Product Standard)
|
|
202
|
+
- `*.cads.yaml`: CADS asset definitions (architecture assets)
|
|
203
|
+
- `*.openapi.yaml` / `*.openapi.json`: OpenAPI specification files
|
|
204
|
+
- `*.bpmn.xml`: BPMN 2.0 process model files
|
|
205
|
+
- `*.dmn.xml`: DMN 1.3 decision model files
|
|
206
|
+
|
|
207
|
+
## Usage
|
|
208
|
+
|
|
209
|
+
### File System Backend (Native Apps)
|
|
210
|
+
|
|
211
|
+
```rust
|
|
212
|
+
use data_modelling_sdk::storage::filesystem::FileSystemStorageBackend;
|
|
213
|
+
use data_modelling_sdk::model::ModelLoader;
|
|
214
|
+
|
|
215
|
+
let storage = FileSystemStorageBackend::new("/path/to/workspace");
|
|
216
|
+
let loader = ModelLoader::new(storage);
|
|
217
|
+
let result = loader.load_model("workspace_path").await?;
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### Browser Storage Backend (WASM Apps)
|
|
221
|
+
|
|
222
|
+
```rust
|
|
223
|
+
use data_modelling_sdk::storage::browser::BrowserStorageBackend;
|
|
224
|
+
use data_modelling_sdk::model::ModelLoader;
|
|
225
|
+
|
|
226
|
+
let storage = BrowserStorageBackend::new("db_name", "store_name");
|
|
227
|
+
let loader = ModelLoader::new(storage);
|
|
228
|
+
let result = loader.load_model("workspace_path").await?;
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### API Backend (Online Mode)
|
|
232
|
+
|
|
233
|
+
```rust
|
|
234
|
+
use data_modelling_sdk::storage::api::ApiStorageBackend;
|
|
235
|
+
use data_modelling_sdk::model::ModelLoader;
|
|
236
|
+
|
|
237
|
+
let storage = ApiStorageBackend::new("http://localhost:8081/api/v1", Some("session_id"));
|
|
238
|
+
let loader = ModelLoader::new(storage);
|
|
239
|
+
let result = loader.load_model("workspace_path").await?;
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### WASM Bindings (Browser/Offline Mode)
|
|
243
|
+
|
|
244
|
+
The SDK exposes WASM bindings for parsing and export operations, enabling offline functionality in web applications.
|
|
245
|
+
|
|
246
|
+
**Build the WASM module**:
|
|
247
|
+
```bash
|
|
248
|
+
wasm-pack build --target web --out-dir pkg --features wasm
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
**Use in JavaScript/TypeScript**:
|
|
252
|
+
```javascript
|
|
253
|
+
import init, { parseOdcsYaml, exportToOdcsYaml } from './pkg/data_modelling_sdk.js';
|
|
254
|
+
|
|
255
|
+
// Initialize the module
|
|
256
|
+
await init();
|
|
257
|
+
|
|
258
|
+
// Parse ODCS YAML
|
|
259
|
+
const yaml = `apiVersion: v3.1.0
|
|
260
|
+
kind: DataContract
|
|
261
|
+
name: users
|
|
262
|
+
schema:
|
|
263
|
+
fields:
|
|
264
|
+
- name: id
|
|
265
|
+
type: bigint`;
|
|
266
|
+
|
|
267
|
+
const resultJson = parseOdcsYaml(yaml);
|
|
268
|
+
const result = JSON.parse(resultJson);
|
|
269
|
+
console.log('Parsed tables:', result.tables);
|
|
270
|
+
|
|
271
|
+
// Export to ODCS YAML
|
|
272
|
+
const workspace = {
|
|
273
|
+
tables: [{
|
|
274
|
+
id: "550e8400-e29b-41d4-a716-446655440000",
|
|
275
|
+
name: "users",
|
|
276
|
+
columns: [{ name: "id", data_type: "bigint", nullable: false, primary_key: true }]
|
|
277
|
+
}],
|
|
278
|
+
relationships: []
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
const exportedYaml = exportToOdcsYaml(JSON.stringify(workspace));
|
|
282
|
+
console.log('Exported YAML:', exportedYaml);
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
**Available WASM Functions**:
|
|
286
|
+
|
|
287
|
+
**Import/Export**:
|
|
288
|
+
- `parseOdcsYaml(yamlContent: string): string` - Parse ODCS YAML to workspace structure
|
|
289
|
+
- `exportToOdcsYaml(workspaceJson: string): string` - Export workspace to ODCS YAML
|
|
290
|
+
- `importFromSql(sqlContent: string, dialect: string): string` - Import from SQL (supported dialects: "postgres"/"postgresql", "mysql", "sqlite", "generic", "databricks")
|
|
291
|
+
- `importFromAvro(avroContent: string): string` - Import from AVRO schema
|
|
292
|
+
- `importFromJsonSchema(jsonSchemaContent: string): string` - Import from JSON Schema
|
|
293
|
+
- `importFromProtobuf(protobufContent: string): string` - Import from Protobuf
|
|
294
|
+
- `importFromCads(yamlContent: string): string` - Import CADS (Compute Asset Description Specification) YAML
|
|
295
|
+
- `importFromOdps(yamlContent: string): string` - Import ODPS (Open Data Product Standard) YAML
|
|
296
|
+
- `exportToOdps(productJson: string): string` - Export ODPS data product to YAML format
|
|
297
|
+
- `validateOdps(yamlContent: string): void` - Validate ODPS YAML content against ODPS JSON Schema (requires `odps-validation` feature)
|
|
298
|
+
- `importBpmnModel(domainId: string, xmlContent: string, modelName?: string): string` - Import BPMN 2.0 XML model
|
|
299
|
+
- `importDmnModel(domainId: string, xmlContent: string, modelName?: string): string` - Import DMN 1.3 XML model
|
|
300
|
+
- `importOpenapiSpec(domainId: string, content: string, apiName?: string): string` - Import OpenAPI 3.1.1 specification
|
|
301
|
+
- `exportToSql(workspaceJson: string, dialect: string): string` - Export to SQL (supported dialects: "postgres"/"postgresql", "mysql", "sqlite", "generic", "databricks")
|
|
302
|
+
- `exportToAvro(workspaceJson: string): string` - Export to AVRO schema
|
|
303
|
+
- `exportToJsonSchema(workspaceJson: string): string` - Export to JSON Schema
|
|
304
|
+
- `exportToProtobuf(workspaceJson: string): string` - Export to Protobuf
|
|
305
|
+
- `exportToCads(workspaceJson: string): string` - Export to CADS YAML
|
|
306
|
+
- `exportToOdps(workspaceJson: string): string` - Export to ODPS YAML
|
|
307
|
+
- `exportBpmnModel(xmlContent: string): string` - Export BPMN model to XML
|
|
308
|
+
- `exportDmnModel(xmlContent: string): string` - Export DMN model to XML
|
|
309
|
+
- `exportOpenapiSpec(content: string, sourceFormat: string, targetFormat?: string): string` - Export OpenAPI spec with optional format conversion
|
|
310
|
+
- `convertToOdcs(input: string, format?: string): string` - Universal converter: convert any format to ODCS v3.1.0
|
|
311
|
+
- `convertOpenapiToOdcs(openapiContent: string, componentName: string, tableName?: string): string` - Convert OpenAPI schema component to ODCS table
|
|
312
|
+
- `analyzeOpenapiConversion(openapiContent: string, componentName: string): string` - Analyze OpenAPI component conversion feasibility
|
|
313
|
+
- `migrateDataflowToDomain(dataflowYaml: string, domainName?: string): string` - Migrate DataFlow YAML to Domain schema format
|
|
314
|
+
|
|
315
|
+
**Domain Operations**:
|
|
316
|
+
- `createDomain(name: string): string` - Create a new business domain
|
|
317
|
+
- `addSystemToDomain(workspaceJson: string, domainId: string, systemJson: string): string` - Add a system to a domain
|
|
318
|
+
- `addCadsNodeToDomain(workspaceJson: string, domainId: string, nodeJson: string): string` - Add a CADS node to a domain
|
|
319
|
+
- `addOdcsNodeToDomain(workspaceJson: string, domainId: string, nodeJson: string): string` - Add an ODCS node to a domain
|
|
320
|
+
|
|
321
|
+
**Filtering**:
|
|
322
|
+
- `filterNodesByOwner(workspaceJson: string, owner: string): string` - Filter tables by owner
|
|
323
|
+
- `filterRelationshipsByOwner(workspaceJson: string, owner: string): string` - Filter relationships by owner
|
|
324
|
+
- `filterNodesByInfrastructureType(workspaceJson: string, infrastructureType: string): string` - Filter tables by infrastructure type
|
|
325
|
+
- `filterRelationshipsByInfrastructureType(workspaceJson: string, infrastructureType: string): string` - Filter relationships by infrastructure type
|
|
326
|
+
- `filterByTags(workspaceJson: string, tag: string): string` - Filter nodes and relationships by tag (supports Simple, Pair, and List tag formats)
|
|
327
|
+
|
|
328
|
+
## Database Support
|
|
329
|
+
|
|
330
|
+
The SDK includes an optional database layer for high-performance queries on large workspaces (10-100x faster than file-based operations).
|
|
331
|
+
|
|
332
|
+
### Database Backends
|
|
333
|
+
|
|
334
|
+
- **DuckDB**: Embedded analytical database, ideal for CLI tools and local development
|
|
335
|
+
- **PostgreSQL**: Server-based database for team environments and shared access
|
|
336
|
+
|
|
337
|
+
### Quick Start
|
|
338
|
+
|
|
339
|
+
```bash
|
|
340
|
+
# Build CLI with database support
|
|
341
|
+
cargo build --release --bin data-modelling-cli --features cli-full
|
|
342
|
+
|
|
343
|
+
# Initialize database for a workspace
|
|
344
|
+
./target/release/data-modelling-cli db init --workspace ./my-workspace
|
|
345
|
+
|
|
346
|
+
# Sync YAML files to database
|
|
347
|
+
./target/release/data-modelling-cli db sync --workspace ./my-workspace
|
|
348
|
+
|
|
349
|
+
# Query the database
|
|
350
|
+
./target/release/data-modelling-cli query "SELECT name FROM tables" --workspace ./my-workspace
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
### Configuration
|
|
354
|
+
|
|
355
|
+
Database settings are stored in `.data-model.toml`:
|
|
356
|
+
|
|
357
|
+
```toml
|
|
358
|
+
[database]
|
|
359
|
+
backend = "duckdb"
|
|
360
|
+
path = ".data-model.duckdb"
|
|
361
|
+
|
|
362
|
+
[sync]
|
|
363
|
+
auto_sync = true
|
|
364
|
+
|
|
365
|
+
[git]
|
|
366
|
+
hooks_enabled = true
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
### Git Hooks Integration
|
|
370
|
+
|
|
371
|
+
When initializing a database in a Git repository, the CLI automatically installs:
|
|
372
|
+
|
|
373
|
+
- **Pre-commit hook**: Exports database changes to YAML before commit
|
|
374
|
+
- **Post-checkout hook**: Syncs YAML files to database after checkout
|
|
375
|
+
|
|
376
|
+
This ensures YAML files and database stay in sync across branches and collaborators.
|
|
377
|
+
|
|
378
|
+
See [CLI.md](docs/CLI.md) for detailed database command documentation.
|
|
379
|
+
|
|
380
|
+
## Development
|
|
381
|
+
|
|
382
|
+
### Pre-commit Hooks
|
|
383
|
+
|
|
384
|
+
This project uses pre-commit hooks to ensure code quality. Install them with:
|
|
385
|
+
|
|
386
|
+
```bash
|
|
387
|
+
# Install pre-commit (if not already installed)
|
|
388
|
+
pip install pre-commit
|
|
389
|
+
|
|
390
|
+
# Install the git hooks
|
|
391
|
+
pre-commit install
|
|
392
|
+
|
|
393
|
+
# Run hooks manually on all files
|
|
394
|
+
pre-commit run --all-files
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
The hooks will automatically run on `git commit` and check:
|
|
398
|
+
- Rust formatting (`cargo fmt`)
|
|
399
|
+
- Rust linting (`cargo clippy`)
|
|
400
|
+
- Security audit (`cargo audit`)
|
|
401
|
+
- File formatting (trailing whitespace, end of file, etc.)
|
|
402
|
+
- YAML/TOML/JSON syntax
|
|
403
|
+
|
|
404
|
+
### CI/CD
|
|
405
|
+
|
|
406
|
+
GitHub Actions workflows automatically run on push and pull requests:
|
|
407
|
+
- **Lint**: Format check, clippy, and security audit
|
|
408
|
+
- **Test**: Unit and integration tests on Linux, macOS, and Windows
|
|
409
|
+
- **Build**: Release build verification
|
|
410
|
+
- **Publish**: Automatic publishing to crates.io on main branch (after all checks pass)
|
|
411
|
+
|
|
412
|
+
## Documentation
|
|
413
|
+
|
|
414
|
+
- **[Architecture Guide](docs/ARCHITECTURE.md)**: Comprehensive guide to project architecture, design decisions, and use cases
|
|
415
|
+
- **[Schema Overview Guide](docs/SCHEMA_OVERVIEW.md)**: Detailed documentation of all supported schemas
|
|
416
|
+
|
|
417
|
+
The SDK supports:
|
|
418
|
+
- **ODCS v3.1.0**: Primary format for data contracts (tables)
|
|
419
|
+
- **ODCL v1.2.1**: Legacy data contract format (backward compatibility)
|
|
420
|
+
- **ODPS**: Data products linking to ODCS Tables
|
|
421
|
+
- **CADS v1.0**: Compute assets (AI/ML models, applications, pipelines)
|
|
422
|
+
- **BPMN 2.0**: Business Process Model and Notation (process models stored in native XML)
|
|
423
|
+
- **DMN 1.3**: Decision Model and Notation (decision models stored in native XML)
|
|
424
|
+
- **OpenAPI 3.1.1**: API specifications (stored in native YAML or JSON)
|
|
425
|
+
- **Business Domain Schema**: Organize systems, CADS nodes, and ODCS nodes
|
|
426
|
+
- **Universal Converter**: Convert any format to ODCS v3.1.0
|
|
427
|
+
- **OpenAPI to ODCS Converter**: Convert OpenAPI schema components to ODCS table definitions
|
|
428
|
+
|
|
429
|
+
### Schema Reference Directory
|
|
430
|
+
|
|
431
|
+
The SDK maintains JSON Schema definitions for all supported formats in the `schemas/` directory:
|
|
432
|
+
|
|
433
|
+
- **ODCS v3.1.0**: `schemas/odcs-json-schema-v3.1.0.json` - Primary format for data contracts
|
|
434
|
+
- **ODCL v1.2.1**: `schemas/odcl-json-schema-1.2.1.json` - Legacy data contract format
|
|
435
|
+
- **ODPS**: `schemas/odps-json-schema-latest.json` - Data products linking to ODCS tables
|
|
436
|
+
- **CADS v1.0**: `schemas/cads.schema.json` - Compute assets (AI/ML models, applications, pipelines)
|
|
437
|
+
|
|
438
|
+
These schemas serve as authoritative references for validation, documentation, and compliance. See [schemas/README.md](schemas/README.md) for detailed information about each schema.
|
|
439
|
+
|
|
440
|
+
## Status
|
|
441
|
+
|
|
442
|
+
The SDK provides comprehensive support for multiple data modeling formats:
|
|
443
|
+
|
|
444
|
+
- ✅ Storage backend abstraction and implementations
|
|
445
|
+
- ✅ Database backend abstraction (DuckDB, PostgreSQL)
|
|
446
|
+
- ✅ Model loader/saver structure
|
|
447
|
+
- ✅ Full import/export implementation for all supported formats
|
|
448
|
+
- ✅ Validation module structure
|
|
449
|
+
- ✅ Business Domain schema support
|
|
450
|
+
- ✅ Universal format converter
|
|
451
|
+
- ✅ Enhanced tag support (Simple, Pair, List)
|
|
452
|
+
- ✅ Full ODCS/ODCL field preservation
|
|
453
|
+
- ✅ Schema reference directory (`schemas/`) with JSON Schema definitions for all supported formats
|
|
454
|
+
- ✅ Bidirectional YAML ↔ Database sync with change detection
|
|
455
|
+
- ✅ Git hooks for automatic synchronization
|
|
456
|
+
- ✅ Decision Records (DDL) with MADR format support
|
|
457
|
+
- ✅ Knowledge Base (KB) with domain partitioning
|