mdmodels-core 0.2.6 → 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.
- package/mdmodels-core.d.ts +159 -151
- package/mdmodels-core_bg.js +91 -83
- package/mdmodels-core_bg.wasm +0 -0
- package/package.json +1 -1
package/mdmodels-core.d.ts
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
/**
|
|
4
|
-
* Parses the given
|
|
4
|
+
* Parses the given JSON schema string into a `DataModel`.
|
|
5
5
|
*
|
|
6
6
|
* # Arguments
|
|
7
7
|
*
|
|
8
|
-
* * `
|
|
8
|
+
* * `json_schema` - A string slice that holds the JSON schema to be parsed.
|
|
9
9
|
*
|
|
10
10
|
* # Returns
|
|
11
11
|
*
|
|
12
|
-
* A `
|
|
12
|
+
* A `String` or an error `JsError`.
|
|
13
13
|
*/
|
|
14
|
-
export function
|
|
14
|
+
export function from_json_schema(json_schema: any): string;
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
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
|
-
* * `
|
|
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(
|
|
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
|
|
30
|
+
export function json_schema(markdown_content: string, root: string | undefined, openai: boolean): string;
|
|
30
31
|
/**
|
|
31
|
-
*
|
|
32
|
+
* Validates the given markdown content and returns the validation result as a `Validator`.
|
|
32
33
|
*
|
|
33
34
|
* # Arguments
|
|
34
35
|
*
|
|
35
|
-
* * `
|
|
36
|
+
* * `markdown_content` - A string slice that holds the markdown content to be validated.
|
|
36
37
|
*
|
|
37
38
|
* # Returns
|
|
38
39
|
*
|
|
39
|
-
*
|
|
40
|
+
* Either an empty `Validator` or an error `Validator`.
|
|
40
41
|
*/
|
|
41
|
-
export function
|
|
42
|
+
export function validate(markdown_content: string): Validator;
|
|
42
43
|
/**
|
|
43
|
-
*
|
|
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
|
-
* * `
|
|
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(
|
|
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
|
|
57
|
+
export function convert_to(markdown_content: string, template: Templates): string;
|
|
58
58
|
/**
|
|
59
|
-
*
|
|
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
|
|
63
|
+
* * `markdown_content` - A string slice that holds the markdown content to be parsed.
|
|
64
64
|
*
|
|
65
65
|
* # Returns
|
|
66
66
|
*
|
|
67
|
-
*
|
|
67
|
+
* A `DataModel` or an error `JsError`.
|
|
68
68
|
*/
|
|
69
|
-
export function
|
|
69
|
+
export function parse_model(markdown_content: string): DataModel;
|
|
70
70
|
/**
|
|
71
71
|
* Enumeration of available templates.
|
|
72
72
|
*/
|
|
@@ -83,79 +83,92 @@ 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 =
|
|
89
|
+
JsonSchema = 3,
|
|
94
90
|
/**
|
|
95
91
|
* JSON Schema All
|
|
96
92
|
*/
|
|
97
|
-
JsonSchemaAll =
|
|
93
|
+
JsonSchemaAll = 4,
|
|
94
|
+
/**
|
|
95
|
+
* JSON-LD
|
|
96
|
+
*/
|
|
97
|
+
JsonLd = 5,
|
|
98
98
|
/**
|
|
99
99
|
* SHACL
|
|
100
100
|
*/
|
|
101
|
-
|
|
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 =
|
|
113
|
+
PythonDataclass = 9,
|
|
106
114
|
/**
|
|
107
115
|
* Python Pydantic XML
|
|
108
116
|
*/
|
|
109
|
-
PythonPydanticXML =
|
|
117
|
+
PythonPydanticXML = 10,
|
|
110
118
|
/**
|
|
111
119
|
* Python Pydantic
|
|
112
120
|
*/
|
|
113
|
-
PythonPydantic =
|
|
121
|
+
PythonPydantic = 11,
|
|
114
122
|
/**
|
|
115
123
|
* MkDocs
|
|
116
124
|
*/
|
|
117
|
-
MkDocs =
|
|
125
|
+
MkDocs = 12,
|
|
118
126
|
/**
|
|
119
127
|
* Internal
|
|
120
128
|
*/
|
|
121
|
-
Internal =
|
|
129
|
+
Internal = 13,
|
|
122
130
|
/**
|
|
123
131
|
* Typescript (io-ts)
|
|
124
132
|
*/
|
|
125
|
-
Typescript =
|
|
133
|
+
Typescript = 14,
|
|
126
134
|
/**
|
|
127
135
|
* Typescript (Zod)
|
|
128
136
|
*/
|
|
129
|
-
TypescriptZod =
|
|
137
|
+
TypescriptZod = 15,
|
|
130
138
|
/**
|
|
131
139
|
* Rust
|
|
132
140
|
*/
|
|
133
|
-
Rust =
|
|
141
|
+
Rust = 16,
|
|
134
142
|
/**
|
|
135
143
|
* Protobuf
|
|
136
144
|
*/
|
|
137
|
-
Protobuf =
|
|
145
|
+
Protobuf = 17,
|
|
138
146
|
/**
|
|
139
147
|
* Graphql
|
|
140
148
|
*/
|
|
141
|
-
Graphql =
|
|
149
|
+
Graphql = 18,
|
|
142
150
|
/**
|
|
143
151
|
* Golang
|
|
144
152
|
*/
|
|
145
|
-
Golang =
|
|
153
|
+
Golang = 19,
|
|
146
154
|
/**
|
|
147
155
|
* Linkml
|
|
148
156
|
*/
|
|
149
|
-
Linkml =
|
|
157
|
+
Linkml = 20,
|
|
150
158
|
/**
|
|
151
159
|
* Julia
|
|
152
160
|
*/
|
|
153
|
-
Julia =
|
|
161
|
+
Julia = 21,
|
|
154
162
|
/**
|
|
155
163
|
* Mermaid class diagram
|
|
156
164
|
*/
|
|
157
|
-
Mermaid =
|
|
165
|
+
Mermaid = 22,
|
|
158
166
|
}
|
|
167
|
+
/**
|
|
168
|
+
* Represents an XML type, either an attribute or an element.
|
|
169
|
+
*/
|
|
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 } };
|
|
171
|
+
|
|
159
172
|
export interface PositionRange {
|
|
160
173
|
start: number;
|
|
161
174
|
end: number;
|
|
@@ -168,101 +181,30 @@ export interface Position {
|
|
|
168
181
|
}
|
|
169
182
|
|
|
170
183
|
/**
|
|
171
|
-
*
|
|
172
|
-
*/
|
|
173
|
-
export type XMLType = { Attribute: { is_attr: boolean; name: string } } | { Element: { is_attr: boolean; name: string } } | { Wrapped: { is_attr: boolean; name: string; wrapped: string[] | undefined } };
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* A raw key-value representation of an attribute option.
|
|
177
|
-
*
|
|
178
|
-
* This struct provides a simple string-based representation of options,
|
|
179
|
-
* which is useful for serialization/deserialization and when working
|
|
180
|
-
* with untyped data.
|
|
181
|
-
*/
|
|
182
|
-
export interface RawOption {
|
|
183
|
-
/**
|
|
184
|
-
* The key/name of the option
|
|
185
|
-
*/
|
|
186
|
-
key: string;
|
|
187
|
-
/**
|
|
188
|
-
* The string value of the option
|
|
189
|
-
*/
|
|
190
|
-
value: string;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Represents an option for an attribute in a data model.
|
|
195
|
-
*
|
|
196
|
-
* This enum provides a strongly-typed representation of various attribute options
|
|
197
|
-
* that can be used to configure and constrain attributes in a data model.
|
|
198
|
-
*
|
|
199
|
-
* The options are grouped into several categories:
|
|
200
|
-
* - JSON Schema validation options (e.g., minimum/maximum values, length constraints)
|
|
201
|
-
* - SQL database options (e.g., primary key)
|
|
202
|
-
* - LinkML specific options (e.g., readonly, recommended)
|
|
203
|
-
* - Custom options via the `Other` variant
|
|
204
|
-
*
|
|
205
|
-
*/
|
|
206
|
-
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 } };
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Represents an enumeration with a name and mappings.
|
|
184
|
+
* Validator for checking the integrity of a data model.
|
|
210
185
|
*/
|
|
211
|
-
export interface
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
*/
|
|
215
|
-
name: string;
|
|
216
|
-
/**
|
|
217
|
-
* Mappings associated with the enumeration.
|
|
218
|
-
*/
|
|
219
|
-
mappings: Map<string, string>;
|
|
220
|
-
/**
|
|
221
|
-
* Documentation string for the enumeration.
|
|
222
|
-
*/
|
|
223
|
-
docstring: string;
|
|
224
|
-
/**
|
|
225
|
-
* The line number of the enumeration
|
|
226
|
-
*/
|
|
227
|
-
position: Position | undefined;
|
|
186
|
+
export interface Validator {
|
|
187
|
+
is_valid: boolean;
|
|
188
|
+
errors: ValidationError[];
|
|
228
189
|
}
|
|
229
190
|
|
|
230
191
|
/**
|
|
231
|
-
* Represents
|
|
192
|
+
* Represents a validation error in the data model.
|
|
232
193
|
*/
|
|
233
|
-
export interface
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
attributes: Attribute[];
|
|
242
|
-
/**
|
|
243
|
-
* Documentation string for the object.
|
|
244
|
-
*/
|
|
245
|
-
docstring: string;
|
|
246
|
-
/**
|
|
247
|
-
* Optional term associated with the object.
|
|
248
|
-
*/
|
|
249
|
-
term?: string;
|
|
250
|
-
/**
|
|
251
|
-
* Other objects that this object gets mixed in with.
|
|
252
|
-
*/
|
|
253
|
-
mixins?: string[];
|
|
254
|
-
/**
|
|
255
|
-
* The line number of the object
|
|
256
|
-
*/
|
|
257
|
-
position?: Position;
|
|
194
|
+
export interface ValidationError {
|
|
195
|
+
message: string;
|
|
196
|
+
object: string | undefined;
|
|
197
|
+
attribute: string | undefined;
|
|
198
|
+
location: string;
|
|
199
|
+
solution: string | undefined;
|
|
200
|
+
error_type: ErrorType;
|
|
201
|
+
positions: Position[];
|
|
258
202
|
}
|
|
259
203
|
|
|
260
204
|
/**
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
* Can be either a remote URL or a local file path.
|
|
205
|
+
* Enum representing the type of validation error.
|
|
264
206
|
*/
|
|
265
|
-
export type
|
|
207
|
+
export type ErrorType = "NameError" | "TypeError" | "DuplicateError" | "GlobalError" | "XMLError" | "ObjectError";
|
|
266
208
|
|
|
267
209
|
/**
|
|
268
210
|
* Represents the front matter data of a markdown file.
|
|
@@ -302,14 +244,12 @@ export interface FrontMatter {
|
|
|
302
244
|
"allow-empty"?: boolean;
|
|
303
245
|
}
|
|
304
246
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
export type DataType = { Boolean: boolean } | { Integer: number } | { Float: number } | { String: string };
|
|
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 };
|
|
313
253
|
|
|
314
254
|
/**
|
|
315
255
|
* Represents an attribute with various properties and options.
|
|
@@ -369,29 +309,97 @@ export interface Attribute {
|
|
|
369
309
|
import_prefix?: string;
|
|
370
310
|
}
|
|
371
311
|
|
|
312
|
+
export type DataType = { Boolean: boolean } | { Integer: number } | { Float: number } | { String: string };
|
|
313
|
+
|
|
372
314
|
/**
|
|
373
|
-
*
|
|
315
|
+
* A raw key-value representation of an attribute option.
|
|
316
|
+
*
|
|
317
|
+
* This struct provides a simple string-based representation of options,
|
|
318
|
+
* which is useful for serialization/deserialization and when working
|
|
319
|
+
* with untyped data.
|
|
374
320
|
*/
|
|
375
|
-
export interface
|
|
376
|
-
|
|
377
|
-
|
|
321
|
+
export interface RawOption {
|
|
322
|
+
/**
|
|
323
|
+
* The key/name of the option
|
|
324
|
+
*/
|
|
325
|
+
key: string;
|
|
326
|
+
/**
|
|
327
|
+
* The string value of the option
|
|
328
|
+
*/
|
|
329
|
+
value: string;
|
|
378
330
|
}
|
|
379
331
|
|
|
380
332
|
/**
|
|
381
|
-
*
|
|
333
|
+
* Represents an option for an attribute in a data model.
|
|
334
|
+
*
|
|
335
|
+
* This enum provides a strongly-typed representation of various attribute options
|
|
336
|
+
* that can be used to configure and constrain attributes in a data model.
|
|
337
|
+
*
|
|
338
|
+
* The options are grouped into several categories:
|
|
339
|
+
* - JSON Schema validation options (e.g., minimum/maximum values, length constraints)
|
|
340
|
+
* - SQL database options (e.g., primary key)
|
|
341
|
+
* - LinkML specific options (e.g., readonly, recommended)
|
|
342
|
+
* - Custom options via the `Other` variant
|
|
343
|
+
*
|
|
382
344
|
*/
|
|
383
|
-
export type
|
|
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 } };
|
|
346
|
+
|
|
347
|
+
export interface DataModel {
|
|
348
|
+
name?: string;
|
|
349
|
+
objects: Object[];
|
|
350
|
+
enums: Enumeration[];
|
|
351
|
+
config?: FrontMatter;
|
|
352
|
+
}
|
|
384
353
|
|
|
385
354
|
/**
|
|
386
|
-
* Represents
|
|
355
|
+
* Represents an enumeration with a name and mappings.
|
|
387
356
|
*/
|
|
388
|
-
export interface
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
357
|
+
export interface Enumeration {
|
|
358
|
+
/**
|
|
359
|
+
* Name of the enumeration.
|
|
360
|
+
*/
|
|
361
|
+
name: string;
|
|
362
|
+
/**
|
|
363
|
+
* Mappings associated with the enumeration.
|
|
364
|
+
*/
|
|
365
|
+
mappings: Map<string, string>;
|
|
366
|
+
/**
|
|
367
|
+
* Documentation string for the enumeration.
|
|
368
|
+
*/
|
|
369
|
+
docstring: string;
|
|
370
|
+
/**
|
|
371
|
+
* The line number of the enumeration
|
|
372
|
+
*/
|
|
373
|
+
position: Position | undefined;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Represents an object with a name, attributes, docstring, and an optional term.
|
|
378
|
+
*/
|
|
379
|
+
export interface Object {
|
|
380
|
+
/**
|
|
381
|
+
* Name of the object.
|
|
382
|
+
*/
|
|
383
|
+
name: string;
|
|
384
|
+
/**
|
|
385
|
+
* List of attributes associated with the object.
|
|
386
|
+
*/
|
|
387
|
+
attributes: Attribute[];
|
|
388
|
+
/**
|
|
389
|
+
* Documentation string for the object.
|
|
390
|
+
*/
|
|
391
|
+
docstring: string;
|
|
392
|
+
/**
|
|
393
|
+
* Optional term associated with the object.
|
|
394
|
+
*/
|
|
395
|
+
term?: string;
|
|
396
|
+
/**
|
|
397
|
+
* Other objects that this object gets mixed in with.
|
|
398
|
+
*/
|
|
399
|
+
mixins?: string[];
|
|
400
|
+
/**
|
|
401
|
+
* The line number of the object
|
|
402
|
+
*/
|
|
403
|
+
position?: Position;
|
|
396
404
|
}
|
|
397
405
|
|
package/mdmodels-core_bg.js
CHANGED
|
@@ -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:
|
|
358
|
+
JsonSchema: 3, "3": "JsonSchema",
|
|
363
359
|
/**
|
|
364
360
|
* JSON Schema All
|
|
365
361
|
*/
|
|
366
|
-
JsonSchemaAll:
|
|
362
|
+
JsonSchemaAll: 4, "4": "JsonSchemaAll",
|
|
363
|
+
/**
|
|
364
|
+
* JSON-LD
|
|
365
|
+
*/
|
|
366
|
+
JsonLd: 5, "5": "JsonLd",
|
|
367
367
|
/**
|
|
368
368
|
* SHACL
|
|
369
369
|
*/
|
|
370
|
-
|
|
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:
|
|
382
|
+
PythonDataclass: 9, "9": "PythonDataclass",
|
|
375
383
|
/**
|
|
376
384
|
* Python Pydantic XML
|
|
377
385
|
*/
|
|
378
|
-
PythonPydanticXML:
|
|
386
|
+
PythonPydanticXML: 10, "10": "PythonPydanticXML",
|
|
379
387
|
/**
|
|
380
388
|
* Python Pydantic
|
|
381
389
|
*/
|
|
382
|
-
PythonPydantic:
|
|
390
|
+
PythonPydantic: 11, "11": "PythonPydantic",
|
|
383
391
|
/**
|
|
384
392
|
* MkDocs
|
|
385
393
|
*/
|
|
386
|
-
MkDocs:
|
|
394
|
+
MkDocs: 12, "12": "MkDocs",
|
|
387
395
|
/**
|
|
388
396
|
* Internal
|
|
389
397
|
*/
|
|
390
|
-
Internal:
|
|
398
|
+
Internal: 13, "13": "Internal",
|
|
391
399
|
/**
|
|
392
400
|
* Typescript (io-ts)
|
|
393
401
|
*/
|
|
394
|
-
Typescript:
|
|
402
|
+
Typescript: 14, "14": "Typescript",
|
|
395
403
|
/**
|
|
396
404
|
* Typescript (Zod)
|
|
397
405
|
*/
|
|
398
|
-
TypescriptZod:
|
|
406
|
+
TypescriptZod: 15, "15": "TypescriptZod",
|
|
399
407
|
/**
|
|
400
408
|
* Rust
|
|
401
409
|
*/
|
|
402
|
-
Rust:
|
|
410
|
+
Rust: 16, "16": "Rust",
|
|
403
411
|
/**
|
|
404
412
|
* Protobuf
|
|
405
413
|
*/
|
|
406
|
-
Protobuf:
|
|
414
|
+
Protobuf: 17, "17": "Protobuf",
|
|
407
415
|
/**
|
|
408
416
|
* Graphql
|
|
409
417
|
*/
|
|
410
|
-
Graphql:
|
|
418
|
+
Graphql: 18, "18": "Graphql",
|
|
411
419
|
/**
|
|
412
420
|
* Golang
|
|
413
421
|
*/
|
|
414
|
-
Golang:
|
|
422
|
+
Golang: 19, "19": "Golang",
|
|
415
423
|
/**
|
|
416
424
|
* Linkml
|
|
417
425
|
*/
|
|
418
|
-
Linkml:
|
|
426
|
+
Linkml: 20, "20": "Linkml",
|
|
419
427
|
/**
|
|
420
428
|
* Julia
|
|
421
429
|
*/
|
|
422
|
-
Julia:
|
|
430
|
+
Julia: 21, "21": "Julia",
|
|
423
431
|
/**
|
|
424
432
|
* Mermaid class diagram
|
|
425
433
|
*/
|
|
426
|
-
Mermaid:
|
|
434
|
+
Mermaid: 22, "22": "Mermaid",
|
|
427
435
|
});
|
|
428
436
|
|
|
429
437
|
export function __wbg_String_8f0eb39a4a4c2f66(arg0, arg1) {
|
package/mdmodels-core_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED