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 +24 -4
- package/mdmodels-core.d.ts +107 -82
- package/mdmodels-core_bg.js +7 -1
- package/mdmodels-core_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,15 +1,25 @@
|
|
|
1
|
-
|
|
2
1
|
# MD-Models
|
|
3
2
|
|
|
4
3
|
 
|
|
5
4
|

|
|
6
5
|

|
|
7
6
|
|
|
8
|
-
Welcome to Markdown Models (MD-Models), a powerful framework for research data management that prioritizes
|
|
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
|
-
|
|
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://
|
|
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
|
package/mdmodels-core.d.ts
CHANGED
|
@@ -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
|
-
*
|
|
83
|
+
* Validator for checking the integrity of a data model.
|
|
78
84
|
*/
|
|
79
|
-
export
|
|
85
|
+
export interface Validator {
|
|
86
|
+
is_valid: boolean;
|
|
87
|
+
errors: ValidationError[];
|
|
88
|
+
}
|
|
80
89
|
|
|
81
90
|
/**
|
|
82
|
-
*
|
|
91
|
+
* Enum representing the type of validation error.
|
|
83
92
|
*/
|
|
84
|
-
export
|
|
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
|
|
96
|
+
* Represents a validation error in the data model.
|
|
105
97
|
*/
|
|
106
|
-
export interface
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
-
*
|
|
208
|
+
* Represents an enumeration with a name and mappings.
|
|
249
209
|
*/
|
|
250
|
-
export interface
|
|
251
|
-
|
|
252
|
-
|
|
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
|
-
*
|
|
230
|
+
* Represents an object with a name, attributes, docstring, and an optional term.
|
|
257
231
|
*/
|
|
258
|
-
export
|
|
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
|
|
260
|
+
* Represents an XML type, either an attribute or an element.
|
|
262
261
|
*/
|
|
263
|
-
export
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
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
|
+
|
package/mdmodels-core_bg.js
CHANGED
|
@@ -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) {
|
package/mdmodels-core_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED