mdmodels-core 0.2.3 → 0.2.4

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.
@@ -59,124 +59,173 @@ export function validate(markdown_content: string): Validator;
59
59
  * Enumeration of available templates.
60
60
  */
61
61
  export enum Templates {
62
+ /**
63
+ * XML Schema
64
+ */
62
65
  XmlSchema = 0,
66
+ /**
67
+ * Markdown
68
+ */
63
69
  Markdown = 1,
70
+ /**
71
+ * Compact Markdown
72
+ */
64
73
  CompactMarkdown = 2,
74
+ /**
75
+ * SHACL
76
+ */
65
77
  Shacl = 3,
78
+ /**
79
+ * JSON Schema
80
+ */
66
81
  JsonSchema = 4,
82
+ /**
83
+ * JSON Schema All
84
+ */
67
85
  JsonSchemaAll = 5,
86
+ /**
87
+ * SHACL
88
+ */
68
89
  Shex = 6,
90
+ /**
91
+ * Python Dataclass
92
+ */
69
93
  PythonDataclass = 7,
94
+ /**
95
+ * Python Pydantic XML
96
+ */
70
97
  PythonPydanticXML = 8,
98
+ /**
99
+ * Python Pydantic
100
+ */
71
101
  PythonPydantic = 9,
102
+ /**
103
+ * MkDocs
104
+ */
72
105
  MkDocs = 10,
106
+ /**
107
+ * Internal
108
+ */
73
109
  Internal = 11,
110
+ /**
111
+ * Typescript (io-ts)
112
+ */
74
113
  Typescript = 12,
114
+ /**
115
+ * Typescript (Zod)
116
+ */
75
117
  TypescriptZod = 13,
118
+ /**
119
+ * Rust
120
+ */
76
121
  Rust = 14,
122
+ /**
123
+ * Protobuf
124
+ */
77
125
  Protobuf = 15,
126
+ /**
127
+ * Graphql
128
+ */
78
129
  Graphql = 16,
130
+ /**
131
+ * Golang
132
+ */
79
133
  Golang = 17,
134
+ /**
135
+ * Linkml
136
+ */
80
137
  Linkml = 18,
138
+ /**
139
+ * Julia
140
+ */
81
141
  Julia = 19,
142
+ /**
143
+ * Mermaid class diagram
144
+ */
145
+ Mermaid = 20,
82
146
  }
83
- export interface DataModel {
84
- name?: string;
85
- objects: Object[];
86
- enums: Enumeration[];
87
- config?: FrontMatter;
88
- }
89
-
90
- export type DataType = { Boolean: boolean } | { Integer: number } | { Float: number } | { String: string };
147
+ /**
148
+ * Represents different types of model imports.
149
+ *
150
+ * Can be either a remote URL or a local file path.
151
+ */
152
+ export type ImportType = { Remote: string } | { Local: string };
91
153
 
92
154
  /**
93
- * Represents an attribute with various properties and options.
155
+ * Represents the front matter data of a markdown file.
94
156
  */
95
- export interface Attribute {
96
- /**
97
- * The name of the attribute.
98
- */
99
- name: string;
100
- /**
101
- * Indicates if the attribute is an array.
102
- */
103
- multiple: boolean;
104
- /**
105
- * Is an identifier or not
106
- */
107
- is_id: boolean;
108
- /**
109
- * Data types associated with the attribute.
110
- */
111
- dtypes: string[];
112
- /**
113
- * Documentation string for the attribute.
114
- */
115
- docstring: string;
157
+ export interface FrontMatter {
116
158
  /**
117
- * List of additional options for the attribute.
159
+ * Identifier field of the model.
118
160
  */
119
- options: AttrOption[];
161
+ id: string | undefined;
120
162
  /**
121
- * Term associated with the attribute, if any.
163
+ * A boolean field with a default value, renamed from `id-field`.
122
164
  */
123
- term: string | undefined;
165
+ "id-field"?: boolean;
124
166
  /**
125
- * Indicates if the attribute is required.
167
+ * Optional hashmap of prefixes.
126
168
  */
127
- required: boolean;
169
+ prefixes: Map<string, string> | undefined;
128
170
  /**
129
- * Default value for the attribute.
171
+ * Optional namespace map.
130
172
  */
131
- default?: DataType;
173
+ nsmap: Map<string, string> | undefined;
132
174
  /**
133
- * XML type information for the attribute.
175
+ * A string field with a default value representing the repository URL.
134
176
  */
135
- xml?: XMLType;
177
+ repo?: string;
136
178
  /**
137
- * Is an enumeration or not
179
+ * A string field with a default value representing the prefix.
138
180
  */
139
- is_enum: boolean;
181
+ prefix?: string;
140
182
  /**
141
- * The line number of the attribute
183
+ * Import remote or local models.
142
184
  */
143
- position: Position | undefined;
185
+ imports?: Map<string, ImportType>;
144
186
  /**
145
- * The prefix of the attribute, if it is an import
187
+ * Allow empty models.
146
188
  */
147
- import_prefix?: string;
148
- }
149
-
150
- /**
151
- * Validator for checking the integrity of a data model.
152
- */
153
- export interface Validator {
154
- is_valid: boolean;
155
- errors: ValidationError[];
189
+ "allow-empty"?: boolean;
156
190
  }
157
191
 
158
192
  /**
159
- * Enum representing the type of validation error.
193
+ * Represents an XML type, either an attribute or an element.
160
194
  */
161
- export type ErrorType = "NameError" | "TypeError" | "DuplicateError" | "GlobalError" | "XMLError" | "ObjectError";
195
+ export type XMLType = { Attribute: { is_attr: boolean; name: string } } | { Element: { is_attr: boolean; name: string } } | { Wrapped: { is_attr: boolean; name: string; wrapped: string[] | undefined } };
162
196
 
163
197
  /**
164
- * Represents a validation error in the data model.
198
+ * A raw key-value representation of an attribute option.
199
+ *
200
+ * This struct provides a simple string-based representation of options,
201
+ * which is useful for serialization/deserialization and when working
202
+ * with untyped data.
165
203
  */
166
- export interface ValidationError {
167
- message: string;
168
- object: string | undefined;
169
- attribute: string | undefined;
170
- location: string;
171
- solution: string | undefined;
172
- error_type: ErrorType;
173
- positions: Position[];
204
+ export interface RawOption {
205
+ /**
206
+ * The key/name of the option
207
+ */
208
+ key: string;
209
+ /**
210
+ * The string value of the option
211
+ */
212
+ value: string;
174
213
  }
175
214
 
176
215
  /**
177
- * Represents an XML type, either an attribute or an element.
216
+ * Represents an option for an attribute in a data model.
217
+ *
218
+ * This enum provides a strongly-typed representation of various attribute options
219
+ * that can be used to configure and constrain attributes in a data model.
220
+ *
221
+ * The options are grouped into several categories:
222
+ * - JSON Schema validation options (e.g., minimum/maximum values, length constraints)
223
+ * - SQL database options (e.g., primary key)
224
+ * - LinkML specific options (e.g., readonly, recommended)
225
+ * - Custom options via the `Other` variant
226
+ *
178
227
  */
179
- export type XMLType = { Attribute: { is_attr: boolean; name: string } } | { Element: { is_attr: boolean; name: string } } | { Wrapped: { is_attr: boolean; name: string; wrapped: string[] | undefined } };
228
+ 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 } };
180
229
 
181
230
  /**
182
231
  * Represents an enumeration with a name and mappings.
@@ -230,84 +279,66 @@ export interface Object {
230
279
  position?: Position;
231
280
  }
232
281
 
233
- /**
234
- * Represents different types of model imports.
235
- *
236
- * Can be either a remote URL or a local file path.
237
- */
238
- export type ImportType = { Remote: string } | { Local: string };
282
+ export type DataType = { Boolean: boolean } | { Integer: number } | { Float: number } | { String: string };
239
283
 
240
284
  /**
241
- * Represents the front matter data of a markdown file.
285
+ * Represents an attribute with various properties and options.
242
286
  */
243
- export interface FrontMatter {
287
+ export interface Attribute {
244
288
  /**
245
- * Identifier field of the model.
289
+ * The name of the attribute.
246
290
  */
247
- id: string | undefined;
291
+ name: string;
248
292
  /**
249
- * A boolean field with a default value, renamed from `id-field`.
293
+ * Indicates if the attribute is an array.
250
294
  */
251
- "id-field"?: boolean;
295
+ multiple: boolean;
252
296
  /**
253
- * Optional hashmap of prefixes.
297
+ * Is an identifier or not
254
298
  */
255
- prefixes: Map<string, string> | undefined;
299
+ is_id: boolean;
256
300
  /**
257
- * Optional namespace map.
301
+ * Data types associated with the attribute.
258
302
  */
259
- nsmap: Map<string, string> | undefined;
303
+ dtypes: string[];
260
304
  /**
261
- * A string field with a default value representing the repository URL.
305
+ * Documentation string for the attribute.
262
306
  */
263
- repo?: string;
307
+ docstring: string;
264
308
  /**
265
- * A string field with a default value representing the prefix.
309
+ * List of additional options for the attribute.
266
310
  */
267
- prefix?: string;
311
+ options: AttrOption[];
268
312
  /**
269
- * Import remote or local models.
313
+ * Term associated with the attribute, if any.
270
314
  */
271
- imports?: Map<string, ImportType>;
315
+ term: string | undefined;
272
316
  /**
273
- * Allow empty models.
317
+ * Indicates if the attribute is required.
274
318
  */
275
- "allow-empty"?: boolean;
276
- }
277
-
278
- /**
279
- * A raw key-value representation of an attribute option.
280
- *
281
- * This struct provides a simple string-based representation of options,
282
- * which is useful for serialization/deserialization and when working
283
- * with untyped data.
284
- */
285
- export interface RawOption {
319
+ required: boolean;
286
320
  /**
287
- * The key/name of the option
321
+ * Default value for the attribute.
288
322
  */
289
- key: string;
323
+ default?: DataType;
290
324
  /**
291
- * The string value of the option
325
+ * XML type information for the attribute.
292
326
  */
293
- value: string;
327
+ xml?: XMLType;
328
+ /**
329
+ * Is an enumeration or not
330
+ */
331
+ is_enum: boolean;
332
+ /**
333
+ * The line number of the attribute
334
+ */
335
+ position: Position | undefined;
336
+ /**
337
+ * The prefix of the attribute, if it is an import
338
+ */
339
+ import_prefix?: string;
294
340
  }
295
341
 
296
- /**
297
- * Represents an option for an attribute in a data model.
298
- *
299
- * This enum provides a strongly-typed representation of various attribute options
300
- * that can be used to configure and constrain attributes in a data model.
301
- *
302
- * The options are grouped into several categories:
303
- * - JSON Schema validation options (e.g., minimum/maximum values, length constraints)
304
- * - SQL database options (e.g., primary key)
305
- * - LinkML specific options (e.g., readonly, recommended)
306
- * - Custom options via the `Other` variant
307
- *
308
- */
309
- 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 } };
310
-
311
342
  export interface PositionRange {
312
343
  start: number;
313
344
  end: number;
@@ -319,3 +350,36 @@ export interface Position {
319
350
  offset: PositionRange;
320
351
  }
321
352
 
353
+ /**
354
+ * Validator for checking the integrity of a data model.
355
+ */
356
+ export interface Validator {
357
+ is_valid: boolean;
358
+ errors: ValidationError[];
359
+ }
360
+
361
+ /**
362
+ * Enum representing the type of validation error.
363
+ */
364
+ export type ErrorType = "NameError" | "TypeError" | "DuplicateError" | "GlobalError" | "XMLError" | "ObjectError";
365
+
366
+ /**
367
+ * Represents a validation error in the data model.
368
+ */
369
+ export interface ValidationError {
370
+ message: string;
371
+ object: string | undefined;
372
+ attribute: string | undefined;
373
+ location: string;
374
+ solution: string | undefined;
375
+ error_type: ErrorType;
376
+ positions: Position[];
377
+ }
378
+
379
+ export interface DataModel {
380
+ name?: string;
381
+ objects: Object[];
382
+ enums: Enumeration[];
383
+ config?: FrontMatter;
384
+ }
385
+
@@ -224,29 +224,93 @@ 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 | 13 | 14 | 15 | 16 | 17 | 18 | 19}
227
+ * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20}
228
228
  */
229
229
  export const Templates = Object.freeze({
230
+ /**
231
+ * XML Schema
232
+ */
230
233
  XmlSchema: 0, "0": "XmlSchema",
234
+ /**
235
+ * Markdown
236
+ */
231
237
  Markdown: 1, "1": "Markdown",
238
+ /**
239
+ * Compact Markdown
240
+ */
232
241
  CompactMarkdown: 2, "2": "CompactMarkdown",
242
+ /**
243
+ * SHACL
244
+ */
233
245
  Shacl: 3, "3": "Shacl",
246
+ /**
247
+ * JSON Schema
248
+ */
234
249
  JsonSchema: 4, "4": "JsonSchema",
250
+ /**
251
+ * JSON Schema All
252
+ */
235
253
  JsonSchemaAll: 5, "5": "JsonSchemaAll",
254
+ /**
255
+ * SHACL
256
+ */
236
257
  Shex: 6, "6": "Shex",
258
+ /**
259
+ * Python Dataclass
260
+ */
237
261
  PythonDataclass: 7, "7": "PythonDataclass",
262
+ /**
263
+ * Python Pydantic XML
264
+ */
238
265
  PythonPydanticXML: 8, "8": "PythonPydanticXML",
266
+ /**
267
+ * Python Pydantic
268
+ */
239
269
  PythonPydantic: 9, "9": "PythonPydantic",
270
+ /**
271
+ * MkDocs
272
+ */
240
273
  MkDocs: 10, "10": "MkDocs",
274
+ /**
275
+ * Internal
276
+ */
241
277
  Internal: 11, "11": "Internal",
278
+ /**
279
+ * Typescript (io-ts)
280
+ */
242
281
  Typescript: 12, "12": "Typescript",
282
+ /**
283
+ * Typescript (Zod)
284
+ */
243
285
  TypescriptZod: 13, "13": "TypescriptZod",
286
+ /**
287
+ * Rust
288
+ */
244
289
  Rust: 14, "14": "Rust",
290
+ /**
291
+ * Protobuf
292
+ */
245
293
  Protobuf: 15, "15": "Protobuf",
294
+ /**
295
+ * Graphql
296
+ */
246
297
  Graphql: 16, "16": "Graphql",
298
+ /**
299
+ * Golang
300
+ */
247
301
  Golang: 17, "17": "Golang",
302
+ /**
303
+ * Linkml
304
+ */
248
305
  Linkml: 18, "18": "Linkml",
306
+ /**
307
+ * Julia
308
+ */
249
309
  Julia: 19, "19": "Julia",
310
+ /**
311
+ * Mermaid class diagram
312
+ */
313
+ Mermaid: 20, "20": "Mermaid",
250
314
  });
251
315
 
252
316
  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.2.3",
8
+ "version": "0.2.4",
9
9
  "license": "MIT",
10
10
  "repository": {
11
11
  "type": "git",