opentology 0.1.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.
Files changed (67) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +609 -0
  3. package/dist/commands/context.d.ts +29 -0
  4. package/dist/commands/context.js +369 -0
  5. package/dist/commands/delete.d.ts +2 -0
  6. package/dist/commands/delete.js +46 -0
  7. package/dist/commands/diff.d.ts +2 -0
  8. package/dist/commands/diff.js +43 -0
  9. package/dist/commands/drop.d.ts +2 -0
  10. package/dist/commands/drop.js +41 -0
  11. package/dist/commands/graph.d.ts +2 -0
  12. package/dist/commands/graph.js +130 -0
  13. package/dist/commands/infer.d.ts +2 -0
  14. package/dist/commands/infer.js +47 -0
  15. package/dist/commands/init.d.ts +2 -0
  16. package/dist/commands/init.js +53 -0
  17. package/dist/commands/mcp.d.ts +2 -0
  18. package/dist/commands/mcp.js +9 -0
  19. package/dist/commands/prefix.d.ts +2 -0
  20. package/dist/commands/prefix.js +73 -0
  21. package/dist/commands/pull.d.ts +2 -0
  22. package/dist/commands/pull.js +43 -0
  23. package/dist/commands/push.d.ts +2 -0
  24. package/dist/commands/push.js +79 -0
  25. package/dist/commands/query.d.ts +2 -0
  26. package/dist/commands/query.js +119 -0
  27. package/dist/commands/shapes.d.ts +2 -0
  28. package/dist/commands/shapes.js +67 -0
  29. package/dist/commands/status.d.ts +2 -0
  30. package/dist/commands/status.js +47 -0
  31. package/dist/commands/validate.d.ts +2 -0
  32. package/dist/commands/validate.js +46 -0
  33. package/dist/index.d.ts +2 -0
  34. package/dist/index.js +38 -0
  35. package/dist/lib/codebase-scanner.d.ts +41 -0
  36. package/dist/lib/codebase-scanner.js +360 -0
  37. package/dist/lib/config.d.ts +16 -0
  38. package/dist/lib/config.js +70 -0
  39. package/dist/lib/embedded-adapter.d.ts +45 -0
  40. package/dist/lib/embedded-adapter.js +202 -0
  41. package/dist/lib/http-adapter.d.ts +41 -0
  42. package/dist/lib/http-adapter.js +169 -0
  43. package/dist/lib/oxigraph.d.ts +62 -0
  44. package/dist/lib/oxigraph.js +323 -0
  45. package/dist/lib/reasoner.d.ts +19 -0
  46. package/dist/lib/reasoner.js +310 -0
  47. package/dist/lib/shacl.d.ts +22 -0
  48. package/dist/lib/shacl.js +105 -0
  49. package/dist/lib/sparql-utils.d.ts +28 -0
  50. package/dist/lib/sparql-utils.js +217 -0
  51. package/dist/lib/store-adapter.d.ts +50 -0
  52. package/dist/lib/store-adapter.js +1 -0
  53. package/dist/lib/store-factory.d.ts +9 -0
  54. package/dist/lib/store-factory.js +71 -0
  55. package/dist/lib/validator.d.ts +10 -0
  56. package/dist/lib/validator.js +40 -0
  57. package/dist/mcp/server.d.ts +3 -0
  58. package/dist/mcp/server.js +1020 -0
  59. package/dist/templates/claude-md-context.d.ts +4 -0
  60. package/dist/templates/claude-md-context.js +104 -0
  61. package/dist/templates/otx-ontology.d.ts +2 -0
  62. package/dist/templates/otx-ontology.js +31 -0
  63. package/dist/templates/session-start-hook.d.ts +1 -0
  64. package/dist/templates/session-start-hook.js +94 -0
  65. package/dist/templates/slash-commands.d.ts +5 -0
  66. package/dist/templates/slash-commands.js +108 -0
  67. package/package.json +58 -0
@@ -0,0 +1,202 @@
1
+ import { DataFactory as N3DataFactory } from 'n3';
2
+ import oxigraph from 'oxigraph';
3
+ import { termToSparql, parseTurtle, extractPrefixes, serializeQuadsToTurtle, } from './sparql-utils.js';
4
+ /**
5
+ * Convert an oxigraph WASM Term object to the SparqlResults binding format.
6
+ */
7
+ function termToBinding(term) {
8
+ switch (term.termType) {
9
+ case 'NamedNode':
10
+ return { type: 'uri', value: term.value };
11
+ case 'BlankNode':
12
+ return { type: 'bnode', value: term.value };
13
+ case 'Literal': {
14
+ const entry = {
15
+ type: 'literal',
16
+ value: term.value,
17
+ };
18
+ if (term.datatype) {
19
+ entry.datatype = term.datatype.value;
20
+ }
21
+ return entry;
22
+ }
23
+ default:
24
+ return { type: 'uri', value: term.value };
25
+ }
26
+ }
27
+ /**
28
+ * Convert an oxigraph WASM Quad to an n3-compatible Quad for serialization.
29
+ */
30
+ function wasmQuadToN3Quad(q) {
31
+ const subject = q.subject.termType === 'BlankNode'
32
+ ? N3DataFactory.blankNode(q.subject.value)
33
+ : N3DataFactory.namedNode(q.subject.value);
34
+ const predicate = N3DataFactory.namedNode(q.predicate.value);
35
+ let object;
36
+ if (q.object.termType === 'Literal') {
37
+ if (q.object.language) {
38
+ object = N3DataFactory.literal(q.object.value, q.object.language);
39
+ }
40
+ else if (q.object.datatype &&
41
+ q.object.datatype.value !== 'http://www.w3.org/2001/XMLSchema#string') {
42
+ object = N3DataFactory.literal(q.object.value, N3DataFactory.namedNode(q.object.datatype.value));
43
+ }
44
+ else {
45
+ object = N3DataFactory.literal(q.object.value);
46
+ }
47
+ }
48
+ else if (q.object.termType === 'BlankNode') {
49
+ object = N3DataFactory.blankNode(q.object.value);
50
+ }
51
+ else {
52
+ object = N3DataFactory.namedNode(q.object.value);
53
+ }
54
+ return N3DataFactory.quad(subject, predicate, object);
55
+ }
56
+ export class EmbeddedAdapter {
57
+ constructor() {
58
+ this.store = new oxigraph.Store();
59
+ }
60
+ /**
61
+ * Load Turtle data directly into a named graph.
62
+ */
63
+ loadTurtleIntoGraph(turtle, graphUri) {
64
+ this.store.load(turtle, {
65
+ format: 'text/turtle',
66
+ base_iri: 'http://example.org/',
67
+ to_graph_name: oxigraph.namedNode(graphUri),
68
+ });
69
+ }
70
+ async askQuery(query) {
71
+ const result = this.store.query(query);
72
+ return result === true;
73
+ }
74
+ async sparqlQuery(query) {
75
+ const rawResults = this.store.query(query);
76
+ // rawResults is an iterable of Map-like objects for SELECT queries
77
+ const bindings = [];
78
+ const varsSet = new Set();
79
+ for (const row of rawResults) {
80
+ const binding = {};
81
+ for (const [key, value] of row) {
82
+ varsSet.add(key);
83
+ if (value != null) {
84
+ binding[key] = termToBinding(value);
85
+ }
86
+ }
87
+ bindings.push(binding);
88
+ }
89
+ return {
90
+ head: { vars: [...varsSet] },
91
+ results: { bindings },
92
+ };
93
+ }
94
+ async sparqlUpdate(update) {
95
+ this.store.update(update);
96
+ }
97
+ async constructQuery(query) {
98
+ const rawQuads = this.store.query(query);
99
+ const n3Quads = [];
100
+ for (const q of rawQuads) {
101
+ n3Quads.push(wasmQuadToN3Quad(q));
102
+ }
103
+ return serializeQuadsToTurtle(n3Quads);
104
+ }
105
+ async insertTurtle(graphUri, turtle) {
106
+ if (!turtle.trim()) {
107
+ return;
108
+ }
109
+ this.loadTurtleIntoGraph(turtle, graphUri);
110
+ }
111
+ async getGraphTripleCount(graphUri) {
112
+ const query = `SELECT (COUNT(*) AS ?count) WHERE { GRAPH <${graphUri}> { ?s ?p ?o } }`;
113
+ const results = await this.sparqlQuery(query);
114
+ const binding = results.results.bindings[0];
115
+ if (!binding || !binding['count']) {
116
+ return 0;
117
+ }
118
+ return parseInt(binding['count'].value, 10);
119
+ }
120
+ async exportGraph(graphUri) {
121
+ const quads = this.store.match(null, null, null, oxigraph.namedNode(graphUri));
122
+ const n3Quads = [];
123
+ for (const q of quads) {
124
+ n3Quads.push(wasmQuadToN3Quad(q));
125
+ }
126
+ return serializeQuadsToTurtle(n3Quads);
127
+ }
128
+ async dropGraph(graphUri) {
129
+ this.store.update(`DROP SILENT GRAPH <${graphUri}>`);
130
+ }
131
+ async deleteTriples(graphUri, options) {
132
+ if (options.turtle !== undefined) {
133
+ const quads = await parseTurtle(options.turtle);
134
+ if (quads.length === 0) {
135
+ return;
136
+ }
137
+ const tripleLines = quads
138
+ .map((q) => ` ${termToSparql(q.subject)} ${termToSparql(q.predicate)} ${termToSparql(q.object)} .`)
139
+ .join('\n');
140
+ const update = `DELETE DATA {\n GRAPH <${graphUri}> {\n${tripleLines}\n }\n}`;
141
+ this.store.update(update);
142
+ }
143
+ else if (options.where !== undefined) {
144
+ const update = `DELETE { GRAPH <${graphUri}> { ?s ?p ?o } } WHERE { GRAPH <${graphUri}> { ?s ?p ?o . ${options.where} } }`;
145
+ this.store.update(update);
146
+ }
147
+ else {
148
+ throw new Error('deleteTriples: either options.turtle or options.where must be provided');
149
+ }
150
+ }
151
+ async diffGraph(graphUri, localTurtle) {
152
+ const localQuads = await parseTurtle(localTurtle);
153
+ const localSet = new Set(localQuads.map((q) => `${termToSparql(q.subject)} ${termToSparql(q.predicate)} ${termToSparql(q.object)}`));
154
+ // Get remote quads from the store
155
+ const remoteRawQuads = this.store.match(null, null, null, oxigraph.namedNode(graphUri));
156
+ const remoteSet = new Set();
157
+ for (const q of remoteRawQuads) {
158
+ const n3q = wasmQuadToN3Quad(q);
159
+ remoteSet.add(`${termToSparql(n3q.subject)} ${termToSparql(n3q.predicate)} ${termToSparql(n3q.object)}`);
160
+ }
161
+ const added = [...localSet].filter((t) => !remoteSet.has(t));
162
+ const removed = [...remoteSet].filter((t) => !localSet.has(t));
163
+ const unchanged = [...localSet].filter((t) => remoteSet.has(t)).length;
164
+ return { added, removed, unchanged };
165
+ }
166
+ async getSchemaOverview(graphUri) {
167
+ const tripleCount = await this.getGraphTripleCount(graphUri);
168
+ const classResults = await this.sparqlQuery(`SELECT DISTINCT ?class WHERE { GRAPH <${graphUri}> { ?s a ?class } } ORDER BY ?class`);
169
+ const classes = classResults.results.bindings
170
+ .map((b) => b['class']?.value)
171
+ .filter((v) => v !== undefined);
172
+ const propResults = await this.sparqlQuery(`SELECT DISTINCT ?prop WHERE { GRAPH <${graphUri}> { ?s ?prop ?o } } ORDER BY ?prop`);
173
+ const properties = propResults.results.bindings
174
+ .map((b) => b['prop']?.value)
175
+ .filter((v) => v !== undefined);
176
+ const prefixes = extractPrefixes([...classes, ...properties]);
177
+ return { prefixes, classes, properties, tripleCount };
178
+ }
179
+ async getClassDetails(graphUri, classUri) {
180
+ const countResults = await this.sparqlQuery(`SELECT (COUNT(?s) as ?count) WHERE { GRAPH <${graphUri}> { ?s a <${classUri}> } }`);
181
+ const countBinding = countResults.results.bindings[0];
182
+ const instanceCount = countBinding?.['count']
183
+ ? parseInt(countBinding['count'].value, 10)
184
+ : 0;
185
+ const propResults = await this.sparqlQuery(`SELECT ?prop (COUNT(?prop) as ?count) WHERE { GRAPH <${graphUri}> { ?s a <${classUri}> . ?s ?prop ?o } } GROUP BY ?prop ORDER BY DESC(?count)`);
186
+ const properties = propResults.results.bindings
187
+ .filter((b) => b['prop'] && b['count'])
188
+ .map((b) => ({
189
+ property: b['prop'].value,
190
+ count: parseInt(b['count'].value, 10),
191
+ }));
192
+ const sampleResults = await this.sparqlQuery(`SELECT ?s ?p ?o WHERE { GRAPH <${graphUri}> { ?s a <${classUri}> . ?s ?p ?o } } LIMIT 5`);
193
+ const sampleTriples = sampleResults.results.bindings
194
+ .filter((b) => b['s'] && b['p'] && b['o'])
195
+ .map((b) => ({
196
+ s: b['s'].value,
197
+ p: b['p'].value,
198
+ o: b['o'].value,
199
+ }));
200
+ return { classUri, instanceCount, properties, sampleTriples };
201
+ }
202
+ }
@@ -0,0 +1,41 @@
1
+ import type { StoreAdapter, SparqlResults } from './store-adapter.js';
2
+ export declare class HttpAdapter implements StoreAdapter {
3
+ private endpoint;
4
+ constructor(endpoint: string);
5
+ askQuery(query: string): Promise<boolean>;
6
+ sparqlQuery(query: string): Promise<SparqlResults>;
7
+ sparqlUpdate(update: string): Promise<void>;
8
+ constructQuery(query: string): Promise<string>;
9
+ insertTurtle(graphUri: string, turtle: string): Promise<void>;
10
+ getGraphTripleCount(graphUri: string): Promise<number>;
11
+ exportGraph(graphUri: string): Promise<string>;
12
+ dropGraph(graphUri: string): Promise<void>;
13
+ deleteTriples(graphUri: string, options: {
14
+ turtle?: string;
15
+ where?: string;
16
+ }): Promise<void>;
17
+ diffGraph(graphUri: string, localTurtle: string): Promise<{
18
+ added: string[];
19
+ removed: string[];
20
+ unchanged: number;
21
+ }>;
22
+ getSchemaOverview(graphUri: string): Promise<{
23
+ prefixes: Record<string, string>;
24
+ classes: string[];
25
+ properties: string[];
26
+ tripleCount: number;
27
+ }>;
28
+ getClassDetails(graphUri: string, classUri: string): Promise<{
29
+ classUri: string;
30
+ instanceCount: number;
31
+ properties: Array<{
32
+ property: string;
33
+ count: number;
34
+ }>;
35
+ sampleTriples: Array<{
36
+ s: string;
37
+ p: string;
38
+ o: string;
39
+ }>;
40
+ }>;
41
+ }
@@ -0,0 +1,169 @@
1
+ import { termToSparql, parseTurtle, extractPrefixes, serializeQuadsToTurtle, } from './sparql-utils.js';
2
+ export class HttpAdapter {
3
+ constructor(endpoint) {
4
+ this.endpoint = endpoint;
5
+ }
6
+ async askQuery(query) {
7
+ const url = `${this.endpoint}/query`;
8
+ const response = await fetch(url, {
9
+ method: 'POST',
10
+ headers: {
11
+ 'Content-Type': 'application/sparql-query',
12
+ Accept: 'application/sparql-results+json',
13
+ },
14
+ body: query,
15
+ });
16
+ if (!response.ok) {
17
+ const body = await response.text().catch(() => '');
18
+ throw new Error(`ASK query failed (${response.status} ${response.statusText})${body ? `: ${body}` : ''}`);
19
+ }
20
+ const json = await response.json();
21
+ return json.boolean === true;
22
+ }
23
+ async sparqlQuery(query) {
24
+ const url = `${this.endpoint}/query`;
25
+ const response = await fetch(url, {
26
+ method: 'POST',
27
+ headers: {
28
+ 'Content-Type': 'application/sparql-query',
29
+ Accept: 'application/sparql-results+json',
30
+ },
31
+ body: query,
32
+ });
33
+ if (!response.ok) {
34
+ const body = await response.text().catch(() => '');
35
+ throw new Error(`SPARQL query failed (${response.status} ${response.statusText})${body ? `: ${body}` : ''}`);
36
+ }
37
+ return response.json();
38
+ }
39
+ async sparqlUpdate(update) {
40
+ const url = `${this.endpoint}/update`;
41
+ const response = await fetch(url, {
42
+ method: 'POST',
43
+ headers: {
44
+ 'Content-Type': 'application/sparql-update',
45
+ },
46
+ body: update,
47
+ });
48
+ if (!response.ok) {
49
+ const body = await response.text().catch(() => '');
50
+ throw new Error(`SPARQL update failed (${response.status} ${response.statusText})${body ? `: ${body}` : ''}`);
51
+ }
52
+ }
53
+ async constructQuery(query) {
54
+ const response = await fetch(`${this.endpoint}/query`, {
55
+ method: 'POST',
56
+ headers: {
57
+ 'Content-Type': 'application/sparql-query',
58
+ Accept: 'text/turtle',
59
+ },
60
+ body: query,
61
+ });
62
+ if (!response.ok) {
63
+ const body = await response.text().catch(() => '');
64
+ throw new Error(`SPARQL CONSTRUCT query failed (${response.status} ${response.statusText})${body ? `: ${body}` : ''}`);
65
+ }
66
+ return response.text();
67
+ }
68
+ async insertTurtle(graphUri, turtle) {
69
+ const quads = await parseTurtle(turtle);
70
+ if (quads.length === 0) {
71
+ return;
72
+ }
73
+ const tripleLines = quads
74
+ .map((q) => ` ${termToSparql(q.subject)} ${termToSparql(q.predicate)} ${termToSparql(q.object)} .`)
75
+ .join('\n');
76
+ const update = `INSERT DATA {\n GRAPH <${graphUri}> {\n${tripleLines}\n }\n}`;
77
+ await this.sparqlUpdate(update);
78
+ }
79
+ async getGraphTripleCount(graphUri) {
80
+ const query = `SELECT (COUNT(*) AS ?count) WHERE { GRAPH <${graphUri}> { ?s ?p ?o } }`;
81
+ const results = await this.sparqlQuery(query);
82
+ const binding = results.results.bindings[0];
83
+ if (!binding || !binding['count']) {
84
+ return 0;
85
+ }
86
+ return parseInt(binding['count'].value, 10);
87
+ }
88
+ async exportGraph(graphUri) {
89
+ const query = `CONSTRUCT { ?s ?p ?o } WHERE { GRAPH <${graphUri}> { ?s ?p ?o } }`;
90
+ const turtleText = await this.constructQuery(query);
91
+ // Re-serialize through n3 to ensure consistent formatting
92
+ const quads = await parseTurtle(turtleText);
93
+ return serializeQuadsToTurtle(quads);
94
+ }
95
+ async dropGraph(graphUri) {
96
+ await this.sparqlUpdate(`DROP SILENT GRAPH <${graphUri}>`);
97
+ }
98
+ async deleteTriples(graphUri, options) {
99
+ if (options.turtle !== undefined) {
100
+ const quads = await parseTurtle(options.turtle);
101
+ if (quads.length === 0) {
102
+ return;
103
+ }
104
+ const tripleLines = quads
105
+ .map((q) => ` ${termToSparql(q.subject)} ${termToSparql(q.predicate)} ${termToSparql(q.object)} .`)
106
+ .join('\n');
107
+ const update = `DELETE DATA {\n GRAPH <${graphUri}> {\n${tripleLines}\n }\n}`;
108
+ await this.sparqlUpdate(update);
109
+ }
110
+ else if (options.where !== undefined) {
111
+ const update = `DELETE { GRAPH <${graphUri}> { ?s ?p ?o } } WHERE { GRAPH <${graphUri}> { ?s ?p ?o . ${options.where} } }`;
112
+ await this.sparqlUpdate(update);
113
+ }
114
+ else {
115
+ throw new Error('deleteTriples: either options.turtle or options.where must be provided');
116
+ }
117
+ }
118
+ async diffGraph(graphUri, localTurtle) {
119
+ const localQuads = await parseTurtle(localTurtle);
120
+ const localSet = new Set(localQuads.map((q) => `${termToSparql(q.subject)} ${termToSparql(q.predicate)} ${termToSparql(q.object)}`));
121
+ // Fetch remote quads via CONSTRUCT
122
+ const query = `CONSTRUCT { ?s ?p ?o } WHERE { GRAPH <${graphUri}> { ?s ?p ?o } }`;
123
+ const remoteTurtle = await this.constructQuery(query);
124
+ const remoteQuads = remoteTurtle.trim()
125
+ ? await parseTurtle(remoteTurtle)
126
+ : [];
127
+ const remoteSet = new Set(remoteQuads.map((q) => `${termToSparql(q.subject)} ${termToSparql(q.predicate)} ${termToSparql(q.object)}`));
128
+ const added = [...localSet].filter((t) => !remoteSet.has(t));
129
+ const removed = [...remoteSet].filter((t) => !localSet.has(t));
130
+ const unchanged = [...localSet].filter((t) => remoteSet.has(t)).length;
131
+ return { added, removed, unchanged };
132
+ }
133
+ async getSchemaOverview(graphUri) {
134
+ const tripleCount = await this.getGraphTripleCount(graphUri);
135
+ const classResults = await this.sparqlQuery(`SELECT DISTINCT ?class WHERE { GRAPH <${graphUri}> { ?s a ?class } } ORDER BY ?class`);
136
+ const classes = classResults.results.bindings
137
+ .map((b) => b['class']?.value)
138
+ .filter((v) => v !== undefined);
139
+ const propResults = await this.sparqlQuery(`SELECT DISTINCT ?prop WHERE { GRAPH <${graphUri}> { ?s ?prop ?o } } ORDER BY ?prop`);
140
+ const properties = propResults.results.bindings
141
+ .map((b) => b['prop']?.value)
142
+ .filter((v) => v !== undefined);
143
+ const prefixes = extractPrefixes([...classes, ...properties]);
144
+ return { prefixes, classes, properties, tripleCount };
145
+ }
146
+ async getClassDetails(graphUri, classUri) {
147
+ const countResults = await this.sparqlQuery(`SELECT (COUNT(?s) as ?count) WHERE { GRAPH <${graphUri}> { ?s a <${classUri}> } }`);
148
+ const countBinding = countResults.results.bindings[0];
149
+ const instanceCount = countBinding?.['count']
150
+ ? parseInt(countBinding['count'].value, 10)
151
+ : 0;
152
+ const propResults = await this.sparqlQuery(`SELECT ?prop (COUNT(?prop) as ?count) WHERE { GRAPH <${graphUri}> { ?s a <${classUri}> . ?s ?prop ?o } } GROUP BY ?prop ORDER BY DESC(?count)`);
153
+ const properties = propResults.results.bindings
154
+ .filter((b) => b['prop'] && b['count'])
155
+ .map((b) => ({
156
+ property: b['prop'].value,
157
+ count: parseInt(b['count'].value, 10),
158
+ }));
159
+ const sampleResults = await this.sparqlQuery(`SELECT ?s ?p ?o WHERE { GRAPH <${graphUri}> { ?s a <${classUri}> . ?s ?p ?o } } LIMIT 5`);
160
+ const sampleTriples = sampleResults.results.bindings
161
+ .filter((b) => b['s'] && b['p'] && b['o'])
162
+ .map((b) => ({
163
+ s: b['s'].value,
164
+ p: b['p'].value,
165
+ o: b['o'].value,
166
+ }));
167
+ return { classUri, instanceCount, properties, sampleTriples };
168
+ }
169
+ }
@@ -0,0 +1,62 @@
1
+ export interface SparqlResults {
2
+ head: {
3
+ vars: string[];
4
+ };
5
+ results: {
6
+ bindings: Array<Record<string, {
7
+ type: string;
8
+ value: string;
9
+ datatype?: string;
10
+ }>>;
11
+ };
12
+ }
13
+ export declare function sparqlQuery(endpoint: string, query: string): Promise<SparqlResults>;
14
+ export declare function sparqlUpdate(endpoint: string, update: string): Promise<void>;
15
+ export declare function insertTurtle(endpoint: string, graphUri: string, turtle: string): Promise<void>;
16
+ export declare function getGraphTripleCount(endpoint: string, graphUri: string): Promise<number>;
17
+ /**
18
+ * Returns true if the query already manages its own graph scoping.
19
+ * Matches GRAPH, FROM NAMED, or FROM < (case-insensitive).
20
+ */
21
+ export declare function hasGraphScope(sparql: string): boolean;
22
+ /**
23
+ * Wraps the WHERE body of a SPARQL SELECT/CONSTRUCT/ASK/DESCRIBE query so
24
+ * that all triple patterns are scoped to `graphUri`.
25
+ *
26
+ * Handles:
27
+ * SELECT ... WHERE { ... } → standard form
28
+ * SELECT ... { ... } → shorthand (no WHERE keyword)
29
+ *
30
+ * Returns null if the outermost `{ ... }` block cannot be located safely.
31
+ */
32
+ export declare function autoScopeQuery(sparql: string, graphUri: string): string | null;
33
+ export declare function dropGraph(endpoint: string, graphUri: string): Promise<void>;
34
+ export declare function deleteTriples(endpoint: string, graphUri: string, options: {
35
+ turtle?: string;
36
+ where?: string;
37
+ }): Promise<void>;
38
+ export declare function getSchemaOverview(endpoint: string, graphUri: string): Promise<{
39
+ prefixes: Record<string, string>;
40
+ classes: string[];
41
+ properties: string[];
42
+ tripleCount: number;
43
+ }>;
44
+ export declare function getClassDetails(endpoint: string, graphUri: string, classUri: string): Promise<{
45
+ classUri: string;
46
+ instanceCount: number;
47
+ properties: Array<{
48
+ property: string;
49
+ count: number;
50
+ }>;
51
+ sampleTriples: Array<{
52
+ s: string;
53
+ p: string;
54
+ o: string;
55
+ }>;
56
+ }>;
57
+ export declare function diffGraph(endpoint: string, graphUri: string, localTurtle: string): Promise<{
58
+ added: string[];
59
+ removed: string[];
60
+ unchanged: number;
61
+ }>;
62
+ export declare function exportGraph(endpoint: string, graphUri: string): Promise<string>;