ldkit 1.1.0 → 2.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 (152) hide show
  1. package/README.md +15 -5
  2. package/esm/library/decoder.js +20 -30
  3. package/esm/library/encoder.js +33 -17
  4. package/esm/library/engine/mod.js +2 -2
  5. package/esm/library/engine/query_engine.js +40 -0
  6. package/esm/library/engine/query_engine_proxy.js +8 -8
  7. package/esm/library/engine/types.js +1 -0
  8. package/esm/library/lens/lens.js +416 -27
  9. package/esm/library/lens/mod.js +1 -1
  10. package/esm/library/lens/query_builder.js +86 -52
  11. package/esm/library/lens/search_helper.js +142 -0
  12. package/esm/library/lens/update_helper.js +157 -0
  13. package/esm/library/namespace.js +36 -0
  14. package/esm/library/options.js +50 -0
  15. package/esm/library/schema/data_types.js +3 -38
  16. package/esm/library/schema/search.js +1 -0
  17. package/esm/library/schema/utils.js +31 -6
  18. package/esm/library/sparql/mod.js +2 -1
  19. package/esm/library/sparql/sparql_expression_builders.js +18 -0
  20. package/esm/library/sparql/sparql_query_builders.js +65 -0
  21. package/esm/library/sparql/sparql_shared_builders.js +1 -0
  22. package/esm/library/sparql/sparql_tag.js +27 -1
  23. package/esm/library/sparql/sparql_update_builders.js +70 -0
  24. package/esm/library/sparql/stringify.js +3 -4
  25. package/esm/mod.js +4 -4
  26. package/esm/{library/namespaces → namespaces}/dbo.js +7 -2
  27. package/esm/{library/namespaces → namespaces}/dc.js +7 -2
  28. package/esm/{library/namespaces → namespaces}/dcterms.js +7 -2
  29. package/esm/{library/namespaces → namespaces}/foaf.js +7 -2
  30. package/esm/{library/namespaces → namespaces}/gr.js +7 -2
  31. package/esm/namespaces/ldkit.js +11 -0
  32. package/esm/namespaces/owl.js +91 -0
  33. package/{script/library → esm}/namespaces/rdf.js +7 -4
  34. package/{script/library → esm}/namespaces/rdfs.js +7 -4
  35. package/esm/{library/namespaces → namespaces}/schema.js +7 -2
  36. package/esm/{library/namespaces → namespaces}/sioc.js +7 -2
  37. package/{script/library → esm}/namespaces/skos.js +7 -4
  38. package/{script/library → esm}/namespaces/xsd.js +7 -4
  39. package/esm/namespaces.js +30 -1
  40. package/esm/rdf.js +14 -1
  41. package/esm/sparql.js +13 -0
  42. package/package.json +8 -8
  43. package/script/library/decoder.js +25 -38
  44. package/script/library/encoder.js +38 -24
  45. package/script/library/engine/mod.js +16 -5
  46. package/script/library/engine/query_engine.js +40 -0
  47. package/script/library/engine/query_engine_proxy.js +7 -7
  48. package/script/library/engine/types.js +2 -0
  49. package/script/library/lens/lens.js +417 -29
  50. package/script/library/lens/mod.js +15 -4
  51. package/script/library/lens/query_builder.js +87 -56
  52. package/script/library/lens/search_helper.js +146 -0
  53. package/script/library/lens/update_helper.js +161 -0
  54. package/script/library/namespace.js +40 -0
  55. package/script/library/options.js +56 -0
  56. package/script/library/schema/data_types.js +3 -41
  57. package/script/library/schema/search.js +2 -0
  58. package/script/library/schema/utils.js +33 -11
  59. package/script/library/sparql/mod.js +17 -3
  60. package/script/library/sparql/sparql_expression_builders.js +22 -0
  61. package/script/library/sparql/sparql_query_builders.js +65 -0
  62. package/script/library/sparql/sparql_shared_builders.js +3 -1
  63. package/script/library/sparql/sparql_tag.js +30 -7
  64. package/script/library/sparql/sparql_update_builders.js +70 -0
  65. package/script/library/sparql/stringify.js +4 -8
  66. package/script/mod.js +20 -11
  67. package/script/{library/namespaces → namespaces}/dbo.js +8 -2
  68. package/script/{library/namespaces → namespaces}/dc.js +8 -2
  69. package/script/{library/namespaces → namespaces}/dcterms.js +8 -2
  70. package/script/{library/namespaces → namespaces}/foaf.js +8 -2
  71. package/script/{library/namespaces → namespaces}/gr.js +8 -2
  72. package/script/namespaces/ldkit.js +14 -0
  73. package/script/namespaces/owl.js +94 -0
  74. package/{esm/library → script}/namespaces/rdf.js +10 -2
  75. package/{esm/library → script}/namespaces/rdfs.js +10 -2
  76. package/script/{library/namespaces → namespaces}/schema.js +8 -2
  77. package/script/{library/namespaces → namespaces}/sioc.js +8 -2
  78. package/{esm/library → script}/namespaces/skos.js +10 -2
  79. package/{esm/library → script}/namespaces/xsd.js +10 -2
  80. package/script/namespaces.js +44 -1
  81. package/script/rdf.js +20 -15
  82. package/script/sparql.js +13 -0
  83. package/types/library/decoder.d.ts +4 -3
  84. package/types/library/encoder.d.ts +5 -3
  85. package/types/library/engine/mod.d.ts +2 -2
  86. package/types/library/engine/query_engine.d.ts +50 -9
  87. package/types/library/engine/query_engine_proxy.d.ts +4 -3
  88. package/types/library/engine/types.d.ts +23 -0
  89. package/types/library/lens/lens.d.ts +401 -24
  90. package/types/library/lens/mod.d.ts +1 -1
  91. package/types/library/lens/query_builder.d.ts +11 -11
  92. package/types/library/lens/search_helper.d.ts +21 -0
  93. package/types/library/lens/types.d.ts +5 -2
  94. package/types/library/lens/update_helper.d.ts +23 -0
  95. package/types/library/namespace.d.ts +41 -0
  96. package/types/library/options.d.ts +70 -0
  97. package/types/library/rdf.d.ts +8 -15
  98. package/types/library/schema/data_types.d.ts +44 -37
  99. package/types/library/schema/interface.d.ts +75 -20
  100. package/types/library/schema/mod.d.ts +4 -2
  101. package/types/library/schema/schema.d.ts +23 -16
  102. package/types/library/schema/search.d.ts +20 -0
  103. package/types/library/schema/utils.d.ts +3 -3
  104. package/types/library/sparql/mod.d.ts +2 -1
  105. package/types/library/sparql/sparql_expression_builders.d.ts +19 -0
  106. package/types/library/sparql/sparql_query_builders.d.ts +68 -3
  107. package/types/library/sparql/sparql_shared_builders.d.ts +1 -0
  108. package/types/library/sparql/sparql_tag.d.ts +29 -1
  109. package/types/library/sparql/sparql_update_builders.d.ts +68 -0
  110. package/types/mod.d.ts +5 -6
  111. package/types/namespaces/dbo.d.ts +10 -0
  112. package/types/namespaces/dc.d.ts +10 -0
  113. package/types/namespaces/dcterms.d.ts +10 -0
  114. package/types/namespaces/foaf.d.ts +10 -0
  115. package/types/namespaces/gr.d.ts +10 -0
  116. package/types/namespaces/ldkit.d.ts +10 -0
  117. package/types/namespaces/owl.d.ts +10 -0
  118. package/types/namespaces/rdf.d.ts +10 -0
  119. package/types/namespaces/rdfs.d.ts +10 -0
  120. package/types/namespaces/schema.d.ts +10 -0
  121. package/types/namespaces/sioc.d.ts +10 -0
  122. package/types/namespaces/skos.d.ts +10 -0
  123. package/types/namespaces/xsd.d.ts +10 -0
  124. package/types/namespaces.d.ts +30 -1
  125. package/types/rdf.d.ts +14 -1
  126. package/types/sparql.d.ts +13 -0
  127. package/esm/library/global.js +0 -25
  128. package/esm/library/lens/query_helper.js +0 -102
  129. package/esm/library/namespaces/ldkit.js +0 -6
  130. package/esm/library/namespaces/mod.js +0 -13
  131. package/esm/library/namespaces/namespace.js +0 -11
  132. package/script/library/global.js +0 -32
  133. package/script/library/lens/query_helper.js +0 -106
  134. package/script/library/namespaces/ldkit.js +0 -8
  135. package/script/library/namespaces/mod.js +0 -32
  136. package/script/library/namespaces/namespace.js +0 -15
  137. package/types/library/global.d.ts +0 -5
  138. package/types/library/lens/query_helper.d.ts +0 -19
  139. package/types/library/namespaces/dbo.d.ts +0 -3649
  140. package/types/library/namespaces/dc.d.ts +0 -21
  141. package/types/library/namespaces/dcterms.d.ts +0 -104
  142. package/types/library/namespaces/foaf.d.ts +0 -69
  143. package/types/library/namespaces/gr.d.ts +0 -175
  144. package/types/library/namespaces/ldkit.d.ts +0 -7
  145. package/types/library/namespaces/mod.d.ts +0 -13
  146. package/types/library/namespaces/namespace.d.ts +0 -15
  147. package/types/library/namespaces/rdf.d.ts +0 -28
  148. package/types/library/namespaces/rdfs.d.ts +0 -21
  149. package/types/library/namespaces/schema.d.ts +0 -2697
  150. package/types/library/namespaces/sioc.d.ts +0 -105
  151. package/types/library/namespaces/skos.d.ts +0 -38
  152. package/types/library/namespaces/xsd.d.ts +0 -56
@@ -1,5 +1,13 @@
1
- import { createNamespace } from "./namespace.js";
2
- export default createNamespace({
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.rdf = void 0;
4
+ const namespace_js_1 = require("../library/namespace.js");
5
+ /**
6
+ * The RDF Concepts Vocabulary (RDF)
7
+ *
8
+ * `@rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>`,
9
+ */
10
+ exports.rdf = (0, namespace_js_1.createNamespace)({
3
11
  iri: "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
4
12
  prefix: "rdf:",
5
13
  terms: [
@@ -1,5 +1,13 @@
1
- import { createNamespace } from "./namespace.js";
2
- export default createNamespace({
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.rdfs = void 0;
4
+ const namespace_js_1 = require("../library/namespace.js");
5
+ /**
6
+ * The RDF Schema vocabulary (RDFS)
7
+ *
8
+ * `@rdfs: <http://www.w3.org/2000/01/rdf-schema#>`,
9
+ */
10
+ exports.rdfs = (0, namespace_js_1.createNamespace)({
3
11
  iri: "http://www.w3.org/2000/01/rdf-schema#",
4
12
  prefix: "rdfs:",
5
13
  terms: [
@@ -1,7 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const namespace_js_1 = require("./namespace.js");
4
- exports.default = (0, namespace_js_1.createNamespace)({
3
+ exports.schema = void 0;
4
+ const namespace_js_1 = require("../library/namespace.js");
5
+ /**
6
+ * Schema.org vocabulary
7
+ *
8
+ * `@schema: <http://schema.org/>`,
9
+ */
10
+ exports.schema = (0, namespace_js_1.createNamespace)({
5
11
  iri: "http://schema.org/",
6
12
  prefix: "schema:",
7
13
  terms: [
@@ -1,7 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const namespace_js_1 = require("./namespace.js");
4
- exports.default = (0, namespace_js_1.createNamespace)({
3
+ exports.sioc = void 0;
4
+ const namespace_js_1 = require("../library/namespace.js");
5
+ /**
6
+ * SIOC Core Ontology Namespace
7
+ *
8
+ * `@sioc: <http://rdfs.org/sioc/ns#>`,
9
+ */
10
+ exports.sioc = (0, namespace_js_1.createNamespace)({
5
11
  iri: "http://rdfs.org/sioc/ns#",
6
12
  prefix: "sioc:",
7
13
  terms: [
@@ -1,5 +1,13 @@
1
- import { createNamespace } from "./namespace.js";
2
- export default createNamespace({
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.skos = void 0;
4
+ const namespace_js_1 = require("../library/namespace.js");
5
+ /**
6
+ * SKOS - Simple Knowledge Organization System
7
+ *
8
+ * `@skos: <http://www.w3.org/2004/02/skos/core#>`,
9
+ */
10
+ exports.skos = (0, namespace_js_1.createNamespace)({
3
11
  iri: "http://www.w3.org/2004/02/skos/core#",
4
12
  prefix: "skos:",
5
13
  terms: [
@@ -1,5 +1,13 @@
1
- import { createNamespace } from "./namespace.js";
2
- export default createNamespace({
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.xsd = void 0;
4
+ const namespace_js_1 = require("../library/namespace.js");
5
+ /**
6
+ * XML Schema Definition Language (XSD)
7
+ *
8
+ * `@xsd: <http://www.w3.org/2001/XMLSchema#>`,
9
+ */
10
+ exports.xsd = (0, namespace_js_1.createNamespace)({
3
11
  iri: "http://www.w3.org/2001/XMLSchema#",
4
12
  prefix: "xsd:",
5
13
  terms: [
@@ -14,4 +14,47 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./library/namespaces/mod.js"), exports);
17
+ exports.xsd = exports.skos = exports.sioc = exports.schema = exports.rdfs = exports.rdf = exports.owl = exports.ldkit = exports.gr = exports.foaf = exports.dcterms = exports.dc = exports.dbo = void 0;
18
+ /**
19
+ * Popular namespaces used in Linked Data, fully compatible with LDkit,
20
+ * offering autocompletion and type checking in IDE.
21
+ *
22
+ * Create your own namespaces using {@link createNamespace} helper.
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * import { rdf, schema } from "ldkit/namespaces";
27
+ *
28
+ * console.log(rdf.type); // "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
29
+ * console.log(schema.Person); // "http://schema.org/Person"
30
+ * ```
31
+ *
32
+ * @module
33
+ */
34
+ var dbo_js_1 = require("./namespaces/dbo.js");
35
+ Object.defineProperty(exports, "dbo", { enumerable: true, get: function () { return dbo_js_1.dbo; } });
36
+ var dc_js_1 = require("./namespaces/dc.js");
37
+ Object.defineProperty(exports, "dc", { enumerable: true, get: function () { return dc_js_1.dc; } });
38
+ var dcterms_js_1 = require("./namespaces/dcterms.js");
39
+ Object.defineProperty(exports, "dcterms", { enumerable: true, get: function () { return dcterms_js_1.dcterms; } });
40
+ var foaf_js_1 = require("./namespaces/foaf.js");
41
+ Object.defineProperty(exports, "foaf", { enumerable: true, get: function () { return foaf_js_1.foaf; } });
42
+ var gr_js_1 = require("./namespaces/gr.js");
43
+ Object.defineProperty(exports, "gr", { enumerable: true, get: function () { return gr_js_1.gr; } });
44
+ var ldkit_js_1 = require("./namespaces/ldkit.js");
45
+ Object.defineProperty(exports, "ldkit", { enumerable: true, get: function () { return ldkit_js_1.ldkit; } });
46
+ var owl_js_1 = require("./namespaces/owl.js");
47
+ Object.defineProperty(exports, "owl", { enumerable: true, get: function () { return owl_js_1.owl; } });
48
+ var rdf_js_1 = require("./namespaces/rdf.js");
49
+ Object.defineProperty(exports, "rdf", { enumerable: true, get: function () { return rdf_js_1.rdf; } });
50
+ var rdfs_js_1 = require("./namespaces/rdfs.js");
51
+ Object.defineProperty(exports, "rdfs", { enumerable: true, get: function () { return rdfs_js_1.rdfs; } });
52
+ var schema_js_1 = require("./namespaces/schema.js");
53
+ Object.defineProperty(exports, "schema", { enumerable: true, get: function () { return schema_js_1.schema; } });
54
+ var sioc_js_1 = require("./namespaces/sioc.js");
55
+ Object.defineProperty(exports, "sioc", { enumerable: true, get: function () { return sioc_js_1.sioc; } });
56
+ var skos_js_1 = require("./namespaces/skos.js");
57
+ Object.defineProperty(exports, "skos", { enumerable: true, get: function () { return skos_js_1.skos; } });
58
+ var xsd_js_1 = require("./namespaces/xsd.js");
59
+ Object.defineProperty(exports, "xsd", { enumerable: true, get: function () { return xsd_js_1.xsd; } });
60
+ __exportStar(require("./library/namespace.js"), exports);
package/script/rdf.js CHANGED
@@ -1,17 +1,22 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
2
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./library/rdf.js"), exports);
3
+ exports.toRdf = exports.N3 = exports.fromRdf = exports.DefaultGraph = exports.DataFactory = void 0;
4
+ /**
5
+ * RDF utilities
6
+ *
7
+ * This module contains a re-export of external RDF libraries that are used
8
+ * in LDkit and may be used in tandem with LDkit in Linked Data applications as well.
9
+ *
10
+ * Included packages:
11
+ * - [@rdfjs/types](https://github.com/rdfjs/types) [RDF/JS](https://rdf.js.org/) authoritative TypeScript typings
12
+ * - [n3](https://rdf.js.org/N3.js/) RDF parser and serializer
13
+ * - [rdf-data-factory](https://github.com/rubensworks/rdf-data-factory.js) A TypeScript/JavaScript implementation of the RDF/JS data factory
14
+ * - [rdf-literal](https://github.com/rubensworks/rdf-literal.js) Translates between RDF literals and JavaScript primitives
15
+ * @module
16
+ */
17
+ var rdf_js_1 = require("./library/rdf.js");
18
+ Object.defineProperty(exports, "DataFactory", { enumerable: true, get: function () { return rdf_js_1.DataFactory; } });
19
+ Object.defineProperty(exports, "DefaultGraph", { enumerable: true, get: function () { return rdf_js_1.DefaultGraph; } });
20
+ Object.defineProperty(exports, "fromRdf", { enumerable: true, get: function () { return rdf_js_1.fromRdf; } });
21
+ Object.defineProperty(exports, "N3", { enumerable: true, get: function () { return rdf_js_1.N3; } });
22
+ Object.defineProperty(exports, "toRdf", { enumerable: true, get: function () { return rdf_js_1.toRdf; } });
package/script/sparql.js CHANGED
@@ -14,4 +14,17 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ /**
18
+ * SPARQL builders that provide a fluent interface for building SPARQL queries
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * import { SELECT } from "ldkit/sparql";
23
+ *
24
+ * const query = SELECT`?s ?p ?o`.WHERE`?s ?p ?o`.LIMIT(10).build();
25
+ * console.log(query); // SELECT ?s ?p ?o WHERE { ?s ?p ?o } LIMIT 10;
26
+ * ```
27
+ *
28
+ * @module
29
+ */
17
30
  __exportStar(require("./library/sparql/mod.js"), exports);
@@ -1,5 +1,6 @@
1
- import { type Context, Graph } from "./rdf.js";
2
- import type { Schema } from "./schema/mod.js";
1
+ import type { Options } from "./options.js";
2
+ import { Graph } from "./rdf.js";
3
+ import type { ExpandedSchema } from "./schema/mod.js";
4
+ export declare const decode: (graph: Graph, schema: ExpandedSchema, options: Options) => DecodedNode[];
3
5
  type DecodedNode = Record<string, unknown>;
4
- export declare const decode: (graph: Graph, schema: Schema, context: Context) => DecodedNode[];
5
6
  export {};
@@ -1,5 +1,7 @@
1
- import { type Context, type RDF } from "./rdf.js";
2
- import type { Schema } from "./schema/mod.js";
1
+ import type { Options } from "./options.js";
2
+ import { DataFactory, type RDF } from "./rdf.js";
3
+ import type { ExpandedSchema } from "./schema/mod.js";
3
4
  type DecodedNode = Record<string, unknown>;
4
- export declare const encode: (node: DecodedNode, schema: Schema, context: Context, variableInitCounter?: number) => RDF.Quad[];
5
+ export declare const encode: (node: DecodedNode, schema: ExpandedSchema, options: Options, includeType?: boolean, variableInitCounter?: number) => RDF.Quad[];
6
+ export declare const encodeValue: (value: unknown, datatype: string, df: DataFactory) => RDF.Literal | import("rdf-data-factory").NamedNode<string>;
5
7
  export {};
@@ -1,2 +1,2 @@
1
- export { QueryEngine } from "./query_engine.js";
2
- export { QueryEngineProxy } from "./query_engine_proxy.js";
1
+ export * from "./query_engine.js";
2
+ export * from "./types.js";
@@ -1,16 +1,57 @@
1
- import { type Context, type IQueryEngine, type RDF } from "../rdf.js";
1
+ import { type RDF } from "../rdf.js";
2
+ import { type IQueryEngine, type QueryContext } from "./types.js";
2
3
  import { type ResolverType } from "./query_resolvers.js";
4
+ /**
5
+ * A query engine that can query a SPARQL endpoint.
6
+ *
7
+ * Implements {@link IQueryEngine} interface.
8
+ *
9
+ * This engine is used by default if no other engine is configured.
10
+ * See {@link Options} for more details.
11
+ *
12
+ * If you need to query other data sources, or multiple SPARQL endpoints,
13
+ * you can use [Comunica](https://comunica.dev) instead, extend this engine,
14
+ * or implement your own.
15
+ */
3
16
  export declare class QueryEngine implements IQueryEngine {
4
- protected getSparqlEndpoint(context?: Context): string;
5
- protected getFetch(context?: Context): typeof fetch;
6
- query(query: string, responseType: string, context?: Context): Promise<Response>;
7
- queryAndResolve<T extends ResolverType>(type: T, query: string, context?: Context): Promise<{
17
+ protected getSparqlEndpoint(context?: QueryContext): string;
18
+ protected getFetch(context?: QueryContext): typeof fetch;
19
+ protected query(query: string, responseType: string, context?: QueryContext): Promise<Response>;
20
+ protected queryAndResolve<T extends ResolverType>(type: T, query: string, context?: QueryContext): Promise<{
8
21
  boolean: boolean;
9
22
  bindings: RDF.ResultStream<RDF.Bindings>;
10
23
  quads: RDF.ResultStream<RDF.Quad>;
11
24
  }[T]>;
12
- queryBindings(query: string, context?: Context): Promise<RDF.ResultStream<RDF.Bindings>>;
13
- queryBoolean(query: string, context?: Context): Promise<boolean>;
14
- queryQuads(query: string, context?: Context): Promise<RDF.ResultStream<RDF.Quad>>;
15
- queryVoid(query: string, context?: Context): Promise<void>;
25
+ /**
26
+ * Executes a SPARQL SELECT query and returns a stream of bindings.
27
+ *
28
+ * @param query SPARQL query string
29
+ * @param context Engine context
30
+ * @returns Stream of bindings
31
+ */
32
+ queryBindings(query: string, context?: QueryContext): Promise<RDF.ResultStream<RDF.Bindings>>;
33
+ /**
34
+ * Executes a SPARQL ASK query and returns a boolean result.
35
+ *
36
+ * @param query SPARQL query string
37
+ * @param context Engine context
38
+ * @returns Boolean result
39
+ */
40
+ queryBoolean(query: string, context?: QueryContext): Promise<boolean>;
41
+ /**
42
+ * Executes a SPARQL CONSTRUCT query and returns a stream of quads.
43
+ *
44
+ * @param query SPARQL query string
45
+ * @param context Engine context
46
+ * @returns Stream of quads
47
+ */
48
+ queryQuads(query: string, context?: QueryContext): Promise<RDF.ResultStream<RDF.Quad>>;
49
+ /**
50
+ * Executes a SPARQL UPDATE query and returns nothing.
51
+ *
52
+ * @param query SPARQL query string
53
+ * @param context Engine context
54
+ * @returns Nothing
55
+ */
56
+ queryVoid(query: string, context?: QueryContext): Promise<void>;
16
57
  }
@@ -1,8 +1,9 @@
1
- import { type Context, IQueryEngine, type RDF } from "../rdf.js";
1
+ import { type RDF } from "../rdf.js";
2
+ import type { IQueryEngine, QueryContext } from "./types.js";
2
3
  export declare class QueryEngineProxy {
3
- private readonly context;
4
4
  private readonly engine;
5
- constructor(context?: Context, engine?: IQueryEngine);
5
+ private readonly context;
6
+ constructor(engine: IQueryEngine, context: QueryContext);
6
7
  queryBoolean(query: string): Promise<boolean>;
7
8
  queryBindings(query: string): Promise<RDF.Bindings[]>;
8
9
  queryGraph(query: string): Promise<import("../rdf.js").Graph>;
@@ -0,0 +1,23 @@
1
+ import type { IQueryContextCommon, QuerySourceUnidentified } from "@comunica/types";
2
+ import { RDF } from "../rdf.js";
3
+ /**
4
+ * A set of context entries that can be passed to a query engine,
5
+ * such as data sources, fetch configuration, etc.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { QueryContext, QueryEngine } from "ldkit";
10
+ *
11
+ * const context: QueryContext = {
12
+ * sources: ["https://dbpedia.org/sparql"],
13
+ * };
14
+ *
15
+ * const engine = new QueryEngine();
16
+ * await engine.queryBoolean("ASK { ?s ?p ?o }", context);
17
+ * ```
18
+ */
19
+ export type QueryContext = RDF.QueryStringContext & RDF.QuerySourceContext<QuerySourceUnidentified> & IQueryContextCommon;
20
+ /**
21
+ * Interface of a query engine compatible with LDkit
22
+ */
23
+ export type IQueryEngine = RDF.StringSparqlQueryable<RDF.SparqlResultSupport, QueryContext>;