shacl-wasm-node 0.1.10 → 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 CHANGED
@@ -92,9 +92,24 @@ validator.validateText(text, format, base, inference) // inference: "none" (
92
92
  validator.shapeCount // shapes compiled
93
93
 
94
94
  const { validateTurtle } = require('./pkg-node/shacl_wasm.js');
95
- validateTurtle(shapesTurtle, dataTurtle, base); // one-shot, no reuse
95
+ validateTurtle(dataTurtle, shapesTurtle, base); // one-shot, no reuse
96
+ validateTurtle(selfDescribingTurtle); // shapes carried by the data
96
97
  ```
97
98
 
99
+ **The one-shot takes `(data, shapes)`, and took `(shapes, data)` before 0.2.0.**
100
+ Data comes first in every other surface — the Python `validate(data, shapes)`,
101
+ the CLI's `--data`/`--shapes`, and the Rust API under all of them — and this
102
+ was the only one reversed. Omitting `shapes` validates a self-describing
103
+ document against the shapes it carries, as the other two also do.
104
+
105
+ Transposing them used to be a silent fault rather than a loud one: the data
106
+ graph compiled as a shapes graph, declared no shapes, and validating against no
107
+ shapes conforms — so the caller was told their graph was valid when nothing had
108
+ been checked. A shapes graph with no shapes now throws instead, which is what
109
+ makes the reordering safe: code written for the old signature fails rather than
110
+ passing. `Validator.fromTurtle` stays permissive, since it exposes
111
+ `shapeCount` for a caller who wants to decide for themselves.
112
+
98
113
  `inference: "rdfs"` validates against the RDFS closure of the data, so a finding
99
114
  can depend on an entailed `rdf:type` rather than only an asserted one.
100
115
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "shacl-wasm-node",
3
3
  "description": "WebAssembly bindings for the shacl validation engine (CommonJS, for Node and require())",
4
- "version": "0.1.10",
4
+ "version": "0.2.0",
5
5
  "license": "MIT OR Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",
package/shacl_wasm.d.ts CHANGED
@@ -90,5 +90,17 @@ export function start(): void;
90
90
  /**
91
91
  * One-shot validation, for a caller with a single data graph that gains
92
92
  * nothing from holding a compiled [`Validator`].
93
+ *
94
+ * `data` comes first, and `shapes` may be omitted for a self-describing
95
+ * document that carries its own — the same call shape as the Python binding's
96
+ * `validate(data, shapes=None)`, the CLI's `--data`/`--shapes`, and the Rust
97
+ * `validate(data, shapes_graph, ..)` underneath all of them.
98
+ *
99
+ * It used to take `(shapes, data)`, alone among the four. Transposing the two
100
+ * is not a loud mistake but a quiet one: the data graph compiles as a shapes
101
+ * graph, declares no shapes, and validating anything against no shapes
102
+ * conforms. The caller is told their graph is valid when nothing was checked.
103
+ * Hence the guard below, which is what makes this reordering safe to make —
104
+ * a call written for the old signature now fails instead of passing.
93
105
  */
94
- export function validateTurtle(shapes: string, data: string, base?: string | null): Report;
106
+ export function validateTurtle(data: string, shapes?: string | null, base?: string | null): Report;
package/shacl_wasm.js CHANGED
@@ -261,18 +261,30 @@ exports.start = start;
261
261
  /**
262
262
  * One-shot validation, for a caller with a single data graph that gains
263
263
  * nothing from holding a compiled [`Validator`].
264
- * @param {string} shapes
264
+ *
265
+ * `data` comes first, and `shapes` may be omitted for a self-describing
266
+ * document that carries its own — the same call shape as the Python binding's
267
+ * `validate(data, shapes=None)`, the CLI's `--data`/`--shapes`, and the Rust
268
+ * `validate(data, shapes_graph, ..)` underneath all of them.
269
+ *
270
+ * It used to take `(shapes, data)`, alone among the four. Transposing the two
271
+ * is not a loud mistake but a quiet one: the data graph compiles as a shapes
272
+ * graph, declares no shapes, and validating anything against no shapes
273
+ * conforms. The caller is told their graph is valid when nothing was checked.
274
+ * Hence the guard below, which is what makes this reordering safe to make —
275
+ * a call written for the old signature now fails instead of passing.
265
276
  * @param {string} data
277
+ * @param {string | null} [shapes]
266
278
  * @param {string | null} [base]
267
279
  * @returns {Report}
268
280
  */
269
- function validateTurtle(shapes, data, base) {
281
+ function validateTurtle(data, shapes, base) {
270
282
  try {
271
283
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
272
- const ptr0 = passStringToWasm0(shapes, wasm.__wbindgen_export, wasm.__wbindgen_export2);
284
+ const ptr0 = passStringToWasm0(data, wasm.__wbindgen_export, wasm.__wbindgen_export2);
273
285
  const len0 = WASM_VECTOR_LEN;
274
- const ptr1 = passStringToWasm0(data, wasm.__wbindgen_export, wasm.__wbindgen_export2);
275
- const len1 = WASM_VECTOR_LEN;
286
+ var ptr1 = isLikeNone(shapes) ? 0 : passStringToWasm0(shapes, wasm.__wbindgen_export, wasm.__wbindgen_export2);
287
+ var len1 = WASM_VECTOR_LEN;
276
288
  var ptr2 = isLikeNone(base) ? 0 : passStringToWasm0(base, wasm.__wbindgen_export, wasm.__wbindgen_export2);
277
289
  var len2 = WASM_VECTOR_LEN;
278
290
  wasm.validateTurtle(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
Binary file