mdmodels-core 0.1.8 → 0.2.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/README.md CHANGED
@@ -1,15 +1,25 @@
1
-
2
1
  # MD-Models
3
2
 
4
3
  ![Crates.io Version](https://img.shields.io/crates/v/mdmodels) ![NPM Version](https://img.shields.io/npm/v/mdmodels-core)
5
4
  ![PyPI - Version](https://img.shields.io/pypi/v/mdmodels-core)
6
5
  ![Build Status](https://github.com/JR-1991/sdrdm.rs/actions/workflows/test.yml/badge.svg)
7
6
 
8
- Welcome to Markdown Models (MD-Models), a powerful framework for research data management that prioritizes flexibility and efficiency.
7
+ Welcome to Markdown Models (MD-Models), a powerful framework for research data management that prioritizes narrative and readability for data models.
9
8
 
10
9
  With an adaptable markdown-based schema language, MD-Models automatically generates schemas and programming language representations. This markdown schema forms the foundation for object-oriented models, enabling seamless cross-format compatibility and simplifying modifications to data structures.
11
10
 
12
- Check out the [documentation](https://fairchemistry.github.io/md-models/) for more information.
11
+ ## Core Philosophy
12
+
13
+ The primary motivation behind MD-Models is to reduce cognitive overhead and maintenance burden by unifying documentation and structural definition into a single source of truth. Traditional approaches often require maintaining separate artifacts:
14
+
15
+ 1. Technical schemas (JSON Schema, XSD, ShEx, SHACL)
16
+ 2. Programming language implementations
17
+ 3. Documentation for domain experts
18
+ 4. API documentation
19
+
20
+ This separation frequently leads to documentation drift and increases the cognitive load on both developers and domain experts.
21
+
22
+ Check out the [documentation and graph editor](https://mdmodels.vercel.app/?about) for more information.
13
23
 
14
24
  ### Example
15
25
 
@@ -73,10 +83,20 @@ The following templates are available:
73
83
  - `python-dataclass`: Python dataclass implementation with JSON-LD support
74
84
  - `python-pydantic`: PyDantic implementation with JSON-LD support
75
85
  - `python-pydantic-xml`: PyDantic implementation with XML support
86
+ - `typescript`: TypeScript interface definitions with JSON-LD support
87
+ - `typescript-zod`: TypeScript Zod schema definitions
88
+ - `rust`: Rust struct definitions with serde support
89
+ - `golang`: Go struct definitions
90
+ - `protobuf`: Protocol Buffer schema definition
91
+ - `graphql`: GraphQL schema definition
76
92
  - `xml-schema`: XML schema definition
77
93
  - `json-schema`: JSON schema definition
94
+ - `json-schema-all`: Multiple JSON schema definitions (one per object)
78
95
  - `shacl`: SHACL shapes definition
79
96
  - `shex`: ShEx shapes definition
97
+ - `compact-markdown`: Compact markdown representation
98
+ - `mkdocs`: MkDocs documentation format
99
+ - `linkml`: LinkML schema definition
80
100
 
81
101
  ## Installation options
82
102
 
@@ -88,7 +108,7 @@ The main Rust crate is compiled to Python and WebAssembly, allowing the usage be
88
108
  pip install mdmodels-core
89
109
  ```
90
110
 
91
- - **[Python Package](https://pypi.org/project/mdmodels/)**: Install via pip:
111
+ - **[Python Package](https://github.com/FAIRChemistry/py-mdmodels/tree/master)**: Install via pip:
92
112
  ```bash
93
113
  # Provides in-memory data models, database support, LLM support, etc.
94
114
  pip install mdmodels
@@ -72,69 +72,36 @@ export enum Templates {
72
72
  MkDocs = 10,
73
73
  Internal = 11,
74
74
  Typescript = 12,
75
+ TypescriptZod = 13,
76
+ Rust = 14,
77
+ Protobuf = 15,
78
+ Graphql = 16,
79
+ Golang = 17,
80
+ Linkml = 18,
75
81
  }
76
82
  /**
77
- * Represents an XML type, either an attribute or an element.
83
+ * Validator for checking the integrity of a data model.
78
84
  */
79
- export type XMLType = { Attribute: { is_attr: boolean; name: string } } | { Element: { is_attr: boolean; name: string } };
85
+ export interface Validator {
86
+ is_valid: boolean;
87
+ errors: ValidationError[];
88
+ }
80
89
 
81
90
  /**
82
- * Represents an enumeration with a name and mappings.
91
+ * Enum representing the type of validation error.
83
92
  */
84
- export interface Enumeration {
85
- /**
86
- * Name of the enumeration.
87
- */
88
- name: string;
89
- /**
90
- * Mappings associated with the enumeration.
91
- */
92
- mappings: Map<string, string>;
93
- /**
94
- * Documentation string for the enumeration.
95
- */
96
- docstring: string;
97
- /**
98
- * The line number of the enumeration
99
- */
100
- position: Position | undefined;
101
- }
93
+ export type ErrorType = "NameError" | "TypeError" | "DuplicateError" | "GlobalError";
102
94
 
103
95
  /**
104
- * Represents an object with a name, attributes, docstring, and an optional term.
96
+ * Represents a validation error in the data model.
105
97
  */
106
- export interface Object {
107
- /**
108
- * Name of the object.
109
- */
110
- name: string;
111
- /**
112
- * List of attributes associated with the object.
113
- */
114
- attributes: Attribute[];
115
- /**
116
- * Documentation string for the object.
117
- */
118
- docstring: string;
119
- /**
120
- * Optional term associated with the object.
121
- */
122
- term?: string;
123
- /**
124
- * Parent object of the object.
125
- */
126
- parent?: string;
127
- /**
128
- * The line number of the object
129
- */
130
- position?: Position;
131
- }
132
-
133
- export interface DataModel {
134
- name?: string;
135
- objects: Object[];
136
- enums: Enumeration[];
137
- config?: FrontMatter;
98
+ export interface ValidationError {
99
+ message: string;
100
+ object: string | undefined;
101
+ attribute: string | undefined;
102
+ location: string;
103
+ error_type: ErrorType;
104
+ positions: Position[];
138
105
  }
139
106
 
140
107
  export interface PositionRange {
@@ -176,20 +143,6 @@ export interface FrontMatter {
176
143
 
177
144
  export type DataType = { Boolean: boolean } | { Integer: number } | { Float: number } | { String: string };
178
145
 
179
- /**
180
- * Represents an option for an attribute.
181
- */
182
- export interface AttrOption {
183
- /**
184
- * The key of the option.
185
- */
186
- key: string;
187
- /**
188
- * The value of the option.
189
- */
190
- value: string;
191
- }
192
-
193
146
  /**
194
147
  * Represents an attribute with various properties and options.
195
148
  */
@@ -244,28 +197,100 @@ export interface Attribute {
244
197
  position: Position | undefined;
245
198
  }
246
199
 
200
+ export interface DataModel {
201
+ name?: string;
202
+ objects: Object[];
203
+ enums: Enumeration[];
204
+ config?: FrontMatter;
205
+ }
206
+
247
207
  /**
248
- * Validator for checking the integrity of a data model.
208
+ * Represents an enumeration with a name and mappings.
249
209
  */
250
- export interface Validator {
251
- is_valid: boolean;
252
- errors: ValidationError[];
210
+ export interface Enumeration {
211
+ /**
212
+ * Name of the enumeration.
213
+ */
214
+ name: string;
215
+ /**
216
+ * Mappings associated with the enumeration.
217
+ */
218
+ mappings: Map<string, string>;
219
+ /**
220
+ * Documentation string for the enumeration.
221
+ */
222
+ docstring: string;
223
+ /**
224
+ * The line number of the enumeration
225
+ */
226
+ position: Position | undefined;
253
227
  }
254
228
 
255
229
  /**
256
- * Enum representing the type of validation error.
230
+ * Represents an object with a name, attributes, docstring, and an optional term.
257
231
  */
258
- export type ErrorType = "NameError" | "TypeError" | "DuplicateError" | "GlobalError";
232
+ export interface Object {
233
+ /**
234
+ * Name of the object.
235
+ */
236
+ name: string;
237
+ /**
238
+ * List of attributes associated with the object.
239
+ */
240
+ attributes: Attribute[];
241
+ /**
242
+ * Documentation string for the object.
243
+ */
244
+ docstring: string;
245
+ /**
246
+ * Optional term associated with the object.
247
+ */
248
+ term?: string;
249
+ /**
250
+ * Parent object of the object.
251
+ */
252
+ parent?: string;
253
+ /**
254
+ * The line number of the object
255
+ */
256
+ position?: Position;
257
+ }
259
258
 
260
259
  /**
261
- * Represents a validation error in the data model.
260
+ * Represents an XML type, either an attribute or an element.
262
261
  */
263
- export interface ValidationError {
264
- message: string;
265
- object: string | undefined;
266
- attribute: string | undefined;
267
- location: string;
268
- error_type: ErrorType;
269
- positions: Position[];
262
+ export type XMLType = { Attribute: { is_attr: boolean; name: string } } | { Element: { is_attr: boolean; name: string } };
263
+
264
+ /**
265
+ * A raw key-value representation of an attribute option.
266
+ *
267
+ * This struct provides a simple string-based representation of options,
268
+ * which is useful for serialization/deserialization and when working
269
+ * with untyped data.
270
+ */
271
+ export interface RawOption {
272
+ /**
273
+ * The key/name of the option
274
+ */
275
+ key: string;
276
+ /**
277
+ * The string value of the option
278
+ */
279
+ value: string;
270
280
  }
271
281
 
282
+ /**
283
+ * Represents an option for an attribute in a data model.
284
+ *
285
+ * This enum provides a strongly-typed representation of various attribute options
286
+ * that can be used to configure and constrain attributes in a data model.
287
+ *
288
+ * The options are grouped into several categories:
289
+ * - JSON Schema validation options (e.g., minimum/maximum values, length constraints)
290
+ * - SQL database options (e.g., primary key)
291
+ * - LinkML specific options (e.g., readonly, recommended)
292
+ * - Custom options via the `Other` variant
293
+ *
294
+ */
295
+ export type AttrOption = { Example: string } | { MinimumValue: number } | { MaximumValue: number } | { MinItems: number } | { MaxItems: number } | { MinLength: number } | { MaxLength: number } | { Pattern: string } | { Unique: boolean } | { MultipleOf: number } | { ExclusiveMinimum: number } | { ExclusiveMaximum: number } | { PrimaryKey: boolean } | { ReadOnly: boolean } | { Recommended: boolean } | { Other: { key: string; value: string } };
296
+
@@ -224,7 +224,7 @@ export function validate(markdown_content) {
224
224
 
225
225
  /**
226
226
  * Enumeration of available templates.
227
- * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12}
227
+ * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18}
228
228
  */
229
229
  export const Templates = Object.freeze({
230
230
  XmlSchema: 0, "0": "XmlSchema",
@@ -240,6 +240,12 @@ export const Templates = Object.freeze({
240
240
  MkDocs: 10, "10": "MkDocs",
241
241
  Internal: 11, "11": "Internal",
242
242
  Typescript: 12, "12": "Typescript",
243
+ TypescriptZod: 13, "13": "TypescriptZod",
244
+ Rust: 14, "14": "Rust",
245
+ Protobuf: 15, "15": "Protobuf",
246
+ Graphql: 16, "16": "Graphql",
247
+ Golang: 17, "17": "Golang",
248
+ Linkml: 18, "18": "Linkml",
243
249
  });
244
250
 
245
251
  export function __wbg_String_8f0eb39a4a4c2f66(arg0, arg1) {
Binary file
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "Jan Range <jan.range@simtech.uni-stuttgart.de>"
6
6
  ],
7
7
  "description": "A tool to generate models, code and schemas from markdown files",
8
- "version": "0.1.8",
8
+ "version": "0.2.0",
9
9
  "license": "MIT",
10
10
  "repository": {
11
11
  "type": "git",