holos-wasm-node 0.18.0 → 0.19.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
@@ -46,10 +46,28 @@ store.dump('nquads'); // everything the store holds
46
46
  | What you get back | From |
47
47
  |---|---|
48
48
  | `true` / `false` | ASK |
49
- | terms in rdf-js shape — `{termType, value}`, plus `language` and `datatype` on a literal | SELECT |
49
+ | terms in rdf-js shape — `{termType, value}`, plus `language`, `direction` and `datatype` on a literal; and `.variables` on the array | SELECT |
50
50
  | N-Triples strings, one per triple, no trailing separator | CONSTRUCT, DESCRIBE |
51
51
  | a document in the format you asked for | `queryRdf` |
52
52
  | `{inserted, deleted, graphsCreated, graphsDropped}` | `update` |
53
+ | `{pending, result}`, the host fetching what is pending | `queryFederated` |
54
+ | the plan as JSON, with statistics from the run | `explain` |
55
+
56
+ A SELECT result carries **`.variables`**, the projected variables in order, as a property on the
57
+ array — so `result.length` and `for (const row of result)` keep working. The rows cannot carry
58
+ this: an unbound variable is absent from a row, so one unbound in *every* row is invisible, and
59
+ a result with no rows has no columns at all — while `head.vars` in the SPARQL results JSON
60
+ format must list every projected variable regardless. Without it a caller has to parse the
61
+ projection out of the query text.
62
+
63
+ A literal's **`direction`** is its RDF 1.2 base direction, `"ltr"`, `"rtl"` or `""` — the same
64
+ "always present, empty when absent" convention as `language`, because a field that is sometimes
65
+ missing makes every reader check before it can compare.
66
+
67
+ **`explain` evaluates.** The results are drained and discarded before the plan is written,
68
+ because the statistics are gathered as rows flow through the operators — a plan serialised
69
+ before that reports zeroes everywhere. So it costs a full run and tells you what the run did,
70
+ not what the planner intended.
53
71
 
54
72
  **SELECT returns terms, not strings, since 0.17.0.** They used to be N-Triples strings,
55
73
  which made every consumer parse term syntax to reach a value, and no RDF library in JS
package/holos_wasm.d.ts CHANGED
@@ -30,6 +30,23 @@ export class Store {
30
30
  * and every JS RDF library can parse what comes back.
31
31
  */
32
32
  dump(format: string): string;
33
+ /**
34
+ * The query plan, as JSON, with the statistics from actually running it.
35
+ *
36
+ * HOLOS has had this since the CLI's `--explain`; it was simply not reachable from here,
37
+ * so a browser could run a query far faster than a server and still not say how.
38
+ *
39
+ * **It evaluates.** The results are drained and discarded, because an explanation
40
+ * serialised before the results are consumed reports zeroes for every operator — the
41
+ * statistics are gathered as rows flow through it. So this costs a full run and answers
42
+ * what that run did, rather than what the planner intended.
43
+ *
44
+ * # Errors
45
+ *
46
+ * As `query`, plus the case where the engine returns no explanation at all, which would
47
+ * mean the request for one was dropped on the way through.
48
+ */
49
+ explain(query: string, base?: string | null): string;
33
50
  /**
34
51
  * Load Turtle, which is the common case.
35
52
  */
package/holos_wasm.js CHANGED
@@ -80,6 +80,47 @@ class Store {
80
80
  wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
81
81
  }
82
82
  }
83
+ /**
84
+ * The query plan, as JSON, with the statistics from actually running it.
85
+ *
86
+ * HOLOS has had this since the CLI's `--explain`; it was simply not reachable from here,
87
+ * so a browser could run a query far faster than a server and still not say how.
88
+ *
89
+ * **It evaluates.** The results are drained and discarded, because an explanation
90
+ * serialised before the results are consumed reports zeroes for every operator — the
91
+ * statistics are gathered as rows flow through it. So this costs a full run and answers
92
+ * what that run did, rather than what the planner intended.
93
+ *
94
+ * # Errors
95
+ *
96
+ * As `query`, plus the case where the engine returns no explanation at all, which would
97
+ * mean the request for one was dropped on the way through.
98
+ * @param {string} query
99
+ * @param {string | null} [base]
100
+ * @returns {string}
101
+ */
102
+ explain(query, base) {
103
+ let deferred4_0;
104
+ let deferred4_1;
105
+ try {
106
+ const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
107
+ const len0 = WASM_VECTOR_LEN;
108
+ var ptr1 = isLikeNone(base) ? 0 : passStringToWasm0(base, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
109
+ var len1 = WASM_VECTOR_LEN;
110
+ const ret = wasm.store_explain(this.__wbg_ptr, ptr0, len0, ptr1, len1);
111
+ var ptr3 = ret[0];
112
+ var len3 = ret[1];
113
+ if (ret[3]) {
114
+ ptr3 = 0; len3 = 0;
115
+ throw takeFromExternrefTable0(ret[2]);
116
+ }
117
+ deferred4_0 = ptr3;
118
+ deferred4_1 = len3;
119
+ return getStringFromWasm0(ptr3, len3);
120
+ } finally {
121
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
122
+ }
123
+ }
83
124
  /**
84
125
  * Load Turtle, which is the common case.
85
126
  * @param {string} text
Binary file
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "holos-wasm-node",
3
3
  "description": "WebAssembly bindings for the HOLOS RDF 1.2 store and SPARQL 1.2 engine (CommonJS, for Node and require())",
4
- "version": "0.18.0",
4
+ "version": "0.19.0",
5
5
  "license": "MIT OR Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",