mdmodels-core 0.2.7 → 0.2.8

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.
@@ -1,72 +1,72 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  /**
4
- * Parses the given markdown content into a `DataModel` and returns it as a `JsValue`.
4
+ * Parses the given JSON schema string into a `DataModel`.
5
5
  *
6
6
  * # Arguments
7
7
  *
8
- * * `markdown_content` - A string slice that holds the markdown content to be parsed.
8
+ * * `json_schema` - A string slice that holds the JSON schema to be parsed.
9
9
  *
10
10
  * # Returns
11
11
  *
12
- * A `DataModel` or an error `JsError`.
12
+ * A `String` or an error `JsError`.
13
13
  */
14
- export function parse_model(markdown_content: string): DataModel;
14
+ export function from_json_schema(json_schema: any): string;
15
15
  /**
16
- * Converts the given markdown content into a specified template format.
16
+ * Returns the JSON schema for the given markdown content.
17
17
  *
18
18
  * # Arguments
19
19
  *
20
20
  * * `markdown_content` - A string slice that holds the markdown content to be converted.
21
- * * `template` - The template format to convert the markdown content into.
21
+ * * `root` - The root object to use for the schema.
22
+ * * `openai` - Whether to remove options from the schema properties. OpenAI does not support options.
22
23
  *
23
24
  * # Returns
24
25
  *
25
26
  * A `Result` which is:
26
- * - `Ok(String)` if the conversion is successful.
27
+ * - `Ok(JsValue)` if the conversion is successful.
27
28
  * - `Err(JsValue)` if there is an error during parsing or conversion.
28
29
  */
29
- export function convert_to(markdown_content: string, template: Templates): string;
30
+ export function json_schema(markdown_content: string, root: string | undefined, openai: boolean): string;
30
31
  /**
31
- * Parses the given JSON schema string into a `DataModel`.
32
+ * Validates the given markdown content and returns the validation result as a `Validator`.
32
33
  *
33
34
  * # Arguments
34
35
  *
35
- * * `json_schema` - A string slice that holds the JSON schema to be parsed.
36
+ * * `markdown_content` - A string slice that holds the markdown content to be validated.
36
37
  *
37
38
  * # Returns
38
39
  *
39
- * A `String` or an error `JsError`.
40
+ * Either an empty `Validator` or an error `Validator`.
40
41
  */
41
- export function from_json_schema(json_schema: any): string;
42
+ export function validate(markdown_content: string): Validator;
42
43
  /**
43
- * Returns the JSON schema for the given markdown content.
44
+ * Converts the given markdown content into a specified template format.
44
45
  *
45
46
  * # Arguments
46
47
  *
47
48
  * * `markdown_content` - A string slice that holds the markdown content to be converted.
48
- * * `root` - The root object to use for the schema.
49
- * * `openai` - Whether to remove options from the schema properties. OpenAI does not support options.
49
+ * * `template` - The template format to convert the markdown content into.
50
50
  *
51
51
  * # Returns
52
52
  *
53
53
  * A `Result` which is:
54
- * - `Ok(JsValue)` if the conversion is successful.
54
+ * - `Ok(String)` if the conversion is successful.
55
55
  * - `Err(JsValue)` if there is an error during parsing or conversion.
56
56
  */
57
- export function json_schema(markdown_content: string, root: string | undefined, openai: boolean): string;
57
+ export function convert_to(markdown_content: string, template: Templates): string;
58
58
  /**
59
- * Validates the given markdown content and returns the validation result as a `Validator`.
59
+ * Parses the given markdown content into a `DataModel` and returns it as a `JsValue`.
60
60
  *
61
61
  * # Arguments
62
62
  *
63
- * * `markdown_content` - A string slice that holds the markdown content to be validated.
63
+ * * `markdown_content` - A string slice that holds the markdown content to be parsed.
64
64
  *
65
65
  * # Returns
66
66
  *
67
- * Either an empty `Validator` or an error `Validator`.
67
+ * A `DataModel` or an error `JsError`.
68
68
  */
69
- export function validate(markdown_content: string): Validator;
69
+ export function parse_model(markdown_content: string): DataModel;
70
70
  /**
71
71
  * Enumeration of available templates.
72
72
  */
@@ -83,84 +83,103 @@ export enum Templates {
83
83
  * Compact Markdown
84
84
  */
85
85
  CompactMarkdown = 2,
86
- /**
87
- * SHACL
88
- */
89
- Shacl = 3,
90
86
  /**
91
87
  * JSON Schema
92
88
  */
93
- JsonSchema = 4,
89
+ JsonSchema = 3,
94
90
  /**
95
91
  * JSON Schema All
96
92
  */
97
- JsonSchemaAll = 5,
93
+ JsonSchemaAll = 4,
94
+ /**
95
+ * JSON-LD
96
+ */
97
+ JsonLd = 5,
98
98
  /**
99
99
  * SHACL
100
100
  */
101
- Shex = 6,
101
+ Shacl = 6,
102
+ /**
103
+ * OWL
104
+ */
105
+ Owl = 7,
106
+ /**
107
+ * ShEx
108
+ */
109
+ Shex = 8,
102
110
  /**
103
111
  * Python Dataclass
104
112
  */
105
- PythonDataclass = 7,
113
+ PythonDataclass = 9,
106
114
  /**
107
115
  * Python Pydantic XML
108
116
  */
109
- PythonPydanticXML = 8,
117
+ PythonPydanticXML = 10,
110
118
  /**
111
119
  * Python Pydantic
112
120
  */
113
- PythonPydantic = 9,
121
+ PythonPydantic = 11,
114
122
  /**
115
123
  * MkDocs
116
124
  */
117
- MkDocs = 10,
125
+ MkDocs = 12,
118
126
  /**
119
127
  * Internal
120
128
  */
121
- Internal = 11,
129
+ Internal = 13,
122
130
  /**
123
131
  * Typescript (io-ts)
124
132
  */
125
- Typescript = 12,
133
+ Typescript = 14,
126
134
  /**
127
135
  * Typescript (Zod)
128
136
  */
129
- TypescriptZod = 13,
137
+ TypescriptZod = 15,
130
138
  /**
131
139
  * Rust
132
140
  */
133
- Rust = 14,
141
+ Rust = 16,
134
142
  /**
135
143
  * Protobuf
136
144
  */
137
- Protobuf = 15,
145
+ Protobuf = 17,
138
146
  /**
139
147
  * Graphql
140
148
  */
141
- Graphql = 16,
149
+ Graphql = 18,
142
150
  /**
143
151
  * Golang
144
152
  */
145
- Golang = 17,
153
+ Golang = 19,
146
154
  /**
147
155
  * Linkml
148
156
  */
149
- Linkml = 18,
157
+ Linkml = 20,
150
158
  /**
151
159
  * Julia
152
160
  */
153
- Julia = 19,
161
+ Julia = 21,
154
162
  /**
155
163
  * Mermaid class diagram
156
164
  */
157
- Mermaid = 20,
165
+ Mermaid = 22,
158
166
  }
159
167
  /**
160
168
  * Represents an XML type, either an attribute or an element.
161
169
  */
162
170
  export type XMLType = { Attribute: { is_attr: boolean; name: string } } | { Element: { is_attr: boolean; name: string } } | { Wrapped: { is_attr: boolean; name: string; wrapped: string[] | undefined } };
163
171
 
172
+ export interface PositionRange {
173
+ start: number;
174
+ end: number;
175
+ }
176
+
177
+ export interface Position {
178
+ line: number;
179
+ column: PositionRange;
180
+ offset: PositionRange;
181
+ }
182
+
164
183
  /**
165
184
  * Validator for checking the integrity of a data model.
166
185
  */
@@ -169,11 +188,6 @@ export interface Validator {
169
188
  errors: ValidationError[];
170
189
  }
171
190
 
172
- /**
173
- * Enum representing the type of validation error.
174
- */
175
- export type ErrorType = "NameError" | "TypeError" | "DuplicateError" | "GlobalError" | "XMLError" | "ObjectError";
176
-
177
191
  /**
178
192
  * Represents a validation error in the data model.
179
193
  */
@@ -187,30 +201,10 @@ export interface ValidationError {
187
201
  positions: Position[];
188
202
  }
189
203
 
190
- export interface DataModel {
191
- name?: string;
192
- objects: Object[];
193
- enums: Enumeration[];
194
- config?: FrontMatter;
195
- }
196
-
197
- export interface PositionRange {
198
- start: number;
199
- end: number;
200
- }
201
-
202
- export interface Position {
203
- line: number;
204
- column: PositionRange;
205
- offset: PositionRange;
206
- }
207
-
208
204
  /**
209
- * Represents different types of model imports.
210
- *
211
- * Can be either a remote URL or a local file path.
205
+ * Enum representing the type of validation error.
212
206
  */
213
- export type ImportType = { Remote: string } | { Local: string };
207
+ export type ErrorType = "NameError" | "TypeError" | "DuplicateError" | "GlobalError" | "XMLError" | "ObjectError";
214
208
 
215
209
  /**
216
210
  * Represents the front matter data of a markdown file.
@@ -250,6 +244,73 @@ export interface FrontMatter {
250
244
  "allow-empty"?: boolean;
251
245
  }
252
246
 
247
+ /**
248
+ * Represents different types of model imports.
249
+ *
250
+ * Can be either a remote URL or a local file path.
251
+ */
252
+ export type ImportType = { Remote: string } | { Local: string };
253
+
254
+ /**
255
+ * Represents an attribute with various properties and options.
256
+ */
257
+ export interface Attribute {
258
+ /**
259
+ * The name of the attribute.
260
+ */
261
+ name: string;
262
+ /**
263
+ * Indicates if the attribute is an array.
264
+ */
265
+ multiple: boolean;
266
+ /**
267
+ * Is an identifier or not
268
+ */
269
+ is_id: boolean;
270
+ /**
271
+ * Data types associated with the attribute.
272
+ */
273
+ dtypes: string[];
274
+ /**
275
+ * Documentation string for the attribute.
276
+ */
277
+ docstring: string;
278
+ /**
279
+ * List of additional options for the attribute.
280
+ */
281
+ options: AttrOption[];
282
+ /**
283
+ * Term associated with the attribute, if any.
284
+ */
285
+ term: string | undefined;
286
+ /**
287
+ * Indicates if the attribute is required.
288
+ */
289
+ required: boolean;
290
+ /**
291
+ * Default value for the attribute.
292
+ */
293
+ default?: DataType;
294
+ /**
295
+ * XML type information for the attribute.
296
+ */
297
+ xml?: XMLType;
298
+ /**
299
+ * Is an enumeration or not
300
+ */
301
+ is_enum: boolean;
302
+ /**
303
+ * The line number of the attribute
304
+ */
305
+ position: Position | undefined;
306
+ /**
307
+ * The prefix of the attribute, if it is an import
308
+ */
309
+ import_prefix?: string;
310
+ }
311
+
312
+ export type DataType = { Boolean: boolean } | { Integer: number } | { Float: number } | { String: string };
313
+
253
314
  /**
254
315
  * A raw key-value representation of an attribute option.
255
316
  *
@@ -283,6 +344,13 @@ export interface RawOption {
283
344
  */
284
345
  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 } };
285
346
 
347
+ export interface DataModel {
348
+ name?: string;
349
+ objects: Object[];
350
+ enums: Enumeration[];
351
+ config?: FrontMatter;
352
+ }
353
+
286
354
  /**
287
355
  * Represents an enumeration with a name and mappings.
288
356
  */
@@ -335,63 +403,3 @@ export interface Object {
335
403
  position?: Position;
336
404
  }
337
405
 
338
- export type DataType = { Boolean: boolean } | { Integer: number } | { Float: number } | { String: string };
339
-
340
- /**
341
- * Represents an attribute with various properties and options.
342
- */
343
- export interface Attribute {
344
- /**
345
- * The name of the attribute.
346
- */
347
- name: string;
348
- /**
349
- * Indicates if the attribute is an array.
350
- */
351
- multiple: boolean;
352
- /**
353
- * Is an identifier or not
354
- */
355
- is_id: boolean;
356
- /**
357
- * Data types associated with the attribute.
358
- */
359
- dtypes: string[];
360
- /**
361
- * Documentation string for the attribute.
362
- */
363
- docstring: string;
364
- /**
365
- * List of additional options for the attribute.
366
- */
367
- options: AttrOption[];
368
- /**
369
- * Term associated with the attribute, if any.
370
- */
371
- term: string | undefined;
372
- /**
373
- * Indicates if the attribute is required.
374
- */
375
- required: boolean;
376
- /**
377
- * Default value for the attribute.
378
- */
379
- default?: DataType;
380
- /**
381
- * XML type information for the attribute.
382
- */
383
- xml?: XMLType;
384
- /**
385
- * Is an enumeration or not
386
- */
387
- is_enum: boolean;
388
- /**
389
- * The line number of the attribute
390
- */
391
- position: Position | undefined;
392
- /**
393
- * The prefix of the attribute, if it is an import
394
- */
395
- import_prefix?: string;
396
- }
397
-
@@ -180,67 +180,6 @@ function takeFromExternrefTable0(idx) {
180
180
  wasm.__externref_table_dealloc(idx);
181
181
  return value;
182
182
  }
183
- /**
184
- * Parses the given markdown content into a `DataModel` and returns it as a `JsValue`.
185
- *
186
- * # Arguments
187
- *
188
- * * `markdown_content` - A string slice that holds the markdown content to be parsed.
189
- *
190
- * # Returns
191
- *
192
- * A `DataModel` or an error `JsError`.
193
- * @param {string} markdown_content
194
- * @returns {DataModel}
195
- */
196
- export function parse_model(markdown_content) {
197
- const ptr0 = passStringToWasm0(markdown_content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
198
- const len0 = WASM_VECTOR_LEN;
199
- const ret = wasm.parse_model(ptr0, len0);
200
- if (ret[2]) {
201
- throw takeFromExternrefTable0(ret[1]);
202
- }
203
- return takeFromExternrefTable0(ret[0]);
204
- }
205
-
206
- /**
207
- * Converts the given markdown content into a specified template format.
208
- *
209
- * # Arguments
210
- *
211
- * * `markdown_content` - A string slice that holds the markdown content to be converted.
212
- * * `template` - The template format to convert the markdown content into.
213
- *
214
- * # Returns
215
- *
216
- * A `Result` which is:
217
- * - `Ok(String)` if the conversion is successful.
218
- * - `Err(JsValue)` if there is an error during parsing or conversion.
219
- * @param {string} markdown_content
220
- * @param {Templates} template
221
- * @returns {string}
222
- */
223
- export function convert_to(markdown_content, template) {
224
- let deferred3_0;
225
- let deferred3_1;
226
- try {
227
- const ptr0 = passStringToWasm0(markdown_content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
228
- const len0 = WASM_VECTOR_LEN;
229
- const ret = wasm.convert_to(ptr0, len0, template);
230
- var ptr2 = ret[0];
231
- var len2 = ret[1];
232
- if (ret[3]) {
233
- ptr2 = 0; len2 = 0;
234
- throw takeFromExternrefTable0(ret[2]);
235
- }
236
- deferred3_0 = ptr2;
237
- deferred3_1 = len2;
238
- return getStringFromWasm0(ptr2, len2);
239
- } finally {
240
- wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
241
- }
242
- }
243
-
244
183
  /**
245
184
  * Parses the given JSON schema string into a `DataModel`.
246
185
  *
@@ -335,9 +274,70 @@ export function validate(markdown_content) {
335
274
  return ret;
336
275
  }
337
276
 
277
+ /**
278
+ * Converts the given markdown content into a specified template format.
279
+ *
280
+ * # Arguments
281
+ *
282
+ * * `markdown_content` - A string slice that holds the markdown content to be converted.
283
+ * * `template` - The template format to convert the markdown content into.
284
+ *
285
+ * # Returns
286
+ *
287
+ * A `Result` which is:
288
+ * - `Ok(String)` if the conversion is successful.
289
+ * - `Err(JsValue)` if there is an error during parsing or conversion.
290
+ * @param {string} markdown_content
291
+ * @param {Templates} template
292
+ * @returns {string}
293
+ */
294
+ export function convert_to(markdown_content, template) {
295
+ let deferred3_0;
296
+ let deferred3_1;
297
+ try {
298
+ const ptr0 = passStringToWasm0(markdown_content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
299
+ const len0 = WASM_VECTOR_LEN;
300
+ const ret = wasm.convert_to(ptr0, len0, template);
301
+ var ptr2 = ret[0];
302
+ var len2 = ret[1];
303
+ if (ret[3]) {
304
+ ptr2 = 0; len2 = 0;
305
+ throw takeFromExternrefTable0(ret[2]);
306
+ }
307
+ deferred3_0 = ptr2;
308
+ deferred3_1 = len2;
309
+ return getStringFromWasm0(ptr2, len2);
310
+ } finally {
311
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
312
+ }
313
+ }
314
+
315
+ /**
316
+ * Parses the given markdown content into a `DataModel` and returns it as a `JsValue`.
317
+ *
318
+ * # Arguments
319
+ *
320
+ * * `markdown_content` - A string slice that holds the markdown content to be parsed.
321
+ *
322
+ * # Returns
323
+ *
324
+ * A `DataModel` or an error `JsError`.
325
+ * @param {string} markdown_content
326
+ * @returns {DataModel}
327
+ */
328
+ export function parse_model(markdown_content) {
329
+ const ptr0 = passStringToWasm0(markdown_content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
330
+ const len0 = WASM_VECTOR_LEN;
331
+ const ret = wasm.parse_model(ptr0, len0);
332
+ if (ret[2]) {
333
+ throw takeFromExternrefTable0(ret[1]);
334
+ }
335
+ return takeFromExternrefTable0(ret[0]);
336
+ }
337
+
338
338
  /**
339
339
  * Enumeration of available templates.
340
- * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20}
340
+ * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22}
341
341
  */
342
342
  export const Templates = Object.freeze({
343
343
  /**
@@ -352,78 +352,86 @@ export const Templates = Object.freeze({
352
352
  * Compact Markdown
353
353
  */
354
354
  CompactMarkdown: 2, "2": "CompactMarkdown",
355
- /**
356
- * SHACL
357
- */
358
- Shacl: 3, "3": "Shacl",
359
355
  /**
360
356
  * JSON Schema
361
357
  */
362
- JsonSchema: 4, "4": "JsonSchema",
358
+ JsonSchema: 3, "3": "JsonSchema",
363
359
  /**
364
360
  * JSON Schema All
365
361
  */
366
- JsonSchemaAll: 5, "5": "JsonSchemaAll",
362
+ JsonSchemaAll: 4, "4": "JsonSchemaAll",
363
+ /**
364
+ * JSON-LD
365
+ */
366
+ JsonLd: 5, "5": "JsonLd",
367
367
  /**
368
368
  * SHACL
369
369
  */
370
- Shex: 6, "6": "Shex",
370
+ Shacl: 6, "6": "Shacl",
371
+ /**
372
+ * OWL
373
+ */
374
+ Owl: 7, "7": "Owl",
375
+ /**
376
+ * ShEx
377
+ */
378
+ Shex: 8, "8": "Shex",
371
379
  /**
372
380
  * Python Dataclass
373
381
  */
374
- PythonDataclass: 7, "7": "PythonDataclass",
382
+ PythonDataclass: 9, "9": "PythonDataclass",
375
383
  /**
376
384
  * Python Pydantic XML
377
385
  */
378
- PythonPydanticXML: 8, "8": "PythonPydanticXML",
386
+ PythonPydanticXML: 10, "10": "PythonPydanticXML",
379
387
  /**
380
388
  * Python Pydantic
381
389
  */
382
- PythonPydantic: 9, "9": "PythonPydantic",
390
+ PythonPydantic: 11, "11": "PythonPydantic",
383
391
  /**
384
392
  * MkDocs
385
393
  */
386
- MkDocs: 10, "10": "MkDocs",
394
+ MkDocs: 12, "12": "MkDocs",
387
395
  /**
388
396
  * Internal
389
397
  */
390
- Internal: 11, "11": "Internal",
398
+ Internal: 13, "13": "Internal",
391
399
  /**
392
400
  * Typescript (io-ts)
393
401
  */
394
- Typescript: 12, "12": "Typescript",
402
+ Typescript: 14, "14": "Typescript",
395
403
  /**
396
404
  * Typescript (Zod)
397
405
  */
398
- TypescriptZod: 13, "13": "TypescriptZod",
406
+ TypescriptZod: 15, "15": "TypescriptZod",
399
407
  /**
400
408
  * Rust
401
409
  */
402
- Rust: 14, "14": "Rust",
410
+ Rust: 16, "16": "Rust",
403
411
  /**
404
412
  * Protobuf
405
413
  */
406
- Protobuf: 15, "15": "Protobuf",
414
+ Protobuf: 17, "17": "Protobuf",
407
415
  /**
408
416
  * Graphql
409
417
  */
410
- Graphql: 16, "16": "Graphql",
418
+ Graphql: 18, "18": "Graphql",
411
419
  /**
412
420
  * Golang
413
421
  */
414
- Golang: 17, "17": "Golang",
422
+ Golang: 19, "19": "Golang",
415
423
  /**
416
424
  * Linkml
417
425
  */
418
- Linkml: 18, "18": "Linkml",
426
+ Linkml: 20, "20": "Linkml",
419
427
  /**
420
428
  * Julia
421
429
  */
422
- Julia: 19, "19": "Julia",
430
+ Julia: 21, "21": "Julia",
423
431
  /**
424
432
  * Mermaid class diagram
425
433
  */
426
- Mermaid: 20, "20": "Mermaid",
434
+ Mermaid: 22, "22": "Mermaid",
427
435
  });
428
436
 
429
437
  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.7",
8
+ "version": "0.2.8",
9
9
  "license": "MIT",
10
10
  "repository": {
11
11
  "type": "git",