ldkit 0.8.0 → 2.0.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 (157) hide show
  1. package/README.md +5 -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 +57 -29
  6. package/esm/library/engine/query_engine_proxy.js +8 -8
  7. package/esm/library/engine/query_resolvers.js +72 -0
  8. package/esm/library/engine/types.js +1 -0
  9. package/esm/library/lens/lens.js +414 -25
  10. package/esm/library/lens/mod.js +1 -1
  11. package/esm/library/lens/query_builder.js +81 -50
  12. package/esm/library/lens/search_helper.js +142 -0
  13. package/esm/library/lens/update_helper.js +157 -0
  14. package/esm/library/namespace.js +36 -0
  15. package/esm/library/options.js +50 -0
  16. package/esm/library/rdf.js +3 -2
  17. package/esm/library/schema/data_types.js +3 -38
  18. package/esm/library/schema/search.js +1 -0
  19. package/esm/library/schema/utils.js +31 -6
  20. package/esm/library/sparql/mod.js +2 -1
  21. package/esm/library/sparql/sparql_expression_builders.js +18 -0
  22. package/esm/library/sparql/sparql_query_builders.js +65 -0
  23. package/esm/library/sparql/sparql_shared_builders.js +1 -0
  24. package/esm/library/sparql/sparql_tag.js +27 -1
  25. package/esm/library/sparql/sparql_update_builders.js +70 -0
  26. package/esm/library/sparql/stringify.js +3 -4
  27. package/esm/mod.js +4 -3
  28. package/esm/{library/namespaces → namespaces}/dbo.js +7 -2
  29. package/esm/{library/namespaces → namespaces}/dc.js +7 -2
  30. package/esm/{library/namespaces → namespaces}/dcterms.js +7 -2
  31. package/esm/{library/namespaces → namespaces}/foaf.js +7 -2
  32. package/esm/{library/namespaces → namespaces}/gr.js +7 -2
  33. package/esm/namespaces/ldkit.js +11 -0
  34. package/esm/namespaces/owl.js +91 -0
  35. package/{script/library → esm}/namespaces/rdf.js +7 -4
  36. package/{script/library → esm}/namespaces/rdfs.js +7 -4
  37. package/esm/{library/namespaces → namespaces}/schema.js +7 -2
  38. package/esm/{library/namespaces → namespaces}/sioc.js +7 -2
  39. package/{script/library → esm}/namespaces/skos.js +7 -4
  40. package/{script/library → esm}/namespaces/xsd.js +7 -4
  41. package/esm/namespaces.js +30 -1
  42. package/esm/rdf.js +14 -1
  43. package/esm/sparql.js +13 -0
  44. package/package.json +4 -2
  45. package/script/library/decoder.js +25 -38
  46. package/script/library/encoder.js +38 -24
  47. package/script/library/engine/mod.js +16 -5
  48. package/script/library/engine/query_engine.js +57 -29
  49. package/script/library/engine/query_engine_proxy.js +7 -7
  50. package/script/library/engine/query_resolvers.js +77 -0
  51. package/script/library/engine/types.js +2 -0
  52. package/script/library/lens/lens.js +415 -27
  53. package/script/library/lens/mod.js +15 -4
  54. package/script/library/lens/query_builder.js +82 -54
  55. package/script/library/lens/search_helper.js +146 -0
  56. package/script/library/lens/update_helper.js +161 -0
  57. package/script/library/namespace.js +40 -0
  58. package/script/library/options.js +56 -0
  59. package/script/library/rdf.js +27 -3
  60. package/script/library/schema/data_types.js +3 -41
  61. package/script/library/schema/search.js +2 -0
  62. package/script/library/schema/utils.js +33 -11
  63. package/script/library/sparql/mod.js +17 -3
  64. package/script/library/sparql/sparql_expression_builders.js +22 -0
  65. package/script/library/sparql/sparql_query_builders.js +65 -0
  66. package/script/library/sparql/sparql_shared_builders.js +3 -1
  67. package/script/library/sparql/sparql_tag.js +30 -7
  68. package/script/library/sparql/sparql_update_builders.js +70 -0
  69. package/script/library/sparql/stringify.js +4 -8
  70. package/script/mod.js +20 -9
  71. package/script/{library/namespaces → namespaces}/dbo.js +8 -2
  72. package/script/{library/namespaces → namespaces}/dc.js +8 -2
  73. package/script/{library/namespaces → namespaces}/dcterms.js +8 -2
  74. package/script/{library/namespaces → namespaces}/foaf.js +8 -2
  75. package/script/{library/namespaces → namespaces}/gr.js +8 -2
  76. package/script/namespaces/ldkit.js +14 -0
  77. package/script/namespaces/owl.js +94 -0
  78. package/{esm/library → script}/namespaces/rdf.js +10 -2
  79. package/{esm/library → script}/namespaces/rdfs.js +10 -2
  80. package/script/{library/namespaces → namespaces}/schema.js +8 -2
  81. package/script/{library/namespaces → namespaces}/sioc.js +8 -2
  82. package/{esm/library → script}/namespaces/skos.js +10 -2
  83. package/{esm/library → script}/namespaces/xsd.js +10 -2
  84. package/script/namespaces.js +44 -1
  85. package/script/rdf.js +20 -15
  86. package/script/sparql.js +13 -0
  87. package/types/library/decoder.d.ts +4 -3
  88. package/types/library/encoder.d.ts +5 -3
  89. package/types/library/engine/mod.d.ts +2 -2
  90. package/types/library/engine/query_engine.d.ts +55 -13
  91. package/types/library/engine/query_engine_proxy.d.ts +4 -3
  92. package/types/library/engine/query_resolvers.d.ts +10 -0
  93. package/types/library/engine/types.d.ts +23 -0
  94. package/types/library/lens/lens.d.ts +400 -23
  95. package/types/library/lens/mod.d.ts +1 -1
  96. package/types/library/lens/query_builder.d.ts +10 -10
  97. package/types/library/lens/search_helper.d.ts +21 -0
  98. package/types/library/lens/types.d.ts +5 -2
  99. package/types/library/lens/update_helper.d.ts +23 -0
  100. package/types/library/namespace.d.ts +41 -0
  101. package/types/library/options.d.ts +72 -0
  102. package/types/library/rdf.d.ts +10 -16
  103. package/types/library/schema/data_types.d.ts +44 -37
  104. package/types/library/schema/interface.d.ts +75 -20
  105. package/types/library/schema/mod.d.ts +4 -2
  106. package/types/library/schema/schema.d.ts +23 -16
  107. package/types/library/schema/search.d.ts +20 -0
  108. package/types/library/schema/utils.d.ts +3 -3
  109. package/types/library/sparql/mod.d.ts +2 -1
  110. package/types/library/sparql/sparql_expression_builders.d.ts +19 -0
  111. package/types/library/sparql/sparql_query_builders.d.ts +68 -3
  112. package/types/library/sparql/sparql_shared_builders.d.ts +1 -0
  113. package/types/library/sparql/sparql_tag.d.ts +29 -1
  114. package/types/library/sparql/sparql_update_builders.d.ts +68 -0
  115. package/types/mod.d.ts +5 -5
  116. package/types/namespaces/dbo.d.ts +10 -0
  117. package/types/namespaces/dc.d.ts +10 -0
  118. package/types/namespaces/dcterms.d.ts +10 -0
  119. package/types/namespaces/foaf.d.ts +10 -0
  120. package/types/namespaces/gr.d.ts +10 -0
  121. package/types/namespaces/ldkit.d.ts +10 -0
  122. package/types/namespaces/owl.d.ts +10 -0
  123. package/types/namespaces/rdf.d.ts +10 -0
  124. package/types/namespaces/rdfs.d.ts +10 -0
  125. package/types/namespaces/schema.d.ts +10 -0
  126. package/types/namespaces/sioc.d.ts +10 -0
  127. package/types/namespaces/skos.d.ts +10 -0
  128. package/types/namespaces/xsd.d.ts +10 -0
  129. package/types/namespaces.d.ts +30 -1
  130. package/types/rdf.d.ts +14 -1
  131. package/types/sparql.d.ts +13 -0
  132. package/esm/library/global.js +0 -25
  133. package/esm/library/lens/query_helper.js +0 -102
  134. package/esm/library/namespaces/ldkit.js +0 -6
  135. package/esm/library/namespaces/mod.js +0 -13
  136. package/esm/library/namespaces/namespace.js +0 -11
  137. package/script/library/global.js +0 -32
  138. package/script/library/lens/query_helper.js +0 -106
  139. package/script/library/namespaces/ldkit.js +0 -8
  140. package/script/library/namespaces/mod.js +0 -32
  141. package/script/library/namespaces/namespace.js +0 -15
  142. package/types/library/global.d.ts +0 -5
  143. package/types/library/lens/query_helper.d.ts +0 -19
  144. package/types/library/namespaces/dbo.d.ts +0 -3649
  145. package/types/library/namespaces/dc.d.ts +0 -21
  146. package/types/library/namespaces/dcterms.d.ts +0 -104
  147. package/types/library/namespaces/foaf.d.ts +0 -69
  148. package/types/library/namespaces/gr.d.ts +0 -175
  149. package/types/library/namespaces/ldkit.d.ts +0 -7
  150. package/types/library/namespaces/mod.d.ts +0 -13
  151. package/types/library/namespaces/namespace.d.ts +0 -15
  152. package/types/library/namespaces/rdf.d.ts +0 -28
  153. package/types/library/namespaces/rdfs.d.ts +0 -21
  154. package/types/library/namespaces/schema.d.ts +0 -2697
  155. package/types/library/namespaces/sioc.d.ts +0 -105
  156. package/types/library/namespaces/skos.d.ts +0 -38
  157. package/types/library/namespaces/xsd.d.ts +0 -56
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.owl = void 0;
4
+ const namespace_js_1 = require("../library/namespace.js");
5
+ /**
6
+ * OWL Web Ontology Language
7
+ *
8
+ * `@owl: <http://www.w3.org/2002/07/owl#>`,
9
+ */
10
+ exports.owl = (0, namespace_js_1.createNamespace)({
11
+ iri: "http://www.w3.org/2002/07/owl#",
12
+ prefix: "owl:",
13
+ terms: [
14
+ "owl:AllDifferent",
15
+ "owl:AllDisjointClasses",
16
+ "owl:AllDisjointProperties",
17
+ "owl:allValuesFrom",
18
+ "owl:annotatedProperty",
19
+ "owl:annotatedSource",
20
+ "owl:annotatedTarget",
21
+ "owl:Annotation",
22
+ "owl:AnnotationProperty",
23
+ "owl:assertionProperty",
24
+ "owl:AsymmetricProperty",
25
+ "owl:Axiom",
26
+ "owl:backwardCompatibleWith",
27
+ "owl:bottomDataProperty",
28
+ "owl:bottomObjectProperty",
29
+ "owl:cardinality",
30
+ "owl:Class",
31
+ "owl:complementOf",
32
+ "owl:DataRange",
33
+ "owl:datatypeComplementOf",
34
+ "owl:DatatypeProperty",
35
+ "owl:deprecated",
36
+ "owl:DeprecatedClass",
37
+ "owl:DeprecatedProperty",
38
+ "owl:differentFrom",
39
+ "owl:disjointUnionOf",
40
+ "owl:disjointWith",
41
+ "owl:distinctMembers",
42
+ "owl:equivalentClass",
43
+ "owl:equivalentProperty",
44
+ "owl:FunctionalProperty",
45
+ "owl:hasKey",
46
+ "owl:hasSelf",
47
+ "owl:hasValue",
48
+ "owl:imports",
49
+ "owl:incompatibleWith",
50
+ "owl:intersectionOf",
51
+ "owl:InverseFunctionalProperty",
52
+ "owl:inverseOf",
53
+ "owl:IrreflexiveProperty",
54
+ "owl:maxCardinality",
55
+ "owl:maxQualifiedCardinality",
56
+ "owl:members",
57
+ "owl:minCardinality",
58
+ "owl:minQualifiedCardinality",
59
+ "owl:NamedIndividual",
60
+ "owl:NegativePropertyAssertion",
61
+ "owl:Nothing",
62
+ "owl:ObjectProperty",
63
+ "owl:onClass",
64
+ "owl:onDataRange",
65
+ "owl:onDatatype",
66
+ "owl:oneOf",
67
+ "owl:onProperty",
68
+ "owl:onProperties",
69
+ "owl:Ontology",
70
+ "owl:OntologyProperty",
71
+ "owl:priorVersion",
72
+ "owl:propertyChainAxiom",
73
+ "owl:propertyDisjointWith",
74
+ "owl:qualifiedCardinality",
75
+ "owl:rational",
76
+ "owl:real",
77
+ "owl:ReflexiveProperty",
78
+ "owl:Restriction",
79
+ "owl:sameAs",
80
+ "owl:someValuesFrom",
81
+ "owl:sourceIndividual",
82
+ "owl:SymmetricProperty",
83
+ "owl:targetIndividual",
84
+ "owl:targetValue",
85
+ "owl:Thing",
86
+ "owl:topDataProperty",
87
+ "owl:topObjectProperty",
88
+ "owl:TransitiveProperty",
89
+ "owl:unionOf",
90
+ "owl:versionInfo",
91
+ "owl:versionIRI",
92
+ "owl:withRestrictions",
93
+ ],
94
+ });
@@ -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) => any;
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,15 +1,57 @@
1
- import { type Context, type IQueryEngine, type RDF, RDFJSON } from "../rdf.js";
2
- type QueryResponseFormat = {
3
- "application/sparql-results+json": RDFJSON.SparqlResultsJsonFormat;
4
- "application/rdf+json": RDFJSON.RdfJsonFormat;
5
- };
1
+ import { type RDF } from "../rdf.js";
2
+ import { type IQueryEngine, type QueryContext } from "./types.js";
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
+ */
6
16
  export declare class QueryEngine implements IQueryEngine {
7
- protected getSparqlEndpoint(context?: Context): string;
8
- protected getFetch(context?: Context): typeof fetch;
9
- query<ResponseType extends keyof QueryResponseFormat, ResponseFormat = QueryResponseFormat[ResponseType]>(query: string, responseType: ResponseType, context?: Context): Promise<ResponseFormat>;
10
- queryBindings(query: string, context?: Context): Promise<RDF.ResultStream<RDF.Bindings>>;
11
- queryBoolean(query: string, context?: Context): Promise<boolean>;
12
- queryQuads(query: string, context?: Context): Promise<RDF.ResultStream<RDF.Quad>>;
13
- queryVoid(query: string, context?: Context): Promise<void>;
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<{
21
+ boolean: boolean;
22
+ bindings: RDF.ResultStream<RDF.Bindings>;
23
+ quads: RDF.ResultStream<RDF.Quad>;
24
+ }[T]>;
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>;
14
57
  }
15
- export {};
@@ -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,10 @@
1
+ import { type RDF } from "../rdf.js";
2
+ type ResolveFormat = {
3
+ "boolean": boolean;
4
+ "bindings": RDF.ResultStream<RDF.Bindings>;
5
+ "quads": RDF.ResultStream<RDF.Quad>;
6
+ };
7
+ export type ResolverType = keyof ResolveFormat;
8
+ export declare const getResponseTypes: (resolverType: ResolverType) => string[];
9
+ export declare const resolve: <T extends keyof ResolveFormat>(resolverType: T, response: Response) => Promise<ResolveFormat[T]>;
10
+ export {};
@@ -0,0 +1,23 @@
1
+ import type { IDataSource, IQueryContextCommon } 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<IDataSource> & IQueryContextCommon;
20
+ /**
21
+ * Interface of a query engine compatible with LDkit
22
+ */
23
+ export type IQueryEngine = RDF.StringSparqlQueryable<RDF.SparqlResultSupport, QueryContext>;