ldkit 2.2.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/cli.d.ts +3 -0
- package/esm/cli.d.ts.map +1 -0
- package/esm/cli.js +117 -0
- package/{types → esm}/library/asynciterator.d.ts +1 -0
- package/esm/library/asynciterator.d.ts.map +1 -0
- package/{types → esm}/library/decoder.d.ts +1 -0
- package/esm/library/decoder.d.ts.map +1 -0
- package/esm/library/decoder.js +2 -2
- package/{types → esm}/library/encoder.d.ts +2 -1
- package/esm/library/encoder.d.ts.map +1 -0
- package/esm/library/encoder.js +3 -4
- package/{types → esm}/library/engine/mod.d.ts +1 -0
- package/esm/library/engine/mod.d.ts.map +1 -0
- package/{types → esm}/library/engine/query_engine.d.ts +1 -0
- package/esm/library/engine/query_engine.d.ts.map +1 -0
- package/{types → esm}/library/engine/query_engine_proxy.d.ts +1 -0
- package/esm/library/engine/query_engine_proxy.d.ts.map +1 -0
- package/{types → esm}/library/engine/query_resolvers.d.ts +2 -1
- package/esm/library/engine/query_resolvers.d.ts.map +1 -0
- package/{types → esm}/library/engine/types.d.ts +1 -0
- package/esm/library/engine/types.d.ts.map +1 -0
- package/{types → esm}/library/lens/lens.d.ts +1 -0
- package/esm/library/lens/lens.d.ts.map +1 -0
- package/esm/library/lens/mod.d.ts +2 -0
- package/esm/library/lens/mod.d.ts.map +1 -0
- package/{types → esm}/library/lens/query_builder.d.ts +1 -0
- package/esm/library/lens/query_builder.d.ts.map +1 -0
- package/{types → esm}/library/lens/search_helper.d.ts +1 -0
- package/esm/library/lens/search_helper.d.ts.map +1 -0
- package/{types → esm}/library/lens/types.d.ts +1 -0
- package/esm/library/lens/types.d.ts.map +1 -0
- package/{types → esm}/library/lens/update_helper.d.ts +1 -0
- package/esm/library/lens/update_helper.d.ts.map +1 -0
- package/{types → esm}/library/namespace.d.ts +1 -0
- package/esm/library/namespace.d.ts.map +1 -0
- package/{types → esm}/library/options.d.ts +26 -25
- package/esm/library/options.d.ts.map +1 -0
- package/{types → esm}/library/rdf.d.ts +4 -3
- package/esm/library/rdf.d.ts.map +1 -0
- package/{types → esm}/library/schema/data_types.d.ts +13 -2
- package/esm/library/schema/data_types.d.ts.map +1 -0
- package/{types → esm}/library/schema/interface.d.ts +1 -0
- package/esm/library/schema/interface.d.ts.map +1 -0
- package/{types → esm}/library/schema/mod.d.ts +2 -1
- package/esm/library/schema/mod.d.ts.map +1 -0
- package/{types → esm}/library/schema/schema.d.ts +1 -0
- package/esm/library/schema/schema.d.ts.map +1 -0
- package/{types → esm}/library/schema/search.d.ts +1 -0
- package/esm/library/schema/search.d.ts.map +1 -0
- package/{types → esm}/library/schema/utils.d.ts +1 -0
- package/esm/library/schema/utils.d.ts.map +1 -0
- package/{types → esm}/library/sparql/escape.d.ts +1 -0
- package/esm/library/sparql/escape.d.ts.map +1 -0
- package/{types → esm}/library/sparql/mod.d.ts +1 -0
- package/esm/library/sparql/mod.d.ts.map +1 -0
- package/{types → esm}/library/sparql/sparql_expression_builders.d.ts +1 -0
- package/esm/library/sparql/sparql_expression_builders.d.ts.map +1 -0
- package/{types → esm}/library/sparql/sparql_query_builders.d.ts +1 -0
- package/esm/library/sparql/sparql_query_builders.d.ts.map +1 -0
- package/{types → esm}/library/sparql/sparql_shared_builders.d.ts +1 -0
- package/esm/library/sparql/sparql_shared_builders.d.ts.map +1 -0
- package/{types → esm}/library/sparql/sparql_tag.d.ts +1 -0
- package/esm/library/sparql/sparql_tag.d.ts.map +1 -0
- package/{types → esm}/library/sparql/sparql_update_builders.d.ts +1 -0
- package/esm/library/sparql/sparql_update_builders.d.ts.map +1 -0
- package/{types → esm}/library/sparql/stringify.d.ts +1 -0
- package/esm/library/sparql/stringify.d.ts.map +1 -0
- package/esm/library/translator.d.ts +39 -0
- package/esm/library/translator.d.ts.map +1 -0
- package/esm/library/translator.js +62 -0
- package/{types → esm}/library/utils.d.ts +1 -0
- package/esm/library/utils.d.ts.map +1 -0
- package/esm/mod.d.ts +7 -0
- package/esm/mod.d.ts.map +1 -0
- package/esm/mod.js +1 -0
- package/esm/namespaces/dbo.d.ts +11 -0
- package/esm/namespaces/dbo.d.ts.map +1 -0
- package/esm/namespaces/dc.d.ts +11 -0
- package/esm/namespaces/dc.d.ts.map +1 -0
- package/esm/namespaces/dcterms.d.ts +11 -0
- package/esm/namespaces/dcterms.d.ts.map +1 -0
- package/esm/namespaces/foaf.d.ts +11 -0
- package/esm/namespaces/foaf.d.ts.map +1 -0
- package/esm/namespaces/foaf.js +12 -0
- package/esm/namespaces/gr.d.ts +11 -0
- package/esm/namespaces/gr.d.ts.map +1 -0
- package/esm/namespaces/ldkit.d.ts +11 -0
- package/esm/namespaces/ldkit.d.ts.map +1 -0
- package/esm/namespaces/owl.d.ts +11 -0
- package/esm/namespaces/owl.d.ts.map +1 -0
- package/esm/namespaces/rdf.d.ts +11 -0
- package/esm/namespaces/rdf.d.ts.map +1 -0
- package/esm/namespaces/rdfs.d.ts +11 -0
- package/esm/namespaces/rdfs.d.ts.map +1 -0
- package/esm/namespaces/schema.d.ts +11 -0
- package/esm/namespaces/schema.d.ts.map +1 -0
- package/esm/namespaces/sioc.d.ts +11 -0
- package/esm/namespaces/sioc.d.ts.map +1 -0
- package/esm/namespaces/skos.d.ts +11 -0
- package/esm/namespaces/skos.d.ts.map +1 -0
- package/esm/namespaces/xsd.d.ts +11 -0
- package/esm/namespaces/xsd.d.ts.map +1 -0
- package/{types → esm}/namespaces.d.ts +1 -0
- package/esm/namespaces.d.ts.map +1 -0
- package/{types → esm}/rdf.d.ts +1 -0
- package/esm/rdf.d.ts.map +1 -0
- package/esm/scripts/context_to_schema.d.ts +12 -0
- package/esm/scripts/context_to_schema.d.ts.map +1 -0
- package/esm/scripts/context_to_schema.js +152 -0
- package/esm/scripts/schema_to_script.d.ts +19 -0
- package/esm/scripts/schema_to_script.d.ts.map +1 -0
- package/esm/scripts/schema_to_script.js +222 -0
- package/esm/scripts/shex_to_schema.d.ts +6 -0
- package/esm/scripts/shex_to_schema.d.ts.map +1 -0
- package/esm/scripts/shex_to_schema.js +233 -0
- package/esm/scripts/shexj_types.d.ts +537 -0
- package/esm/scripts/shexj_types.d.ts.map +1 -0
- package/esm/scripts/shexj_types.js +2 -0
- package/{types → esm}/sparql.d.ts +1 -0
- package/esm/sparql.d.ts.map +1 -0
- package/package.json +23 -40
- package/script/cli.d.ts +3 -0
- package/script/cli.d.ts.map +1 -0
- package/script/cli.js +119 -0
- package/script/library/asynciterator.d.ts +30 -0
- package/script/library/asynciterator.d.ts.map +1 -0
- package/script/library/decoder.d.ts +7 -0
- package/script/library/decoder.d.ts.map +1 -0
- package/script/library/decoder.js +6 -6
- package/script/library/encoder.d.ts +8 -0
- package/script/library/encoder.d.ts.map +1 -0
- package/script/library/encoder.js +2 -3
- package/script/library/engine/mod.d.ts +3 -0
- package/script/library/engine/mod.d.ts.map +1 -0
- package/script/library/engine/query_engine.d.ts +58 -0
- package/script/library/engine/query_engine.d.ts.map +1 -0
- package/script/library/engine/query_engine_proxy.d.ts +12 -0
- package/script/library/engine/query_engine_proxy.d.ts.map +1 -0
- package/script/library/engine/query_resolvers.d.ts +11 -0
- package/script/library/engine/query_resolvers.d.ts.map +1 -0
- package/script/library/engine/types.d.ts +24 -0
- package/script/library/engine/types.d.ts.map +1 -0
- package/script/library/lens/lens.d.ts +416 -0
- package/script/library/lens/lens.d.ts.map +1 -0
- package/script/library/lens/lens.js +2 -2
- package/script/library/lens/mod.d.ts +2 -0
- package/script/library/lens/mod.d.ts.map +1 -0
- package/script/library/lens/query_builder.d.ts +23 -0
- package/script/library/lens/query_builder.d.ts.map +1 -0
- package/script/library/lens/search_helper.d.ts +22 -0
- package/script/library/lens/search_helper.d.ts.map +1 -0
- package/script/library/lens/types.d.ts +9 -0
- package/script/library/lens/types.d.ts.map +1 -0
- package/script/library/lens/update_helper.d.ts +24 -0
- package/script/library/lens/update_helper.d.ts.map +1 -0
- package/script/library/namespace.d.ts +42 -0
- package/script/library/namespace.d.ts.map +1 -0
- package/script/library/namespace.js +1 -2
- package/script/library/options.d.ts +72 -0
- package/script/library/options.d.ts.map +1 -0
- package/script/library/options.js +3 -4
- package/script/library/rdf.d.ts +78 -0
- package/script/library/rdf.d.ts.map +1 -0
- package/script/library/schema/data_types.d.ts +57 -0
- package/script/library/schema/data_types.d.ts.map +1 -0
- package/script/library/schema/interface.d.ts +88 -0
- package/script/library/schema/interface.d.ts.map +1 -0
- package/script/library/schema/mod.d.ts +6 -0
- package/script/library/schema/mod.d.ts.map +1 -0
- package/script/library/schema/schema.d.ts +38 -0
- package/script/library/schema/schema.d.ts.map +1 -0
- package/script/library/schema/search.d.ts +21 -0
- package/script/library/schema/search.d.ts.map +1 -0
- package/script/library/schema/utils.d.ts +4 -0
- package/script/library/schema/utils.d.ts.map +1 -0
- package/script/library/sparql/escape.d.ts +2 -0
- package/script/library/sparql/escape.d.ts.map +1 -0
- package/script/library/sparql/mod.d.ts +5 -0
- package/script/library/sparql/mod.d.ts.map +1 -0
- package/script/library/sparql/sparql_expression_builders.d.ts +20 -0
- package/script/library/sparql/sparql_expression_builders.d.ts.map +1 -0
- package/script/library/sparql/sparql_query_builders.d.ts +105 -0
- package/script/library/sparql/sparql_query_builders.d.ts.map +1 -0
- package/script/library/sparql/sparql_shared_builders.d.ts +17 -0
- package/script/library/sparql/sparql_shared_builders.d.ts.map +1 -0
- package/script/library/sparql/sparql_tag.d.ts +32 -0
- package/script/library/sparql/sparql_tag.d.ts.map +1 -0
- package/script/library/sparql/sparql_update_builders.d.ts +91 -0
- package/script/library/sparql/sparql_update_builders.d.ts.map +1 -0
- package/script/library/sparql/stringify.d.ts +7 -0
- package/script/library/sparql/stringify.d.ts.map +1 -0
- package/script/library/translator.d.ts +39 -0
- package/script/library/translator.d.ts.map +1 -0
- package/script/library/translator.js +67 -0
- package/script/library/utils.d.ts +2 -0
- package/script/library/utils.d.ts.map +1 -0
- package/script/mod.d.ts +7 -0
- package/script/mod.d.ts.map +1 -0
- package/script/mod.js +3 -1
- package/{types → script}/namespaces/dbo.d.ts +1 -0
- package/script/namespaces/dbo.d.ts.map +1 -0
- package/{types → script}/namespaces/dc.d.ts +1 -0
- package/script/namespaces/dc.d.ts.map +1 -0
- package/{types → script}/namespaces/dcterms.d.ts +1 -0
- package/script/namespaces/dcterms.d.ts.map +1 -0
- package/script/namespaces/foaf.d.ts +11 -0
- package/script/namespaces/foaf.d.ts.map +1 -0
- package/script/namespaces/foaf.js +12 -0
- package/{types → script}/namespaces/gr.d.ts +1 -0
- package/script/namespaces/gr.d.ts.map +1 -0
- package/{types → script}/namespaces/ldkit.d.ts +1 -0
- package/script/namespaces/ldkit.d.ts.map +1 -0
- package/{types → script}/namespaces/owl.d.ts +1 -0
- package/script/namespaces/owl.d.ts.map +1 -0
- package/{types → script}/namespaces/rdf.d.ts +1 -0
- package/script/namespaces/rdf.d.ts.map +1 -0
- package/{types → script}/namespaces/rdfs.d.ts +1 -0
- package/script/namespaces/rdfs.d.ts.map +1 -0
- package/{types → script}/namespaces/schema.d.ts +1 -0
- package/script/namespaces/schema.d.ts.map +1 -0
- package/{types → script}/namespaces/sioc.d.ts +1 -0
- package/script/namespaces/sioc.d.ts.map +1 -0
- package/{types → script}/namespaces/skos.d.ts +1 -0
- package/script/namespaces/skos.d.ts.map +1 -0
- package/{types → script}/namespaces/xsd.d.ts +1 -0
- package/script/namespaces/xsd.d.ts.map +1 -0
- package/script/namespaces.d.ts +31 -0
- package/script/namespaces.d.ts.map +1 -0
- package/script/rdf.d.ts +15 -0
- package/script/rdf.d.ts.map +1 -0
- package/script/scripts/context_to_schema.d.ts +12 -0
- package/script/scripts/context_to_schema.d.ts.map +1 -0
- package/script/scripts/context_to_schema.js +155 -0
- package/script/scripts/schema_to_script.d.ts +19 -0
- package/script/scripts/schema_to_script.d.ts.map +1 -0
- package/script/scripts/schema_to_script.js +225 -0
- package/script/scripts/shex_to_schema.d.ts +6 -0
- package/script/scripts/shex_to_schema.d.ts.map +1 -0
- package/script/scripts/shex_to_schema.js +241 -0
- package/script/scripts/shexj_types.d.ts +537 -0
- package/script/scripts/shexj_types.d.ts.map +1 -0
- package/script/scripts/shexj_types.js +3 -0
- package/script/sparql.d.ts +15 -0
- package/script/sparql.d.ts.map +1 -0
- package/types/library/lens/mod.d.ts +0 -1
- package/types/mod.d.ts +0 -5
- package/types/namespaces/foaf.d.ts +0 -10
|
@@ -0,0 +1,416 @@
|
|
|
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
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* import { createLens } from "ldkit";
|
|
78
|
+
* import { schema } from "ldkit/namespaces";
|
|
79
|
+
*
|
|
80
|
+
* // Create a schema
|
|
81
|
+
* const PersonSchema = {
|
|
82
|
+
* "@type": schema.Person,
|
|
83
|
+
* name: schema.name,
|
|
84
|
+
* } as const;
|
|
85
|
+
*
|
|
86
|
+
* // Create a resource using the data schema above
|
|
87
|
+
* const Persons = createLens(PersonSchema);
|
|
88
|
+
*
|
|
89
|
+
* // Count all persons
|
|
90
|
+
* const count = await Persons.count(); // number
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
* @returns total number of entities corresponding to the data schema
|
|
94
|
+
*/
|
|
95
|
+
count(max?: number): Promise<number>;
|
|
96
|
+
/**
|
|
97
|
+
* Find entities with a custom SPARQL query.
|
|
98
|
+
*
|
|
99
|
+
* The query must be a CONSTRUCT query, and the root nodes must be of type `ldkit:Resource`.
|
|
100
|
+
* So that the decoder can decode the results, the query must also return all properties
|
|
101
|
+
* according to the data schema.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* import { createLens } from "ldkit";
|
|
106
|
+
* import { ldkit, schema } from "ldkit/namespaces";
|
|
107
|
+
* import { CONSTRUCT } from "ldkit/sparql";
|
|
108
|
+
*
|
|
109
|
+
* // Create a schema
|
|
110
|
+
* const PersonSchema = {
|
|
111
|
+
* "@type": schema.Person,
|
|
112
|
+
* name: schema.name,
|
|
113
|
+
* } as const;
|
|
114
|
+
*
|
|
115
|
+
* // Create a resource using the data schema above
|
|
116
|
+
* const Persons = createLens(PersonSchema);
|
|
117
|
+
*
|
|
118
|
+
* // Query to find all persons named "Doe"
|
|
119
|
+
* const query = CONSTRUCT`?s a <${ldkit.Resource}>; <${schema.name}> ?name`
|
|
120
|
+
* .WHERE`?s <${schema.name}> ?name; <${schema.familyName}> "Doe"`.build();
|
|
121
|
+
*
|
|
122
|
+
* // Find all persons that match the custom query
|
|
123
|
+
* const doePersons = await Persons.query(query);
|
|
124
|
+
* ```
|
|
125
|
+
*
|
|
126
|
+
* @param sparqlConstructQuery CONSTRUCT SPARQL query
|
|
127
|
+
* @returns Found entities
|
|
128
|
+
*/
|
|
129
|
+
query(sparqlConstructQuery: string): Promise<Unite<SchemaInterface<T>>[]>;
|
|
130
|
+
/**
|
|
131
|
+
* Find entities that match the given search criteria.
|
|
132
|
+
*
|
|
133
|
+
* The search criteria is a JSON object that may contain properties from the data schema.
|
|
134
|
+
* In addition you can specify how many results to return and how many to skip
|
|
135
|
+
* for pagination purposes.
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```typescript
|
|
139
|
+
* import { createLens } from "ldkit";
|
|
140
|
+
* import { schema } from "ldkit/namespaces";
|
|
141
|
+
*
|
|
142
|
+
* // Create a schema
|
|
143
|
+
* const PersonSchema = {
|
|
144
|
+
* "@type": schema.Person,
|
|
145
|
+
* name: schema.name,
|
|
146
|
+
* } as const;
|
|
147
|
+
*
|
|
148
|
+
* // Create a resource using the data schema above
|
|
149
|
+
* const Persons = createLens(PersonSchema);
|
|
150
|
+
*
|
|
151
|
+
* // Find 100 persons with name that starts with "Ada"
|
|
152
|
+
* const persons = await Persons.find({
|
|
153
|
+
* where: {
|
|
154
|
+
* name: { $strStarts: "Ada" },
|
|
155
|
+
* },
|
|
156
|
+
* take: 100,
|
|
157
|
+
* });
|
|
158
|
+
* ```
|
|
159
|
+
*
|
|
160
|
+
* @param options Search criteria and pagination options
|
|
161
|
+
* @returns entities that match the given search criteria
|
|
162
|
+
*/
|
|
163
|
+
find(options?: {
|
|
164
|
+
where?: SchemaSearchInterface<T> | string | RDF.Quad[];
|
|
165
|
+
take?: number;
|
|
166
|
+
skip?: number;
|
|
167
|
+
}): Promise<Unite<SchemaInterface<T>>[]>;
|
|
168
|
+
/**
|
|
169
|
+
* Find one entity that matches the given search criteria.
|
|
170
|
+
*
|
|
171
|
+
* The search criteria is a JSON object that may contain properties from the data schema.
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```typescript
|
|
175
|
+
* import { createLens } from "ldkit";
|
|
176
|
+
* import { schema } from "ldkit/namespaces";
|
|
177
|
+
*
|
|
178
|
+
* // Create a schema
|
|
179
|
+
* const PersonSchema = {
|
|
180
|
+
* "@type": schema.Person,
|
|
181
|
+
* name: schema.name,
|
|
182
|
+
* } as const;
|
|
183
|
+
*
|
|
184
|
+
* // Create a resource using the data schema above
|
|
185
|
+
* const Persons = createLens(PersonSchema);
|
|
186
|
+
*
|
|
187
|
+
* // Find one person with name that starts with "Ada"
|
|
188
|
+
* const person = await Persons.findOne({
|
|
189
|
+
* name: { $strStarts: "Ada" },
|
|
190
|
+
* });
|
|
191
|
+
* ```
|
|
192
|
+
*
|
|
193
|
+
* @param options Search criteria and pagination options
|
|
194
|
+
* @returns entities that match the given search criteria
|
|
195
|
+
*/
|
|
196
|
+
findOne(where?: SchemaSearchInterface<T>): Promise<Unite<SchemaInterface<T>> | null>;
|
|
197
|
+
/**
|
|
198
|
+
* Find a single entity that matches the given IRI.
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* ```typescript
|
|
202
|
+
* import { createLens } from "ldkit";
|
|
203
|
+
* import { schema } from "ldkit/namespaces";
|
|
204
|
+
*
|
|
205
|
+
* // Create a schema
|
|
206
|
+
* const PersonSchema = {
|
|
207
|
+
* "@type": schema.Person,
|
|
208
|
+
* name: schema.name,
|
|
209
|
+
* } as const;
|
|
210
|
+
*
|
|
211
|
+
* // Create a resource using the data schema above
|
|
212
|
+
* const Persons = createLens(PersonSchema);
|
|
213
|
+
*
|
|
214
|
+
* // Get a particular person identified by IRI
|
|
215
|
+
* const ada = await Persons.findByIri("http://dbpedia.org/resource/Ada_Lovelace");
|
|
216
|
+
* console.log(ada?.name); // string "Ada Lovelace"
|
|
217
|
+
* ```
|
|
218
|
+
*
|
|
219
|
+
* @param iri IRI of the entity to find
|
|
220
|
+
* @returns Entity if found, null otherwise
|
|
221
|
+
*/
|
|
222
|
+
findByIri(iri: IRI): Promise<Unite<SchemaInterface<T>> | null>;
|
|
223
|
+
/**
|
|
224
|
+
* Find entities that match the given IRIs.
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```typescript
|
|
228
|
+
* import { createLens } from "ldkit";
|
|
229
|
+
* import { schema } from "ldkit/namespaces";
|
|
230
|
+
*
|
|
231
|
+
* // Create a schema
|
|
232
|
+
* const PersonSchema = {
|
|
233
|
+
* "@type": schema.Person,
|
|
234
|
+
* name: schema.name,
|
|
235
|
+
* } as const;
|
|
236
|
+
*
|
|
237
|
+
* // Create a resource using the data schema above
|
|
238
|
+
* const Persons = createLens(PersonSchema);
|
|
239
|
+
*
|
|
240
|
+
* // Get specific persons identified by IRIs
|
|
241
|
+
* const matches = await Persons.findByIris([
|
|
242
|
+
* "http://dbpedia.org/resource/Ada_Lovelace",
|
|
243
|
+
* "http://dbpedia.org/resource/Alan_Turing"
|
|
244
|
+
* ]);
|
|
245
|
+
* console.log(matches[0].name); // string "Ada Lovelace"
|
|
246
|
+
* console.log(matches[1].name); // string "Alan Turing"
|
|
247
|
+
* ```
|
|
248
|
+
*
|
|
249
|
+
* @param iris IRIs of the entities to find
|
|
250
|
+
* @returns Array of found entities, empty array if there are no matches
|
|
251
|
+
*/
|
|
252
|
+
findByIris(iris: IRI[]): Promise<Unite<SchemaInterface<T>>[]>;
|
|
253
|
+
private updateQuery;
|
|
254
|
+
/**
|
|
255
|
+
* Inserts one or more entities to the data store.
|
|
256
|
+
*
|
|
257
|
+
* @example
|
|
258
|
+
* ```typescript
|
|
259
|
+
* import { createLens } from "ldkit";
|
|
260
|
+
* import { schema } from "ldkit/namespaces";
|
|
261
|
+
*
|
|
262
|
+
* // Create a schema
|
|
263
|
+
* const PersonSchema = {
|
|
264
|
+
* "@type": schema.Person,
|
|
265
|
+
* name: schema.name,
|
|
266
|
+
* } as const;
|
|
267
|
+
*
|
|
268
|
+
* // Create a resource using the data schema above
|
|
269
|
+
* const Persons = createLens(PersonSchema);
|
|
270
|
+
*
|
|
271
|
+
* // Insert a new person
|
|
272
|
+
* await Persons.insert({
|
|
273
|
+
* $id: "http://example.org/Alan_Turing",
|
|
274
|
+
* name: "Alan Turing",
|
|
275
|
+
* });
|
|
276
|
+
* ```
|
|
277
|
+
*
|
|
278
|
+
* @param entities Entities to insert
|
|
279
|
+
* @returns Nothing
|
|
280
|
+
*/
|
|
281
|
+
insert(...entities: Entity<SchemaInterface<T>>[]): Promise<void>;
|
|
282
|
+
/**
|
|
283
|
+
* Inserts raw RDF quads to the data store.
|
|
284
|
+
*
|
|
285
|
+
* This method is useful when you need to insert data that is not covered by the data schema.
|
|
286
|
+
*
|
|
287
|
+
* @example
|
|
288
|
+
* ```typescript
|
|
289
|
+
* import { createLens } from "ldkit";
|
|
290
|
+
* import { schema } from "ldkit/namespaces";
|
|
291
|
+
* import { DataFactory } from "ldkit/rdf";
|
|
292
|
+
*
|
|
293
|
+
* // Create a schema
|
|
294
|
+
* const PersonSchema = {
|
|
295
|
+
* "@type": schema.Person,
|
|
296
|
+
* name: schema.name,
|
|
297
|
+
* } as const;
|
|
298
|
+
*
|
|
299
|
+
* // Create a resource using the data schema above
|
|
300
|
+
* const Persons = createLens(PersonSchema);
|
|
301
|
+
*
|
|
302
|
+
* // Create a custom quad to insert
|
|
303
|
+
* const df = new DataFactory();
|
|
304
|
+
* const quad = df.quad(
|
|
305
|
+
* df.namedNode("http://example.org/Alan_Turing"),
|
|
306
|
+
* df.namedNode("http://schema.org/name"),
|
|
307
|
+
* df.literal("Alan Turing"),
|
|
308
|
+
* );
|
|
309
|
+
*
|
|
310
|
+
* // Insert the quad
|
|
311
|
+
* await Persons.insertData(quad);
|
|
312
|
+
* ```
|
|
313
|
+
*
|
|
314
|
+
* @param quads Quads to insert to the data store
|
|
315
|
+
* @returns Nothing
|
|
316
|
+
*/
|
|
317
|
+
insertData(...quads: RDF.Quad[]): Promise<void>;
|
|
318
|
+
/**
|
|
319
|
+
* Updates one or more entities in the data store.
|
|
320
|
+
*
|
|
321
|
+
* @example
|
|
322
|
+
* ```typescript
|
|
323
|
+
* import { createLens } from "ldkit";
|
|
324
|
+
* import { schema } from "ldkit/namespaces";
|
|
325
|
+
*
|
|
326
|
+
* // Create a schema
|
|
327
|
+
* const PersonSchema = {
|
|
328
|
+
* "@type": schema.Person,
|
|
329
|
+
* name: schema.name,
|
|
330
|
+
* } as const;
|
|
331
|
+
*
|
|
332
|
+
* // Create a resource using the data schema above
|
|
333
|
+
* const Persons = createLens(PersonSchema);
|
|
334
|
+
*
|
|
335
|
+
* // Update Alan Turing's name
|
|
336
|
+
* await Persons.update({
|
|
337
|
+
* $id: "http://example.org/Alan_Turing",
|
|
338
|
+
* name: "Not Alan Turing",
|
|
339
|
+
* });
|
|
340
|
+
* ```
|
|
341
|
+
*
|
|
342
|
+
* @param entities Partial entities to update
|
|
343
|
+
* @returns Nothing
|
|
344
|
+
*/
|
|
345
|
+
update(...entities: SchemaUpdateInterface<T>[]): Promise<void>;
|
|
346
|
+
/**
|
|
347
|
+
* Deletes one or more entities from the data store.
|
|
348
|
+
*
|
|
349
|
+
* This method accepts IRIs of the entities to delete and attemps
|
|
350
|
+
* to delete all triples from the database that corresponds to
|
|
351
|
+
* the data schema. Other triples that are not covered by the data
|
|
352
|
+
* schema will not be deleted.
|
|
353
|
+
*
|
|
354
|
+
* If you need to have more control of what triples to delete,
|
|
355
|
+
* use {@link deleteData} instead.
|
|
356
|
+
*
|
|
357
|
+
* @example
|
|
358
|
+
* ```typescript
|
|
359
|
+
* import { createLens } from "ldkit";
|
|
360
|
+
* import { schema } from "ldkit/namespaces";
|
|
361
|
+
*
|
|
362
|
+
* // Create a schema
|
|
363
|
+
* const PersonSchema = {
|
|
364
|
+
* "@type": schema.Person,
|
|
365
|
+
* name: schema.name,
|
|
366
|
+
* } as const;
|
|
367
|
+
*
|
|
368
|
+
* // Create a resource using the data schema above
|
|
369
|
+
* const Persons = createLens(PersonSchema);
|
|
370
|
+
*
|
|
371
|
+
* // Delete a person
|
|
372
|
+
* await Persons.delete("http://example.org/Alan_Turing");
|
|
373
|
+
* ```
|
|
374
|
+
*
|
|
375
|
+
* @param identities Identities or IRIs of the entities to delete
|
|
376
|
+
* @returns Nothing
|
|
377
|
+
*/
|
|
378
|
+
delete(...identities: Identity[] | IRI[]): Promise<void>;
|
|
379
|
+
/**
|
|
380
|
+
* Deletes raw RDF quads from the data store.
|
|
381
|
+
*
|
|
382
|
+
* This method is useful when you need to delete data that is not covered by the data schema.
|
|
383
|
+
*
|
|
384
|
+
* @example
|
|
385
|
+
* ```typescript
|
|
386
|
+
* import { createLens } from "ldkit";
|
|
387
|
+
* import { schema } from "ldkit/namespaces";
|
|
388
|
+
* import { DataFactory } from "ldkit/rdf";
|
|
389
|
+
*
|
|
390
|
+
* // Create a schema
|
|
391
|
+
* const PersonSchema = {
|
|
392
|
+
* "@type": schema.Person,
|
|
393
|
+
* name: schema.name,
|
|
394
|
+
* } as const;
|
|
395
|
+
*
|
|
396
|
+
* // Create a resource using the data schema and context above
|
|
397
|
+
* const Persons = createLens(PersonSchema);
|
|
398
|
+
*
|
|
399
|
+
* // Create a custom quad to insert
|
|
400
|
+
* const df = new DataFactory();
|
|
401
|
+
* const quad = df.quad(
|
|
402
|
+
* df.namedNode("http://example.org/Alan_Turing"),
|
|
403
|
+
* df.namedNode("http://schema.org/name"),
|
|
404
|
+
* df.literal("Alan Turing"),
|
|
405
|
+
* );
|
|
406
|
+
*
|
|
407
|
+
* // Delete the quad
|
|
408
|
+
* await Persons.deleteData(quad);
|
|
409
|
+
* ```
|
|
410
|
+
*
|
|
411
|
+
* @param quads Quads to delete from the data store
|
|
412
|
+
* @returns Nothing
|
|
413
|
+
*/
|
|
414
|
+
deleteData(...quads: RDF.Quad[]): Promise<void>;
|
|
415
|
+
}
|
|
416
|
+
//# 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 =
|
|
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
|
*
|
|
@@ -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(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,GAAG,CAAC,EAAE,MAAM;IAQvB,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"}
|
|
@@ -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 =
|
|
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;
|