@cooljapan/oxirs 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 ADDED
@@ -0,0 +1,260 @@
1
+ # oxirs-wasm
2
+
3
+ **WebAssembly bindings for OxiRS - Run RDF/SPARQL in the browser**
4
+
5
+ [![Crates.io](https://img.shields.io/crates/v/oxirs-wasm.svg)](https://crates.io/crates/oxirs-wasm)
6
+ [![docs.rs](https://docs.rs/oxirs-wasm/badge.svg)](https://docs.rs/oxirs-wasm)
7
+ [![npm](https://img.shields.io/npm/v/oxirs-wasm.svg)](https://www.npmjs.com/package/oxirs-wasm)
8
+
9
+ Lightweight RDF and SPARQL implementation compiled to WebAssembly for browser, Node.js, and edge deployment.
10
+
11
+ ## Features
12
+
13
+ - **In-memory RDF Store**: HashSet-based triple storage with O(1) lookups
14
+ - **RDF Parsing**: Turtle and N-Triples format support
15
+ - **SPARQL Queries**: SELECT, ASK, CONSTRUCT with pattern matching
16
+ - **TypeScript Support**: Full type definitions
17
+ - **Zero Server Dependencies**: No Tokio, runs in single-threaded WASM
18
+ - **Lightweight**: ~300KB optimized binary
19
+
20
+ ## Installation
21
+
22
+ ### NPM (Browser/Node.js)
23
+
24
+ ```bash
25
+ npm install oxirs-wasm
26
+ ```
27
+
28
+ ### Cargo (Rust WASM Project)
29
+
30
+ ```toml
31
+ [dependencies]
32
+ oxirs-wasm = "0.1"
33
+ ```
34
+
35
+ ## Quick Start
36
+
37
+ ### JavaScript/TypeScript
38
+
39
+ ```typescript
40
+ import { initialize, createStore } from 'oxirs-wasm';
41
+
42
+ // Initialize WASM module
43
+ await initialize();
44
+
45
+ // Create RDF store
46
+ const store = await createStore();
47
+
48
+ // Load Turtle data
49
+ const turtle = `
50
+ @prefix : <http://example.org/> .
51
+ :alice :knows :bob .
52
+ :bob :name "Bob" .
53
+ `;
54
+ const count = await store.loadTurtle(turtle);
55
+ console.log(`Loaded ${count} triples`);
56
+
57
+ // Execute SPARQL query
58
+ const results = await store.query(`
59
+ SELECT ?person ?name WHERE {
60
+ ?person :name ?name .
61
+ }
62
+ `);
63
+ console.log(results);
64
+ // [{ person: "http://example.org/bob", name: "\"Bob\"" }]
65
+
66
+ // ASK query
67
+ const exists = await store.ask(`
68
+ ASK { :alice :knows :bob }
69
+ `);
70
+ console.log('Alice knows Bob:', exists); // true
71
+
72
+ // Export to N-Triples
73
+ const ntriples = store.toNTriples();
74
+ console.log(ntriples);
75
+ ```
76
+
77
+ ### HTML Integration
78
+
79
+ ```html
80
+ <!DOCTYPE html>
81
+ <html>
82
+ <head>
83
+ <title>RDF in Browser</title>
84
+ </head>
85
+ <body>
86
+ <script type="module">
87
+ import { initialize, createStore } from './pkg/oxirs_wasm.js';
88
+
89
+ async function run() {
90
+ await initialize();
91
+ const store = await createStore();
92
+
93
+ await store.loadTurtle(`
94
+ @prefix : <http://example.org/> .
95
+ :alice :knows :bob .
96
+ `);
97
+
98
+ const results = await store.query(
99
+ 'SELECT ?s ?o WHERE { ?s :knows ?o }'
100
+ );
101
+
102
+ console.log('Results:', results);
103
+ }
104
+
105
+ run();
106
+ </script>
107
+ </body>
108
+ </html>
109
+ ```
110
+
111
+ ## Building from Source
112
+
113
+ ```bash
114
+ # Install wasm-pack
115
+ curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
116
+
117
+ # Build WASM package
118
+ cd platforms/oxirs-wasm
119
+ wasm-pack build --target web --release
120
+
121
+ # The output will be in pkg/
122
+ # - oxirs_wasm.js (ES module)
123
+ # - oxirs_wasm_bg.wasm (binary)
124
+ # - oxirs_wasm.d.ts (TypeScript types)
125
+ ```
126
+
127
+ ## API Reference
128
+
129
+ ### Store Operations
130
+
131
+ ```typescript
132
+ class OxiRSStore {
133
+ constructor();
134
+
135
+ // Load RDF data
136
+ loadTurtle(turtle: string): Promise<number>;
137
+ loadNTriples(ntriples: string): Promise<number>;
138
+
139
+ // Triple operations
140
+ insert(subject: string, predicate: string, object: string): boolean;
141
+ delete(subject: string, predicate: string, object: string): boolean;
142
+ contains(subject: string, predicate: string, object: string): boolean;
143
+ size(): number;
144
+ clear(): void;
145
+
146
+ // SPARQL queries
147
+ query(sparql: string): Promise<QueryResult[]>;
148
+ ask(sparql: string): Promise<boolean>;
149
+ construct(sparql: string): Promise<Triple[]>;
150
+
151
+ // Export
152
+ toTurtle(): string;
153
+ toNTriples(): string;
154
+
155
+ // Indexes
156
+ subjects(): string[];
157
+ predicates(): string[];
158
+ objects(): string[];
159
+
160
+ // Namespaces
161
+ addPrefix(prefix: string, uri: string): void;
162
+ }
163
+ ```
164
+
165
+ ## Deployment Targets
166
+
167
+ ### Browser
168
+
169
+ ```html
170
+ <script type="module">
171
+ import init, { createStore } from './pkg/oxirs_wasm.js';
172
+ await init();
173
+ const store = await createStore();
174
+ </script>
175
+ ```
176
+
177
+ ### Node.js
178
+
179
+ ```javascript
180
+ const { initialize, createStore } = require('oxirs-wasm');
181
+
182
+ (async () => {
183
+ await initialize();
184
+ const store = await createStore();
185
+ // ...
186
+ })();
187
+ ```
188
+
189
+ ### Cloudflare Workers
190
+
191
+ ```typescript
192
+ import { initialize, createStore } from 'oxirs-wasm';
193
+
194
+ export default {
195
+ async fetch(request: Request): Promise<Response> {
196
+ await initialize();
197
+ const store = await createStore();
198
+
199
+ // Process RDF data
200
+ const { rdf, sparql } = await request.json();
201
+ await store.loadTurtle(rdf);
202
+ const results = await store.query(sparql);
203
+
204
+ return new Response(JSON.stringify(results));
205
+ }
206
+ };
207
+ ```
208
+
209
+ ### Deno Deploy
210
+
211
+ ```typescript
212
+ import { initialize, createStore } from 'https://esm.sh/oxirs-wasm';
213
+
214
+ Deno.serve(async (req) => {
215
+ await initialize();
216
+ const store = await createStore();
217
+ // ...
218
+ });
219
+ ```
220
+
221
+ ## Limitations
222
+
223
+ Current implementation focuses on core functionality:
224
+
225
+ - ❌ No persistent storage (in-memory only)
226
+ - ❌ No SPARQL UPDATE/DESCRIBE
227
+ - ❌ No RDFS/OWL reasoning
228
+ - ❌ No SHACL validation
229
+ - ❌ No federated queries (SERVICE)
230
+ - ❌ Limited SPARQL features (basic graph patterns only)
231
+
232
+ For full SPARQL support, use the server-side `oxirs-fuseki` crate.
233
+
234
+ ## Performance
235
+
236
+ - **WASM binary size**: ~300KB (optimized with wasm-opt)
237
+ - **Initialization**: ~100ms (first load, cached)
238
+ - **Parsing**: 10K triples/sec (Turtle)
239
+ - **Query execution**: 1K queries/sec (simple patterns)
240
+ - **Memory**: ~200KB per 1K triples
241
+
242
+ ## Use Cases
243
+
244
+ - **Browser RDF Editors**: Client-side validation and editing
245
+ - **Offline Applications**: Local knowledge graphs without server
246
+ - **Edge Computing**: IoT devices, embedded systems
247
+ - **Privacy-Preserving**: Process sensitive data locally
248
+ - **Developer Tools**: RDF/SPARQL playground in browser
249
+ - **Static Sites**: Jamstack with client-side queries
250
+
251
+ ## Dependencies
252
+
253
+ - `wasm-bindgen` - JavaScript interop
254
+ - `js-sys` - JavaScript standard library bindings
255
+ - `web-sys` - Web APIs (console, performance)
256
+ - `getrandom` - Random number generation (js feature)
257
+
258
+ ## License
259
+
260
+ Licensed under the Apache License, Version 2.0.
package/index.js ADDED
@@ -0,0 +1,41 @@
1
+ /**
2
+ * OxiRS WASM - JavaScript wrapper
3
+ *
4
+ * @module oxirs-wasm
5
+ */
6
+
7
+ import init, { OxiRSStore, Triple, version, log } from './oxirs_wasm.js';
8
+
9
+ let initialized = false;
10
+
11
+ /**
12
+ * Initialize the WASM module
13
+ * @returns {Promise<void>}
14
+ */
15
+ export async function initialize() {
16
+ if (!initialized) {
17
+ await init();
18
+ initialized = true;
19
+ }
20
+ }
21
+
22
+ /**
23
+ * Create a new RDF store
24
+ * @returns {Promise<OxiRSStore>}
25
+ */
26
+ export async function createStore() {
27
+ await initialize();
28
+ return new OxiRSStore();
29
+ }
30
+
31
+ /**
32
+ * Get the version of OxiRS WASM
33
+ * @returns {Promise<string>}
34
+ */
35
+ export async function getVersion() {
36
+ await initialize();
37
+ return version();
38
+ }
39
+
40
+ // Re-export classes
41
+ export { OxiRSStore, Triple, log };
@@ -0,0 +1,113 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * OxiRS in-memory RDF store exposed to JavaScript via wasm_bindgen
6
+ */
7
+ export class OxiRSStore {
8
+ free(): void;
9
+ [Symbol.dispose](): void;
10
+ /**
11
+ * Register a namespace prefix
12
+ */
13
+ addPrefix(prefix: string, uri: string): void;
14
+ /**
15
+ * Execute a SPARQL ASK query
16
+ */
17
+ ask(sparql: string): boolean;
18
+ /**
19
+ * Clear all triples
20
+ */
21
+ clear(): void;
22
+ /**
23
+ * Execute a SPARQL CONSTRUCT query
24
+ */
25
+ construct(sparql: string): Triple[];
26
+ /**
27
+ * Check if a triple exists
28
+ */
29
+ contains(subject: string, predicate: string, object: string): boolean;
30
+ /**
31
+ * Delete a single triple, returning true if it was found
32
+ */
33
+ delete(subject: string, predicate: string, object: string): boolean;
34
+ /**
35
+ * Insert a single triple
36
+ */
37
+ insert(subject: string, predicate: string, object: string): boolean;
38
+ /**
39
+ * Load N-Triples data
40
+ */
41
+ loadNTriples(ntriples: string): number;
42
+ /**
43
+ * Load Turtle data
44
+ */
45
+ loadTurtle(turtle: string): number;
46
+ /**
47
+ * Create a new empty store
48
+ */
49
+ constructor();
50
+ /**
51
+ * Get all objects
52
+ */
53
+ objects(): string[];
54
+ /**
55
+ * Get all predicates
56
+ */
57
+ predicates(): string[];
58
+ /**
59
+ * Execute a SPARQL SELECT query
60
+ */
61
+ query(sparql: string): any;
62
+ /**
63
+ * Get the number of triples
64
+ */
65
+ size(): number;
66
+ /**
67
+ * Get all subjects
68
+ */
69
+ subjects(): string[];
70
+ /**
71
+ * Export to N-Triples format
72
+ */
73
+ toNTriples(): string;
74
+ /**
75
+ * Export to Turtle format
76
+ */
77
+ toTurtle(): string;
78
+ }
79
+
80
+ /**
81
+ * Query result for JavaScript
82
+ */
83
+ export class QueryResult {
84
+ private constructor();
85
+ free(): void;
86
+ [Symbol.dispose](): void;
87
+ readonly bindings: any[];
88
+ readonly length: number;
89
+ }
90
+
91
+ /**
92
+ * RDF Triple representation for JavaScript
93
+ */
94
+ export class Triple {
95
+ free(): void;
96
+ [Symbol.dispose](): void;
97
+ constructor(subject: string, predicate: string, object: string);
98
+ readonly object: string;
99
+ readonly predicate: string;
100
+ readonly subject: string;
101
+ }
102
+
103
+ export function init(): void;
104
+
105
+ /**
106
+ * Log a message to the browser console
107
+ */
108
+ export function log(message: string): void;
109
+
110
+ /**
111
+ * Get OxiRS WASM version
112
+ */
113
+ export function version(): string;
package/oxirs_wasm.js ADDED
@@ -0,0 +1,9 @@
1
+ /* @ts-self-types="./oxirs_wasm.d.ts" */
2
+
3
+ import * as wasm from "./oxirs_wasm_bg.wasm";
4
+ import { __wbg_set_wasm } from "./oxirs_wasm_bg.js";
5
+ __wbg_set_wasm(wasm);
6
+ wasm.__wbindgen_start();
7
+ export {
8
+ OxiRSStore, QueryResult, Triple, init, log, version
9
+ } from "./oxirs_wasm_bg.js";
@@ -0,0 +1,687 @@
1
+ /**
2
+ * OxiRS in-memory RDF store exposed to JavaScript via wasm_bindgen
3
+ */
4
+ export class OxiRSStore {
5
+ __destroy_into_raw() {
6
+ const ptr = this.__wbg_ptr;
7
+ this.__wbg_ptr = 0;
8
+ OxiRSStoreFinalization.unregister(this);
9
+ return ptr;
10
+ }
11
+ free() {
12
+ const ptr = this.__destroy_into_raw();
13
+ wasm.__wbg_oxirsstore_free(ptr, 0);
14
+ }
15
+ /**
16
+ * Register a namespace prefix
17
+ * @param {string} prefix
18
+ * @param {string} uri
19
+ */
20
+ addPrefix(prefix, uri) {
21
+ const ptr0 = passStringToWasm0(prefix, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
22
+ const len0 = WASM_VECTOR_LEN;
23
+ const ptr1 = passStringToWasm0(uri, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
24
+ const len1 = WASM_VECTOR_LEN;
25
+ wasm.oxirsstore_addPrefix(this.__wbg_ptr, ptr0, len0, ptr1, len1);
26
+ }
27
+ /**
28
+ * Execute a SPARQL ASK query
29
+ * @param {string} sparql
30
+ * @returns {boolean}
31
+ */
32
+ ask(sparql) {
33
+ try {
34
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
35
+ const ptr0 = passStringToWasm0(sparql, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
36
+ const len0 = WASM_VECTOR_LEN;
37
+ wasm.oxirsstore_ask(retptr, this.__wbg_ptr, ptr0, len0);
38
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
39
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
40
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
41
+ if (r2) {
42
+ throw takeObject(r1);
43
+ }
44
+ return r0 !== 0;
45
+ } finally {
46
+ wasm.__wbindgen_add_to_stack_pointer(16);
47
+ }
48
+ }
49
+ /**
50
+ * Clear all triples
51
+ */
52
+ clear() {
53
+ wasm.oxirsstore_clear(this.__wbg_ptr);
54
+ }
55
+ /**
56
+ * Execute a SPARQL CONSTRUCT query
57
+ * @param {string} sparql
58
+ * @returns {Triple[]}
59
+ */
60
+ construct(sparql) {
61
+ try {
62
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
63
+ const ptr0 = passStringToWasm0(sparql, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
64
+ const len0 = WASM_VECTOR_LEN;
65
+ wasm.oxirsstore_construct(retptr, this.__wbg_ptr, ptr0, len0);
66
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
67
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
68
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
69
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
70
+ if (r3) {
71
+ throw takeObject(r2);
72
+ }
73
+ var v2 = getArrayJsValueFromWasm0(r0, r1).slice();
74
+ wasm.__wbindgen_export(r0, r1 * 4, 4);
75
+ return v2;
76
+ } finally {
77
+ wasm.__wbindgen_add_to_stack_pointer(16);
78
+ }
79
+ }
80
+ /**
81
+ * Check if a triple exists
82
+ * @param {string} subject
83
+ * @param {string} predicate
84
+ * @param {string} object
85
+ * @returns {boolean}
86
+ */
87
+ contains(subject, predicate, object) {
88
+ const ptr0 = passStringToWasm0(subject, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
89
+ const len0 = WASM_VECTOR_LEN;
90
+ const ptr1 = passStringToWasm0(predicate, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
91
+ const len1 = WASM_VECTOR_LEN;
92
+ const ptr2 = passStringToWasm0(object, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
93
+ const len2 = WASM_VECTOR_LEN;
94
+ const ret = wasm.oxirsstore_contains(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
95
+ return ret !== 0;
96
+ }
97
+ /**
98
+ * Delete a single triple, returning true if it was found
99
+ * @param {string} subject
100
+ * @param {string} predicate
101
+ * @param {string} object
102
+ * @returns {boolean}
103
+ */
104
+ delete(subject, predicate, object) {
105
+ const ptr0 = passStringToWasm0(subject, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
106
+ const len0 = WASM_VECTOR_LEN;
107
+ const ptr1 = passStringToWasm0(predicate, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
108
+ const len1 = WASM_VECTOR_LEN;
109
+ const ptr2 = passStringToWasm0(object, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
110
+ const len2 = WASM_VECTOR_LEN;
111
+ const ret = wasm.oxirsstore_delete(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
112
+ return ret !== 0;
113
+ }
114
+ /**
115
+ * Insert a single triple
116
+ * @param {string} subject
117
+ * @param {string} predicate
118
+ * @param {string} object
119
+ * @returns {boolean}
120
+ */
121
+ insert(subject, predicate, object) {
122
+ const ptr0 = passStringToWasm0(subject, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
123
+ const len0 = WASM_VECTOR_LEN;
124
+ const ptr1 = passStringToWasm0(predicate, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
125
+ const len1 = WASM_VECTOR_LEN;
126
+ const ptr2 = passStringToWasm0(object, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
127
+ const len2 = WASM_VECTOR_LEN;
128
+ const ret = wasm.oxirsstore_insert(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
129
+ return ret !== 0;
130
+ }
131
+ /**
132
+ * Load N-Triples data
133
+ * @param {string} ntriples
134
+ * @returns {number}
135
+ */
136
+ loadNTriples(ntriples) {
137
+ try {
138
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
139
+ const ptr0 = passStringToWasm0(ntriples, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
140
+ const len0 = WASM_VECTOR_LEN;
141
+ wasm.oxirsstore_loadNTriples(retptr, this.__wbg_ptr, ptr0, len0);
142
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
143
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
144
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
145
+ if (r2) {
146
+ throw takeObject(r1);
147
+ }
148
+ return r0 >>> 0;
149
+ } finally {
150
+ wasm.__wbindgen_add_to_stack_pointer(16);
151
+ }
152
+ }
153
+ /**
154
+ * Load Turtle data
155
+ * @param {string} turtle
156
+ * @returns {number}
157
+ */
158
+ loadTurtle(turtle) {
159
+ try {
160
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
161
+ const ptr0 = passStringToWasm0(turtle, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
162
+ const len0 = WASM_VECTOR_LEN;
163
+ wasm.oxirsstore_loadTurtle(retptr, this.__wbg_ptr, ptr0, len0);
164
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
165
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
166
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
167
+ if (r2) {
168
+ throw takeObject(r1);
169
+ }
170
+ return r0 >>> 0;
171
+ } finally {
172
+ wasm.__wbindgen_add_to_stack_pointer(16);
173
+ }
174
+ }
175
+ /**
176
+ * Create a new empty store
177
+ */
178
+ constructor() {
179
+ const ret = wasm.oxirsstore_new();
180
+ this.__wbg_ptr = ret >>> 0;
181
+ OxiRSStoreFinalization.register(this, this.__wbg_ptr, this);
182
+ return this;
183
+ }
184
+ /**
185
+ * Get all objects
186
+ * @returns {string[]}
187
+ */
188
+ objects() {
189
+ try {
190
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
191
+ wasm.oxirsstore_objects(retptr, this.__wbg_ptr);
192
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
193
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
194
+ var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
195
+ wasm.__wbindgen_export(r0, r1 * 4, 4);
196
+ return v1;
197
+ } finally {
198
+ wasm.__wbindgen_add_to_stack_pointer(16);
199
+ }
200
+ }
201
+ /**
202
+ * Get all predicates
203
+ * @returns {string[]}
204
+ */
205
+ predicates() {
206
+ try {
207
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
208
+ wasm.oxirsstore_predicates(retptr, this.__wbg_ptr);
209
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
210
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
211
+ var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
212
+ wasm.__wbindgen_export(r0, r1 * 4, 4);
213
+ return v1;
214
+ } finally {
215
+ wasm.__wbindgen_add_to_stack_pointer(16);
216
+ }
217
+ }
218
+ /**
219
+ * Execute a SPARQL SELECT query
220
+ * @param {string} sparql
221
+ * @returns {any}
222
+ */
223
+ query(sparql) {
224
+ try {
225
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
226
+ const ptr0 = passStringToWasm0(sparql, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
227
+ const len0 = WASM_VECTOR_LEN;
228
+ wasm.oxirsstore_query(retptr, this.__wbg_ptr, ptr0, len0);
229
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
230
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
231
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
232
+ if (r2) {
233
+ throw takeObject(r1);
234
+ }
235
+ return takeObject(r0);
236
+ } finally {
237
+ wasm.__wbindgen_add_to_stack_pointer(16);
238
+ }
239
+ }
240
+ /**
241
+ * Get the number of triples
242
+ * @returns {number}
243
+ */
244
+ size() {
245
+ const ret = wasm.oxirsstore_size(this.__wbg_ptr);
246
+ return ret >>> 0;
247
+ }
248
+ /**
249
+ * Get all subjects
250
+ * @returns {string[]}
251
+ */
252
+ subjects() {
253
+ try {
254
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
255
+ wasm.oxirsstore_subjects(retptr, this.__wbg_ptr);
256
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
257
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
258
+ var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
259
+ wasm.__wbindgen_export(r0, r1 * 4, 4);
260
+ return v1;
261
+ } finally {
262
+ wasm.__wbindgen_add_to_stack_pointer(16);
263
+ }
264
+ }
265
+ /**
266
+ * Export to N-Triples format
267
+ * @returns {string}
268
+ */
269
+ toNTriples() {
270
+ let deferred1_0;
271
+ let deferred1_1;
272
+ try {
273
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
274
+ wasm.oxirsstore_toNTriples(retptr, this.__wbg_ptr);
275
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
276
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
277
+ deferred1_0 = r0;
278
+ deferred1_1 = r1;
279
+ return getStringFromWasm0(r0, r1);
280
+ } finally {
281
+ wasm.__wbindgen_add_to_stack_pointer(16);
282
+ wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
283
+ }
284
+ }
285
+ /**
286
+ * Export to Turtle format
287
+ * @returns {string}
288
+ */
289
+ toTurtle() {
290
+ let deferred1_0;
291
+ let deferred1_1;
292
+ try {
293
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
294
+ wasm.oxirsstore_toTurtle(retptr, this.__wbg_ptr);
295
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
296
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
297
+ deferred1_0 = r0;
298
+ deferred1_1 = r1;
299
+ return getStringFromWasm0(r0, r1);
300
+ } finally {
301
+ wasm.__wbindgen_add_to_stack_pointer(16);
302
+ wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
303
+ }
304
+ }
305
+ }
306
+ if (Symbol.dispose) OxiRSStore.prototype[Symbol.dispose] = OxiRSStore.prototype.free;
307
+
308
+ /**
309
+ * Query result for JavaScript
310
+ */
311
+ export class QueryResult {
312
+ __destroy_into_raw() {
313
+ const ptr = this.__wbg_ptr;
314
+ this.__wbg_ptr = 0;
315
+ QueryResultFinalization.unregister(this);
316
+ return ptr;
317
+ }
318
+ free() {
319
+ const ptr = this.__destroy_into_raw();
320
+ wasm.__wbg_queryresult_free(ptr, 0);
321
+ }
322
+ /**
323
+ * @returns {any[]}
324
+ */
325
+ get bindings() {
326
+ try {
327
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
328
+ wasm.queryresult_bindings(retptr, this.__wbg_ptr);
329
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
330
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
331
+ var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
332
+ wasm.__wbindgen_export(r0, r1 * 4, 4);
333
+ return v1;
334
+ } finally {
335
+ wasm.__wbindgen_add_to_stack_pointer(16);
336
+ }
337
+ }
338
+ /**
339
+ * @returns {number}
340
+ */
341
+ get length() {
342
+ const ret = wasm.queryresult_length(this.__wbg_ptr);
343
+ return ret >>> 0;
344
+ }
345
+ }
346
+ if (Symbol.dispose) QueryResult.prototype[Symbol.dispose] = QueryResult.prototype.free;
347
+
348
+ /**
349
+ * RDF Triple representation for JavaScript
350
+ */
351
+ export class Triple {
352
+ static __wrap(ptr) {
353
+ ptr = ptr >>> 0;
354
+ const obj = Object.create(Triple.prototype);
355
+ obj.__wbg_ptr = ptr;
356
+ TripleFinalization.register(obj, obj.__wbg_ptr, obj);
357
+ return obj;
358
+ }
359
+ __destroy_into_raw() {
360
+ const ptr = this.__wbg_ptr;
361
+ this.__wbg_ptr = 0;
362
+ TripleFinalization.unregister(this);
363
+ return ptr;
364
+ }
365
+ free() {
366
+ const ptr = this.__destroy_into_raw();
367
+ wasm.__wbg_triple_free(ptr, 0);
368
+ }
369
+ /**
370
+ * @param {string} subject
371
+ * @param {string} predicate
372
+ * @param {string} object
373
+ */
374
+ constructor(subject, predicate, object) {
375
+ const ptr0 = passStringToWasm0(subject, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
376
+ const len0 = WASM_VECTOR_LEN;
377
+ const ptr1 = passStringToWasm0(predicate, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
378
+ const len1 = WASM_VECTOR_LEN;
379
+ const ptr2 = passStringToWasm0(object, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
380
+ const len2 = WASM_VECTOR_LEN;
381
+ const ret = wasm.triple_new(ptr0, len0, ptr1, len1, ptr2, len2);
382
+ this.__wbg_ptr = ret >>> 0;
383
+ TripleFinalization.register(this, this.__wbg_ptr, this);
384
+ return this;
385
+ }
386
+ /**
387
+ * @returns {string}
388
+ */
389
+ get object() {
390
+ let deferred1_0;
391
+ let deferred1_1;
392
+ try {
393
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
394
+ wasm.triple_object(retptr, this.__wbg_ptr);
395
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
396
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
397
+ deferred1_0 = r0;
398
+ deferred1_1 = r1;
399
+ return getStringFromWasm0(r0, r1);
400
+ } finally {
401
+ wasm.__wbindgen_add_to_stack_pointer(16);
402
+ wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
403
+ }
404
+ }
405
+ /**
406
+ * @returns {string}
407
+ */
408
+ get predicate() {
409
+ let deferred1_0;
410
+ let deferred1_1;
411
+ try {
412
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
413
+ wasm.triple_predicate(retptr, this.__wbg_ptr);
414
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
415
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
416
+ deferred1_0 = r0;
417
+ deferred1_1 = r1;
418
+ return getStringFromWasm0(r0, r1);
419
+ } finally {
420
+ wasm.__wbindgen_add_to_stack_pointer(16);
421
+ wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
422
+ }
423
+ }
424
+ /**
425
+ * @returns {string}
426
+ */
427
+ get subject() {
428
+ let deferred1_0;
429
+ let deferred1_1;
430
+ try {
431
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
432
+ wasm.triple_subject(retptr, this.__wbg_ptr);
433
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
434
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
435
+ deferred1_0 = r0;
436
+ deferred1_1 = r1;
437
+ return getStringFromWasm0(r0, r1);
438
+ } finally {
439
+ wasm.__wbindgen_add_to_stack_pointer(16);
440
+ wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
441
+ }
442
+ }
443
+ }
444
+ if (Symbol.dispose) Triple.prototype[Symbol.dispose] = Triple.prototype.free;
445
+
446
+ export function init() {
447
+ wasm.init();
448
+ }
449
+
450
+ /**
451
+ * Log a message to the browser console
452
+ * @param {string} message
453
+ */
454
+ export function log(message) {
455
+ const ptr0 = passStringToWasm0(message, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
456
+ const len0 = WASM_VECTOR_LEN;
457
+ wasm.log(ptr0, len0);
458
+ }
459
+
460
+ /**
461
+ * Get OxiRS WASM version
462
+ * @returns {string}
463
+ */
464
+ export function version() {
465
+ let deferred1_0;
466
+ let deferred1_1;
467
+ try {
468
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
469
+ wasm.version(retptr);
470
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
471
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
472
+ deferred1_0 = r0;
473
+ deferred1_1 = r1;
474
+ return getStringFromWasm0(r0, r1);
475
+ } finally {
476
+ wasm.__wbindgen_add_to_stack_pointer(16);
477
+ wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
478
+ }
479
+ }
480
+ export function __wbg___wbindgen_throw_6ddd609b62940d55(arg0, arg1) {
481
+ throw new Error(getStringFromWasm0(arg0, arg1));
482
+ }
483
+ export function __wbg_error_a6fa202b58aa1cd3(arg0, arg1) {
484
+ let deferred0_0;
485
+ let deferred0_1;
486
+ try {
487
+ deferred0_0 = arg0;
488
+ deferred0_1 = arg1;
489
+ console.error(getStringFromWasm0(arg0, arg1));
490
+ } finally {
491
+ wasm.__wbindgen_export(deferred0_0, deferred0_1, 1);
492
+ }
493
+ }
494
+ export function __wbg_log_524eedafa26daa59(arg0) {
495
+ console.log(getObject(arg0));
496
+ }
497
+ export function __wbg_new_227d7c05414eb861() {
498
+ const ret = new Error();
499
+ return addHeapObject(ret);
500
+ }
501
+ export function __wbg_new_a70fbab9066b301f() {
502
+ const ret = new Array();
503
+ return addHeapObject(ret);
504
+ }
505
+ export function __wbg_new_ab79df5bd7c26067() {
506
+ const ret = new Object();
507
+ return addHeapObject(ret);
508
+ }
509
+ export function __wbg_push_e87b0e732085a946(arg0, arg1) {
510
+ const ret = getObject(arg0).push(getObject(arg1));
511
+ return ret;
512
+ }
513
+ export function __wbg_set_7eaa4f96924fd6b3() { return handleError(function (arg0, arg1, arg2) {
514
+ const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
515
+ return ret;
516
+ }, arguments); }
517
+ export function __wbg_stack_3b0d974bbf31e44f(arg0, arg1) {
518
+ const ret = getObject(arg1).stack;
519
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
520
+ const len1 = WASM_VECTOR_LEN;
521
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
522
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
523
+ }
524
+ export function __wbg_triple_new(arg0) {
525
+ const ret = Triple.__wrap(arg0);
526
+ return addHeapObject(ret);
527
+ }
528
+ export function __wbindgen_cast_0000000000000001(arg0, arg1) {
529
+ // Cast intrinsic for `Ref(String) -> Externref`.
530
+ const ret = getStringFromWasm0(arg0, arg1);
531
+ return addHeapObject(ret);
532
+ }
533
+ export function __wbindgen_object_clone_ref(arg0) {
534
+ const ret = getObject(arg0);
535
+ return addHeapObject(ret);
536
+ }
537
+ export function __wbindgen_object_drop_ref(arg0) {
538
+ takeObject(arg0);
539
+ }
540
+ const OxiRSStoreFinalization = (typeof FinalizationRegistry === 'undefined')
541
+ ? { register: () => {}, unregister: () => {} }
542
+ : new FinalizationRegistry(ptr => wasm.__wbg_oxirsstore_free(ptr >>> 0, 1));
543
+ const QueryResultFinalization = (typeof FinalizationRegistry === 'undefined')
544
+ ? { register: () => {}, unregister: () => {} }
545
+ : new FinalizationRegistry(ptr => wasm.__wbg_queryresult_free(ptr >>> 0, 1));
546
+ const TripleFinalization = (typeof FinalizationRegistry === 'undefined')
547
+ ? { register: () => {}, unregister: () => {} }
548
+ : new FinalizationRegistry(ptr => wasm.__wbg_triple_free(ptr >>> 0, 1));
549
+
550
+ function addHeapObject(obj) {
551
+ if (heap_next === heap.length) heap.push(heap.length + 1);
552
+ const idx = heap_next;
553
+ heap_next = heap[idx];
554
+
555
+ heap[idx] = obj;
556
+ return idx;
557
+ }
558
+
559
+ function dropObject(idx) {
560
+ if (idx < 1028) return;
561
+ heap[idx] = heap_next;
562
+ heap_next = idx;
563
+ }
564
+
565
+ function getArrayJsValueFromWasm0(ptr, len) {
566
+ ptr = ptr >>> 0;
567
+ const mem = getDataViewMemory0();
568
+ const result = [];
569
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
570
+ result.push(takeObject(mem.getUint32(i, true)));
571
+ }
572
+ return result;
573
+ }
574
+
575
+ let cachedDataViewMemory0 = null;
576
+ function getDataViewMemory0() {
577
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
578
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
579
+ }
580
+ return cachedDataViewMemory0;
581
+ }
582
+
583
+ function getStringFromWasm0(ptr, len) {
584
+ ptr = ptr >>> 0;
585
+ return decodeText(ptr, len);
586
+ }
587
+
588
+ let cachedUint8ArrayMemory0 = null;
589
+ function getUint8ArrayMemory0() {
590
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
591
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
592
+ }
593
+ return cachedUint8ArrayMemory0;
594
+ }
595
+
596
+ function getObject(idx) { return heap[idx]; }
597
+
598
+ function handleError(f, args) {
599
+ try {
600
+ return f.apply(this, args);
601
+ } catch (e) {
602
+ wasm.__wbindgen_export2(addHeapObject(e));
603
+ }
604
+ }
605
+
606
+ let heap = new Array(1024).fill(undefined);
607
+ heap.push(undefined, null, true, false);
608
+
609
+ let heap_next = heap.length;
610
+
611
+ function passStringToWasm0(arg, malloc, realloc) {
612
+ if (realloc === undefined) {
613
+ const buf = cachedTextEncoder.encode(arg);
614
+ const ptr = malloc(buf.length, 1) >>> 0;
615
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
616
+ WASM_VECTOR_LEN = buf.length;
617
+ return ptr;
618
+ }
619
+
620
+ let len = arg.length;
621
+ let ptr = malloc(len, 1) >>> 0;
622
+
623
+ const mem = getUint8ArrayMemory0();
624
+
625
+ let offset = 0;
626
+
627
+ for (; offset < len; offset++) {
628
+ const code = arg.charCodeAt(offset);
629
+ if (code > 0x7F) break;
630
+ mem[ptr + offset] = code;
631
+ }
632
+ if (offset !== len) {
633
+ if (offset !== 0) {
634
+ arg = arg.slice(offset);
635
+ }
636
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
637
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
638
+ const ret = cachedTextEncoder.encodeInto(arg, view);
639
+
640
+ offset += ret.written;
641
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
642
+ }
643
+
644
+ WASM_VECTOR_LEN = offset;
645
+ return ptr;
646
+ }
647
+
648
+ function takeObject(idx) {
649
+ const ret = getObject(idx);
650
+ dropObject(idx);
651
+ return ret;
652
+ }
653
+
654
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
655
+ cachedTextDecoder.decode();
656
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
657
+ let numBytesDecoded = 0;
658
+ function decodeText(ptr, len) {
659
+ numBytesDecoded += len;
660
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
661
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
662
+ cachedTextDecoder.decode();
663
+ numBytesDecoded = len;
664
+ }
665
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
666
+ }
667
+
668
+ const cachedTextEncoder = new TextEncoder();
669
+
670
+ if (!('encodeInto' in cachedTextEncoder)) {
671
+ cachedTextEncoder.encodeInto = function (arg, view) {
672
+ const buf = cachedTextEncoder.encode(arg);
673
+ view.set(buf);
674
+ return {
675
+ read: arg.length,
676
+ written: buf.length
677
+ };
678
+ };
679
+ }
680
+
681
+ let WASM_VECTOR_LEN = 0;
682
+
683
+
684
+ let wasm;
685
+ export function __wbg_set_wasm(val) {
686
+ wasm = val;
687
+ }
Binary file
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@cooljapan/oxirs",
3
+ "type": "module",
4
+ "collaborators": [
5
+ "KitaSan <info@kitasan.io>"
6
+ ],
7
+ "description": "WebAssembly bindings for OxiRS - Run RDF/SPARQL in the browser",
8
+ "version": "0.2.0",
9
+ "license": "Apache-2.0",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/cool-japan/oxirs"
13
+ },
14
+ "files": [
15
+ "oxirs_wasm_bg.wasm",
16
+ "oxirs_wasm.js",
17
+ "oxirs_wasm_bg.js",
18
+ "oxirs_wasm.d.ts",
19
+ "index.js",
20
+ "types.d.ts"
21
+ ],
22
+ "main": "index.js",
23
+ "module": "oxirs_wasm.js",
24
+ "homepage": "https://github.com/cool-japan/oxirs",
25
+ "types": "types.d.ts",
26
+ "sideEffects": [
27
+ "./oxirs_wasm.js",
28
+ "./snippets/*"
29
+ ],
30
+ "keywords": [
31
+ "wasm",
32
+ "webassembly",
33
+ "rdf",
34
+ "sparql",
35
+ "browser",
36
+ "semantic-web",
37
+ "linked-data"
38
+ ],
39
+ "publishConfig": {
40
+ "access": "public"
41
+ }
42
+ }
package/types.d.ts ADDED
@@ -0,0 +1,159 @@
1
+ /**
2
+ * OxiRS WASM TypeScript definitions
3
+ */
4
+
5
+ declare module '@cooljapan/oxirs' {
6
+ /**
7
+ * Initialize the WASM module
8
+ */
9
+ export function initialize(): Promise<void>;
10
+
11
+ /**
12
+ * Create a new RDF store
13
+ */
14
+ export function createStore(): Promise<OxiRSStore>;
15
+
16
+ /**
17
+ * Get the version of OxiRS WASM
18
+ */
19
+ export function getVersion(): Promise<string>;
20
+
21
+ /**
22
+ * Log a message to the browser console
23
+ */
24
+ export function log(message: string): void;
25
+
26
+ /**
27
+ * RDF Triple
28
+ */
29
+ export class Triple {
30
+ constructor(subject: string, predicate: string, object: string);
31
+
32
+ readonly subject: string;
33
+ readonly predicate: string;
34
+ readonly object: string;
35
+ }
36
+
37
+ /**
38
+ * In-memory RDF store
39
+ */
40
+ export class OxiRSStore {
41
+ constructor();
42
+
43
+ /**
44
+ * Load Turtle data
45
+ * @param turtle - Turtle formatted RDF data
46
+ * @returns Number of triples loaded
47
+ */
48
+ loadTurtle(turtle: string): Promise<number>;
49
+
50
+ /**
51
+ * Load N-Triples data
52
+ * @param ntriples - N-Triples formatted RDF data
53
+ * @returns Number of triples loaded
54
+ */
55
+ loadNTriples(ntriples: string): Promise<number>;
56
+
57
+ /**
58
+ * Insert a single triple
59
+ */
60
+ insert(subject: string, predicate: string, object: string): boolean;
61
+
62
+ /**
63
+ * Delete a single triple
64
+ */
65
+ delete(subject: string, predicate: string, object: string): boolean;
66
+
67
+ /**
68
+ * Check if a triple exists
69
+ */
70
+ contains(subject: string, predicate: string, object: string): boolean;
71
+
72
+ /**
73
+ * Get the number of triples
74
+ */
75
+ size(): number;
76
+
77
+ /**
78
+ * Clear all triples
79
+ */
80
+ clear(): void;
81
+
82
+ /**
83
+ * Execute a SPARQL SELECT query
84
+ * @param sparql - SPARQL query string
85
+ * @returns Array of binding objects
86
+ */
87
+ query(sparql: string): Promise<QueryResult[]>;
88
+
89
+ /**
90
+ * Execute a SPARQL ASK query
91
+ * @param sparql - SPARQL query string
92
+ * @returns Boolean result
93
+ */
94
+ ask(sparql: string): Promise<boolean>;
95
+
96
+ /**
97
+ * Execute a SPARQL CONSTRUCT query
98
+ * @param sparql - SPARQL query string
99
+ * @returns Array of Triple objects
100
+ */
101
+ construct(sparql: string): Promise<Triple[]>;
102
+
103
+ /**
104
+ * Export to Turtle format
105
+ */
106
+ toTurtle(): string;
107
+
108
+ /**
109
+ * Export to N-Triples format
110
+ */
111
+ toNTriples(): string;
112
+
113
+ /**
114
+ * Get all subjects
115
+ */
116
+ subjects(): string[];
117
+
118
+ /**
119
+ * Get all predicates
120
+ */
121
+ predicates(): string[];
122
+
123
+ /**
124
+ * Get all objects
125
+ */
126
+ objects(): string[];
127
+
128
+ /**
129
+ * Add a namespace prefix
130
+ */
131
+ addPrefix(prefix: string, uri: string): void;
132
+ }
133
+
134
+ /**
135
+ * Query result binding
136
+ */
137
+ export interface QueryResult {
138
+ [variable: string]: string;
139
+ }
140
+
141
+ /**
142
+ * Validation report
143
+ */
144
+ export interface ValidationReport {
145
+ conforms: boolean;
146
+ results: ValidationResult[];
147
+ }
148
+
149
+ /**
150
+ * Validation result
151
+ */
152
+ export interface ValidationResult {
153
+ focusNode: string;
154
+ resultPath?: string;
155
+ value?: string;
156
+ message: string;
157
+ severity: 'Violation' | 'Warning' | 'Info';
158
+ }
159
+ }