ldkit 2.3.0 → 2.5.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 (246) hide show
  1. package/README.md +25 -0
  2. package/esm/cli.d.ts +3 -0
  3. package/esm/cli.d.ts.map +1 -0
  4. package/esm/cli.js +117 -0
  5. package/{types → esm}/library/asynciterator.d.ts +1 -0
  6. package/esm/library/asynciterator.d.ts.map +1 -0
  7. package/{types → esm}/library/decoder.d.ts +1 -0
  8. package/esm/library/decoder.d.ts.map +1 -0
  9. package/{types → esm}/library/encoder.d.ts +1 -0
  10. package/esm/library/encoder.d.ts.map +1 -0
  11. package/{types → esm}/library/engine/mod.d.ts +1 -0
  12. package/esm/library/engine/mod.d.ts.map +1 -0
  13. package/{types → esm}/library/engine/query_engine.d.ts +1 -0
  14. package/esm/library/engine/query_engine.d.ts.map +1 -0
  15. package/{types → esm}/library/engine/query_engine_proxy.d.ts +1 -0
  16. package/esm/library/engine/query_engine_proxy.d.ts.map +1 -0
  17. package/{types → esm}/library/engine/query_resolvers.d.ts +2 -1
  18. package/esm/library/engine/query_resolvers.d.ts.map +1 -0
  19. package/{types → esm}/library/engine/types.d.ts +1 -0
  20. package/esm/library/engine/types.d.ts.map +1 -0
  21. package/{types → esm}/library/lens/lens.d.ts +17 -1
  22. package/esm/library/lens/lens.d.ts.map +1 -0
  23. package/esm/library/lens/lens.js +18 -2
  24. package/esm/library/lens/mod.d.ts +2 -0
  25. package/esm/library/lens/mod.d.ts.map +1 -0
  26. package/{types → esm}/library/lens/query_builder.d.ts +2 -1
  27. package/esm/library/lens/query_builder.d.ts.map +1 -0
  28. package/esm/library/lens/query_builder.js +2 -2
  29. package/{types → esm}/library/lens/search_helper.d.ts +1 -0
  30. package/esm/library/lens/search_helper.d.ts.map +1 -0
  31. package/{types → esm}/library/lens/types.d.ts +1 -0
  32. package/esm/library/lens/types.d.ts.map +1 -0
  33. package/{types → esm}/library/lens/update_helper.d.ts +1 -0
  34. package/esm/library/lens/update_helper.d.ts.map +1 -0
  35. package/{types → esm}/library/namespace.d.ts +1 -0
  36. package/esm/library/namespace.d.ts.map +1 -0
  37. package/{types → esm}/library/options.d.ts +26 -25
  38. package/esm/library/options.d.ts.map +1 -0
  39. package/esm/library/options.js +1 -0
  40. package/{types → esm}/library/rdf.d.ts +4 -3
  41. package/esm/library/rdf.d.ts.map +1 -0
  42. package/esm/library/rdf.js +0 -7
  43. package/{types → esm}/library/schema/data_types.d.ts +1 -0
  44. package/esm/library/schema/data_types.d.ts.map +1 -0
  45. package/{types → esm}/library/schema/interface.d.ts +1 -0
  46. package/esm/library/schema/interface.d.ts.map +1 -0
  47. package/{types → esm}/library/schema/mod.d.ts +1 -0
  48. package/esm/library/schema/mod.d.ts.map +1 -0
  49. package/{types → esm}/library/schema/schema.d.ts +1 -0
  50. package/esm/library/schema/schema.d.ts.map +1 -0
  51. package/{types → esm}/library/schema/search.d.ts +1 -0
  52. package/esm/library/schema/search.d.ts.map +1 -0
  53. package/{types → esm}/library/schema/utils.d.ts +1 -0
  54. package/esm/library/schema/utils.d.ts.map +1 -0
  55. package/{types → esm}/library/sparql/escape.d.ts +1 -0
  56. package/esm/library/sparql/escape.d.ts.map +1 -0
  57. package/{types → esm}/library/sparql/mod.d.ts +1 -0
  58. package/esm/library/sparql/mod.d.ts.map +1 -0
  59. package/{types → esm}/library/sparql/sparql_expression_builders.d.ts +1 -0
  60. package/esm/library/sparql/sparql_expression_builders.d.ts.map +1 -0
  61. package/{types → esm}/library/sparql/sparql_query_builders.d.ts +1 -0
  62. package/esm/library/sparql/sparql_query_builders.d.ts.map +1 -0
  63. package/{types → esm}/library/sparql/sparql_shared_builders.d.ts +1 -0
  64. package/esm/library/sparql/sparql_shared_builders.d.ts.map +1 -0
  65. package/{types → esm}/library/sparql/sparql_tag.d.ts +1 -0
  66. package/esm/library/sparql/sparql_tag.d.ts.map +1 -0
  67. package/{types → esm}/library/sparql/sparql_update_builders.d.ts +1 -0
  68. package/esm/library/sparql/sparql_update_builders.d.ts.map +1 -0
  69. package/{types → esm}/library/sparql/stringify.d.ts +1 -0
  70. package/esm/library/sparql/stringify.d.ts.map +1 -0
  71. package/{types → esm}/library/translator.d.ts +1 -0
  72. package/esm/library/translator.d.ts.map +1 -0
  73. package/{types → esm}/library/utils.d.ts +1 -0
  74. package/esm/library/utils.d.ts.map +1 -0
  75. package/{types → esm}/mod.d.ts +1 -0
  76. package/esm/mod.d.ts.map +1 -0
  77. package/esm/namespaces/dbo.d.ts +11 -0
  78. package/esm/namespaces/dbo.d.ts.map +1 -0
  79. package/esm/namespaces/dc.d.ts +11 -0
  80. package/esm/namespaces/dc.d.ts.map +1 -0
  81. package/esm/namespaces/dcterms.d.ts +11 -0
  82. package/esm/namespaces/dcterms.d.ts.map +1 -0
  83. package/esm/namespaces/foaf.d.ts +11 -0
  84. package/esm/namespaces/foaf.d.ts.map +1 -0
  85. package/esm/namespaces/foaf.js +12 -0
  86. package/esm/namespaces/gr.d.ts +11 -0
  87. package/esm/namespaces/gr.d.ts.map +1 -0
  88. package/esm/namespaces/ldkit.d.ts +11 -0
  89. package/esm/namespaces/ldkit.d.ts.map +1 -0
  90. package/esm/namespaces/owl.d.ts +11 -0
  91. package/esm/namespaces/owl.d.ts.map +1 -0
  92. package/esm/namespaces/rdf.d.ts +11 -0
  93. package/esm/namespaces/rdf.d.ts.map +1 -0
  94. package/esm/namespaces/rdfs.d.ts +11 -0
  95. package/esm/namespaces/rdfs.d.ts.map +1 -0
  96. package/esm/namespaces/schema.d.ts +11 -0
  97. package/esm/namespaces/schema.d.ts.map +1 -0
  98. package/esm/namespaces/sioc.d.ts +11 -0
  99. package/esm/namespaces/sioc.d.ts.map +1 -0
  100. package/esm/namespaces/skos.d.ts +11 -0
  101. package/esm/namespaces/skos.d.ts.map +1 -0
  102. package/esm/namespaces/xsd.d.ts +11 -0
  103. package/esm/namespaces/xsd.d.ts.map +1 -0
  104. package/{types → esm}/namespaces.d.ts +1 -0
  105. package/esm/namespaces.d.ts.map +1 -0
  106. package/{types → esm}/rdf.d.ts +1 -0
  107. package/esm/rdf.d.ts.map +1 -0
  108. package/esm/scripts/context_to_schema.d.ts +12 -0
  109. package/esm/scripts/context_to_schema.d.ts.map +1 -0
  110. package/esm/scripts/context_to_schema.js +152 -0
  111. package/esm/scripts/schema_to_script.d.ts +19 -0
  112. package/esm/scripts/schema_to_script.d.ts.map +1 -0
  113. package/esm/scripts/schema_to_script.js +222 -0
  114. package/esm/scripts/shex_to_schema.d.ts +6 -0
  115. package/esm/scripts/shex_to_schema.d.ts.map +1 -0
  116. package/esm/scripts/shex_to_schema.js +233 -0
  117. package/esm/scripts/shexj_types.d.ts +537 -0
  118. package/esm/scripts/shexj_types.d.ts.map +1 -0
  119. package/esm/scripts/shexj_types.js +2 -0
  120. package/{types → esm}/sparql.d.ts +1 -0
  121. package/esm/sparql.d.ts.map +1 -0
  122. package/package.json +31 -49
  123. package/script/cli.d.ts +3 -0
  124. package/script/cli.d.ts.map +1 -0
  125. package/script/cli.js +119 -0
  126. package/script/library/asynciterator.d.ts +30 -0
  127. package/script/library/asynciterator.d.ts.map +1 -0
  128. package/script/library/decoder.d.ts +7 -0
  129. package/script/library/decoder.d.ts.map +1 -0
  130. package/script/library/encoder.d.ts +8 -0
  131. package/script/library/encoder.d.ts.map +1 -0
  132. package/script/library/engine/mod.d.ts +3 -0
  133. package/script/library/engine/mod.d.ts.map +1 -0
  134. package/script/library/engine/query_engine.d.ts +58 -0
  135. package/script/library/engine/query_engine.d.ts.map +1 -0
  136. package/script/library/engine/query_engine_proxy.d.ts +12 -0
  137. package/script/library/engine/query_engine_proxy.d.ts.map +1 -0
  138. package/script/library/engine/query_resolvers.d.ts +11 -0
  139. package/script/library/engine/query_resolvers.d.ts.map +1 -0
  140. package/script/library/engine/types.d.ts +24 -0
  141. package/script/library/engine/types.d.ts.map +1 -0
  142. package/script/library/lens/lens.d.ts +431 -0
  143. package/script/library/lens/lens.d.ts.map +1 -0
  144. package/script/library/lens/lens.js +20 -4
  145. package/script/library/lens/mod.d.ts +2 -0
  146. package/script/library/lens/mod.d.ts.map +1 -0
  147. package/script/library/lens/query_builder.d.ts +23 -0
  148. package/script/library/lens/query_builder.d.ts.map +1 -0
  149. package/script/library/lens/query_builder.js +2 -2
  150. package/script/library/lens/search_helper.d.ts +22 -0
  151. package/script/library/lens/search_helper.d.ts.map +1 -0
  152. package/script/library/lens/types.d.ts +9 -0
  153. package/script/library/lens/types.d.ts.map +1 -0
  154. package/script/library/lens/update_helper.d.ts +24 -0
  155. package/script/library/lens/update_helper.d.ts.map +1 -0
  156. package/script/library/namespace.d.ts +42 -0
  157. package/script/library/namespace.d.ts.map +1 -0
  158. package/script/library/namespace.js +1 -2
  159. package/script/library/options.d.ts +72 -0
  160. package/script/library/options.d.ts.map +1 -0
  161. package/script/library/options.js +4 -4
  162. package/script/library/rdf.d.ts +78 -0
  163. package/script/library/rdf.d.ts.map +1 -0
  164. package/script/library/rdf.js +0 -7
  165. package/script/library/schema/data_types.d.ts +57 -0
  166. package/script/library/schema/data_types.d.ts.map +1 -0
  167. package/script/library/schema/interface.d.ts +88 -0
  168. package/script/library/schema/interface.d.ts.map +1 -0
  169. package/script/library/schema/mod.d.ts +6 -0
  170. package/script/library/schema/mod.d.ts.map +1 -0
  171. package/script/library/schema/schema.d.ts +38 -0
  172. package/script/library/schema/schema.d.ts.map +1 -0
  173. package/script/library/schema/search.d.ts +21 -0
  174. package/script/library/schema/search.d.ts.map +1 -0
  175. package/script/library/schema/utils.d.ts +4 -0
  176. package/script/library/schema/utils.d.ts.map +1 -0
  177. package/script/library/sparql/escape.d.ts +2 -0
  178. package/script/library/sparql/escape.d.ts.map +1 -0
  179. package/script/library/sparql/mod.d.ts +5 -0
  180. package/script/library/sparql/mod.d.ts.map +1 -0
  181. package/script/library/sparql/sparql_expression_builders.d.ts +20 -0
  182. package/script/library/sparql/sparql_expression_builders.d.ts.map +1 -0
  183. package/script/library/sparql/sparql_query_builders.d.ts +105 -0
  184. package/script/library/sparql/sparql_query_builders.d.ts.map +1 -0
  185. package/script/library/sparql/sparql_shared_builders.d.ts +17 -0
  186. package/script/library/sparql/sparql_shared_builders.d.ts.map +1 -0
  187. package/script/library/sparql/sparql_tag.d.ts +32 -0
  188. package/script/library/sparql/sparql_tag.d.ts.map +1 -0
  189. package/script/library/sparql/sparql_update_builders.d.ts +91 -0
  190. package/script/library/sparql/sparql_update_builders.d.ts.map +1 -0
  191. package/script/library/sparql/stringify.d.ts +7 -0
  192. package/script/library/sparql/stringify.d.ts.map +1 -0
  193. package/script/library/translator.d.ts +39 -0
  194. package/script/library/translator.d.ts.map +1 -0
  195. package/script/library/translator.js +3 -4
  196. package/script/library/utils.d.ts +2 -0
  197. package/script/library/utils.d.ts.map +1 -0
  198. package/script/mod.d.ts +7 -0
  199. package/script/mod.d.ts.map +1 -0
  200. package/{types → script}/namespaces/dbo.d.ts +1 -0
  201. package/script/namespaces/dbo.d.ts.map +1 -0
  202. package/{types → script}/namespaces/dc.d.ts +1 -0
  203. package/script/namespaces/dc.d.ts.map +1 -0
  204. package/{types → script}/namespaces/dcterms.d.ts +1 -0
  205. package/script/namespaces/dcterms.d.ts.map +1 -0
  206. package/script/namespaces/foaf.d.ts +11 -0
  207. package/script/namespaces/foaf.d.ts.map +1 -0
  208. package/script/namespaces/foaf.js +12 -0
  209. package/{types → script}/namespaces/gr.d.ts +1 -0
  210. package/script/namespaces/gr.d.ts.map +1 -0
  211. package/{types → script}/namespaces/ldkit.d.ts +1 -0
  212. package/script/namespaces/ldkit.d.ts.map +1 -0
  213. package/{types → script}/namespaces/owl.d.ts +1 -0
  214. package/script/namespaces/owl.d.ts.map +1 -0
  215. package/{types → script}/namespaces/rdf.d.ts +1 -0
  216. package/script/namespaces/rdf.d.ts.map +1 -0
  217. package/{types → script}/namespaces/rdfs.d.ts +1 -0
  218. package/script/namespaces/rdfs.d.ts.map +1 -0
  219. package/{types → script}/namespaces/schema.d.ts +1 -0
  220. package/script/namespaces/schema.d.ts.map +1 -0
  221. package/{types → script}/namespaces/sioc.d.ts +1 -0
  222. package/script/namespaces/sioc.d.ts.map +1 -0
  223. package/{types → script}/namespaces/skos.d.ts +1 -0
  224. package/script/namespaces/skos.d.ts.map +1 -0
  225. package/{types → script}/namespaces/xsd.d.ts +1 -0
  226. package/script/namespaces/xsd.d.ts.map +1 -0
  227. package/script/namespaces.d.ts +31 -0
  228. package/script/namespaces.d.ts.map +1 -0
  229. package/script/rdf.d.ts +15 -0
  230. package/script/rdf.d.ts.map +1 -0
  231. package/script/scripts/context_to_schema.d.ts +12 -0
  232. package/script/scripts/context_to_schema.d.ts.map +1 -0
  233. package/script/scripts/context_to_schema.js +155 -0
  234. package/script/scripts/schema_to_script.d.ts +19 -0
  235. package/script/scripts/schema_to_script.d.ts.map +1 -0
  236. package/script/scripts/schema_to_script.js +225 -0
  237. package/script/scripts/shex_to_schema.d.ts +6 -0
  238. package/script/scripts/shex_to_schema.d.ts.map +1 -0
  239. package/script/scripts/shex_to_schema.js +241 -0
  240. package/script/scripts/shexj_types.d.ts +537 -0
  241. package/script/scripts/shexj_types.d.ts.map +1 -0
  242. package/script/scripts/shexj_types.js +3 -0
  243. package/script/sparql.d.ts +15 -0
  244. package/script/sparql.d.ts.map +1 -0
  245. package/types/library/lens/mod.d.ts +0 -1
  246. package/types/namespaces/foaf.d.ts +0 -10
@@ -0,0 +1,431 @@
1
+ import type { IRI, RDF } from "../rdf.js";
2
+ import { type Options } from "../options.js";
3
+ import { type Identity, type Schema, type SchemaInterface, type SchemaSearchInterface, type SchemaUpdateInterface } from "../schema/mod.js";
4
+ import type { Entity, Unite } from "./types.js";
5
+ /**
6
+ * Creates an instance of Lens that lets you query and update RDF data
7
+ * via data schema using TypeScript native data types.
8
+ *
9
+ * In order to create a Lens instance, you need to provide a data schema
10
+ * that describes the data model which serves to translate data between
11
+ * Linked Data and TypeScript native types (see {@link Schema} for details).
12
+ *
13
+ * You can also pass a set of options for LDkit and a query engine that
14
+ * specify the data source, preferred language, etc. (see {@link Options} for details).
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * import { createLens, type Options } from "ldkit";
19
+ * import { dbo, rdfs, xsd } from "ldkit/namespaces";
20
+ *
21
+ * // Create options for query engine
22
+ * const options: Options = {
23
+ * sources: ["https://dbpedia.org/sparql"], // SPARQL endpoint
24
+ * language: "en", // Preferred language
25
+ * };
26
+ *
27
+ * // Create a schema
28
+ * const PersonSchema = {
29
+ * "@type": dbo.Person,
30
+ * name: rdfs.label,
31
+ * abstract: dbo.abstract,
32
+ * birthDate: {
33
+ * "@id": dbo.birthDate,
34
+ * "@type": xsd.date,
35
+ * },
36
+ * } as const;
37
+ *
38
+ * // Create a resource using the data schema and options above
39
+ * const Persons = createLens(PersonSchema, options);
40
+ *
41
+ * // List some persons
42
+ * const persons = await Persons.find({ take: 10 });
43
+ * for (const person of persons) {
44
+ * console.log(person.name); // string
45
+ * console.log(person.birthDate); // Date
46
+ * }
47
+ *
48
+ * // Get a particular person identified by IRI
49
+ * const ada = await Persons.findByIri("http://dbpedia.org/resource/Ada_Lovelace");
50
+ * console.log(ada?.name); // string "Ada Lovelace"
51
+ * console.log(ada?.birthDate); // Date object of 1815-12-10
52
+ * ```
53
+ *
54
+ * @param schema data schema which extends {@link Schema}
55
+ * @param options optional {@link Options} - contains LDkit and query engine configuration
56
+ * @returns Lens instance that provides interface to Linked Data based on the schema
57
+ */
58
+ export declare function createLens<T extends Schema>(schema: T, options?: Options): Lens<T>;
59
+ /**
60
+ * Lens provides an interface to Linked Data based on the data schema.
61
+ *
62
+ * For the best developer experience, use the {@link createLens} function to create the instance.
63
+ */
64
+ export declare class Lens<T extends Schema> {
65
+ private readonly schema;
66
+ private readonly options;
67
+ private readonly engine;
68
+ private readonly queryBuilder;
69
+ constructor(schema: T, options?: Options);
70
+ private decode;
71
+ private log;
72
+ /**
73
+ * Returns the total number of entities corresponding to the data schema.
74
+ * Optionally, you can specify search criteria and a maximum number of results to count.
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * import { createLens } from "ldkit";
79
+ * import { schema } from "ldkit/namespaces";
80
+ *
81
+ * // Create a schema
82
+ * const PersonSchema = {
83
+ * "@type": schema.Person,
84
+ * name: schema.name,
85
+ * } as const;
86
+ *
87
+ * // Create a resource using the data schema above
88
+ * const Persons = createLens(PersonSchema);
89
+ *
90
+ * // Count all persons
91
+ * const count = await Persons.count(); // number
92
+ *
93
+ * // Count all persons with name that starts with "Ada"
94
+ * const adaCount = await Persons.count({
95
+ * where: {
96
+ * name: { $strStarts: "Ada" },
97
+ * },
98
+ * });
99
+ *
100
+ * // Count all persons, but limit the result to 100
101
+ * const limitedCount = await Persons.count({ max: 100 });
102
+ * ```
103
+ *
104
+ * @param options Search criteria and maximum number of results to count
105
+ * @returns total number of entities corresponding to the data schema
106
+ */
107
+ count(options?: {
108
+ where?: SchemaSearchInterface<T>;
109
+ max?: number;
110
+ }): Promise<number>;
111
+ /**
112
+ * Find entities with a custom SPARQL query.
113
+ *
114
+ * The query must be a CONSTRUCT query, and the root nodes must be of type `ldkit:Resource`.
115
+ * So that the decoder can decode the results, the query must also return all properties
116
+ * according to the data schema.
117
+ *
118
+ * @example
119
+ * ```typescript
120
+ * import { createLens } from "ldkit";
121
+ * import { ldkit, schema } from "ldkit/namespaces";
122
+ * import { CONSTRUCT } from "ldkit/sparql";
123
+ *
124
+ * // Create a schema
125
+ * const PersonSchema = {
126
+ * "@type": schema.Person,
127
+ * name: schema.name,
128
+ * } as const;
129
+ *
130
+ * // Create a resource using the data schema above
131
+ * const Persons = createLens(PersonSchema);
132
+ *
133
+ * // Query to find all persons named "Doe"
134
+ * const query = CONSTRUCT`?s a <${ldkit.Resource}>; <${schema.name}> ?name`
135
+ * .WHERE`?s <${schema.name}> ?name; <${schema.familyName}> "Doe"`.build();
136
+ *
137
+ * // Find all persons that match the custom query
138
+ * const doePersons = await Persons.query(query);
139
+ * ```
140
+ *
141
+ * @param sparqlConstructQuery CONSTRUCT SPARQL query
142
+ * @returns Found entities
143
+ */
144
+ query(sparqlConstructQuery: string): Promise<Unite<SchemaInterface<T>>[]>;
145
+ /**
146
+ * Find entities that match the given search criteria.
147
+ *
148
+ * The search criteria is a JSON object that may contain properties from the data schema.
149
+ * In addition you can specify how many results to return and how many to skip
150
+ * for pagination purposes.
151
+ *
152
+ * @example
153
+ * ```typescript
154
+ * import { createLens } from "ldkit";
155
+ * import { schema } from "ldkit/namespaces";
156
+ *
157
+ * // Create a schema
158
+ * const PersonSchema = {
159
+ * "@type": schema.Person,
160
+ * name: schema.name,
161
+ * } as const;
162
+ *
163
+ * // Create a resource using the data schema above
164
+ * const Persons = createLens(PersonSchema);
165
+ *
166
+ * // Find 100 persons with name that starts with "Ada"
167
+ * const persons = await Persons.find({
168
+ * where: {
169
+ * name: { $strStarts: "Ada" },
170
+ * },
171
+ * take: 100,
172
+ * });
173
+ * ```
174
+ *
175
+ * @param options Search criteria and pagination options
176
+ * @returns entities that match the given search criteria
177
+ */
178
+ find(options?: {
179
+ where?: SchemaSearchInterface<T> | string | RDF.Quad[];
180
+ take?: number;
181
+ skip?: number;
182
+ }): Promise<Unite<SchemaInterface<T>>[]>;
183
+ /**
184
+ * Find one entity that matches the given search criteria.
185
+ *
186
+ * The search criteria is a JSON object that may contain properties from the data schema.
187
+ *
188
+ * @example
189
+ * ```typescript
190
+ * import { createLens } from "ldkit";
191
+ * import { schema } from "ldkit/namespaces";
192
+ *
193
+ * // Create a schema
194
+ * const PersonSchema = {
195
+ * "@type": schema.Person,
196
+ * name: schema.name,
197
+ * } as const;
198
+ *
199
+ * // Create a resource using the data schema above
200
+ * const Persons = createLens(PersonSchema);
201
+ *
202
+ * // Find one person with name that starts with "Ada"
203
+ * const person = await Persons.findOne({
204
+ * name: { $strStarts: "Ada" },
205
+ * });
206
+ * ```
207
+ *
208
+ * @param options Search criteria and pagination options
209
+ * @returns entities that match the given search criteria
210
+ */
211
+ findOne(where?: SchemaSearchInterface<T>): Promise<Unite<SchemaInterface<T>> | null>;
212
+ /**
213
+ * Find a single entity that matches the given IRI.
214
+ *
215
+ * @example
216
+ * ```typescript
217
+ * import { createLens } from "ldkit";
218
+ * import { schema } from "ldkit/namespaces";
219
+ *
220
+ * // Create a schema
221
+ * const PersonSchema = {
222
+ * "@type": schema.Person,
223
+ * name: schema.name,
224
+ * } as const;
225
+ *
226
+ * // Create a resource using the data schema above
227
+ * const Persons = createLens(PersonSchema);
228
+ *
229
+ * // Get a particular person identified by IRI
230
+ * const ada = await Persons.findByIri("http://dbpedia.org/resource/Ada_Lovelace");
231
+ * console.log(ada?.name); // string "Ada Lovelace"
232
+ * ```
233
+ *
234
+ * @param iri IRI of the entity to find
235
+ * @returns Entity if found, null otherwise
236
+ */
237
+ findByIri(iri: IRI): Promise<Unite<SchemaInterface<T>> | null>;
238
+ /**
239
+ * Find entities that match the given IRIs.
240
+ *
241
+ * @example
242
+ * ```typescript
243
+ * import { createLens } from "ldkit";
244
+ * import { schema } from "ldkit/namespaces";
245
+ *
246
+ * // Create a schema
247
+ * const PersonSchema = {
248
+ * "@type": schema.Person,
249
+ * name: schema.name,
250
+ * } as const;
251
+ *
252
+ * // Create a resource using the data schema above
253
+ * const Persons = createLens(PersonSchema);
254
+ *
255
+ * // Get specific persons identified by IRIs
256
+ * const matches = await Persons.findByIris([
257
+ * "http://dbpedia.org/resource/Ada_Lovelace",
258
+ * "http://dbpedia.org/resource/Alan_Turing"
259
+ * ]);
260
+ * console.log(matches[0].name); // string "Ada Lovelace"
261
+ * console.log(matches[1].name); // string "Alan Turing"
262
+ * ```
263
+ *
264
+ * @param iris IRIs of the entities to find
265
+ * @returns Array of found entities, empty array if there are no matches
266
+ */
267
+ findByIris(iris: IRI[]): Promise<Unite<SchemaInterface<T>>[]>;
268
+ private updateQuery;
269
+ /**
270
+ * Inserts one or more entities to the data store.
271
+ *
272
+ * @example
273
+ * ```typescript
274
+ * import { createLens } from "ldkit";
275
+ * import { schema } from "ldkit/namespaces";
276
+ *
277
+ * // Create a schema
278
+ * const PersonSchema = {
279
+ * "@type": schema.Person,
280
+ * name: schema.name,
281
+ * } as const;
282
+ *
283
+ * // Create a resource using the data schema above
284
+ * const Persons = createLens(PersonSchema);
285
+ *
286
+ * // Insert a new person
287
+ * await Persons.insert({
288
+ * $id: "http://example.org/Alan_Turing",
289
+ * name: "Alan Turing",
290
+ * });
291
+ * ```
292
+ *
293
+ * @param entities Entities to insert
294
+ * @returns Nothing
295
+ */
296
+ insert(...entities: Entity<SchemaInterface<T>>[]): Promise<void>;
297
+ /**
298
+ * Inserts raw RDF quads to the data store.
299
+ *
300
+ * This method is useful when you need to insert data that is not covered by the data schema.
301
+ *
302
+ * @example
303
+ * ```typescript
304
+ * import { createLens } from "ldkit";
305
+ * import { schema } from "ldkit/namespaces";
306
+ * import { DataFactory } from "ldkit/rdf";
307
+ *
308
+ * // Create a schema
309
+ * const PersonSchema = {
310
+ * "@type": schema.Person,
311
+ * name: schema.name,
312
+ * } as const;
313
+ *
314
+ * // Create a resource using the data schema above
315
+ * const Persons = createLens(PersonSchema);
316
+ *
317
+ * // Create a custom quad to insert
318
+ * const df = new DataFactory();
319
+ * const quad = df.quad(
320
+ * df.namedNode("http://example.org/Alan_Turing"),
321
+ * df.namedNode("http://schema.org/name"),
322
+ * df.literal("Alan Turing"),
323
+ * );
324
+ *
325
+ * // Insert the quad
326
+ * await Persons.insertData(quad);
327
+ * ```
328
+ *
329
+ * @param quads Quads to insert to the data store
330
+ * @returns Nothing
331
+ */
332
+ insertData(...quads: RDF.Quad[]): Promise<void>;
333
+ /**
334
+ * Updates one or more entities in the data store.
335
+ *
336
+ * @example
337
+ * ```typescript
338
+ * import { createLens } from "ldkit";
339
+ * import { schema } from "ldkit/namespaces";
340
+ *
341
+ * // Create a schema
342
+ * const PersonSchema = {
343
+ * "@type": schema.Person,
344
+ * name: schema.name,
345
+ * } as const;
346
+ *
347
+ * // Create a resource using the data schema above
348
+ * const Persons = createLens(PersonSchema);
349
+ *
350
+ * // Update Alan Turing's name
351
+ * await Persons.update({
352
+ * $id: "http://example.org/Alan_Turing",
353
+ * name: "Not Alan Turing",
354
+ * });
355
+ * ```
356
+ *
357
+ * @param entities Partial entities to update
358
+ * @returns Nothing
359
+ */
360
+ update(...entities: SchemaUpdateInterface<T>[]): Promise<void>;
361
+ /**
362
+ * Deletes one or more entities from the data store.
363
+ *
364
+ * This method accepts IRIs of the entities to delete and attemps
365
+ * to delete all triples from the database that corresponds to
366
+ * the data schema. Other triples that are not covered by the data
367
+ * schema will not be deleted.
368
+ *
369
+ * If you need to have more control of what triples to delete,
370
+ * use {@link deleteData} instead.
371
+ *
372
+ * @example
373
+ * ```typescript
374
+ * import { createLens } from "ldkit";
375
+ * import { schema } from "ldkit/namespaces";
376
+ *
377
+ * // Create a schema
378
+ * const PersonSchema = {
379
+ * "@type": schema.Person,
380
+ * name: schema.name,
381
+ * } as const;
382
+ *
383
+ * // Create a resource using the data schema above
384
+ * const Persons = createLens(PersonSchema);
385
+ *
386
+ * // Delete a person
387
+ * await Persons.delete("http://example.org/Alan_Turing");
388
+ * ```
389
+ *
390
+ * @param identities Identities or IRIs of the entities to delete
391
+ * @returns Nothing
392
+ */
393
+ delete(...identities: Identity[] | IRI[]): Promise<void>;
394
+ /**
395
+ * Deletes raw RDF quads from the data store.
396
+ *
397
+ * This method is useful when you need to delete data that is not covered by the data schema.
398
+ *
399
+ * @example
400
+ * ```typescript
401
+ * import { createLens } from "ldkit";
402
+ * import { schema } from "ldkit/namespaces";
403
+ * import { DataFactory } from "ldkit/rdf";
404
+ *
405
+ * // Create a schema
406
+ * const PersonSchema = {
407
+ * "@type": schema.Person,
408
+ * name: schema.name,
409
+ * } as const;
410
+ *
411
+ * // Create a resource using the data schema and context above
412
+ * const Persons = createLens(PersonSchema);
413
+ *
414
+ * // Create a custom quad to insert
415
+ * const df = new DataFactory();
416
+ * const quad = df.quad(
417
+ * df.namedNode("http://example.org/Alan_Turing"),
418
+ * df.namedNode("http://schema.org/name"),
419
+ * df.literal("Alan Turing"),
420
+ * );
421
+ *
422
+ * // Delete the quad
423
+ * await Persons.deleteData(quad);
424
+ * ```
425
+ *
426
+ * @param quads Quads to delete from the data store
427
+ * @returns Nothing
428
+ */
429
+ deleteData(...quads: RDF.Quad[]): Promise<void>;
430
+ }
431
+ //# sourceMappingURL=lens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lens.d.ts","sourceRoot":"","sources":["../../../src/library/lens/lens.ts"],"names":[],"mappings":"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"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Lens = exports.createLens = void 0;
3
+ exports.Lens = void 0;
4
+ exports.createLens = createLens;
4
5
  const options_js_1 = require("../options.js");
5
6
  const mod_js_1 = require("../schema/mod.js");
6
7
  const decoder_js_1 = require("../decoder.js");
@@ -62,7 +63,6 @@ const query_engine_proxy_js_1 = require("../engine/query_engine_proxy.js");
62
63
  function createLens(schema, options) {
63
64
  return new Lens(schema, options);
64
65
  }
65
- exports.createLens = createLens;
66
66
  /**
67
67
  * Lens provides an interface to Linked Data based on the data schema.
68
68
  *
@@ -108,6 +108,7 @@ class Lens {
108
108
  }
109
109
  /**
110
110
  * Returns the total number of entities corresponding to the data schema.
111
+ * Optionally, you can specify search criteria and a maximum number of results to count.
111
112
  *
112
113
  * @example
113
114
  * ```typescript
@@ -125,12 +126,27 @@ class Lens {
125
126
  *
126
127
  * // Count all persons
127
128
  * const count = await Persons.count(); // number
129
+ *
130
+ * // Count all persons with name that starts with "Ada"
131
+ * const adaCount = await Persons.count({
132
+ * where: {
133
+ * name: { $strStarts: "Ada" },
134
+ * },
135
+ * });
136
+ *
137
+ * // Count all persons, but limit the result to 100
138
+ * const limitedCount = await Persons.count({ max: 100 });
128
139
  * ```
129
140
  *
141
+ * @param options Search criteria and maximum number of results to count
130
142
  * @returns total number of entities corresponding to the data schema
131
143
  */
132
- async count(max) {
133
- const q = this.queryBuilder.countQuery(max);
144
+ async count(options = {}) {
145
+ const { where, max } = {
146
+ where: {},
147
+ ...options,
148
+ };
149
+ const q = this.queryBuilder.countQuery(where, max);
134
150
  this.log(q);
135
151
  const bindings = await this.engine.queryBindings(q);
136
152
  return parseInt(bindings[0].get("count").value);
@@ -0,0 +1,2 @@
1
+ export * from "./lens.js";
2
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/library/lens/mod.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { type Options } from "../options.js";
2
+ import { type ExpandedSchema, type SearchSchema } from "../schema/mod.js";
3
+ import { type IRI, type RDF } from "../rdf.js";
4
+ import { type Entity } from "./types.js";
5
+ export declare class QueryBuilder {
6
+ private readonly schema;
7
+ private readonly options;
8
+ private readonly df;
9
+ constructor(schema: ExpandedSchema, options: Options);
10
+ private getResourceSignature;
11
+ private entitiesToQuads;
12
+ private getShape;
13
+ countQuery(where: SearchSchema, max?: number): string;
14
+ getQuery(where: string | RDF.Quad[] | undefined, limit: number, offset: number): string;
15
+ getSearchQuery(where: SearchSchema, limit: number, offset: number): string;
16
+ getByIrisQuery(iris: IRI[], where?: SearchSchema): string;
17
+ insertQuery(entities: Entity[]): string;
18
+ insertDataQuery(quads: RDF.Quad[]): string;
19
+ deleteQuery: (iris: IRI[]) => string;
20
+ deleteDataQuery(quads: RDF.Quad[]): string;
21
+ updateQuery(entities: Entity[]): string;
22
+ }
23
+ //# sourceMappingURL=query_builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query_builder.d.ts","sourceRoot":"","sources":["../../../src/library/lens/query_builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAEL,KAAK,cAAc,EAEnB,KAAK,YAAY,EAClB,MAAM,kBAAkB,CAAC;AAS1B,OAAO,EAAe,KAAK,GAAG,EAAE,KAAK,GAAG,EAAE,MAAM,WAAW,CAAC;AAM5D,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,YAAY,CAAC;AAYzC,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IACxC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAClC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAkB;gBAEzB,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO;IAMpD,OAAO,CAAC,oBAAoB;IAQ5B,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,QAAQ;IA4FhB,UAAU,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,CAAC,EAAE,MAAM;IAW5C,QAAQ,CACN,KAAK,EAAE,MAAM,GAAG,GAAG,CAAC,IAAI,EAAE,GAAG,SAAS,EACtC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM;IAsBhB,cAAc,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAyBjE,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,KAAK,CAAC,EAAE,YAAY;IAchD,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE;IAK9B,eAAe,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,EAAE;IAIjC,WAAW,SAAU,GAAG,EAAE,YAOxB;IAEF,eAAe,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,EAAE;IAIjC,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE;CAU/B"}
@@ -113,8 +113,8 @@ class QueryBuilder {
113
113
  populateConditionsRecursive(this.schema, mainVar, searchSchema);
114
114
  return conditions;
115
115
  }
116
- countQuery(max) {
117
- const quads = this.getShape(Flags.ExcludeOptional | Flags.IncludeTypes);
116
+ countQuery(where, max) {
117
+ const quads = this.getShape(Flags.ExcludeOptional | Flags.IncludeTypes, where);
118
118
  const innerQuery = max === undefined
119
119
  ? quads
120
120
  : (0, mod_js_2.SELECT) `?iri`.WHERE `${quads}`.LIMIT(max);
@@ -0,0 +1,22 @@
1
+ import { type SparqlValue } from "../sparql/mod.js";
2
+ import { type ExpandedProperty, type SearchSchema } from "../schema/mod.js";
3
+ export declare class SearchHelper {
4
+ private readonly property;
5
+ private readonly propertyType;
6
+ private readonly varName;
7
+ private readonly searchSchema;
8
+ private df;
9
+ readonly sparqlValues: SparqlValue[];
10
+ constructor(property: ExpandedProperty, varName: string, searchSchema: SearchSchema);
11
+ process(): void;
12
+ private processOperators;
13
+ private processStringFunctions;
14
+ private processRegex;
15
+ private processLangMatches;
16
+ private processArrayFunctions;
17
+ private processFilter;
18
+ private addFilter;
19
+ private encode;
20
+ private isPlainObject;
21
+ }
22
+ //# sourceMappingURL=search_helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search_helper.d.ts","sourceRoot":"","sources":["../../../src/library/lens/search_helper.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAI5E,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAmB;IAC5C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;IAE5C,OAAO,CAAC,EAAE,CAEP;IAEH,SAAgB,YAAY,EAAE,WAAW,EAAE,CAAM;gBAG/C,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,YAAY;IAUrB,OAAO;IASd,OAAO,CAAC,gBAAgB;IAsBxB,OAAO,CAAC,sBAAsB;IAmB9B,OAAO,CAAC,YAAY;IAWpB,OAAO,CAAC,kBAAkB;IAa1B,OAAO,CAAC,qBAAqB;IAmB7B,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,MAAM;IAId,OAAO,CAAC,aAAa;CAUtB"}
@@ -0,0 +1,9 @@
1
+ import type { Identity } from "../schema/mod.js";
2
+ export type Entity<T extends unknown = Record<string, unknown>> = DeepPartial<T> & Identity;
3
+ export type DeepPartial<T> = T extends Record<string, unknown> ? {
4
+ [P in keyof T]?: DeepPartial<T[P]>;
5
+ } : T;
6
+ export type Unite<T> = T extends Record<string, unknown> ? {
7
+ [Key in keyof T]: T[Key];
8
+ } : T;
9
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/library/lens/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEjD,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAC1D,WAAW,CAAC,CAAC,CAAC,GACd,QAAQ,CAAC;AAEb,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC1D;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GACtC,CAAC,CAAC;AAEN,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACpD;KAAG,GAAG,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC;CAAE,GAC5B,CAAC,CAAC"}
@@ -0,0 +1,24 @@
1
+ import type { Options } from "../options.js";
2
+ import type { RDF } from "../rdf.js";
3
+ import { type SparqlValue } from "../sparql/mod.js";
4
+ import { type ExpandedSchema } from "../schema/mod.js";
5
+ import type { Entity } from "./types.js";
6
+ export declare class UpdateHelper {
7
+ private readonly schema;
8
+ private readonly properties;
9
+ private readonly options;
10
+ private variableCounter;
11
+ readonly deleteQuads: RDF.Quad[];
12
+ readonly insertQuads: RDF.Quad[];
13
+ readonly whereQuads: SparqlValue[];
14
+ constructor(schema: ExpandedSchema, options: Options, variableInitCounter?: number);
15
+ process(entity: Entity): void;
16
+ private processProperty;
17
+ private processSingleProperty;
18
+ private processArrayProperty;
19
+ private processArraySet;
20
+ private processArrayAddRemove;
21
+ private parseArrayUpdateConfig;
22
+ private encode;
23
+ }
24
+ //# sourceMappingURL=update_helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update_helper.d.ts","sourceRoot":"","sources":["../../../src/library/lens/update_helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAY,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAEL,KAAK,cAAc,EAEpB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IACxC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAmC;IAC9D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAElC,OAAO,CAAC,eAAe,CAAK;IAE5B,SAAgB,WAAW,EAAE,GAAG,CAAC,IAAI,EAAE,CAAM;IAC7C,SAAgB,WAAW,EAAE,GAAG,CAAC,IAAI,EAAE,CAAM;IAC7C,SAAgB,UAAU,EAAE,WAAW,EAAE,CAAM;gBAG7C,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,OAAO,EAChB,mBAAmB,SAAI;IAQlB,OAAO,CAAC,MAAM,EAAE,MAAM;IAM7B,OAAO,CAAC,eAAe;IAoBvB,OAAO,CAAC,qBAAqB;IAgC7B,OAAO,CAAC,oBAAoB;IAkB5B,OAAO,CAAC,eAAe;IAqBvB,OAAO,CAAC,qBAAqB;IAyB7B,OAAO,CAAC,sBAAsB;IA8B9B,OAAO,CAAC,MAAM;CASf"}
@@ -0,0 +1,42 @@
1
+ /** Original type of namespace specification */
2
+ export type Namespace = {
3
+ iri: string;
4
+ prefix: string;
5
+ terms: readonly string[];
6
+ };
7
+ /** Resulting type of namespace providing access to all terms, prefix and IRI */
8
+ export type NamespaceInterface<NamespaceSpec extends Namespace> = {
9
+ [Term in NamespaceSpec["terms"][number]]: `${NamespaceSpec["prefix"]}${Term}`;
10
+ } & {
11
+ $prefix: NamespaceSpec["prefix"];
12
+ $iri: NamespaceSpec["iri"];
13
+ };
14
+ /**
15
+ * Creates a strongly typed container for Linked Data vocabulary to provide
16
+ * type safe access to all vocabulary terms as well as IDE autocompletion.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * import { createNamespace } from "ldkit";
21
+ *
22
+ * const onto = createNamespace(
23
+ * {
24
+ * iri: "http://www.example.com/ontology#",
25
+ * prefix: "onto:",
26
+ * terms: [
27
+ * "object",
28
+ * "predicate",
29
+ * "subject",
30
+ * ],
31
+ * } as const,
32
+ * );
33
+ *
34
+ * console.log(onto.subject); // prints http://www.example.com/ontology#subject
35
+ * console.log(onto.unknown); // TypeScript error! This term does not exist
36
+ * ```
37
+ *
38
+ * @param namespaceSpec Specification of the namespace
39
+ * @returns
40
+ */
41
+ export declare function createNamespace<N extends Namespace>(namespaceSpec: N): NamespaceInterface<N>;
42
+ //# sourceMappingURL=namespace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"namespace.d.ts","sourceRoot":"","sources":["../../src/library/namespace.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,MAAM,MAAM,SAAS,GAAG;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1B,CAAC;AAEF,gFAAgF;AAChF,MAAM,MAAM,kBAAkB,CAAC,aAAa,SAAS,SAAS,IAC1D;KACC,IAAI,IAAI,aAAa,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,GACrC,GAAG,aAAa,CAAC,QAAQ,CAAC,GAAG,IAAI,EAAE;CACtC,GACC;IACA,OAAO,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IACjC,IAAI,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;CAC5B,CAAC;AAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,SAAS,EACjD,aAAa,EAAE,CAAC,GACf,kBAAkB,CAAC,CAAC,CAAC,CAWvB"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createNamespace = void 0;
3
+ exports.createNamespace = createNamespace;
4
4
  /**
5
5
  * Creates a strongly typed container for Linked Data vocabulary to provide
6
6
  * type safe access to all vocabulary terms as well as IDE autocompletion.
@@ -37,4 +37,3 @@ function createNamespace(namespaceSpec) {
37
37
  $iri: namespaceSpec["iri"],
38
38
  });
39
39
  }
40
- exports.createNamespace = createNamespace;