mdmodels-core 0.1.4 → 0.1.6
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 +11 -0
- package/mdmodels-core.d.ts +16 -7
- package/mdmodels-core_bg.js +125 -68
- package/mdmodels-core_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -84,3 +84,14 @@ This project uses GitHub Actions for continuous integration. The tests can be ru
|
|
|
84
84
|
cargo test
|
|
85
85
|
cargo clippy
|
|
86
86
|
```
|
|
87
|
+
|
|
88
|
+
### Using pre-commit hooks
|
|
89
|
+
|
|
90
|
+
This project uses [pre-commit](https://pre-commit.com/) to run the `rustfmt` and `clippy` commands on every commit. To install the pre-commit hooks, you can use the following command:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
pip install pre-commit
|
|
94
|
+
pre-commit install
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Once the pre-commit hooks are installed, they will run on every commit. This will ensure that the code is formatted and linted correctly. And the clippy CI will not complain about warnings.
|
package/mdmodels-core.d.ts
CHANGED
|
@@ -12,8 +12,6 @@
|
|
|
12
12
|
* A `Result` which is:
|
|
13
13
|
* - `Ok(JsValue)` if the parsing and serialization are successful.
|
|
14
14
|
* - `Err(JsValue)` if there is an error during parsing or serialization.
|
|
15
|
-
* @param {string} markdown_content
|
|
16
|
-
* @returns {any}
|
|
17
15
|
*/
|
|
18
16
|
export function parse_model(markdown_content: string): any;
|
|
19
17
|
/**
|
|
@@ -29,11 +27,24 @@ export function parse_model(markdown_content: string): any;
|
|
|
29
27
|
* A `Result` which is:
|
|
30
28
|
* - `Ok(String)` if the conversion is successful.
|
|
31
29
|
* - `Err(JsValue)` if there is an error during parsing or conversion.
|
|
32
|
-
* @param {string} markdown_content
|
|
33
|
-
* @param {Templates} template
|
|
34
|
-
* @returns {string}
|
|
35
30
|
*/
|
|
36
31
|
export function convert_to(markdown_content: string, template: Templates): string;
|
|
32
|
+
/**
|
|
33
|
+
* Returns the JSON schema for the given markdown content.
|
|
34
|
+
*
|
|
35
|
+
* # Arguments
|
|
36
|
+
*
|
|
37
|
+
* * `markdown_content` - A string slice that holds the markdown content to be converted.
|
|
38
|
+
* * `root` - The root object to use for the schema.
|
|
39
|
+
* * `openai` - Whether to remove options from the schema properties. OpenAI does not support options.
|
|
40
|
+
*
|
|
41
|
+
* # Returns
|
|
42
|
+
*
|
|
43
|
+
* A `Result` which is:
|
|
44
|
+
* - `Ok(JsValue)` if the conversion is successful.
|
|
45
|
+
* - `Err(JsValue)` if there is an error during parsing or conversion.
|
|
46
|
+
*/
|
|
47
|
+
export function json_schema(markdown_content: string, root: string | undefined, openai: boolean): string;
|
|
37
48
|
/**
|
|
38
49
|
* Validates the given markdown content and returns the validation result as a `JsValue`.
|
|
39
50
|
*
|
|
@@ -46,8 +57,6 @@ export function convert_to(markdown_content: string, template: Templates): strin
|
|
|
46
57
|
* A `Result` which is:
|
|
47
58
|
* - `Ok(JsValue)` if the validation is successful.
|
|
48
59
|
* - `Err(JsValue)` if there is an error during parsing or validation.
|
|
49
|
-
* @param {string} markdown_content
|
|
50
|
-
* @returns {any}
|
|
51
60
|
*/
|
|
52
61
|
export function validate(markdown_content: string): any;
|
|
53
62
|
/**
|
package/mdmodels-core_bg.js
CHANGED
|
@@ -4,11 +4,7 @@ export function __wbg_set_wasm(val) {
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
10
|
-
|
|
11
|
-
cachedTextDecoder.decode();
|
|
7
|
+
let WASM_VECTOR_LEN = 0;
|
|
12
8
|
|
|
13
9
|
let cachedUint8ArrayMemory0 = null;
|
|
14
10
|
|
|
@@ -19,13 +15,6 @@ function getUint8ArrayMemory0() {
|
|
|
19
15
|
return cachedUint8ArrayMemory0;
|
|
20
16
|
}
|
|
21
17
|
|
|
22
|
-
function getStringFromWasm0(ptr, len) {
|
|
23
|
-
ptr = ptr >>> 0;
|
|
24
|
-
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
let WASM_VECTOR_LEN = 0;
|
|
28
|
-
|
|
29
18
|
const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;
|
|
30
19
|
|
|
31
20
|
let cachedTextEncoder = new lTextEncoder('utf-8');
|
|
@@ -82,8 +71,28 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
82
71
|
return ptr;
|
|
83
72
|
}
|
|
84
73
|
|
|
74
|
+
let cachedDataViewMemory0 = null;
|
|
75
|
+
|
|
76
|
+
function getDataViewMemory0() {
|
|
77
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
78
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
79
|
+
}
|
|
80
|
+
return cachedDataViewMemory0;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
|
|
84
|
+
|
|
85
|
+
let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
86
|
+
|
|
87
|
+
cachedTextDecoder.decode();
|
|
88
|
+
|
|
89
|
+
function getStringFromWasm0(ptr, len) {
|
|
90
|
+
ptr = ptr >>> 0;
|
|
91
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
92
|
+
}
|
|
93
|
+
|
|
85
94
|
function takeFromExternrefTable0(idx) {
|
|
86
|
-
const value = wasm.
|
|
95
|
+
const value = wasm.__wbindgen_export_2.get(idx);
|
|
87
96
|
wasm.__externref_table_dealloc(idx);
|
|
88
97
|
return value;
|
|
89
98
|
}
|
|
@@ -150,6 +159,51 @@ export function convert_to(markdown_content, template) {
|
|
|
150
159
|
}
|
|
151
160
|
}
|
|
152
161
|
|
|
162
|
+
function isLikeNone(x) {
|
|
163
|
+
return x === undefined || x === null;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Returns the JSON schema for the given markdown content.
|
|
167
|
+
*
|
|
168
|
+
* # Arguments
|
|
169
|
+
*
|
|
170
|
+
* * `markdown_content` - A string slice that holds the markdown content to be converted.
|
|
171
|
+
* * `root` - The root object to use for the schema.
|
|
172
|
+
* * `openai` - Whether to remove options from the schema properties. OpenAI does not support options.
|
|
173
|
+
*
|
|
174
|
+
* # Returns
|
|
175
|
+
*
|
|
176
|
+
* A `Result` which is:
|
|
177
|
+
* - `Ok(JsValue)` if the conversion is successful.
|
|
178
|
+
* - `Err(JsValue)` if there is an error during parsing or conversion.
|
|
179
|
+
* @param {string} markdown_content
|
|
180
|
+
* @param {string | undefined} root
|
|
181
|
+
* @param {boolean} openai
|
|
182
|
+
* @returns {string}
|
|
183
|
+
*/
|
|
184
|
+
export function json_schema(markdown_content, root, openai) {
|
|
185
|
+
let deferred4_0;
|
|
186
|
+
let deferred4_1;
|
|
187
|
+
try {
|
|
188
|
+
const ptr0 = passStringToWasm0(markdown_content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
189
|
+
const len0 = WASM_VECTOR_LEN;
|
|
190
|
+
var ptr1 = isLikeNone(root) ? 0 : passStringToWasm0(root, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
191
|
+
var len1 = WASM_VECTOR_LEN;
|
|
192
|
+
const ret = wasm.json_schema(ptr0, len0, ptr1, len1, openai);
|
|
193
|
+
var ptr3 = ret[0];
|
|
194
|
+
var len3 = ret[1];
|
|
195
|
+
if (ret[3]) {
|
|
196
|
+
ptr3 = 0; len3 = 0;
|
|
197
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
198
|
+
}
|
|
199
|
+
deferred4_0 = ptr3;
|
|
200
|
+
deferred4_1 = len3;
|
|
201
|
+
return getStringFromWasm0(ptr3, len3);
|
|
202
|
+
} finally {
|
|
203
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
153
207
|
/**
|
|
154
208
|
* Validates the given markdown content and returns the validation result as a `JsValue`.
|
|
155
209
|
*
|
|
@@ -175,48 +229,27 @@ export function validate(markdown_content) {
|
|
|
175
229
|
return takeFromExternrefTable0(ret[0]);
|
|
176
230
|
}
|
|
177
231
|
|
|
178
|
-
let cachedDataViewMemory0 = null;
|
|
179
|
-
|
|
180
|
-
function getDataViewMemory0() {
|
|
181
|
-
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
182
|
-
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
183
|
-
}
|
|
184
|
-
return cachedDataViewMemory0;
|
|
185
|
-
}
|
|
186
232
|
/**
|
|
187
233
|
* Enumeration of available templates.
|
|
234
|
+
* @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12}
|
|
188
235
|
*/
|
|
189
|
-
export const Templates = Object.freeze({
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
export function __wbindgen_number_new(arg0) {
|
|
205
|
-
const ret = arg0;
|
|
206
|
-
return ret;
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
export function __wbindgen_error_new(arg0, arg1) {
|
|
210
|
-
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
211
|
-
return ret;
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
export function __wbindgen_is_string(arg0) {
|
|
215
|
-
const ret = typeof(arg0) === 'string';
|
|
216
|
-
return ret;
|
|
217
|
-
};
|
|
236
|
+
export const Templates = Object.freeze({
|
|
237
|
+
XmlSchema: 0, "0": "XmlSchema",
|
|
238
|
+
Markdown: 1, "1": "Markdown",
|
|
239
|
+
CompactMarkdown: 2, "2": "CompactMarkdown",
|
|
240
|
+
Shacl: 3, "3": "Shacl",
|
|
241
|
+
JsonSchema: 4, "4": "JsonSchema",
|
|
242
|
+
JsonSchemaAll: 5, "5": "JsonSchemaAll",
|
|
243
|
+
Shex: 6, "6": "Shex",
|
|
244
|
+
PythonDataclass: 7, "7": "PythonDataclass",
|
|
245
|
+
PythonPydanticXML: 8, "8": "PythonPydanticXML",
|
|
246
|
+
PythonPydantic: 9, "9": "PythonPydantic",
|
|
247
|
+
MkDocs: 10, "10": "MkDocs",
|
|
248
|
+
Internal: 11, "11": "Internal",
|
|
249
|
+
Typescript: 12, "12": "Typescript",
|
|
250
|
+
});
|
|
218
251
|
|
|
219
|
-
export function
|
|
252
|
+
export function __wbg_String_8f0eb39a4a4c2f66(arg0, arg1) {
|
|
220
253
|
const ret = String(arg1);
|
|
221
254
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
222
255
|
const len1 = WASM_VECTOR_LEN;
|
|
@@ -224,45 +257,50 @@ export function __wbg_String_b9412f8799faab3e(arg0, arg1) {
|
|
|
224
257
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
225
258
|
};
|
|
226
259
|
|
|
227
|
-
export function
|
|
228
|
-
|
|
229
|
-
return ret;
|
|
230
|
-
};
|
|
231
|
-
|
|
232
|
-
export function __wbg_set_f975102236d3c502(arg0, arg1, arg2) {
|
|
233
|
-
arg0[arg1] = arg2;
|
|
260
|
+
export function __wbg_log_770029216eb4d401(arg0, arg1) {
|
|
261
|
+
console.log(getStringFromWasm0(arg0, arg1));
|
|
234
262
|
};
|
|
235
263
|
|
|
236
|
-
export function
|
|
264
|
+
export function __wbg_new_254fa9eac11932ae() {
|
|
237
265
|
const ret = new Array();
|
|
238
266
|
return ret;
|
|
239
267
|
};
|
|
240
268
|
|
|
241
|
-
export function
|
|
242
|
-
const ret = new
|
|
269
|
+
export function __wbg_new_688846f374351c92() {
|
|
270
|
+
const ret = new Object();
|
|
243
271
|
return ret;
|
|
244
272
|
};
|
|
245
273
|
|
|
246
|
-
export function
|
|
247
|
-
const ret = new
|
|
274
|
+
export function __wbg_new_bc96c6a1c0786643() {
|
|
275
|
+
const ret = new Map();
|
|
248
276
|
return ret;
|
|
249
277
|
};
|
|
250
278
|
|
|
251
|
-
export function
|
|
279
|
+
export function __wbg_set_1d80752d0d5f0b21(arg0, arg1, arg2) {
|
|
252
280
|
arg0[arg1 >>> 0] = arg2;
|
|
253
281
|
};
|
|
254
282
|
|
|
255
|
-
export function
|
|
283
|
+
export function __wbg_set_3f1d0b984ed272ed(arg0, arg1, arg2) {
|
|
284
|
+
arg0[arg1] = arg2;
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
export function __wbg_set_76818dc3c59a63d5(arg0, arg1, arg2) {
|
|
256
288
|
const ret = arg0.set(arg1, arg2);
|
|
257
289
|
return ret;
|
|
258
290
|
};
|
|
259
291
|
|
|
260
|
-
export function
|
|
261
|
-
|
|
292
|
+
export function __wbindgen_bigint_from_i64(arg0) {
|
|
293
|
+
const ret = arg0;
|
|
294
|
+
return ret;
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
export function __wbindgen_error_new(arg0, arg1) {
|
|
298
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
299
|
+
return ret;
|
|
262
300
|
};
|
|
263
301
|
|
|
264
302
|
export function __wbindgen_init_externref_table() {
|
|
265
|
-
const table = wasm.
|
|
303
|
+
const table = wasm.__wbindgen_export_2;
|
|
266
304
|
const offset = table.grow(4);
|
|
267
305
|
table.set(0, undefined);
|
|
268
306
|
table.set(offset + 0, undefined);
|
|
@@ -272,3 +310,22 @@ export function __wbindgen_init_externref_table() {
|
|
|
272
310
|
;
|
|
273
311
|
};
|
|
274
312
|
|
|
313
|
+
export function __wbindgen_is_string(arg0) {
|
|
314
|
+
const ret = typeof(arg0) === 'string';
|
|
315
|
+
return ret;
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
export function __wbindgen_number_new(arg0) {
|
|
319
|
+
const ret = arg0;
|
|
320
|
+
return ret;
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
export function __wbindgen_string_new(arg0, arg1) {
|
|
324
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
325
|
+
return ret;
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
export function __wbindgen_throw(arg0, arg1) {
|
|
329
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
330
|
+
};
|
|
331
|
+
|
package/mdmodels-core_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED