ldkit 0.0.1 → 0.0.2
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/_dnt.shims.js +70 -0
- package/esm/library/comunica/bundle.js +82389 -0
- package/esm/library/comunica/mod.js +1 -0
- package/esm/library/context.js +13 -0
- package/esm/library/decoder.js +203 -0
- package/esm/library/encoder.js +116 -0
- package/esm/library/engine.js +9 -0
- package/esm/library/namespaces/dcterms.js +105 -0
- package/esm/library/namespaces/ldkit.js +6 -0
- package/esm/library/namespaces/mod.js +7 -0
- package/esm/library/namespaces/namespace.js +11 -0
- package/esm/library/namespaces/rdf.js +29 -0
- package/esm/library/namespaces/schema.js +2698 -0
- package/esm/library/namespaces/skos.js +39 -0
- package/esm/library/namespaces/xsd.js +57 -0
- package/esm/library/rdf.js +19 -0
- package/esm/library/resource/mod.js +1 -0
- package/esm/library/resource/query_builder.js +147 -0
- package/esm/library/resource/query_helper.js +102 -0
- package/esm/library/resource/resource.js +102 -0
- package/esm/library/resource/types.js +1 -0
- package/esm/library/rxjs.js +2 -0
- package/esm/library/schema/data_types.js +37 -0
- package/esm/library/schema/interface.js +1 -0
- package/esm/library/schema/mod.js +1 -0
- package/esm/library/schema/schema.js +1 -0
- package/esm/library/schema/utils.js +58 -0
- package/esm/library/sparql.js +2 -0
- package/esm/mod.js +3 -0
- package/package.json +16 -5
- package/script/_dnt.shims.js +80 -0
- package/script/library/comunica/bundle.js +82415 -0
- package/script/library/comunica/mod.js +5 -0
- package/script/library/context.js +19 -0
- package/script/library/decoder.js +207 -0
- package/script/library/encoder.js +120 -0
- package/script/library/engine.js +16 -0
- package/script/library/namespaces/dcterms.js +107 -0
- package/script/library/namespaces/ldkit.js +8 -0
- package/script/library/namespaces/mod.js +20 -0
- package/script/library/namespaces/namespace.js +15 -0
- package/script/library/namespaces/rdf.js +31 -0
- package/script/library/namespaces/schema.js +2700 -0
- package/script/library/namespaces/skos.js +41 -0
- package/script/library/namespaces/xsd.js +59 -0
- package/script/library/rdf.js +54 -0
- package/script/library/resource/mod.js +6 -0
- package/script/library/resource/query_builder.js +151 -0
- package/script/library/resource/query_helper.js +106 -0
- package/script/library/resource/resource.js +107 -0
- package/script/{npm.js → library/resource/types.js} +0 -2
- package/script/library/rxjs.js +11 -0
- package/script/library/schema/data_types.js +39 -0
- package/script/library/schema/interface.js +2 -0
- package/script/library/schema/mod.js +6 -0
- package/script/library/schema/schema.js +2 -0
- package/script/library/schema/utils.js +63 -0
- package/script/library/sparql.js +13 -0
- package/script/mod.js +10 -0
- package/esm/npm.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { QueryEngine } from "./bundle.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
let defaultContext = undefined;
|
|
2
|
+
export const createContext = (context) => {
|
|
3
|
+
return context;
|
|
4
|
+
};
|
|
5
|
+
export const createDefaultContext = (context) => {
|
|
6
|
+
defaultContext = createContext(context);
|
|
7
|
+
};
|
|
8
|
+
export const resolveContext = (context) => {
|
|
9
|
+
if (!context && !defaultContext) {
|
|
10
|
+
throw new Error("No context found. Please create a default context or pass one to createResource function");
|
|
11
|
+
}
|
|
12
|
+
return context || defaultContext;
|
|
13
|
+
};
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { fromRdf } from "./rdf.js";
|
|
2
|
+
import { ldkit, rdf } from "./namespaces/mod.js";
|
|
3
|
+
class Decoder {
|
|
4
|
+
constructor(graph, schema, context) {
|
|
5
|
+
Object.defineProperty(this, "graph", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
configurable: true,
|
|
8
|
+
writable: true,
|
|
9
|
+
value: void 0
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(this, "schema", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
configurable: true,
|
|
14
|
+
writable: true,
|
|
15
|
+
value: void 0
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(this, "context", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
configurable: true,
|
|
20
|
+
writable: true,
|
|
21
|
+
value: void 0
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(this, "cache", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
writable: true,
|
|
27
|
+
value: new Map()
|
|
28
|
+
});
|
|
29
|
+
this.graph = graph;
|
|
30
|
+
this.schema = schema;
|
|
31
|
+
this.context = context;
|
|
32
|
+
}
|
|
33
|
+
static decode(graph, schema, context) {
|
|
34
|
+
return new Decoder(graph, schema, context).decode();
|
|
35
|
+
}
|
|
36
|
+
getCachedNode(nodeIri, schema) {
|
|
37
|
+
if (!this.cache.has(schema)) {
|
|
38
|
+
this.cache.set(schema, new Map());
|
|
39
|
+
}
|
|
40
|
+
return this.cache.get(schema).get(nodeIri);
|
|
41
|
+
}
|
|
42
|
+
setCachedNode(nodeIri, schema, decodedNode) {
|
|
43
|
+
if (!this.cache.has(schema)) {
|
|
44
|
+
this.cache.set(schema, new Map());
|
|
45
|
+
}
|
|
46
|
+
this.cache.get(schema).set(nodeIri, decodedNode);
|
|
47
|
+
}
|
|
48
|
+
decode() {
|
|
49
|
+
const output = [];
|
|
50
|
+
for (const [iri, properties] of this.graph) {
|
|
51
|
+
if (properties.has(rdf.type)) {
|
|
52
|
+
const types = properties.get(rdf.type);
|
|
53
|
+
for (const type of types) {
|
|
54
|
+
if (type.termType === "NamedNode" && type.value === ldkit.Resource) {
|
|
55
|
+
output.push(this.decodeNode(iri, this.schema));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (this.graph.size > 0 && output.length < 1) {
|
|
61
|
+
throw new Error(`Unable to decode graph - no resources with type <${ldkit.Resource}> found`);
|
|
62
|
+
}
|
|
63
|
+
return output;
|
|
64
|
+
}
|
|
65
|
+
decodeNode(nodeIri, schema) {
|
|
66
|
+
const cachedNode = this.getCachedNode(nodeIri, schema);
|
|
67
|
+
if (cachedNode) {
|
|
68
|
+
return cachedNode;
|
|
69
|
+
}
|
|
70
|
+
const output = {
|
|
71
|
+
$id: nodeIri,
|
|
72
|
+
};
|
|
73
|
+
const node = this.graph.get(nodeIri);
|
|
74
|
+
if (!node) {
|
|
75
|
+
throw new Error(`Error decoding graph, <${nodeIri}> node not found.`);
|
|
76
|
+
}
|
|
77
|
+
output.$type = this.decodeNodeType(node);
|
|
78
|
+
Object.keys(schema).forEach((key) => {
|
|
79
|
+
if (key === "@type") {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const result = this.decodeNodeProperty(nodeIri, node, key, schema[key]);
|
|
83
|
+
if (result !== undefined) {
|
|
84
|
+
output[key] = result;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
this.setCachedNode(nodeIri, schema, output);
|
|
88
|
+
return output;
|
|
89
|
+
}
|
|
90
|
+
decodeNodeType(node) {
|
|
91
|
+
const typeTerms = node.get(rdf.type);
|
|
92
|
+
if (!typeTerms) {
|
|
93
|
+
return [];
|
|
94
|
+
}
|
|
95
|
+
return typeTerms.reduce((acc, term) => {
|
|
96
|
+
if (term.value !== ldkit.Resource) {
|
|
97
|
+
acc.push(term.value);
|
|
98
|
+
}
|
|
99
|
+
return acc;
|
|
100
|
+
}, []);
|
|
101
|
+
}
|
|
102
|
+
decodeNodeProperty(nodeIri, node, propertyKey, property) {
|
|
103
|
+
const terms = node.get(property["@id"]);
|
|
104
|
+
if (!terms) {
|
|
105
|
+
if (!property["@optional"]) {
|
|
106
|
+
// No data, required property
|
|
107
|
+
throw new Error(`Required property "${propertyKey}" of type <${property["@id"]}> not found on resource <${nodeIri}>`);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
// No data, optional property
|
|
111
|
+
return property["@array"] ? [] : undefined;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (property["@multilang"]) {
|
|
115
|
+
if (property["@array"]) {
|
|
116
|
+
return terms.reduce((acc, term) => {
|
|
117
|
+
if (term.termType !== "Literal") {
|
|
118
|
+
throw new Error(`Property "${propertyKey}" data type mismatch - expected a literal, but received ${term.termType} instead on resource <${nodeIri}>`);
|
|
119
|
+
}
|
|
120
|
+
const language = term.language;
|
|
121
|
+
if (!acc[language]) {
|
|
122
|
+
acc[language] = [];
|
|
123
|
+
}
|
|
124
|
+
acc[language].push(this.decodeTerm(term));
|
|
125
|
+
return acc;
|
|
126
|
+
}, {});
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
return terms.reduce((acc, term) => {
|
|
130
|
+
if (term.termType !== "Literal") {
|
|
131
|
+
throw new Error(`Property "${propertyKey}" data type mismatch - expected a literal, but received ${term.termType} instead on resource <${nodeIri}>`);
|
|
132
|
+
}
|
|
133
|
+
const language = term.language;
|
|
134
|
+
if (!acc[language]) {
|
|
135
|
+
// If there are multiple strings with the same language detected, selecting only the first one
|
|
136
|
+
acc[language] = this.decodeTerm(term);
|
|
137
|
+
}
|
|
138
|
+
return acc;
|
|
139
|
+
}, {});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (property["@array"]) {
|
|
143
|
+
if (property["@context"]) {
|
|
144
|
+
// Collection of resources specified by sub schema
|
|
145
|
+
return terms.map((term) => {
|
|
146
|
+
if (term.termType !== "NamedNode" && term.termType !== "BlankNode") {
|
|
147
|
+
throw new Error(`Property "${propertyKey}" data type mismatch - expected a node, but received ${term.termType} instead on resource <${nodeIri}>`);
|
|
148
|
+
}
|
|
149
|
+
return this.decodeNode(term.value, property["@context"]);
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
// Collection of literals or named nodes
|
|
154
|
+
return terms.map((term) => {
|
|
155
|
+
if (term.termType !== "Literal" && term.termType !== "NamedNode") {
|
|
156
|
+
throw new Error(`Property "${propertyKey}" data type mismatch - expected a literal or named node, but received ${term.termType} instead on resource <${nodeIri}>`);
|
|
157
|
+
}
|
|
158
|
+
return this.decodeTerm(term);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// Single return value expected from this point on
|
|
163
|
+
if (property["@context"]) {
|
|
164
|
+
for (const term of terms) {
|
|
165
|
+
if (term.termType === "NamedNode" || term.termType === "BlankNode") {
|
|
166
|
+
return this.decodeNode(term.value, property["@context"]);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
throw new Error(`Property "${propertyKey}" data type mismatch - expected a named node for context on resource <${nodeIri}>`);
|
|
170
|
+
}
|
|
171
|
+
const preferredLanguage = this.context.language;
|
|
172
|
+
if (preferredLanguage) {
|
|
173
|
+
// Try to find a term that corresponds to the preferred language
|
|
174
|
+
for (const term of terms) {
|
|
175
|
+
if (term.termType === "Literal" &&
|
|
176
|
+
term.language === preferredLanguage) {
|
|
177
|
+
return this.decodeTerm(term);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
// All options exhausted - return first namedNode or literal if there are multiple
|
|
182
|
+
for (const term of terms) {
|
|
183
|
+
if (term.termType === "Literal" || term.termType === "NamedNode") {
|
|
184
|
+
return this.decodeTerm(term);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
throw new Error(`Property "${propertyKey}" data type mismatch - expected a literal or named node instead on resource <${nodeIri}>`);
|
|
188
|
+
}
|
|
189
|
+
decodeTerm(term) {
|
|
190
|
+
if (term.termType === "NamedNode") {
|
|
191
|
+
return term.value;
|
|
192
|
+
}
|
|
193
|
+
else if (term.termType === "Literal") {
|
|
194
|
+
return fromRdf(term);
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
throw new Error(`Unsupported term type to resolve: ${term.termType}`);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
export const decode = (graph, schema, context) => {
|
|
202
|
+
return Decoder.decode(graph, schema, context);
|
|
203
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { toRdf, DataFactory, literal, } from "./rdf.js";
|
|
2
|
+
import { rdf, xsd } from "./namespaces/mod.js";
|
|
3
|
+
export const encode = (node, schema, context, variableInitCounter = 0) => {
|
|
4
|
+
return Encoder.encode(node, schema, context, variableInitCounter);
|
|
5
|
+
};
|
|
6
|
+
class Encoder {
|
|
7
|
+
constructor(context, variableInitCounter) {
|
|
8
|
+
Object.defineProperty(this, "context", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
configurable: true,
|
|
11
|
+
writable: true,
|
|
12
|
+
value: void 0
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(this, "df", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
configurable: true,
|
|
17
|
+
writable: true,
|
|
18
|
+
value: new DataFactory({
|
|
19
|
+
blankNodePrefix: "b",
|
|
20
|
+
})
|
|
21
|
+
});
|
|
22
|
+
Object.defineProperty(this, "variableCounter", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
configurable: true,
|
|
25
|
+
writable: true,
|
|
26
|
+
value: void 0
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(this, "output", {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
configurable: true,
|
|
31
|
+
writable: true,
|
|
32
|
+
value: []
|
|
33
|
+
});
|
|
34
|
+
this.context = context;
|
|
35
|
+
this.variableCounter = variableInitCounter;
|
|
36
|
+
}
|
|
37
|
+
static encode(node, schema, context, variableInitCounter) {
|
|
38
|
+
return new Encoder(context, variableInitCounter).encode(node, schema);
|
|
39
|
+
}
|
|
40
|
+
encode(node, schema) {
|
|
41
|
+
const nodeId = this.getNodeId(node);
|
|
42
|
+
this.encodeNode(node, schema, nodeId);
|
|
43
|
+
return this.output;
|
|
44
|
+
}
|
|
45
|
+
push(s, p, o) {
|
|
46
|
+
this.output.push(this.df.quad(s, p, o));
|
|
47
|
+
}
|
|
48
|
+
getNodeId(node) {
|
|
49
|
+
return node.$id
|
|
50
|
+
? this.df.namedNode(node.$id)
|
|
51
|
+
: this.df.blankNode();
|
|
52
|
+
}
|
|
53
|
+
getNodeTypes(node) {
|
|
54
|
+
if (Array.isArray(node.$type)) {
|
|
55
|
+
return node.$type;
|
|
56
|
+
}
|
|
57
|
+
return node.$type ? [node.$type] : [];
|
|
58
|
+
}
|
|
59
|
+
encodeNode(node, schema, nodeId) {
|
|
60
|
+
this.encodeNodeType(node, schema["@type"], nodeId);
|
|
61
|
+
Object.keys(schema).forEach((key) => {
|
|
62
|
+
if (key === "@type") {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
this.encodeNodeProperty(node[key], schema[key], nodeId);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
encodeNodeType(node, requiredTypes, nodeId) {
|
|
69
|
+
const finalTypes = new Set([...this.getNodeTypes(node), ...requiredTypes]);
|
|
70
|
+
finalTypes.forEach((type) => {
|
|
71
|
+
this.push(nodeId, this.df.namedNode(rdf.type), this.df.namedNode(type));
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
encodeNodeProperty(value, property, nodeId) {
|
|
75
|
+
if (value === undefined) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const propertyId = this.df.namedNode(property["@id"]);
|
|
79
|
+
if (value === null) {
|
|
80
|
+
// TODO
|
|
81
|
+
this.push(nodeId, propertyId, this.df.variable(`v${this.variableCounter++}`));
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (property["@multilang"]) {
|
|
85
|
+
Object.keys(value).forEach((language) => {
|
|
86
|
+
const languageValue = Array.isArray(value[language])
|
|
87
|
+
? value[language]
|
|
88
|
+
: [value[language]];
|
|
89
|
+
languageValue.forEach((singleValue) => {
|
|
90
|
+
this.push(nodeId, propertyId, literal(singleValue, language.length > 0 ? language : undefined));
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const values = Array.isArray(value) ? value : [value];
|
|
96
|
+
values.forEach((val) => {
|
|
97
|
+
if (property["@context"]) {
|
|
98
|
+
const subNodeId = this.getNodeId(val);
|
|
99
|
+
this.encodeNode(val, property["@context"], subNodeId);
|
|
100
|
+
this.push(nodeId, propertyId, subNodeId);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const propertyType = property["@type"] ?? xsd.string;
|
|
104
|
+
if (typeof val === "string" && this.context.language) {
|
|
105
|
+
if (propertyType === xsd.string || propertyType === rdf.langString) {
|
|
106
|
+
this.push(nodeId, propertyId, literal(val, this.context.language));
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const rdfValue = toRdf(val, {
|
|
111
|
+
datatype: this.df.namedNode(property["@type"] ?? xsd.string),
|
|
112
|
+
});
|
|
113
|
+
this.push(nodeId, propertyId, rdfValue);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { QueryEngine } from "./comunica/mod.js";
|
|
2
|
+
import { from, map, switchMap } from "./rxjs.js";
|
|
3
|
+
import { resolveContext } from "./context.js";
|
|
4
|
+
import { quadsToGraph } from "./rdf.js";
|
|
5
|
+
const engine = new QueryEngine();
|
|
6
|
+
export const booleanQuery = (query, context) => from(engine.queryBoolean(query, resolveContext(context)));
|
|
7
|
+
export const bindingsQuery = (query, context) => from(engine.queryBindings(query, resolveContext(context))).pipe(switchMap((stream) => from(stream.toArray())));
|
|
8
|
+
export const quadsQuery = (query, context) => from(engine.queryQuads(query, resolveContext(context))).pipe(switchMap((stream) => from(stream.toArray())), map((quads) => quadsToGraph(quads)));
|
|
9
|
+
export const updateQuery = (query, context) => from(engine.queryVoid(query, resolveContext(context)));
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { createNamespace } from "./namespace.js";
|
|
2
|
+
export default createNamespace({
|
|
3
|
+
iri: "http://purl.org/dc/terms/",
|
|
4
|
+
prefix: "dcterms:",
|
|
5
|
+
terms: [
|
|
6
|
+
"Agent",
|
|
7
|
+
"AgentClass",
|
|
8
|
+
"BibliographicResource",
|
|
9
|
+
"Box",
|
|
10
|
+
"DCMIType",
|
|
11
|
+
"DDC",
|
|
12
|
+
"FileFormat",
|
|
13
|
+
"Frequency",
|
|
14
|
+
"IMT",
|
|
15
|
+
"ISO3166",
|
|
16
|
+
"ISO639-2",
|
|
17
|
+
"ISO639-3",
|
|
18
|
+
"Jurisdiction",
|
|
19
|
+
"LCC",
|
|
20
|
+
"LCSH",
|
|
21
|
+
"LicenseDocument",
|
|
22
|
+
"LinguisticSystem",
|
|
23
|
+
"Location",
|
|
24
|
+
"LocationPeriodOrJurisdiction",
|
|
25
|
+
"MESH",
|
|
26
|
+
"MediaType",
|
|
27
|
+
"MediaTypeOrExtent",
|
|
28
|
+
"MethodOfAccrual",
|
|
29
|
+
"MethodOfInstruction",
|
|
30
|
+
"NLM",
|
|
31
|
+
"Period",
|
|
32
|
+
"PeriodOfTime",
|
|
33
|
+
"PhysicalMedium",
|
|
34
|
+
"PhysicalResource",
|
|
35
|
+
"Point",
|
|
36
|
+
"Policy",
|
|
37
|
+
"ProvenanceStatement",
|
|
38
|
+
"RFC1766",
|
|
39
|
+
"RFC3066",
|
|
40
|
+
"RFC4646",
|
|
41
|
+
"RFC5646",
|
|
42
|
+
"RightsStatement",
|
|
43
|
+
"SizeOrDuration",
|
|
44
|
+
"Standard",
|
|
45
|
+
"TGN",
|
|
46
|
+
"UDC",
|
|
47
|
+
"URI",
|
|
48
|
+
"W3CDTF",
|
|
49
|
+
"abstract",
|
|
50
|
+
"accessRights",
|
|
51
|
+
"accrualMethod",
|
|
52
|
+
"accrualPeriodicity",
|
|
53
|
+
"accrualPolicy",
|
|
54
|
+
"alternative",
|
|
55
|
+
"audience",
|
|
56
|
+
"available",
|
|
57
|
+
"bibliographicCitation",
|
|
58
|
+
"conformsTo",
|
|
59
|
+
"contributor",
|
|
60
|
+
"coverage",
|
|
61
|
+
"created",
|
|
62
|
+
"creator",
|
|
63
|
+
"date",
|
|
64
|
+
"dateAccepted",
|
|
65
|
+
"dateCopyrighted",
|
|
66
|
+
"dateSubmitted",
|
|
67
|
+
"description",
|
|
68
|
+
"educationLevel",
|
|
69
|
+
"extent",
|
|
70
|
+
"format",
|
|
71
|
+
"hasFormat",
|
|
72
|
+
"hasPart",
|
|
73
|
+
"hasVersion",
|
|
74
|
+
"identifier",
|
|
75
|
+
"instructionalMethod",
|
|
76
|
+
"isFormatOf",
|
|
77
|
+
"isPartOf",
|
|
78
|
+
"isReferencedBy",
|
|
79
|
+
"isReplacedBy",
|
|
80
|
+
"isRequiredBy",
|
|
81
|
+
"isVersionOf",
|
|
82
|
+
"issued",
|
|
83
|
+
"language",
|
|
84
|
+
"license",
|
|
85
|
+
"mediator",
|
|
86
|
+
"medium",
|
|
87
|
+
"modified",
|
|
88
|
+
"provenance",
|
|
89
|
+
"publisher",
|
|
90
|
+
"references",
|
|
91
|
+
"relation",
|
|
92
|
+
"replaces",
|
|
93
|
+
"requires",
|
|
94
|
+
"rights",
|
|
95
|
+
"rightsHolder",
|
|
96
|
+
"source",
|
|
97
|
+
"spatial",
|
|
98
|
+
"subject",
|
|
99
|
+
"tableOfContents",
|
|
100
|
+
"temporal",
|
|
101
|
+
"title",
|
|
102
|
+
"type",
|
|
103
|
+
"valid",
|
|
104
|
+
],
|
|
105
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { default as rdf } from "./rdf.js";
|
|
2
|
+
export { default as dcterms } from "./dcterms.js";
|
|
3
|
+
export { default as ldkit } from "./ldkit.js";
|
|
4
|
+
export { default as schema } from "./schema.js";
|
|
5
|
+
export { default as skos } from "./skos.js";
|
|
6
|
+
export { default as xsd } from "./xsd.js";
|
|
7
|
+
export { createNamespace } from "./namespace.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const createNamespace = (namespaceSpec) => Object.assign(
|
|
2
|
+
//<X extends I>(f: [X]) =>
|
|
3
|
+
// `${namespaceSpec.prefix}:${f}` as `${string & P}${string & X}`,
|
|
4
|
+
namespaceSpec.terms.reduce((acc, term) => {
|
|
5
|
+
//acc[term] = `${namespaceSpec.prefix}${term}`
|
|
6
|
+
acc[term] = `${namespaceSpec.iri}${term}`;
|
|
7
|
+
return acc;
|
|
8
|
+
}, {}), {
|
|
9
|
+
$prefix: namespaceSpec["prefix"],
|
|
10
|
+
$iri: namespaceSpec["iri"],
|
|
11
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createNamespace } from "./namespace.js";
|
|
2
|
+
export default createNamespace({
|
|
3
|
+
iri: "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
|
|
4
|
+
prefix: "rdf:",
|
|
5
|
+
terms: [
|
|
6
|
+
"Alt",
|
|
7
|
+
"Bag",
|
|
8
|
+
"CompoundLiteral",
|
|
9
|
+
"HTML",
|
|
10
|
+
"JSON",
|
|
11
|
+
"List",
|
|
12
|
+
"PlainLiteral",
|
|
13
|
+
"Property",
|
|
14
|
+
"Seq",
|
|
15
|
+
"Statement",
|
|
16
|
+
"XMLLiteral",
|
|
17
|
+
"direction",
|
|
18
|
+
"first",
|
|
19
|
+
"langString",
|
|
20
|
+
"language",
|
|
21
|
+
"nil",
|
|
22
|
+
"object",
|
|
23
|
+
"predicate",
|
|
24
|
+
"rest",
|
|
25
|
+
"subject",
|
|
26
|
+
"type",
|
|
27
|
+
"value",
|
|
28
|
+
],
|
|
29
|
+
});
|