@shaclmate/shacl-ast 2.0.22 → 2.0.24
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/dist/IdentifierNodeKind.d.ts +6 -0
- package/dist/IdentifierNodeKind.js +2 -0
- package/dist/NodeShape.d.ts +2 -2
- package/dist/Ontology.d.ts +1 -1
- package/dist/Ontology.js +1 -1
- package/dist/PropertyGroup.js +1 -1
- package/dist/PropertyPath.d.ts +5 -5
- package/dist/PropertyPath.js +14 -24
- package/dist/PropertyShape.d.ts +3 -3
- package/dist/Shape.d.ts +4 -4
- package/dist/Shape.js +1 -1
- package/dist/defaultFactory.js +4 -8
- package/dist/generated.d.ts +562 -50
- package/dist/generated.js +1742 -586
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +8 -13
package/dist/generated.js
CHANGED
|
@@ -1,324 +1,593 @@
|
|
|
1
|
-
import { DataFactory as dataFactory } from "n3";
|
|
1
|
+
import { StoreFactory as _DatasetFactory, DataFactory as dataFactory, } from "n3";
|
|
2
|
+
const datasetFactory = new _DatasetFactory();
|
|
2
3
|
import * as purify from "purify-ts";
|
|
3
4
|
import * as rdfjsResource from "rdfjs-resource";
|
|
4
5
|
import { PropertyPath } from "./PropertyPath.js";
|
|
5
|
-
export var
|
|
6
|
-
(function (
|
|
7
|
-
|
|
6
|
+
export var $RdfVocabularies;
|
|
7
|
+
(function ($RdfVocabularies) {
|
|
8
|
+
let rdf;
|
|
9
|
+
(function (rdf) {
|
|
10
|
+
rdf.first = dataFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#first");
|
|
11
|
+
rdf.nil = dataFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#nil");
|
|
12
|
+
rdf.rest = dataFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#rest");
|
|
13
|
+
rdf.subject = dataFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#subject");
|
|
14
|
+
rdf.type = dataFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
|
|
15
|
+
})(rdf = $RdfVocabularies.rdf || ($RdfVocabularies.rdf = {}));
|
|
16
|
+
let rdfs;
|
|
17
|
+
(function (rdfs) {
|
|
18
|
+
rdfs.subClassOf = dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#subClassOf");
|
|
19
|
+
})(rdfs = $RdfVocabularies.rdfs || ($RdfVocabularies.rdfs = {}));
|
|
20
|
+
let xsd;
|
|
21
|
+
(function (xsd) {
|
|
22
|
+
xsd.boolean = dataFactory.namedNode("http://www.w3.org/2001/XMLSchema#boolean");
|
|
23
|
+
xsd.date = dataFactory.namedNode("http://www.w3.org/2001/XMLSchema#date");
|
|
24
|
+
xsd.dateTime = dataFactory.namedNode("http://www.w3.org/2001/XMLSchema#dateTime");
|
|
25
|
+
xsd.integer = dataFactory.namedNode("http://www.w3.org/2001/XMLSchema#integer");
|
|
26
|
+
})(xsd = $RdfVocabularies.xsd || ($RdfVocabularies.xsd = {}));
|
|
27
|
+
})($RdfVocabularies || ($RdfVocabularies = {}));
|
|
28
|
+
export var BaseShaclCoreShapeStatic;
|
|
29
|
+
(function (BaseShaclCoreShapeStatic) {
|
|
30
|
+
let $Identifier;
|
|
31
|
+
(function ($Identifier) {
|
|
32
|
+
function fromString(identifier) {
|
|
33
|
+
return purify.Either.encase(() => rdfjsResource.Resource.Identifier.fromString({
|
|
34
|
+
dataFactory,
|
|
35
|
+
identifier,
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
$Identifier.fromString = fromString;
|
|
39
|
+
$Identifier.toString = rdfjsResource.Resource.Identifier.toString;
|
|
40
|
+
})($Identifier = BaseShaclCoreShapeStatic.$Identifier || (BaseShaclCoreShapeStatic.$Identifier = {}));
|
|
41
|
+
function $fromRdf(resource, options) {
|
|
42
|
+
let { ignoreRdfType = false, languageIn, objectSet, ...context } = options ?? {};
|
|
43
|
+
if (!objectSet) {
|
|
44
|
+
objectSet = new $RdfjsDatasetObjectSet({ dataset: resource.dataset });
|
|
45
|
+
}
|
|
46
|
+
return ShaclCoreNodeShape.$fromRdf(resource, {
|
|
47
|
+
...context,
|
|
48
|
+
ignoreRdfType: false,
|
|
49
|
+
objectSet,
|
|
50
|
+
}).altLazy(() => ShaclCorePropertyShape.$fromRdf(resource, {
|
|
51
|
+
...context,
|
|
52
|
+
ignoreRdfType: false,
|
|
53
|
+
objectSet,
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
56
|
+
BaseShaclCoreShapeStatic.$fromRdf = $fromRdf;
|
|
57
|
+
function $propertiesFromRdf({ ignoreRdfType: $ignoreRdfType, languageIn: $languageIn, objectSet: $objectSet, resource: $resource,
|
|
8
58
|
// @ts-ignore
|
|
9
|
-
|
|
10
|
-
const identifier =
|
|
11
|
-
const _andEither = purify.Either.of([
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
.toMaybe()
|
|
27
|
-
.toList()),
|
|
28
|
-
]);
|
|
59
|
+
...$context }) {
|
|
60
|
+
const $identifier = $resource.identifier;
|
|
61
|
+
const _andEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.and["identifier"], { unique: true }))
|
|
62
|
+
.chain((values) => values.chainMap((value) => value.toList()))
|
|
63
|
+
.chain((valueLists) => valueLists.chainMap((valueList) => purify.Either.of(rdfjsResource.Resource.Values.fromArray({
|
|
64
|
+
objects: valueList,
|
|
65
|
+
predicate: BaseShaclCoreShapeStatic.$properties.and["identifier"],
|
|
66
|
+
subject: $resource,
|
|
67
|
+
})).chain((values) => values.chainMap((value) => value.toIdentifier()))))
|
|
68
|
+
.map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
|
|
69
|
+
.map((values) => values.toArray())
|
|
70
|
+
.map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
|
|
71
|
+
object: valuesArray,
|
|
72
|
+
predicate: BaseShaclCoreShapeStatic.$properties.and["identifier"],
|
|
73
|
+
subject: $resource,
|
|
74
|
+
}))
|
|
75
|
+
.chain((values) => values.head());
|
|
29
76
|
if (_andEither.isLeft()) {
|
|
30
77
|
return _andEither;
|
|
31
78
|
}
|
|
32
79
|
const and = _andEither.unsafeCoerce();
|
|
33
|
-
const _classesEither = purify.Either.of([
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
.toMaybe()
|
|
43
|
-
.toList()),
|
|
44
|
-
]);
|
|
80
|
+
const _classesEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.classes["identifier"], { unique: true }))
|
|
81
|
+
.chain((values) => values.chainMap((value) => value.toIri()))
|
|
82
|
+
.map((values) => values.toArray())
|
|
83
|
+
.map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
|
|
84
|
+
object: valuesArray,
|
|
85
|
+
predicate: BaseShaclCoreShapeStatic.$properties.classes["identifier"],
|
|
86
|
+
subject: $resource,
|
|
87
|
+
}))
|
|
88
|
+
.chain((values) => values.head());
|
|
45
89
|
if (_classesEither.isLeft()) {
|
|
46
90
|
return _classesEither;
|
|
47
91
|
}
|
|
48
92
|
const classes = _classesEither.unsafeCoerce();
|
|
49
|
-
const _commentsEither = purify.Either.of([
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
93
|
+
const _commentsEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.comments["identifier"], { unique: true }))
|
|
94
|
+
.chain((values) => {
|
|
95
|
+
const literalValuesEither = values.chainMap((value) => value.toLiteral());
|
|
96
|
+
if (literalValuesEither.isLeft()) {
|
|
97
|
+
return literalValuesEither;
|
|
98
|
+
}
|
|
99
|
+
const literalValues = literalValuesEither.unsafeCoerce();
|
|
100
|
+
const nonUniqueLanguageIn = $languageIn ?? [];
|
|
101
|
+
if (nonUniqueLanguageIn.length === 0) {
|
|
102
|
+
return purify.Either.of(literalValues);
|
|
103
|
+
}
|
|
104
|
+
let uniqueLanguageIn;
|
|
105
|
+
if (nonUniqueLanguageIn.length === 1) {
|
|
106
|
+
uniqueLanguageIn = [nonUniqueLanguageIn[0]];
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
uniqueLanguageIn = [];
|
|
110
|
+
for (const languageIn of nonUniqueLanguageIn) {
|
|
111
|
+
if (uniqueLanguageIn.indexOf(languageIn) === -1) {
|
|
112
|
+
uniqueLanguageIn.push(languageIn);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// Return all literals for the first languageIn, then all literals for the second languageIn, etc.
|
|
117
|
+
// Within a languageIn the literals may be in any order.
|
|
118
|
+
let filteredLiteralValues;
|
|
119
|
+
for (const languageIn of uniqueLanguageIn) {
|
|
120
|
+
if (!filteredLiteralValues) {
|
|
121
|
+
filteredLiteralValues = literalValues.filter((value) => value.language === languageIn);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
filteredLiteralValues = filteredLiteralValues.concat(...literalValues
|
|
125
|
+
.filter((value) => value.language === languageIn)
|
|
126
|
+
.toArray());
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return purify.Either.of(filteredLiteralValues);
|
|
130
|
+
})
|
|
131
|
+
.map((values) => values.toArray())
|
|
132
|
+
.map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
|
|
133
|
+
object: valuesArray,
|
|
134
|
+
predicate: BaseShaclCoreShapeStatic.$properties.comments["identifier"],
|
|
135
|
+
subject: $resource,
|
|
136
|
+
}))
|
|
137
|
+
.chain((values) => values.head());
|
|
70
138
|
if (_commentsEither.isLeft()) {
|
|
71
139
|
return _commentsEither;
|
|
72
140
|
}
|
|
73
141
|
const comments = _commentsEither.unsafeCoerce();
|
|
74
|
-
const _datatypeEither = purify.Either.of(
|
|
75
|
-
.values(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
.
|
|
79
|
-
|
|
80
|
-
|
|
142
|
+
const _datatypeEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.datatype["identifier"], { unique: true }))
|
|
143
|
+
.chain((values) => values.chainMap((value) => value.toIri()))
|
|
144
|
+
.map((values) => values.length > 0
|
|
145
|
+
? values.map((value) => purify.Maybe.of(value))
|
|
146
|
+
: rdfjsResource.Resource.Values.fromValue({
|
|
147
|
+
object: purify.Maybe.empty(),
|
|
148
|
+
predicate: BaseShaclCoreShapeStatic.$properties.datatype["identifier"],
|
|
149
|
+
subject: $resource,
|
|
150
|
+
}))
|
|
151
|
+
.chain((values) => values.head());
|
|
81
152
|
if (_datatypeEither.isLeft()) {
|
|
82
153
|
return _datatypeEither;
|
|
83
154
|
}
|
|
84
155
|
const datatype = _datatypeEither.unsafeCoerce();
|
|
85
|
-
const _deactivatedEither = purify.Either.of(
|
|
86
|
-
.
|
|
87
|
-
.
|
|
88
|
-
.
|
|
89
|
-
.
|
|
156
|
+
const _deactivatedEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.deactivated["identifier"], { unique: true }))
|
|
157
|
+
.chain((values) => values.chainMap((value) => value.toBoolean()))
|
|
158
|
+
.map((values) => values.length > 0
|
|
159
|
+
? values.map((value) => purify.Maybe.of(value))
|
|
160
|
+
: rdfjsResource.Resource.Values.fromValue({
|
|
161
|
+
object: purify.Maybe.empty(),
|
|
162
|
+
predicate: BaseShaclCoreShapeStatic.$properties.deactivated["identifier"],
|
|
163
|
+
subject: $resource,
|
|
164
|
+
}))
|
|
165
|
+
.chain((values) => values.head());
|
|
90
166
|
if (_deactivatedEither.isLeft()) {
|
|
91
167
|
return _deactivatedEither;
|
|
92
168
|
}
|
|
93
169
|
const deactivated = _deactivatedEither.unsafeCoerce();
|
|
94
|
-
const _flagsEither = purify.Either.of([
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
.toMaybe()
|
|
104
|
-
.toList()),
|
|
105
|
-
]);
|
|
170
|
+
const _flagsEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.flags["identifier"], { unique: true }))
|
|
171
|
+
.chain((values) => values.chainMap((value) => value.toString()))
|
|
172
|
+
.map((values) => values.toArray())
|
|
173
|
+
.map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
|
|
174
|
+
object: valuesArray,
|
|
175
|
+
predicate: BaseShaclCoreShapeStatic.$properties.flags["identifier"],
|
|
176
|
+
subject: $resource,
|
|
177
|
+
}))
|
|
178
|
+
.chain((values) => values.head());
|
|
106
179
|
if (_flagsEither.isLeft()) {
|
|
107
180
|
return _flagsEither;
|
|
108
181
|
}
|
|
109
182
|
const flags = _flagsEither.unsafeCoerce();
|
|
110
|
-
const _hasValuesEither = purify.Either.of([
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
183
|
+
const _hasValuesEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.hasValues["identifier"], { unique: true }))
|
|
184
|
+
.chain((values) => values.chainMap((value) => purify.Either.of(value.toTerm()).chain((term) => {
|
|
185
|
+
switch (term.termType) {
|
|
186
|
+
case "Literal":
|
|
187
|
+
case "NamedNode":
|
|
188
|
+
return purify.Either.of(term);
|
|
189
|
+
default:
|
|
190
|
+
return purify.Left(new rdfjsResource.Resource.MistypedValueError({
|
|
191
|
+
actualValue: term,
|
|
192
|
+
expectedValueType: "(rdfjs.Literal | rdfjs.NamedNode)",
|
|
193
|
+
focusResource: $resource,
|
|
194
|
+
predicate: BaseShaclCoreShapeStatic.$properties.hasValues["identifier"],
|
|
195
|
+
}));
|
|
196
|
+
}
|
|
197
|
+
})))
|
|
198
|
+
.map((values) => values.toArray())
|
|
199
|
+
.map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
|
|
200
|
+
object: valuesArray,
|
|
201
|
+
predicate: BaseShaclCoreShapeStatic.$properties.hasValues["identifier"],
|
|
202
|
+
subject: $resource,
|
|
203
|
+
}))
|
|
204
|
+
.chain((values) => values.head());
|
|
122
205
|
if (_hasValuesEither.isLeft()) {
|
|
123
206
|
return _hasValuesEither;
|
|
124
207
|
}
|
|
125
208
|
const hasValues = _hasValuesEither.unsafeCoerce();
|
|
126
|
-
const _in_Either = purify.Either.of(
|
|
127
|
-
.values(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
.
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
.
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
209
|
+
const _in_Either = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.in_["identifier"], { unique: true }))
|
|
210
|
+
.chain((values) => values.chainMap((value) => value.toList()))
|
|
211
|
+
.chain((valueLists) => valueLists.chainMap((valueList) => purify.Either.of(rdfjsResource.Resource.Values.fromArray({
|
|
212
|
+
objects: valueList,
|
|
213
|
+
predicate: BaseShaclCoreShapeStatic.$properties.in_["identifier"],
|
|
214
|
+
subject: $resource,
|
|
215
|
+
})).chain((values) => values.chainMap((value) => purify.Either.of(value.toTerm()).chain((term) => {
|
|
216
|
+
switch (term.termType) {
|
|
217
|
+
case "Literal":
|
|
218
|
+
case "NamedNode":
|
|
219
|
+
return purify.Either.of(term);
|
|
220
|
+
default:
|
|
221
|
+
return purify.Left(new rdfjsResource.Resource.MistypedValueError({
|
|
222
|
+
actualValue: term,
|
|
223
|
+
expectedValueType: "(rdfjs.Literal | rdfjs.NamedNode)",
|
|
224
|
+
focusResource: $resource,
|
|
225
|
+
predicate: BaseShaclCoreShapeStatic.$properties.in_["identifier"],
|
|
226
|
+
}));
|
|
227
|
+
}
|
|
228
|
+
})))))
|
|
229
|
+
.map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
|
|
230
|
+
.map((values) => values.length > 0
|
|
231
|
+
? values.map((value) => purify.Maybe.of(value))
|
|
232
|
+
: rdfjsResource.Resource.Values.fromValue({
|
|
233
|
+
object: purify.Maybe.empty(),
|
|
234
|
+
predicate: BaseShaclCoreShapeStatic.$properties.in_["identifier"],
|
|
235
|
+
subject: $resource,
|
|
236
|
+
}))
|
|
237
|
+
.chain((values) => values.head());
|
|
139
238
|
if (_in_Either.isLeft()) {
|
|
140
239
|
return _in_Either;
|
|
141
240
|
}
|
|
142
241
|
const in_ = _in_Either.unsafeCoerce();
|
|
143
|
-
const _isDefinedByEither = purify.Either.of(
|
|
144
|
-
.
|
|
145
|
-
.
|
|
146
|
-
.
|
|
147
|
-
.
|
|
242
|
+
const _isDefinedByEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.isDefinedBy["identifier"], { unique: true }))
|
|
243
|
+
.chain((values) => values.chainMap((value) => value.toIdentifier()))
|
|
244
|
+
.map((values) => values.length > 0
|
|
245
|
+
? values.map((value) => purify.Maybe.of(value))
|
|
246
|
+
: rdfjsResource.Resource.Values.fromValue({
|
|
247
|
+
object: purify.Maybe.empty(),
|
|
248
|
+
predicate: BaseShaclCoreShapeStatic.$properties.isDefinedBy["identifier"],
|
|
249
|
+
subject: $resource,
|
|
250
|
+
}))
|
|
251
|
+
.chain((values) => values.head());
|
|
148
252
|
if (_isDefinedByEither.isLeft()) {
|
|
149
253
|
return _isDefinedByEither;
|
|
150
254
|
}
|
|
151
255
|
const isDefinedBy = _isDefinedByEither.unsafeCoerce();
|
|
152
|
-
const _labelsEither = purify.Either.of([
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
256
|
+
const _labelsEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.labels["identifier"], { unique: true }))
|
|
257
|
+
.chain((values) => {
|
|
258
|
+
const literalValuesEither = values.chainMap((value) => value.toLiteral());
|
|
259
|
+
if (literalValuesEither.isLeft()) {
|
|
260
|
+
return literalValuesEither;
|
|
261
|
+
}
|
|
262
|
+
const literalValues = literalValuesEither.unsafeCoerce();
|
|
263
|
+
const nonUniqueLanguageIn = $languageIn ?? [];
|
|
264
|
+
if (nonUniqueLanguageIn.length === 0) {
|
|
265
|
+
return purify.Either.of(literalValues);
|
|
266
|
+
}
|
|
267
|
+
let uniqueLanguageIn;
|
|
268
|
+
if (nonUniqueLanguageIn.length === 1) {
|
|
269
|
+
uniqueLanguageIn = [nonUniqueLanguageIn[0]];
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
uniqueLanguageIn = [];
|
|
273
|
+
for (const languageIn of nonUniqueLanguageIn) {
|
|
274
|
+
if (uniqueLanguageIn.indexOf(languageIn) === -1) {
|
|
275
|
+
uniqueLanguageIn.push(languageIn);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
// Return all literals for the first languageIn, then all literals for the second languageIn, etc.
|
|
280
|
+
// Within a languageIn the literals may be in any order.
|
|
281
|
+
let filteredLiteralValues;
|
|
282
|
+
for (const languageIn of uniqueLanguageIn) {
|
|
283
|
+
if (!filteredLiteralValues) {
|
|
284
|
+
filteredLiteralValues = literalValues.filter((value) => value.language === languageIn);
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
filteredLiteralValues = filteredLiteralValues.concat(...literalValues
|
|
288
|
+
.filter((value) => value.language === languageIn)
|
|
289
|
+
.toArray());
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
return purify.Either.of(filteredLiteralValues);
|
|
293
|
+
})
|
|
294
|
+
.map((values) => values.toArray())
|
|
295
|
+
.map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
|
|
296
|
+
object: valuesArray,
|
|
297
|
+
predicate: BaseShaclCoreShapeStatic.$properties.labels["identifier"],
|
|
298
|
+
subject: $resource,
|
|
299
|
+
}))
|
|
300
|
+
.chain((values) => values.head());
|
|
173
301
|
if (_labelsEither.isLeft()) {
|
|
174
302
|
return _labelsEither;
|
|
175
303
|
}
|
|
176
304
|
const labels = _labelsEither.unsafeCoerce();
|
|
177
|
-
const _languageInEither = purify.Either.of(
|
|
178
|
-
.
|
|
179
|
-
.
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
.
|
|
185
|
-
.
|
|
186
|
-
.
|
|
187
|
-
.
|
|
305
|
+
const _languageInEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.languageIn["identifier"], { unique: true }))
|
|
306
|
+
.chain((values) => values.chainMap((value) => value.toList()))
|
|
307
|
+
.chain((valueLists) => valueLists.chainMap((valueList) => purify.Either.of(rdfjsResource.Resource.Values.fromArray({
|
|
308
|
+
objects: valueList,
|
|
309
|
+
predicate: BaseShaclCoreShapeStatic.$properties.languageIn["identifier"],
|
|
310
|
+
subject: $resource,
|
|
311
|
+
})).chain((values) => values.chainMap((value) => value.toString()))))
|
|
312
|
+
.map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
|
|
313
|
+
.map((values) => values.length > 0
|
|
314
|
+
? values.map((value) => purify.Maybe.of(value))
|
|
315
|
+
: rdfjsResource.Resource.Values.fromValue({
|
|
316
|
+
object: purify.Maybe.empty(),
|
|
317
|
+
predicate: BaseShaclCoreShapeStatic.$properties.languageIn["identifier"],
|
|
318
|
+
subject: $resource,
|
|
319
|
+
}))
|
|
320
|
+
.chain((values) => values.head());
|
|
188
321
|
if (_languageInEither.isLeft()) {
|
|
189
322
|
return _languageInEither;
|
|
190
323
|
}
|
|
191
324
|
const languageIn = _languageInEither.unsafeCoerce();
|
|
192
|
-
const _maxCountEither = purify.Either.of(
|
|
193
|
-
.values(
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
.
|
|
197
|
-
|
|
198
|
-
|
|
325
|
+
const _maxCountEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.maxCount["identifier"], { unique: true }))
|
|
326
|
+
.chain((values) => values.chainMap((value) => value.toNumber()))
|
|
327
|
+
.map((values) => values.length > 0
|
|
328
|
+
? values.map((value) => purify.Maybe.of(value))
|
|
329
|
+
: rdfjsResource.Resource.Values.fromValue({
|
|
330
|
+
object: purify.Maybe.empty(),
|
|
331
|
+
predicate: BaseShaclCoreShapeStatic.$properties.maxCount["identifier"],
|
|
332
|
+
subject: $resource,
|
|
333
|
+
}))
|
|
334
|
+
.chain((values) => values.head());
|
|
199
335
|
if (_maxCountEither.isLeft()) {
|
|
200
336
|
return _maxCountEither;
|
|
201
337
|
}
|
|
202
338
|
const maxCount = _maxCountEither.unsafeCoerce();
|
|
203
|
-
const _maxExclusiveEither = purify.Either.of(
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
339
|
+
const _maxExclusiveEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.maxExclusive["identifier"], {
|
|
340
|
+
unique: true,
|
|
341
|
+
}))
|
|
342
|
+
.chain((values) => {
|
|
343
|
+
const literalValuesEither = values.chainMap((value) => value.toLiteral());
|
|
344
|
+
if (literalValuesEither.isLeft()) {
|
|
345
|
+
return literalValuesEither;
|
|
346
|
+
}
|
|
347
|
+
const literalValues = literalValuesEither.unsafeCoerce();
|
|
348
|
+
const nonUniqueLanguageIn = $languageIn ?? [];
|
|
349
|
+
if (nonUniqueLanguageIn.length === 0) {
|
|
350
|
+
return purify.Either.of(literalValues);
|
|
351
|
+
}
|
|
352
|
+
let uniqueLanguageIn;
|
|
353
|
+
if (nonUniqueLanguageIn.length === 1) {
|
|
354
|
+
uniqueLanguageIn = [nonUniqueLanguageIn[0]];
|
|
355
|
+
}
|
|
356
|
+
else {
|
|
357
|
+
uniqueLanguageIn = [];
|
|
358
|
+
for (const languageIn of nonUniqueLanguageIn) {
|
|
359
|
+
if (uniqueLanguageIn.indexOf(languageIn) === -1) {
|
|
360
|
+
uniqueLanguageIn.push(languageIn);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
// Return all literals for the first languageIn, then all literals for the second languageIn, etc.
|
|
365
|
+
// Within a languageIn the literals may be in any order.
|
|
366
|
+
let filteredLiteralValues;
|
|
367
|
+
for (const languageIn of uniqueLanguageIn) {
|
|
368
|
+
if (!filteredLiteralValues) {
|
|
369
|
+
filteredLiteralValues = literalValues.filter((value) => value.language === languageIn);
|
|
370
|
+
}
|
|
371
|
+
else {
|
|
372
|
+
filteredLiteralValues = filteredLiteralValues.concat(...literalValues
|
|
373
|
+
.filter((value) => value.language === languageIn)
|
|
374
|
+
.toArray());
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
return purify.Either.of(filteredLiteralValues);
|
|
215
378
|
})
|
|
216
|
-
.
|
|
217
|
-
.
|
|
218
|
-
.
|
|
379
|
+
.map((values) => values.length > 0
|
|
380
|
+
? values.map((value) => purify.Maybe.of(value))
|
|
381
|
+
: rdfjsResource.Resource.Values.fromValue({
|
|
382
|
+
object: purify.Maybe.empty(),
|
|
383
|
+
predicate: BaseShaclCoreShapeStatic.$properties.maxExclusive["identifier"],
|
|
384
|
+
subject: $resource,
|
|
385
|
+
}))
|
|
386
|
+
.chain((values) => values.head());
|
|
219
387
|
if (_maxExclusiveEither.isLeft()) {
|
|
220
388
|
return _maxExclusiveEither;
|
|
221
389
|
}
|
|
222
390
|
const maxExclusive = _maxExclusiveEither.unsafeCoerce();
|
|
223
|
-
const _maxInclusiveEither = purify.Either.of(
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
391
|
+
const _maxInclusiveEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.maxInclusive["identifier"], {
|
|
392
|
+
unique: true,
|
|
393
|
+
}))
|
|
394
|
+
.chain((values) => {
|
|
395
|
+
const literalValuesEither = values.chainMap((value) => value.toLiteral());
|
|
396
|
+
if (literalValuesEither.isLeft()) {
|
|
397
|
+
return literalValuesEither;
|
|
398
|
+
}
|
|
399
|
+
const literalValues = literalValuesEither.unsafeCoerce();
|
|
400
|
+
const nonUniqueLanguageIn = $languageIn ?? [];
|
|
401
|
+
if (nonUniqueLanguageIn.length === 0) {
|
|
402
|
+
return purify.Either.of(literalValues);
|
|
403
|
+
}
|
|
404
|
+
let uniqueLanguageIn;
|
|
405
|
+
if (nonUniqueLanguageIn.length === 1) {
|
|
406
|
+
uniqueLanguageIn = [nonUniqueLanguageIn[0]];
|
|
407
|
+
}
|
|
408
|
+
else {
|
|
409
|
+
uniqueLanguageIn = [];
|
|
410
|
+
for (const languageIn of nonUniqueLanguageIn) {
|
|
411
|
+
if (uniqueLanguageIn.indexOf(languageIn) === -1) {
|
|
412
|
+
uniqueLanguageIn.push(languageIn);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
// Return all literals for the first languageIn, then all literals for the second languageIn, etc.
|
|
417
|
+
// Within a languageIn the literals may be in any order.
|
|
418
|
+
let filteredLiteralValues;
|
|
419
|
+
for (const languageIn of uniqueLanguageIn) {
|
|
420
|
+
if (!filteredLiteralValues) {
|
|
421
|
+
filteredLiteralValues = literalValues.filter((value) => value.language === languageIn);
|
|
422
|
+
}
|
|
423
|
+
else {
|
|
424
|
+
filteredLiteralValues = filteredLiteralValues.concat(...literalValues
|
|
425
|
+
.filter((value) => value.language === languageIn)
|
|
426
|
+
.toArray());
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
return purify.Either.of(filteredLiteralValues);
|
|
235
430
|
})
|
|
236
|
-
.
|
|
237
|
-
.
|
|
238
|
-
.
|
|
431
|
+
.map((values) => values.length > 0
|
|
432
|
+
? values.map((value) => purify.Maybe.of(value))
|
|
433
|
+
: rdfjsResource.Resource.Values.fromValue({
|
|
434
|
+
object: purify.Maybe.empty(),
|
|
435
|
+
predicate: BaseShaclCoreShapeStatic.$properties.maxInclusive["identifier"],
|
|
436
|
+
subject: $resource,
|
|
437
|
+
}))
|
|
438
|
+
.chain((values) => values.head());
|
|
239
439
|
if (_maxInclusiveEither.isLeft()) {
|
|
240
440
|
return _maxInclusiveEither;
|
|
241
441
|
}
|
|
242
442
|
const maxInclusive = _maxInclusiveEither.unsafeCoerce();
|
|
243
|
-
const _maxLengthEither = purify.Either.of(
|
|
244
|
-
.values(
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
.
|
|
248
|
-
|
|
249
|
-
|
|
443
|
+
const _maxLengthEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.maxLength["identifier"], { unique: true }))
|
|
444
|
+
.chain((values) => values.chainMap((value) => value.toNumber()))
|
|
445
|
+
.map((values) => values.length > 0
|
|
446
|
+
? values.map((value) => purify.Maybe.of(value))
|
|
447
|
+
: rdfjsResource.Resource.Values.fromValue({
|
|
448
|
+
object: purify.Maybe.empty(),
|
|
449
|
+
predicate: BaseShaclCoreShapeStatic.$properties.maxLength["identifier"],
|
|
450
|
+
subject: $resource,
|
|
451
|
+
}))
|
|
452
|
+
.chain((values) => values.head());
|
|
250
453
|
if (_maxLengthEither.isLeft()) {
|
|
251
454
|
return _maxLengthEither;
|
|
252
455
|
}
|
|
253
456
|
const maxLength = _maxLengthEither.unsafeCoerce();
|
|
254
|
-
const _minCountEither = purify.Either.of(
|
|
255
|
-
.values(
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
.
|
|
259
|
-
|
|
260
|
-
|
|
457
|
+
const _minCountEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.minCount["identifier"], { unique: true }))
|
|
458
|
+
.chain((values) => values.chainMap((value) => value.toNumber()))
|
|
459
|
+
.map((values) => values.length > 0
|
|
460
|
+
? values.map((value) => purify.Maybe.of(value))
|
|
461
|
+
: rdfjsResource.Resource.Values.fromValue({
|
|
462
|
+
object: purify.Maybe.empty(),
|
|
463
|
+
predicate: BaseShaclCoreShapeStatic.$properties.minCount["identifier"],
|
|
464
|
+
subject: $resource,
|
|
465
|
+
}))
|
|
466
|
+
.chain((values) => values.head());
|
|
261
467
|
if (_minCountEither.isLeft()) {
|
|
262
468
|
return _minCountEither;
|
|
263
469
|
}
|
|
264
470
|
const minCount = _minCountEither.unsafeCoerce();
|
|
265
|
-
const _minExclusiveEither = purify.Either.of(
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
471
|
+
const _minExclusiveEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.minExclusive["identifier"], {
|
|
472
|
+
unique: true,
|
|
473
|
+
}))
|
|
474
|
+
.chain((values) => {
|
|
475
|
+
const literalValuesEither = values.chainMap((value) => value.toLiteral());
|
|
476
|
+
if (literalValuesEither.isLeft()) {
|
|
477
|
+
return literalValuesEither;
|
|
478
|
+
}
|
|
479
|
+
const literalValues = literalValuesEither.unsafeCoerce();
|
|
480
|
+
const nonUniqueLanguageIn = $languageIn ?? [];
|
|
481
|
+
if (nonUniqueLanguageIn.length === 0) {
|
|
482
|
+
return purify.Either.of(literalValues);
|
|
483
|
+
}
|
|
484
|
+
let uniqueLanguageIn;
|
|
485
|
+
if (nonUniqueLanguageIn.length === 1) {
|
|
486
|
+
uniqueLanguageIn = [nonUniqueLanguageIn[0]];
|
|
487
|
+
}
|
|
488
|
+
else {
|
|
489
|
+
uniqueLanguageIn = [];
|
|
490
|
+
for (const languageIn of nonUniqueLanguageIn) {
|
|
491
|
+
if (uniqueLanguageIn.indexOf(languageIn) === -1) {
|
|
492
|
+
uniqueLanguageIn.push(languageIn);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
// Return all literals for the first languageIn, then all literals for the second languageIn, etc.
|
|
497
|
+
// Within a languageIn the literals may be in any order.
|
|
498
|
+
let filteredLiteralValues;
|
|
499
|
+
for (const languageIn of uniqueLanguageIn) {
|
|
500
|
+
if (!filteredLiteralValues) {
|
|
501
|
+
filteredLiteralValues = literalValues.filter((value) => value.language === languageIn);
|
|
502
|
+
}
|
|
503
|
+
else {
|
|
504
|
+
filteredLiteralValues = filteredLiteralValues.concat(...literalValues
|
|
505
|
+
.filter((value) => value.language === languageIn)
|
|
506
|
+
.toArray());
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
return purify.Either.of(filteredLiteralValues);
|
|
277
510
|
})
|
|
278
|
-
.
|
|
279
|
-
.
|
|
280
|
-
.
|
|
511
|
+
.map((values) => values.length > 0
|
|
512
|
+
? values.map((value) => purify.Maybe.of(value))
|
|
513
|
+
: rdfjsResource.Resource.Values.fromValue({
|
|
514
|
+
object: purify.Maybe.empty(),
|
|
515
|
+
predicate: BaseShaclCoreShapeStatic.$properties.minExclusive["identifier"],
|
|
516
|
+
subject: $resource,
|
|
517
|
+
}))
|
|
518
|
+
.chain((values) => values.head());
|
|
281
519
|
if (_minExclusiveEither.isLeft()) {
|
|
282
520
|
return _minExclusiveEither;
|
|
283
521
|
}
|
|
284
522
|
const minExclusive = _minExclusiveEither.unsafeCoerce();
|
|
285
|
-
const _minInclusiveEither = purify.Either.of(
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
523
|
+
const _minInclusiveEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.minInclusive["identifier"], {
|
|
524
|
+
unique: true,
|
|
525
|
+
}))
|
|
526
|
+
.chain((values) => {
|
|
527
|
+
const literalValuesEither = values.chainMap((value) => value.toLiteral());
|
|
528
|
+
if (literalValuesEither.isLeft()) {
|
|
529
|
+
return literalValuesEither;
|
|
530
|
+
}
|
|
531
|
+
const literalValues = literalValuesEither.unsafeCoerce();
|
|
532
|
+
const nonUniqueLanguageIn = $languageIn ?? [];
|
|
533
|
+
if (nonUniqueLanguageIn.length === 0) {
|
|
534
|
+
return purify.Either.of(literalValues);
|
|
535
|
+
}
|
|
536
|
+
let uniqueLanguageIn;
|
|
537
|
+
if (nonUniqueLanguageIn.length === 1) {
|
|
538
|
+
uniqueLanguageIn = [nonUniqueLanguageIn[0]];
|
|
539
|
+
}
|
|
540
|
+
else {
|
|
541
|
+
uniqueLanguageIn = [];
|
|
542
|
+
for (const languageIn of nonUniqueLanguageIn) {
|
|
543
|
+
if (uniqueLanguageIn.indexOf(languageIn) === -1) {
|
|
544
|
+
uniqueLanguageIn.push(languageIn);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
// Return all literals for the first languageIn, then all literals for the second languageIn, etc.
|
|
549
|
+
// Within a languageIn the literals may be in any order.
|
|
550
|
+
let filteredLiteralValues;
|
|
551
|
+
for (const languageIn of uniqueLanguageIn) {
|
|
552
|
+
if (!filteredLiteralValues) {
|
|
553
|
+
filteredLiteralValues = literalValues.filter((value) => value.language === languageIn);
|
|
554
|
+
}
|
|
555
|
+
else {
|
|
556
|
+
filteredLiteralValues = filteredLiteralValues.concat(...literalValues
|
|
557
|
+
.filter((value) => value.language === languageIn)
|
|
558
|
+
.toArray());
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
return purify.Either.of(filteredLiteralValues);
|
|
297
562
|
})
|
|
298
|
-
.
|
|
299
|
-
.
|
|
300
|
-
.
|
|
563
|
+
.map((values) => values.length > 0
|
|
564
|
+
? values.map((value) => purify.Maybe.of(value))
|
|
565
|
+
: rdfjsResource.Resource.Values.fromValue({
|
|
566
|
+
object: purify.Maybe.empty(),
|
|
567
|
+
predicate: BaseShaclCoreShapeStatic.$properties.minInclusive["identifier"],
|
|
568
|
+
subject: $resource,
|
|
569
|
+
}))
|
|
570
|
+
.chain((values) => values.head());
|
|
301
571
|
if (_minInclusiveEither.isLeft()) {
|
|
302
572
|
return _minInclusiveEither;
|
|
303
573
|
}
|
|
304
574
|
const minInclusive = _minInclusiveEither.unsafeCoerce();
|
|
305
|
-
const _minLengthEither = purify.Either.of(
|
|
306
|
-
.values(
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
.
|
|
310
|
-
|
|
311
|
-
|
|
575
|
+
const _minLengthEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.minLength["identifier"], { unique: true }))
|
|
576
|
+
.chain((values) => values.chainMap((value) => value.toNumber()))
|
|
577
|
+
.map((values) => values.length > 0
|
|
578
|
+
? values.map((value) => purify.Maybe.of(value))
|
|
579
|
+
: rdfjsResource.Resource.Values.fromValue({
|
|
580
|
+
object: purify.Maybe.empty(),
|
|
581
|
+
predicate: BaseShaclCoreShapeStatic.$properties.minLength["identifier"],
|
|
582
|
+
subject: $resource,
|
|
583
|
+
}))
|
|
584
|
+
.chain((values) => values.head());
|
|
312
585
|
if (_minLengthEither.isLeft()) {
|
|
313
586
|
return _minLengthEither;
|
|
314
587
|
}
|
|
315
588
|
const minLength = _minLengthEither.unsafeCoerce();
|
|
316
|
-
const _nodeKindEither = purify.Either.of(
|
|
317
|
-
.values(
|
|
318
|
-
unique: true,
|
|
319
|
-
})
|
|
320
|
-
.head()
|
|
321
|
-
.chain((_value) => _value.toIri().chain((iri) => {
|
|
589
|
+
const _nodeKindEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.nodeKind["identifier"], { unique: true }))
|
|
590
|
+
.chain((values) => values.chainMap((value) => value.toIri().chain((iri) => {
|
|
322
591
|
switch (iri.value) {
|
|
323
592
|
case "http://www.w3.org/ns/shacl#BlankNode":
|
|
324
593
|
return purify.Either.of(iri);
|
|
@@ -336,110 +605,102 @@ export var BaseShaclCoreShape;
|
|
|
336
605
|
return purify.Left(new rdfjsResource.Resource.MistypedValueError({
|
|
337
606
|
actualValue: iri,
|
|
338
607
|
expectedValueType: 'rdfjs.NamedNode<"http://www.w3.org/ns/shacl#BlankNode" | "http://www.w3.org/ns/shacl#BlankNodeOrIRI" | "http://www.w3.org/ns/shacl#BlankNodeOrLiteral" | "http://www.w3.org/ns/shacl#IRI" | "http://www.w3.org/ns/shacl#IRIOrLiteral" | "http://www.w3.org/ns/shacl#Literal">',
|
|
339
|
-
focusResource:
|
|
340
|
-
predicate:
|
|
608
|
+
focusResource: $resource,
|
|
609
|
+
predicate: BaseShaclCoreShapeStatic.$properties.nodeKind["identifier"],
|
|
341
610
|
}));
|
|
342
611
|
}
|
|
343
|
-
}))
|
|
344
|
-
.
|
|
612
|
+
})))
|
|
613
|
+
.map((values) => values.length > 0
|
|
614
|
+
? values.map((value) => purify.Maybe.of(value))
|
|
615
|
+
: rdfjsResource.Resource.Values.fromValue({
|
|
616
|
+
object: purify.Maybe.empty(),
|
|
617
|
+
predicate: BaseShaclCoreShapeStatic.$properties.nodeKind["identifier"],
|
|
618
|
+
subject: $resource,
|
|
619
|
+
}))
|
|
620
|
+
.chain((values) => values.head());
|
|
345
621
|
if (_nodeKindEither.isLeft()) {
|
|
346
622
|
return _nodeKindEither;
|
|
347
623
|
}
|
|
348
624
|
const nodeKind = _nodeKindEither.unsafeCoerce();
|
|
349
|
-
const _nodesEither = purify.Either.of([
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
.toMaybe()
|
|
359
|
-
.toList()),
|
|
360
|
-
]);
|
|
625
|
+
const _nodesEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.nodes["identifier"], { unique: true }))
|
|
626
|
+
.chain((values) => values.chainMap((value) => value.toIdentifier()))
|
|
627
|
+
.map((values) => values.toArray())
|
|
628
|
+
.map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
|
|
629
|
+
object: valuesArray,
|
|
630
|
+
predicate: BaseShaclCoreShapeStatic.$properties.nodes["identifier"],
|
|
631
|
+
subject: $resource,
|
|
632
|
+
}))
|
|
633
|
+
.chain((values) => values.head());
|
|
361
634
|
if (_nodesEither.isLeft()) {
|
|
362
635
|
return _nodesEither;
|
|
363
636
|
}
|
|
364
637
|
const nodes = _nodesEither.unsafeCoerce();
|
|
365
|
-
const _notEither = purify.Either.of([
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
.toMaybe()
|
|
375
|
-
.toList()),
|
|
376
|
-
]);
|
|
638
|
+
const _notEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.not["identifier"], { unique: true }))
|
|
639
|
+
.chain((values) => values.chainMap((value) => value.toIdentifier()))
|
|
640
|
+
.map((values) => values.toArray())
|
|
641
|
+
.map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
|
|
642
|
+
object: valuesArray,
|
|
643
|
+
predicate: BaseShaclCoreShapeStatic.$properties.not["identifier"],
|
|
644
|
+
subject: $resource,
|
|
645
|
+
}))
|
|
646
|
+
.chain((values) => values.head());
|
|
377
647
|
if (_notEither.isLeft()) {
|
|
378
648
|
return _notEither;
|
|
379
649
|
}
|
|
380
650
|
const not = _notEither.unsafeCoerce();
|
|
381
|
-
const _orEither = purify.Either.of([
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
.toMaybe()
|
|
397
|
-
.toList()),
|
|
398
|
-
]);
|
|
651
|
+
const _orEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.or["identifier"], { unique: true }))
|
|
652
|
+
.chain((values) => values.chainMap((value) => value.toList()))
|
|
653
|
+
.chain((valueLists) => valueLists.chainMap((valueList) => purify.Either.of(rdfjsResource.Resource.Values.fromArray({
|
|
654
|
+
objects: valueList,
|
|
655
|
+
predicate: BaseShaclCoreShapeStatic.$properties.or["identifier"],
|
|
656
|
+
subject: $resource,
|
|
657
|
+
})).chain((values) => values.chainMap((value) => value.toIdentifier()))))
|
|
658
|
+
.map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
|
|
659
|
+
.map((values) => values.toArray())
|
|
660
|
+
.map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
|
|
661
|
+
object: valuesArray,
|
|
662
|
+
predicate: BaseShaclCoreShapeStatic.$properties.or["identifier"],
|
|
663
|
+
subject: $resource,
|
|
664
|
+
}))
|
|
665
|
+
.chain((values) => values.head());
|
|
399
666
|
if (_orEither.isLeft()) {
|
|
400
667
|
return _orEither;
|
|
401
668
|
}
|
|
402
669
|
const or = _orEither.unsafeCoerce();
|
|
403
|
-
const _patternsEither = purify.Either.of([
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
.toMaybe()
|
|
413
|
-
.toList()),
|
|
414
|
-
]);
|
|
670
|
+
const _patternsEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.patterns["identifier"], { unique: true }))
|
|
671
|
+
.chain((values) => values.chainMap((value) => value.toString()))
|
|
672
|
+
.map((values) => values.toArray())
|
|
673
|
+
.map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
|
|
674
|
+
object: valuesArray,
|
|
675
|
+
predicate: BaseShaclCoreShapeStatic.$properties.patterns["identifier"],
|
|
676
|
+
subject: $resource,
|
|
677
|
+
}))
|
|
678
|
+
.chain((values) => values.head());
|
|
415
679
|
if (_patternsEither.isLeft()) {
|
|
416
680
|
return _patternsEither;
|
|
417
681
|
}
|
|
418
682
|
const patterns = _patternsEither.unsafeCoerce();
|
|
419
|
-
const _xoneEither = purify.Either.of([
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
.toMaybe()
|
|
435
|
-
.toList()),
|
|
436
|
-
]);
|
|
683
|
+
const _xoneEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.xone["identifier"], { unique: true }))
|
|
684
|
+
.chain((values) => values.chainMap((value) => value.toList()))
|
|
685
|
+
.chain((valueLists) => valueLists.chainMap((valueList) => purify.Either.of(rdfjsResource.Resource.Values.fromArray({
|
|
686
|
+
objects: valueList,
|
|
687
|
+
predicate: BaseShaclCoreShapeStatic.$properties.xone["identifier"],
|
|
688
|
+
subject: $resource,
|
|
689
|
+
})).chain((values) => values.chainMap((value) => value.toIdentifier()))))
|
|
690
|
+
.map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
|
|
691
|
+
.map((values) => values.toArray())
|
|
692
|
+
.map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
|
|
693
|
+
object: valuesArray,
|
|
694
|
+
predicate: BaseShaclCoreShapeStatic.$properties.xone["identifier"],
|
|
695
|
+
subject: $resource,
|
|
696
|
+
}))
|
|
697
|
+
.chain((values) => values.head());
|
|
437
698
|
if (_xoneEither.isLeft()) {
|
|
438
699
|
return _xoneEither;
|
|
439
700
|
}
|
|
440
701
|
const xone = _xoneEither.unsafeCoerce();
|
|
441
702
|
return purify.Either.of({
|
|
442
|
-
identifier,
|
|
703
|
+
$identifier,
|
|
443
704
|
and,
|
|
444
705
|
classes,
|
|
445
706
|
comments,
|
|
@@ -467,150 +728,438 @@ export var BaseShaclCoreShape;
|
|
|
467
728
|
xone,
|
|
468
729
|
});
|
|
469
730
|
}
|
|
470
|
-
|
|
471
|
-
|
|
731
|
+
BaseShaclCoreShapeStatic.$propertiesFromRdf = $propertiesFromRdf;
|
|
732
|
+
function $toRdf(_baseShaclCoreShape, options) {
|
|
733
|
+
const mutateGraph = options?.mutateGraph;
|
|
734
|
+
const resourceSet = options?.resourceSet ??
|
|
735
|
+
new rdfjsResource.MutableResourceSet({
|
|
736
|
+
dataFactory,
|
|
737
|
+
dataset: datasetFactory.dataset(),
|
|
738
|
+
});
|
|
739
|
+
const resource = resourceSet.mutableResource(_baseShaclCoreShape.$identifier, { mutateGraph });
|
|
740
|
+
resource.add(BaseShaclCoreShapeStatic.$properties.and["identifier"], _baseShaclCoreShape.and.map((item) => item.length > 0
|
|
741
|
+
? item.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
|
|
742
|
+
if (itemIndex === 0) {
|
|
743
|
+
currentSubListResource = listResource;
|
|
744
|
+
}
|
|
745
|
+
else {
|
|
746
|
+
const newSubListResource = resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph });
|
|
747
|
+
currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier);
|
|
748
|
+
currentSubListResource = newSubListResource;
|
|
749
|
+
}
|
|
750
|
+
currentSubListResource.add($RdfVocabularies.rdf.first, item);
|
|
751
|
+
if (itemIndex + 1 === list.length) {
|
|
752
|
+
currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil);
|
|
753
|
+
}
|
|
754
|
+
return { currentSubListResource, listResource };
|
|
755
|
+
}, {
|
|
756
|
+
currentSubListResource: null,
|
|
757
|
+
listResource: resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph }),
|
|
758
|
+
}).listResource.identifier
|
|
759
|
+
: $RdfVocabularies.rdf.nil));
|
|
760
|
+
resource.add(BaseShaclCoreShapeStatic.$properties.classes["identifier"], _baseShaclCoreShape.classes.map((item) => item));
|
|
761
|
+
resource.add(BaseShaclCoreShapeStatic.$properties.comments["identifier"], _baseShaclCoreShape.comments.map((item) => item));
|
|
762
|
+
resource.add(BaseShaclCoreShapeStatic.$properties.datatype["identifier"], _baseShaclCoreShape.datatype);
|
|
763
|
+
resource.add(BaseShaclCoreShapeStatic.$properties.deactivated["identifier"], _baseShaclCoreShape.deactivated);
|
|
764
|
+
resource.add(BaseShaclCoreShapeStatic.$properties.flags["identifier"], _baseShaclCoreShape.flags.map((item) => item));
|
|
765
|
+
resource.add(BaseShaclCoreShapeStatic.$properties.hasValues["identifier"], _baseShaclCoreShape.hasValues.map((item) => item));
|
|
766
|
+
resource.add(BaseShaclCoreShapeStatic.$properties.in_["identifier"], _baseShaclCoreShape.in_.map((value) => value.length > 0
|
|
767
|
+
? value.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
|
|
768
|
+
if (itemIndex === 0) {
|
|
769
|
+
currentSubListResource = listResource;
|
|
770
|
+
}
|
|
771
|
+
else {
|
|
772
|
+
const newSubListResource = resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph });
|
|
773
|
+
currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier);
|
|
774
|
+
currentSubListResource = newSubListResource;
|
|
775
|
+
}
|
|
776
|
+
currentSubListResource.add($RdfVocabularies.rdf.first, item);
|
|
777
|
+
if (itemIndex + 1 === list.length) {
|
|
778
|
+
currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil);
|
|
779
|
+
}
|
|
780
|
+
return { currentSubListResource, listResource };
|
|
781
|
+
}, {
|
|
782
|
+
currentSubListResource: null,
|
|
783
|
+
listResource: resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph }),
|
|
784
|
+
}).listResource.identifier
|
|
785
|
+
: $RdfVocabularies.rdf.nil));
|
|
786
|
+
resource.add(BaseShaclCoreShapeStatic.$properties.isDefinedBy["identifier"], _baseShaclCoreShape.isDefinedBy);
|
|
787
|
+
resource.add(BaseShaclCoreShapeStatic.$properties.labels["identifier"], _baseShaclCoreShape.labels.map((item) => item));
|
|
788
|
+
resource.add(BaseShaclCoreShapeStatic.$properties.languageIn["identifier"], _baseShaclCoreShape.languageIn.map((value) => value.length > 0
|
|
789
|
+
? value.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
|
|
790
|
+
if (itemIndex === 0) {
|
|
791
|
+
currentSubListResource = listResource;
|
|
792
|
+
}
|
|
793
|
+
else {
|
|
794
|
+
const newSubListResource = resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph });
|
|
795
|
+
currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier);
|
|
796
|
+
currentSubListResource = newSubListResource;
|
|
797
|
+
}
|
|
798
|
+
currentSubListResource.add($RdfVocabularies.rdf.first, item);
|
|
799
|
+
if (itemIndex + 1 === list.length) {
|
|
800
|
+
currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil);
|
|
801
|
+
}
|
|
802
|
+
return { currentSubListResource, listResource };
|
|
803
|
+
}, {
|
|
804
|
+
currentSubListResource: null,
|
|
805
|
+
listResource: resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph }),
|
|
806
|
+
}).listResource.identifier
|
|
807
|
+
: $RdfVocabularies.rdf.nil));
|
|
808
|
+
resource.add(BaseShaclCoreShapeStatic.$properties.maxCount["identifier"], _baseShaclCoreShape.maxCount);
|
|
809
|
+
resource.add(BaseShaclCoreShapeStatic.$properties.maxExclusive["identifier"], _baseShaclCoreShape.maxExclusive);
|
|
810
|
+
resource.add(BaseShaclCoreShapeStatic.$properties.maxInclusive["identifier"], _baseShaclCoreShape.maxInclusive);
|
|
811
|
+
resource.add(BaseShaclCoreShapeStatic.$properties.maxLength["identifier"], _baseShaclCoreShape.maxLength);
|
|
812
|
+
resource.add(BaseShaclCoreShapeStatic.$properties.minCount["identifier"], _baseShaclCoreShape.minCount);
|
|
813
|
+
resource.add(BaseShaclCoreShapeStatic.$properties.minExclusive["identifier"], _baseShaclCoreShape.minExclusive);
|
|
814
|
+
resource.add(BaseShaclCoreShapeStatic.$properties.minInclusive["identifier"], _baseShaclCoreShape.minInclusive);
|
|
815
|
+
resource.add(BaseShaclCoreShapeStatic.$properties.minLength["identifier"], _baseShaclCoreShape.minLength);
|
|
816
|
+
resource.add(BaseShaclCoreShapeStatic.$properties.nodeKind["identifier"], _baseShaclCoreShape.nodeKind);
|
|
817
|
+
resource.add(BaseShaclCoreShapeStatic.$properties.nodes["identifier"], _baseShaclCoreShape.nodes.map((item) => item));
|
|
818
|
+
resource.add(BaseShaclCoreShapeStatic.$properties.not["identifier"], _baseShaclCoreShape.not.map((item) => item));
|
|
819
|
+
resource.add(BaseShaclCoreShapeStatic.$properties.or["identifier"], _baseShaclCoreShape.or.map((item) => item.length > 0
|
|
820
|
+
? item.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
|
|
821
|
+
if (itemIndex === 0) {
|
|
822
|
+
currentSubListResource = listResource;
|
|
823
|
+
}
|
|
824
|
+
else {
|
|
825
|
+
const newSubListResource = resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph });
|
|
826
|
+
currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier);
|
|
827
|
+
currentSubListResource = newSubListResource;
|
|
828
|
+
}
|
|
829
|
+
currentSubListResource.add($RdfVocabularies.rdf.first, item);
|
|
830
|
+
if (itemIndex + 1 === list.length) {
|
|
831
|
+
currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil);
|
|
832
|
+
}
|
|
833
|
+
return { currentSubListResource, listResource };
|
|
834
|
+
}, {
|
|
835
|
+
currentSubListResource: null,
|
|
836
|
+
listResource: resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph }),
|
|
837
|
+
}).listResource.identifier
|
|
838
|
+
: $RdfVocabularies.rdf.nil));
|
|
839
|
+
resource.add(BaseShaclCoreShapeStatic.$properties.patterns["identifier"], _baseShaclCoreShape.patterns.map((item) => item));
|
|
840
|
+
resource.add(BaseShaclCoreShapeStatic.$properties.xone["identifier"], _baseShaclCoreShape.xone.map((item) => item.length > 0
|
|
841
|
+
? item.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
|
|
842
|
+
if (itemIndex === 0) {
|
|
843
|
+
currentSubListResource = listResource;
|
|
844
|
+
}
|
|
845
|
+
else {
|
|
846
|
+
const newSubListResource = resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph });
|
|
847
|
+
currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier);
|
|
848
|
+
currentSubListResource = newSubListResource;
|
|
849
|
+
}
|
|
850
|
+
currentSubListResource.add($RdfVocabularies.rdf.first, item);
|
|
851
|
+
if (itemIndex + 1 === list.length) {
|
|
852
|
+
currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil);
|
|
853
|
+
}
|
|
854
|
+
return { currentSubListResource, listResource };
|
|
855
|
+
}, {
|
|
856
|
+
currentSubListResource: null,
|
|
857
|
+
listResource: resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph }),
|
|
858
|
+
}).listResource.identifier
|
|
859
|
+
: $RdfVocabularies.rdf.nil));
|
|
860
|
+
return resource;
|
|
861
|
+
}
|
|
862
|
+
BaseShaclCoreShapeStatic.$toRdf = $toRdf;
|
|
863
|
+
BaseShaclCoreShapeStatic.$properties = {
|
|
864
|
+
and: {
|
|
865
|
+
identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#and"),
|
|
866
|
+
},
|
|
867
|
+
classes: {
|
|
868
|
+
identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#class"),
|
|
869
|
+
},
|
|
870
|
+
comments: {
|
|
871
|
+
identifier: dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#comment"),
|
|
872
|
+
},
|
|
873
|
+
datatype: {
|
|
874
|
+
identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#datatype"),
|
|
875
|
+
},
|
|
876
|
+
deactivated: {
|
|
877
|
+
identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#deactivated"),
|
|
878
|
+
},
|
|
879
|
+
flags: {
|
|
880
|
+
identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#flags"),
|
|
881
|
+
},
|
|
882
|
+
hasValues: {
|
|
883
|
+
identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#hasValue"),
|
|
884
|
+
},
|
|
885
|
+
in_: { identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#in") },
|
|
886
|
+
isDefinedBy: {
|
|
887
|
+
identifier: dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#isDefinedBy"),
|
|
888
|
+
},
|
|
889
|
+
labels: {
|
|
890
|
+
identifier: dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#label"),
|
|
891
|
+
},
|
|
892
|
+
languageIn: {
|
|
893
|
+
identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#languageIn"),
|
|
894
|
+
},
|
|
895
|
+
maxCount: {
|
|
896
|
+
identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#maxCount"),
|
|
897
|
+
},
|
|
898
|
+
maxExclusive: {
|
|
899
|
+
identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#maxExclusive"),
|
|
900
|
+
},
|
|
901
|
+
maxInclusive: {
|
|
902
|
+
identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#maxInclusive"),
|
|
903
|
+
},
|
|
904
|
+
maxLength: {
|
|
905
|
+
identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#maxLength"),
|
|
906
|
+
},
|
|
907
|
+
minCount: {
|
|
908
|
+
identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#minCount"),
|
|
909
|
+
},
|
|
910
|
+
minExclusive: {
|
|
911
|
+
identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#minExclusive"),
|
|
912
|
+
},
|
|
913
|
+
minInclusive: {
|
|
914
|
+
identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#minInclusive"),
|
|
915
|
+
},
|
|
916
|
+
minLength: {
|
|
917
|
+
identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#minLength"),
|
|
918
|
+
},
|
|
919
|
+
nodeKind: {
|
|
920
|
+
identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#nodeKind"),
|
|
921
|
+
},
|
|
922
|
+
nodes: {
|
|
923
|
+
identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#node"),
|
|
924
|
+
},
|
|
925
|
+
not: {
|
|
926
|
+
identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#not"),
|
|
927
|
+
},
|
|
928
|
+
or: { identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#or") },
|
|
929
|
+
patterns: {
|
|
930
|
+
identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#pattern"),
|
|
931
|
+
},
|
|
932
|
+
xone: {
|
|
933
|
+
identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#xone"),
|
|
934
|
+
},
|
|
935
|
+
};
|
|
936
|
+
})(BaseShaclCoreShapeStatic || (BaseShaclCoreShapeStatic = {}));
|
|
472
937
|
export var ShaclCorePropertyShape;
|
|
473
938
|
(function (ShaclCorePropertyShape) {
|
|
474
|
-
|
|
939
|
+
ShaclCorePropertyShape.$fromRdfType = dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyShape");
|
|
940
|
+
ShaclCorePropertyShape.$Identifier = BaseShaclCoreShapeStatic.$Identifier;
|
|
941
|
+
function $fromRdf(resource, options) {
|
|
942
|
+
let { ignoreRdfType = false, languageIn, objectSet, ...context } = options ?? {};
|
|
943
|
+
if (!objectSet) {
|
|
944
|
+
objectSet = new $RdfjsDatasetObjectSet({ dataset: resource.dataset });
|
|
945
|
+
}
|
|
946
|
+
return ShaclCorePropertyShape.$propertiesFromRdf({
|
|
947
|
+
...context,
|
|
948
|
+
ignoreRdfType,
|
|
949
|
+
languageIn,
|
|
950
|
+
objectSet,
|
|
951
|
+
resource,
|
|
952
|
+
});
|
|
953
|
+
}
|
|
954
|
+
ShaclCorePropertyShape.$fromRdf = $fromRdf;
|
|
955
|
+
function $propertiesFromRdf({ ignoreRdfType: $ignoreRdfType, languageIn: $languageIn, objectSet: $objectSet, resource: $resource,
|
|
475
956
|
// @ts-ignore
|
|
476
|
-
|
|
477
|
-
const
|
|
478
|
-
|
|
957
|
+
...$context }) {
|
|
958
|
+
const $super0Either = BaseShaclCoreShapeStatic.$propertiesFromRdf({
|
|
959
|
+
...$context,
|
|
479
960
|
ignoreRdfType: true,
|
|
480
|
-
languageIn:
|
|
481
|
-
|
|
961
|
+
languageIn: $languageIn,
|
|
962
|
+
objectSet: $objectSet,
|
|
963
|
+
resource: $resource,
|
|
482
964
|
});
|
|
483
|
-
if (
|
|
484
|
-
return
|
|
485
|
-
}
|
|
486
|
-
const
|
|
487
|
-
if (
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
predicate: dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyShape"),
|
|
493
|
-
}));
|
|
965
|
+
if ($super0Either.isLeft()) {
|
|
966
|
+
return $super0Either;
|
|
967
|
+
}
|
|
968
|
+
const $super0 = $super0Either.unsafeCoerce();
|
|
969
|
+
if (!$ignoreRdfType && !$resource.isInstanceOf(ShaclCorePropertyShape.$fromRdfType)) {
|
|
970
|
+
return $resource
|
|
971
|
+
.value($RdfVocabularies.rdf.type)
|
|
972
|
+
.chain((actualRdfType) => actualRdfType.toIri())
|
|
973
|
+
.chain((actualRdfType) => purify.Left(new Error(`${rdfjsResource.Resource.Identifier.toString($resource.identifier)} has unexpected RDF type (actual: ${actualRdfType.value}, expected: http://www.w3.org/ns/shacl#PropertyShape)`)));
|
|
494
974
|
}
|
|
495
|
-
const identifier =
|
|
496
|
-
const type = "ShaclCorePropertyShape";
|
|
497
|
-
const _defaultValueEither = purify.Either.of(
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
.chain((
|
|
501
|
-
.
|
|
975
|
+
const $identifier = $resource.identifier;
|
|
976
|
+
const $type = "ShaclCorePropertyShape";
|
|
977
|
+
const _defaultValueEither = purify.Either.of($resource.values(ShaclCorePropertyShape.$properties.defaultValue["identifier"], {
|
|
978
|
+
unique: true,
|
|
979
|
+
}))
|
|
980
|
+
.chain((values) => values.chainMap((value) => purify.Either.of(value.toTerm()).chain((term) => {
|
|
981
|
+
switch (term.termType) {
|
|
982
|
+
case "Literal":
|
|
983
|
+
case "NamedNode":
|
|
984
|
+
return purify.Either.of(term);
|
|
985
|
+
default:
|
|
986
|
+
return purify.Left(new rdfjsResource.Resource.MistypedValueError({
|
|
987
|
+
actualValue: term,
|
|
988
|
+
expectedValueType: "(rdfjs.Literal | rdfjs.NamedNode)",
|
|
989
|
+
focusResource: $resource,
|
|
990
|
+
predicate: ShaclCorePropertyShape.$properties.defaultValue["identifier"],
|
|
991
|
+
}));
|
|
992
|
+
}
|
|
993
|
+
})))
|
|
994
|
+
.map((values) => values.length > 0
|
|
995
|
+
? values.map((value) => purify.Maybe.of(value))
|
|
996
|
+
: rdfjsResource.Resource.Values.fromValue({
|
|
997
|
+
object: purify.Maybe.empty(),
|
|
998
|
+
predicate: ShaclCorePropertyShape.$properties.defaultValue["identifier"],
|
|
999
|
+
subject: $resource,
|
|
1000
|
+
}))
|
|
1001
|
+
.chain((values) => values.head());
|
|
502
1002
|
if (_defaultValueEither.isLeft()) {
|
|
503
1003
|
return _defaultValueEither;
|
|
504
1004
|
}
|
|
505
1005
|
const defaultValue = _defaultValueEither.unsafeCoerce();
|
|
506
|
-
const _descriptionsEither = purify.Either.of([
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
1006
|
+
const _descriptionsEither = purify.Either.of($resource.values(ShaclCorePropertyShape.$properties.descriptions["identifier"], {
|
|
1007
|
+
unique: true,
|
|
1008
|
+
}))
|
|
1009
|
+
.chain((values) => {
|
|
1010
|
+
const literalValuesEither = values.chainMap((value) => value.toLiteral());
|
|
1011
|
+
if (literalValuesEither.isLeft()) {
|
|
1012
|
+
return literalValuesEither;
|
|
1013
|
+
}
|
|
1014
|
+
const literalValues = literalValuesEither.unsafeCoerce();
|
|
1015
|
+
const nonUniqueLanguageIn = $languageIn ?? [];
|
|
1016
|
+
if (nonUniqueLanguageIn.length === 0) {
|
|
1017
|
+
return purify.Either.of(literalValues);
|
|
1018
|
+
}
|
|
1019
|
+
let uniqueLanguageIn;
|
|
1020
|
+
if (nonUniqueLanguageIn.length === 1) {
|
|
1021
|
+
uniqueLanguageIn = [nonUniqueLanguageIn[0]];
|
|
1022
|
+
}
|
|
1023
|
+
else {
|
|
1024
|
+
uniqueLanguageIn = [];
|
|
1025
|
+
for (const languageIn of nonUniqueLanguageIn) {
|
|
1026
|
+
if (uniqueLanguageIn.indexOf(languageIn) === -1) {
|
|
1027
|
+
uniqueLanguageIn.push(languageIn);
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
// Return all literals for the first languageIn, then all literals for the second languageIn, etc.
|
|
1032
|
+
// Within a languageIn the literals may be in any order.
|
|
1033
|
+
let filteredLiteralValues;
|
|
1034
|
+
for (const languageIn of uniqueLanguageIn) {
|
|
1035
|
+
if (!filteredLiteralValues) {
|
|
1036
|
+
filteredLiteralValues = literalValues.filter((value) => value.language === languageIn);
|
|
1037
|
+
}
|
|
1038
|
+
else {
|
|
1039
|
+
filteredLiteralValues = filteredLiteralValues.concat(...literalValues
|
|
1040
|
+
.filter((value) => value.language === languageIn)
|
|
1041
|
+
.toArray());
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
return purify.Either.of(filteredLiteralValues);
|
|
1045
|
+
})
|
|
1046
|
+
.map((values) => values.toArray())
|
|
1047
|
+
.map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
|
|
1048
|
+
object: valuesArray,
|
|
1049
|
+
predicate: ShaclCorePropertyShape.$properties.descriptions["identifier"],
|
|
1050
|
+
subject: $resource,
|
|
1051
|
+
}))
|
|
1052
|
+
.chain((values) => values.head());
|
|
527
1053
|
if (_descriptionsEither.isLeft()) {
|
|
528
1054
|
return _descriptionsEither;
|
|
529
1055
|
}
|
|
530
1056
|
const descriptions = _descriptionsEither.unsafeCoerce();
|
|
531
|
-
const _groupsEither = purify.Either.of([
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
.toMaybe()
|
|
541
|
-
.toList()),
|
|
542
|
-
]);
|
|
1057
|
+
const _groupsEither = purify.Either.of($resource.values(ShaclCorePropertyShape.$properties.groups["identifier"], { unique: true }))
|
|
1058
|
+
.chain((values) => values.chainMap((value) => value.toIdentifier()))
|
|
1059
|
+
.map((values) => values.toArray())
|
|
1060
|
+
.map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
|
|
1061
|
+
object: valuesArray,
|
|
1062
|
+
predicate: ShaclCorePropertyShape.$properties.groups["identifier"],
|
|
1063
|
+
subject: $resource,
|
|
1064
|
+
}))
|
|
1065
|
+
.chain((values) => values.head());
|
|
543
1066
|
if (_groupsEither.isLeft()) {
|
|
544
1067
|
return _groupsEither;
|
|
545
1068
|
}
|
|
546
1069
|
const groups = _groupsEither.unsafeCoerce();
|
|
547
|
-
const _namesEither = purify.Either.of([
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
1070
|
+
const _namesEither = purify.Either.of($resource.values(ShaclCorePropertyShape.$properties.names["identifier"], { unique: true }))
|
|
1071
|
+
.chain((values) => {
|
|
1072
|
+
const literalValuesEither = values.chainMap((value) => value.toLiteral());
|
|
1073
|
+
if (literalValuesEither.isLeft()) {
|
|
1074
|
+
return literalValuesEither;
|
|
1075
|
+
}
|
|
1076
|
+
const literalValues = literalValuesEither.unsafeCoerce();
|
|
1077
|
+
const nonUniqueLanguageIn = $languageIn ?? [];
|
|
1078
|
+
if (nonUniqueLanguageIn.length === 0) {
|
|
1079
|
+
return purify.Either.of(literalValues);
|
|
1080
|
+
}
|
|
1081
|
+
let uniqueLanguageIn;
|
|
1082
|
+
if (nonUniqueLanguageIn.length === 1) {
|
|
1083
|
+
uniqueLanguageIn = [nonUniqueLanguageIn[0]];
|
|
1084
|
+
}
|
|
1085
|
+
else {
|
|
1086
|
+
uniqueLanguageIn = [];
|
|
1087
|
+
for (const languageIn of nonUniqueLanguageIn) {
|
|
1088
|
+
if (uniqueLanguageIn.indexOf(languageIn) === -1) {
|
|
1089
|
+
uniqueLanguageIn.push(languageIn);
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
// Return all literals for the first languageIn, then all literals for the second languageIn, etc.
|
|
1094
|
+
// Within a languageIn the literals may be in any order.
|
|
1095
|
+
let filteredLiteralValues;
|
|
1096
|
+
for (const languageIn of uniqueLanguageIn) {
|
|
1097
|
+
if (!filteredLiteralValues) {
|
|
1098
|
+
filteredLiteralValues = literalValues.filter((value) => value.language === languageIn);
|
|
1099
|
+
}
|
|
1100
|
+
else {
|
|
1101
|
+
filteredLiteralValues = filteredLiteralValues.concat(...literalValues
|
|
1102
|
+
.filter((value) => value.language === languageIn)
|
|
1103
|
+
.toArray());
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
return purify.Either.of(filteredLiteralValues);
|
|
1107
|
+
})
|
|
1108
|
+
.map((values) => values.toArray())
|
|
1109
|
+
.map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
|
|
1110
|
+
object: valuesArray,
|
|
1111
|
+
predicate: ShaclCorePropertyShape.$properties.names["identifier"],
|
|
1112
|
+
subject: $resource,
|
|
1113
|
+
}))
|
|
1114
|
+
.chain((values) => values.head());
|
|
570
1115
|
if (_namesEither.isLeft()) {
|
|
571
1116
|
return _namesEither;
|
|
572
1117
|
}
|
|
573
1118
|
const names = _namesEither.unsafeCoerce();
|
|
574
|
-
const _orderEither = purify.Either.of(
|
|
575
|
-
.values(
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
.
|
|
579
|
-
|
|
580
|
-
|
|
1119
|
+
const _orderEither = purify.Either.of($resource.values(ShaclCorePropertyShape.$properties.order["identifier"], { unique: true }))
|
|
1120
|
+
.chain((values) => values.chainMap((value) => value.toNumber()))
|
|
1121
|
+
.map((values) => values.length > 0
|
|
1122
|
+
? values.map((value) => purify.Maybe.of(value))
|
|
1123
|
+
: rdfjsResource.Resource.Values.fromValue({
|
|
1124
|
+
object: purify.Maybe.empty(),
|
|
1125
|
+
predicate: ShaclCorePropertyShape.$properties.order["identifier"],
|
|
1126
|
+
subject: $resource,
|
|
1127
|
+
}))
|
|
1128
|
+
.chain((values) => values.head());
|
|
581
1129
|
if (_orderEither.isLeft()) {
|
|
582
1130
|
return _orderEither;
|
|
583
1131
|
}
|
|
584
1132
|
const order = _orderEither.unsafeCoerce();
|
|
585
|
-
const _pathEither =
|
|
586
|
-
.values(
|
|
587
|
-
|
|
588
|
-
})
|
|
589
|
-
.head()
|
|
590
|
-
.chain((value) => value.toResource())
|
|
591
|
-
.chain((_resource) => PropertyPath.fromRdf({
|
|
592
|
-
..._context,
|
|
1133
|
+
const _pathEither = purify.Either.of($resource.values(ShaclCorePropertyShape.$properties.path["identifier"], { unique: true }))
|
|
1134
|
+
.chain((values) => values.chainMap((value) => value.toResource().chain((resource) => PropertyPath.$fromRdf(resource, {
|
|
1135
|
+
...$context,
|
|
593
1136
|
ignoreRdfType: true,
|
|
594
|
-
languageIn:
|
|
595
|
-
|
|
596
|
-
}))
|
|
1137
|
+
languageIn: $languageIn,
|
|
1138
|
+
objectSet: $objectSet,
|
|
1139
|
+
}))))
|
|
1140
|
+
.chain((values) => values.head());
|
|
597
1141
|
if (_pathEither.isLeft()) {
|
|
598
1142
|
return _pathEither;
|
|
599
1143
|
}
|
|
600
1144
|
const path = _pathEither.unsafeCoerce();
|
|
601
|
-
const _uniqueLangEither = purify.Either.of(
|
|
602
|
-
.
|
|
603
|
-
.
|
|
604
|
-
.
|
|
605
|
-
.
|
|
1145
|
+
const _uniqueLangEither = purify.Either.of($resource.values(ShaclCorePropertyShape.$properties.uniqueLang["identifier"], { unique: true }))
|
|
1146
|
+
.chain((values) => values.chainMap((value) => value.toBoolean()))
|
|
1147
|
+
.map((values) => values.length > 0
|
|
1148
|
+
? values.map((value) => purify.Maybe.of(value))
|
|
1149
|
+
: rdfjsResource.Resource.Values.fromValue({
|
|
1150
|
+
object: purify.Maybe.empty(),
|
|
1151
|
+
predicate: ShaclCorePropertyShape.$properties.uniqueLang["identifier"],
|
|
1152
|
+
subject: $resource,
|
|
1153
|
+
}))
|
|
1154
|
+
.chain((values) => values.head());
|
|
606
1155
|
if (_uniqueLangEither.isLeft()) {
|
|
607
1156
|
return _uniqueLangEither;
|
|
608
1157
|
}
|
|
609
1158
|
const uniqueLang = _uniqueLangEither.unsafeCoerce();
|
|
610
1159
|
return purify.Either.of({
|
|
611
|
-
|
|
612
|
-
identifier,
|
|
613
|
-
type,
|
|
1160
|
+
...$super0,
|
|
1161
|
+
$identifier,
|
|
1162
|
+
$type,
|
|
614
1163
|
defaultValue,
|
|
615
1164
|
descriptions,
|
|
616
1165
|
groups,
|
|
@@ -620,227 +1169,834 @@ export var ShaclCorePropertyShape;
|
|
|
620
1169
|
uniqueLang,
|
|
621
1170
|
});
|
|
622
1171
|
}
|
|
623
|
-
ShaclCorePropertyShape
|
|
624
|
-
function
|
|
625
|
-
|
|
1172
|
+
ShaclCorePropertyShape.$propertiesFromRdf = $propertiesFromRdf;
|
|
1173
|
+
function $toRdf(_shaclCorePropertyShape, options) {
|
|
1174
|
+
const ignoreRdfType = !!options?.ignoreRdfType;
|
|
1175
|
+
const mutateGraph = options?.mutateGraph;
|
|
1176
|
+
const resourceSet = options?.resourceSet ??
|
|
1177
|
+
new rdfjsResource.MutableResourceSet({
|
|
1178
|
+
dataFactory,
|
|
1179
|
+
dataset: datasetFactory.dataset(),
|
|
1180
|
+
});
|
|
1181
|
+
const resource = BaseShaclCoreShapeStatic.$toRdf(_shaclCorePropertyShape, {
|
|
1182
|
+
ignoreRdfType: true,
|
|
1183
|
+
mutateGraph,
|
|
1184
|
+
resourceSet,
|
|
1185
|
+
});
|
|
1186
|
+
if (!ignoreRdfType) {
|
|
1187
|
+
resource.add($RdfVocabularies.rdf.type, resource.dataFactory.namedNode("http://purl.org/shaclmate/ontology#ShaclCorePropertyShape"));
|
|
1188
|
+
resource.add($RdfVocabularies.rdf.type, resource.dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyShape"));
|
|
1189
|
+
}
|
|
1190
|
+
resource.add(ShaclCorePropertyShape.$properties.defaultValue["identifier"], _shaclCorePropertyShape.defaultValue);
|
|
1191
|
+
resource.add(ShaclCorePropertyShape.$properties.descriptions["identifier"], _shaclCorePropertyShape.descriptions.map((item) => item));
|
|
1192
|
+
resource.add(ShaclCorePropertyShape.$properties.groups["identifier"], _shaclCorePropertyShape.groups.map((item) => item));
|
|
1193
|
+
resource.add(ShaclCorePropertyShape.$properties.names["identifier"], _shaclCorePropertyShape.names.map((item) => item));
|
|
1194
|
+
resource.add(ShaclCorePropertyShape.$properties.order["identifier"], _shaclCorePropertyShape.order);
|
|
1195
|
+
resource.add(ShaclCorePropertyShape.$properties.path["identifier"], PropertyPath.$toRdf(_shaclCorePropertyShape.path, {
|
|
1196
|
+
mutateGraph: mutateGraph,
|
|
1197
|
+
resourceSet: resourceSet,
|
|
1198
|
+
}));
|
|
1199
|
+
resource.add(ShaclCorePropertyShape.$properties.uniqueLang["identifier"], _shaclCorePropertyShape.uniqueLang);
|
|
1200
|
+
return resource;
|
|
626
1201
|
}
|
|
627
|
-
ShaclCorePropertyShape
|
|
628
|
-
ShaclCorePropertyShape
|
|
1202
|
+
ShaclCorePropertyShape.$toRdf = $toRdf;
|
|
1203
|
+
ShaclCorePropertyShape.$properties = {
|
|
1204
|
+
...BaseShaclCoreShapeStatic.$properties,
|
|
1205
|
+
defaultValue: {
|
|
1206
|
+
identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#defaultValue"),
|
|
1207
|
+
},
|
|
1208
|
+
descriptions: {
|
|
1209
|
+
identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#description"),
|
|
1210
|
+
},
|
|
1211
|
+
groups: {
|
|
1212
|
+
identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#group"),
|
|
1213
|
+
},
|
|
1214
|
+
names: {
|
|
1215
|
+
identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#name"),
|
|
1216
|
+
},
|
|
1217
|
+
order: {
|
|
1218
|
+
identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#order"),
|
|
1219
|
+
},
|
|
1220
|
+
path: {
|
|
1221
|
+
identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#path"),
|
|
1222
|
+
},
|
|
1223
|
+
uniqueLang: {
|
|
1224
|
+
identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#uniqueLang"),
|
|
1225
|
+
},
|
|
1226
|
+
};
|
|
629
1227
|
})(ShaclCorePropertyShape || (ShaclCorePropertyShape = {}));
|
|
630
1228
|
export var ShaclCorePropertyGroup;
|
|
631
1229
|
(function (ShaclCorePropertyGroup) {
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
message: `${rdfjsResource.Resource.Identifier.toString(_resource.identifier)} has unexpected RDF type`,
|
|
640
|
-
predicate: dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyGroup"),
|
|
1230
|
+
ShaclCorePropertyGroup.$fromRdfType = dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyGroup");
|
|
1231
|
+
let $Identifier;
|
|
1232
|
+
(function ($Identifier) {
|
|
1233
|
+
function fromString(identifier) {
|
|
1234
|
+
return purify.Either.encase(() => rdfjsResource.Resource.Identifier.fromString({
|
|
1235
|
+
dataFactory,
|
|
1236
|
+
identifier,
|
|
641
1237
|
}));
|
|
642
1238
|
}
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
1239
|
+
$Identifier.fromString = fromString;
|
|
1240
|
+
$Identifier.toString = rdfjsResource.Resource.Identifier.toString;
|
|
1241
|
+
})($Identifier = ShaclCorePropertyGroup.$Identifier || (ShaclCorePropertyGroup.$Identifier = {}));
|
|
1242
|
+
function $fromRdf(resource, options) {
|
|
1243
|
+
let { ignoreRdfType = false, languageIn, objectSet, ...context } = options ?? {};
|
|
1244
|
+
if (!objectSet) {
|
|
1245
|
+
objectSet = new $RdfjsDatasetObjectSet({ dataset: resource.dataset });
|
|
1246
|
+
}
|
|
1247
|
+
return ShaclCorePropertyGroup.$propertiesFromRdf({
|
|
1248
|
+
...context,
|
|
1249
|
+
ignoreRdfType,
|
|
1250
|
+
languageIn,
|
|
1251
|
+
objectSet,
|
|
1252
|
+
resource,
|
|
1253
|
+
});
|
|
1254
|
+
}
|
|
1255
|
+
ShaclCorePropertyGroup.$fromRdf = $fromRdf;
|
|
1256
|
+
function $propertiesFromRdf({ ignoreRdfType: $ignoreRdfType, languageIn: $languageIn, objectSet: $objectSet, resource: $resource,
|
|
1257
|
+
// @ts-ignore
|
|
1258
|
+
...$context }) {
|
|
1259
|
+
if (!$ignoreRdfType && !$resource.isInstanceOf(ShaclCorePropertyGroup.$fromRdfType)) {
|
|
1260
|
+
return $resource
|
|
1261
|
+
.value($RdfVocabularies.rdf.type)
|
|
1262
|
+
.chain((actualRdfType) => actualRdfType.toIri())
|
|
1263
|
+
.chain((actualRdfType) => purify.Left(new Error(`${rdfjsResource.Resource.Identifier.toString($resource.identifier)} has unexpected RDF type (actual: ${actualRdfType.value}, expected: http://www.w3.org/ns/shacl#PropertyGroup)`)));
|
|
1264
|
+
}
|
|
1265
|
+
const $identifier = $resource.identifier;
|
|
1266
|
+
const $type = "ShaclCorePropertyGroup";
|
|
1267
|
+
const _commentsEither = purify.Either.of($resource.values(ShaclCorePropertyGroup.$properties.comments["identifier"], { unique: true }))
|
|
1268
|
+
.chain((values) => {
|
|
1269
|
+
const literalValuesEither = values.chainMap((value) => value.toLiteral());
|
|
1270
|
+
if (literalValuesEither.isLeft()) {
|
|
1271
|
+
return literalValuesEither;
|
|
1272
|
+
}
|
|
1273
|
+
const literalValues = literalValuesEither.unsafeCoerce();
|
|
1274
|
+
const nonUniqueLanguageIn = $languageIn ?? [];
|
|
1275
|
+
if (nonUniqueLanguageIn.length === 0) {
|
|
1276
|
+
return purify.Either.of(literalValues);
|
|
1277
|
+
}
|
|
1278
|
+
let uniqueLanguageIn;
|
|
1279
|
+
if (nonUniqueLanguageIn.length === 1) {
|
|
1280
|
+
uniqueLanguageIn = [nonUniqueLanguageIn[0]];
|
|
1281
|
+
}
|
|
1282
|
+
else {
|
|
1283
|
+
uniqueLanguageIn = [];
|
|
1284
|
+
for (const languageIn of nonUniqueLanguageIn) {
|
|
1285
|
+
if (uniqueLanguageIn.indexOf(languageIn) === -1) {
|
|
1286
|
+
uniqueLanguageIn.push(languageIn);
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
// Return all literals for the first languageIn, then all literals for the second languageIn, etc.
|
|
1291
|
+
// Within a languageIn the literals may be in any order.
|
|
1292
|
+
let filteredLiteralValues;
|
|
1293
|
+
for (const languageIn of uniqueLanguageIn) {
|
|
1294
|
+
if (!filteredLiteralValues) {
|
|
1295
|
+
filteredLiteralValues = literalValues.filter((value) => value.language === languageIn);
|
|
1296
|
+
}
|
|
1297
|
+
else {
|
|
1298
|
+
filteredLiteralValues = filteredLiteralValues.concat(...literalValues
|
|
1299
|
+
.filter((value) => value.language === languageIn)
|
|
1300
|
+
.toArray());
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
return purify.Either.of(filteredLiteralValues);
|
|
1304
|
+
})
|
|
1305
|
+
.map((values) => values.toArray())
|
|
1306
|
+
.map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
|
|
1307
|
+
object: valuesArray,
|
|
1308
|
+
predicate: ShaclCorePropertyGroup.$properties.comments["identifier"],
|
|
1309
|
+
subject: $resource,
|
|
1310
|
+
}))
|
|
1311
|
+
.chain((values) => values.head());
|
|
666
1312
|
if (_commentsEither.isLeft()) {
|
|
667
1313
|
return _commentsEither;
|
|
668
1314
|
}
|
|
669
1315
|
const comments = _commentsEither.unsafeCoerce();
|
|
670
|
-
const _labelsEither = purify.Either.of([
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
1316
|
+
const _labelsEither = purify.Either.of($resource.values(ShaclCorePropertyGroup.$properties.labels["identifier"], { unique: true }))
|
|
1317
|
+
.chain((values) => {
|
|
1318
|
+
const literalValuesEither = values.chainMap((value) => value.toLiteral());
|
|
1319
|
+
if (literalValuesEither.isLeft()) {
|
|
1320
|
+
return literalValuesEither;
|
|
1321
|
+
}
|
|
1322
|
+
const literalValues = literalValuesEither.unsafeCoerce();
|
|
1323
|
+
const nonUniqueLanguageIn = $languageIn ?? [];
|
|
1324
|
+
if (nonUniqueLanguageIn.length === 0) {
|
|
1325
|
+
return purify.Either.of(literalValues);
|
|
1326
|
+
}
|
|
1327
|
+
let uniqueLanguageIn;
|
|
1328
|
+
if (nonUniqueLanguageIn.length === 1) {
|
|
1329
|
+
uniqueLanguageIn = [nonUniqueLanguageIn[0]];
|
|
1330
|
+
}
|
|
1331
|
+
else {
|
|
1332
|
+
uniqueLanguageIn = [];
|
|
1333
|
+
for (const languageIn of nonUniqueLanguageIn) {
|
|
1334
|
+
if (uniqueLanguageIn.indexOf(languageIn) === -1) {
|
|
1335
|
+
uniqueLanguageIn.push(languageIn);
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
// Return all literals for the first languageIn, then all literals for the second languageIn, etc.
|
|
1340
|
+
// Within a languageIn the literals may be in any order.
|
|
1341
|
+
let filteredLiteralValues;
|
|
1342
|
+
for (const languageIn of uniqueLanguageIn) {
|
|
1343
|
+
if (!filteredLiteralValues) {
|
|
1344
|
+
filteredLiteralValues = literalValues.filter((value) => value.language === languageIn);
|
|
1345
|
+
}
|
|
1346
|
+
else {
|
|
1347
|
+
filteredLiteralValues = filteredLiteralValues.concat(...literalValues
|
|
1348
|
+
.filter((value) => value.language === languageIn)
|
|
1349
|
+
.toArray());
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1352
|
+
return purify.Either.of(filteredLiteralValues);
|
|
1353
|
+
})
|
|
1354
|
+
.map((values) => values.toArray())
|
|
1355
|
+
.map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
|
|
1356
|
+
object: valuesArray,
|
|
1357
|
+
predicate: ShaclCorePropertyGroup.$properties.labels["identifier"],
|
|
1358
|
+
subject: $resource,
|
|
1359
|
+
}))
|
|
1360
|
+
.chain((values) => values.head());
|
|
691
1361
|
if (_labelsEither.isLeft()) {
|
|
692
1362
|
return _labelsEither;
|
|
693
1363
|
}
|
|
694
1364
|
const labels = _labelsEither.unsafeCoerce();
|
|
695
|
-
return purify.Either.of({ identifier, type, comments, labels });
|
|
1365
|
+
return purify.Either.of({ $identifier, $type, comments, labels });
|
|
696
1366
|
}
|
|
697
|
-
ShaclCorePropertyGroup
|
|
698
|
-
function
|
|
699
|
-
|
|
1367
|
+
ShaclCorePropertyGroup.$propertiesFromRdf = $propertiesFromRdf;
|
|
1368
|
+
function $toRdf(_shaclCorePropertyGroup, options) {
|
|
1369
|
+
const ignoreRdfType = !!options?.ignoreRdfType;
|
|
1370
|
+
const mutateGraph = options?.mutateGraph;
|
|
1371
|
+
const resourceSet = options?.resourceSet ??
|
|
1372
|
+
new rdfjsResource.MutableResourceSet({
|
|
1373
|
+
dataFactory,
|
|
1374
|
+
dataset: datasetFactory.dataset(),
|
|
1375
|
+
});
|
|
1376
|
+
const resource = resourceSet.mutableResource(_shaclCorePropertyGroup.$identifier, { mutateGraph });
|
|
1377
|
+
if (!ignoreRdfType) {
|
|
1378
|
+
resource.add($RdfVocabularies.rdf.type, resource.dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyGroup"));
|
|
1379
|
+
}
|
|
1380
|
+
resource.add(ShaclCorePropertyGroup.$properties.comments["identifier"], _shaclCorePropertyGroup.comments.map((item) => item));
|
|
1381
|
+
resource.add(ShaclCorePropertyGroup.$properties.labels["identifier"], _shaclCorePropertyGroup.labels.map((item) => item));
|
|
1382
|
+
return resource;
|
|
700
1383
|
}
|
|
701
|
-
ShaclCorePropertyGroup
|
|
702
|
-
ShaclCorePropertyGroup
|
|
1384
|
+
ShaclCorePropertyGroup.$toRdf = $toRdf;
|
|
1385
|
+
ShaclCorePropertyGroup.$properties = {
|
|
1386
|
+
comments: {
|
|
1387
|
+
identifier: dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#comment"),
|
|
1388
|
+
},
|
|
1389
|
+
labels: {
|
|
1390
|
+
identifier: dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#label"),
|
|
1391
|
+
},
|
|
1392
|
+
};
|
|
703
1393
|
})(ShaclCorePropertyGroup || (ShaclCorePropertyGroup = {}));
|
|
704
1394
|
export var ShaclCoreNodeShape;
|
|
705
1395
|
(function (ShaclCoreNodeShape) {
|
|
706
|
-
|
|
1396
|
+
ShaclCoreNodeShape.$fromRdfType = dataFactory.namedNode("http://www.w3.org/ns/shacl#NodeShape");
|
|
1397
|
+
ShaclCoreNodeShape.$Identifier = BaseShaclCoreShapeStatic.$Identifier;
|
|
1398
|
+
function $fromRdf(resource, options) {
|
|
1399
|
+
let { ignoreRdfType = false, languageIn, objectSet, ...context } = options ?? {};
|
|
1400
|
+
if (!objectSet) {
|
|
1401
|
+
objectSet = new $RdfjsDatasetObjectSet({ dataset: resource.dataset });
|
|
1402
|
+
}
|
|
1403
|
+
return ShaclCoreNodeShape.$propertiesFromRdf({
|
|
1404
|
+
...context,
|
|
1405
|
+
ignoreRdfType,
|
|
1406
|
+
languageIn,
|
|
1407
|
+
objectSet,
|
|
1408
|
+
resource,
|
|
1409
|
+
});
|
|
1410
|
+
}
|
|
1411
|
+
ShaclCoreNodeShape.$fromRdf = $fromRdf;
|
|
1412
|
+
function $propertiesFromRdf({ ignoreRdfType: $ignoreRdfType, languageIn: $languageIn, objectSet: $objectSet, resource: $resource,
|
|
707
1413
|
// @ts-ignore
|
|
708
|
-
|
|
709
|
-
const
|
|
710
|
-
|
|
1414
|
+
...$context }) {
|
|
1415
|
+
const $super0Either = BaseShaclCoreShapeStatic.$propertiesFromRdf({
|
|
1416
|
+
...$context,
|
|
711
1417
|
ignoreRdfType: true,
|
|
712
|
-
languageIn:
|
|
713
|
-
|
|
1418
|
+
languageIn: $languageIn,
|
|
1419
|
+
objectSet: $objectSet,
|
|
1420
|
+
resource: $resource,
|
|
714
1421
|
});
|
|
715
|
-
if (
|
|
716
|
-
return
|
|
717
|
-
}
|
|
718
|
-
const _super0 = _super0Either.unsafeCoerce();
|
|
719
|
-
if (!_ignoreRdfType &&
|
|
720
|
-
!_resource.isInstanceOf(dataFactory.namedNode("http://www.w3.org/ns/shacl#NodeShape"))) {
|
|
721
|
-
return purify.Left(new rdfjsResource.Resource.ValueError({
|
|
722
|
-
focusResource: _resource,
|
|
723
|
-
message: `${rdfjsResource.Resource.Identifier.toString(_resource.identifier)} has unexpected RDF type`,
|
|
724
|
-
predicate: dataFactory.namedNode("http://www.w3.org/ns/shacl#NodeShape"),
|
|
725
|
-
}));
|
|
1422
|
+
if ($super0Either.isLeft()) {
|
|
1423
|
+
return $super0Either;
|
|
726
1424
|
}
|
|
727
|
-
const
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
1425
|
+
const $super0 = $super0Either.unsafeCoerce();
|
|
1426
|
+
if (!$ignoreRdfType && !$resource.isInstanceOf(ShaclCoreNodeShape.$fromRdfType)) {
|
|
1427
|
+
return $resource
|
|
1428
|
+
.value($RdfVocabularies.rdf.type)
|
|
1429
|
+
.chain((actualRdfType) => actualRdfType.toIri())
|
|
1430
|
+
.chain((actualRdfType) => purify.Left(new Error(`${rdfjsResource.Resource.Identifier.toString($resource.identifier)} has unexpected RDF type (actual: ${actualRdfType.value}, expected: http://www.w3.org/ns/shacl#NodeShape)`)));
|
|
1431
|
+
}
|
|
1432
|
+
const $identifier = $resource.identifier;
|
|
1433
|
+
const $type = "ShaclCoreNodeShape";
|
|
1434
|
+
const _closedEither = purify.Either.of($resource.values(ShaclCoreNodeShape.$properties.closed["identifier"], { unique: true }))
|
|
1435
|
+
.chain((values) => values.chainMap((value) => value.toBoolean()))
|
|
1436
|
+
.map((values) => values.length > 0
|
|
1437
|
+
? values.map((value) => purify.Maybe.of(value))
|
|
1438
|
+
: rdfjsResource.Resource.Values.fromValue({
|
|
1439
|
+
object: purify.Maybe.empty(),
|
|
1440
|
+
predicate: ShaclCoreNodeShape.$properties.closed["identifier"],
|
|
1441
|
+
subject: $resource,
|
|
1442
|
+
}))
|
|
1443
|
+
.chain((values) => values.head());
|
|
736
1444
|
if (_closedEither.isLeft()) {
|
|
737
1445
|
return _closedEither;
|
|
738
1446
|
}
|
|
739
1447
|
const closed = _closedEither.unsafeCoerce();
|
|
740
|
-
const _ignoredPropertiesEither = purify.Either.of(
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
.chain((value) => value.toList())
|
|
744
|
-
.
|
|
745
|
-
|
|
746
|
-
.
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
.
|
|
750
|
-
.
|
|
1448
|
+
const _ignoredPropertiesEither = purify.Either.of($resource.values(ShaclCoreNodeShape.$properties.ignoredProperties["identifier"], {
|
|
1449
|
+
unique: true,
|
|
1450
|
+
}))
|
|
1451
|
+
.chain((values) => values.chainMap((value) => value.toList()))
|
|
1452
|
+
.chain((valueLists) => valueLists.chainMap((valueList) => purify.Either.of(rdfjsResource.Resource.Values.fromArray({
|
|
1453
|
+
objects: valueList,
|
|
1454
|
+
predicate: ShaclCoreNodeShape.$properties.ignoredProperties["identifier"],
|
|
1455
|
+
subject: $resource,
|
|
1456
|
+
})).chain((values) => values.chainMap((value) => value.toIri()))))
|
|
1457
|
+
.map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
|
|
1458
|
+
.map((values) => values.length > 0
|
|
1459
|
+
? values.map((value) => purify.Maybe.of(value))
|
|
1460
|
+
: rdfjsResource.Resource.Values.fromValue({
|
|
1461
|
+
object: purify.Maybe.empty(),
|
|
1462
|
+
predicate: ShaclCoreNodeShape.$properties.ignoredProperties["identifier"],
|
|
1463
|
+
subject: $resource,
|
|
1464
|
+
}))
|
|
1465
|
+
.chain((values) => values.head());
|
|
751
1466
|
if (_ignoredPropertiesEither.isLeft()) {
|
|
752
1467
|
return _ignoredPropertiesEither;
|
|
753
1468
|
}
|
|
754
1469
|
const ignoredProperties = _ignoredPropertiesEither.unsafeCoerce();
|
|
755
|
-
const _propertiesEither = purify.Either.of([
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
.toMaybe()
|
|
765
|
-
.toList()),
|
|
766
|
-
]);
|
|
1470
|
+
const _propertiesEither = purify.Either.of($resource.values(ShaclCoreNodeShape.$properties.properties["identifier"], { unique: true }))
|
|
1471
|
+
.chain((values) => values.chainMap((value) => value.toIdentifier()))
|
|
1472
|
+
.map((values) => values.toArray())
|
|
1473
|
+
.map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
|
|
1474
|
+
object: valuesArray,
|
|
1475
|
+
predicate: ShaclCoreNodeShape.$properties.properties["identifier"],
|
|
1476
|
+
subject: $resource,
|
|
1477
|
+
}))
|
|
1478
|
+
.chain((values) => values.head());
|
|
767
1479
|
if (_propertiesEither.isLeft()) {
|
|
768
1480
|
return _propertiesEither;
|
|
769
1481
|
}
|
|
770
1482
|
const properties = _propertiesEither.unsafeCoerce();
|
|
771
1483
|
return purify.Either.of({
|
|
772
|
-
|
|
773
|
-
identifier,
|
|
774
|
-
type,
|
|
1484
|
+
...$super0,
|
|
1485
|
+
$identifier,
|
|
1486
|
+
$type,
|
|
775
1487
|
closed,
|
|
776
1488
|
ignoredProperties,
|
|
777
1489
|
properties,
|
|
778
1490
|
});
|
|
779
1491
|
}
|
|
780
|
-
ShaclCoreNodeShape
|
|
781
|
-
function
|
|
782
|
-
|
|
1492
|
+
ShaclCoreNodeShape.$propertiesFromRdf = $propertiesFromRdf;
|
|
1493
|
+
function $toRdf(_shaclCoreNodeShape, options) {
|
|
1494
|
+
const ignoreRdfType = !!options?.ignoreRdfType;
|
|
1495
|
+
const mutateGraph = options?.mutateGraph;
|
|
1496
|
+
const resourceSet = options?.resourceSet ??
|
|
1497
|
+
new rdfjsResource.MutableResourceSet({
|
|
1498
|
+
dataFactory,
|
|
1499
|
+
dataset: datasetFactory.dataset(),
|
|
1500
|
+
});
|
|
1501
|
+
const resource = BaseShaclCoreShapeStatic.$toRdf(_shaclCoreNodeShape, {
|
|
1502
|
+
ignoreRdfType: true,
|
|
1503
|
+
mutateGraph,
|
|
1504
|
+
resourceSet,
|
|
1505
|
+
});
|
|
1506
|
+
if (!ignoreRdfType) {
|
|
1507
|
+
resource.add($RdfVocabularies.rdf.type, resource.dataFactory.namedNode("http://purl.org/shaclmate/ontology#ShaclCoreNodeShape"));
|
|
1508
|
+
resource.add($RdfVocabularies.rdf.type, resource.dataFactory.namedNode("http://www.w3.org/ns/shacl#NodeShape"));
|
|
1509
|
+
}
|
|
1510
|
+
resource.add(ShaclCoreNodeShape.$properties.closed["identifier"], _shaclCoreNodeShape.closed);
|
|
1511
|
+
resource.add(ShaclCoreNodeShape.$properties.ignoredProperties["identifier"], _shaclCoreNodeShape.ignoredProperties.map((value) => value.length > 0
|
|
1512
|
+
? value.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
|
|
1513
|
+
if (itemIndex === 0) {
|
|
1514
|
+
currentSubListResource = listResource;
|
|
1515
|
+
}
|
|
1516
|
+
else {
|
|
1517
|
+
const newSubListResource = resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph });
|
|
1518
|
+
currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier);
|
|
1519
|
+
currentSubListResource = newSubListResource;
|
|
1520
|
+
}
|
|
1521
|
+
currentSubListResource.add($RdfVocabularies.rdf.first, item);
|
|
1522
|
+
if (itemIndex + 1 === list.length) {
|
|
1523
|
+
currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil);
|
|
1524
|
+
}
|
|
1525
|
+
return { currentSubListResource, listResource };
|
|
1526
|
+
}, {
|
|
1527
|
+
currentSubListResource: null,
|
|
1528
|
+
listResource: resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph }),
|
|
1529
|
+
}).listResource.identifier
|
|
1530
|
+
: $RdfVocabularies.rdf.nil));
|
|
1531
|
+
resource.add(ShaclCoreNodeShape.$properties.properties["identifier"], _shaclCoreNodeShape.properties.map((item) => item));
|
|
1532
|
+
return resource;
|
|
783
1533
|
}
|
|
784
|
-
ShaclCoreNodeShape
|
|
785
|
-
ShaclCoreNodeShape
|
|
1534
|
+
ShaclCoreNodeShape.$toRdf = $toRdf;
|
|
1535
|
+
ShaclCoreNodeShape.$properties = {
|
|
1536
|
+
...BaseShaclCoreShapeStatic.$properties,
|
|
1537
|
+
closed: {
|
|
1538
|
+
identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#closed"),
|
|
1539
|
+
},
|
|
1540
|
+
ignoredProperties: {
|
|
1541
|
+
identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#ignoredProperties"),
|
|
1542
|
+
},
|
|
1543
|
+
properties: {
|
|
1544
|
+
identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#property"),
|
|
1545
|
+
},
|
|
1546
|
+
};
|
|
786
1547
|
})(ShaclCoreNodeShape || (ShaclCoreNodeShape = {}));
|
|
787
1548
|
export var OwlOntology;
|
|
788
1549
|
(function (OwlOntology) {
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
message: `${rdfjsResource.Resource.Identifier.toString(_resource.identifier)} has unexpected RDF type`,
|
|
797
|
-
predicate: dataFactory.namedNode("http://www.w3.org/2002/07/owl#Ontology"),
|
|
1550
|
+
OwlOntology.$fromRdfType = dataFactory.namedNode("http://www.w3.org/2002/07/owl#Ontology");
|
|
1551
|
+
let $Identifier;
|
|
1552
|
+
(function ($Identifier) {
|
|
1553
|
+
function fromString(identifier) {
|
|
1554
|
+
return purify.Either.encase(() => rdfjsResource.Resource.Identifier.fromString({
|
|
1555
|
+
dataFactory,
|
|
1556
|
+
identifier,
|
|
798
1557
|
}));
|
|
799
1558
|
}
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
1559
|
+
$Identifier.fromString = fromString;
|
|
1560
|
+
$Identifier.toString = rdfjsResource.Resource.Identifier.toString;
|
|
1561
|
+
})($Identifier = OwlOntology.$Identifier || (OwlOntology.$Identifier = {}));
|
|
1562
|
+
function $fromRdf(resource, options) {
|
|
1563
|
+
let { ignoreRdfType = false, languageIn, objectSet, ...context } = options ?? {};
|
|
1564
|
+
if (!objectSet) {
|
|
1565
|
+
objectSet = new $RdfjsDatasetObjectSet({ dataset: resource.dataset });
|
|
1566
|
+
}
|
|
1567
|
+
return OwlOntology.$propertiesFromRdf({
|
|
1568
|
+
...context,
|
|
1569
|
+
ignoreRdfType,
|
|
1570
|
+
languageIn,
|
|
1571
|
+
objectSet,
|
|
1572
|
+
resource,
|
|
1573
|
+
});
|
|
1574
|
+
}
|
|
1575
|
+
OwlOntology.$fromRdf = $fromRdf;
|
|
1576
|
+
function $propertiesFromRdf({ ignoreRdfType: $ignoreRdfType, languageIn: $languageIn, objectSet: $objectSet, resource: $resource,
|
|
1577
|
+
// @ts-ignore
|
|
1578
|
+
...$context }) {
|
|
1579
|
+
if (!$ignoreRdfType && !$resource.isInstanceOf(OwlOntology.$fromRdfType)) {
|
|
1580
|
+
return $resource
|
|
1581
|
+
.value($RdfVocabularies.rdf.type)
|
|
1582
|
+
.chain((actualRdfType) => actualRdfType.toIri())
|
|
1583
|
+
.chain((actualRdfType) => purify.Left(new Error(`${rdfjsResource.Resource.Identifier.toString($resource.identifier)} has unexpected RDF type (actual: ${actualRdfType.value}, expected: http://www.w3.org/2002/07/owl#Ontology)`)));
|
|
1584
|
+
}
|
|
1585
|
+
const $identifier = $resource.identifier;
|
|
1586
|
+
const $type = "OwlOntology";
|
|
1587
|
+
const _labelsEither = purify.Either.of($resource.values(OwlOntology.$properties.labels["identifier"], { unique: true }))
|
|
1588
|
+
.chain((values) => {
|
|
1589
|
+
const literalValuesEither = values.chainMap((value) => value.toLiteral());
|
|
1590
|
+
if (literalValuesEither.isLeft()) {
|
|
1591
|
+
return literalValuesEither;
|
|
1592
|
+
}
|
|
1593
|
+
const literalValues = literalValuesEither.unsafeCoerce();
|
|
1594
|
+
const nonUniqueLanguageIn = $languageIn ?? [];
|
|
1595
|
+
if (nonUniqueLanguageIn.length === 0) {
|
|
1596
|
+
return purify.Either.of(literalValues);
|
|
1597
|
+
}
|
|
1598
|
+
let uniqueLanguageIn;
|
|
1599
|
+
if (nonUniqueLanguageIn.length === 1) {
|
|
1600
|
+
uniqueLanguageIn = [nonUniqueLanguageIn[0]];
|
|
1601
|
+
}
|
|
1602
|
+
else {
|
|
1603
|
+
uniqueLanguageIn = [];
|
|
1604
|
+
for (const languageIn of nonUniqueLanguageIn) {
|
|
1605
|
+
if (uniqueLanguageIn.indexOf(languageIn) === -1) {
|
|
1606
|
+
uniqueLanguageIn.push(languageIn);
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1610
|
+
// Return all literals for the first languageIn, then all literals for the second languageIn, etc.
|
|
1611
|
+
// Within a languageIn the literals may be in any order.
|
|
1612
|
+
let filteredLiteralValues;
|
|
1613
|
+
for (const languageIn of uniqueLanguageIn) {
|
|
1614
|
+
if (!filteredLiteralValues) {
|
|
1615
|
+
filteredLiteralValues = literalValues.filter((value) => value.language === languageIn);
|
|
1616
|
+
}
|
|
1617
|
+
else {
|
|
1618
|
+
filteredLiteralValues = filteredLiteralValues.concat(...literalValues
|
|
1619
|
+
.filter((value) => value.language === languageIn)
|
|
1620
|
+
.toArray());
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
return purify.Either.of(filteredLiteralValues);
|
|
1624
|
+
})
|
|
1625
|
+
.map((values) => values.toArray())
|
|
1626
|
+
.map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
|
|
1627
|
+
object: valuesArray,
|
|
1628
|
+
predicate: OwlOntology.$properties.labels["identifier"],
|
|
1629
|
+
subject: $resource,
|
|
1630
|
+
}))
|
|
1631
|
+
.chain((values) => values.head());
|
|
823
1632
|
if (_labelsEither.isLeft()) {
|
|
824
1633
|
return _labelsEither;
|
|
825
1634
|
}
|
|
826
1635
|
const labels = _labelsEither.unsafeCoerce();
|
|
827
|
-
return purify.Either.of({ identifier, type, labels });
|
|
1636
|
+
return purify.Either.of({ $identifier, $type, labels });
|
|
828
1637
|
}
|
|
829
|
-
OwlOntology
|
|
830
|
-
function
|
|
831
|
-
|
|
1638
|
+
OwlOntology.$propertiesFromRdf = $propertiesFromRdf;
|
|
1639
|
+
function $toRdf(_owlOntology, options) {
|
|
1640
|
+
const ignoreRdfType = !!options?.ignoreRdfType;
|
|
1641
|
+
const mutateGraph = options?.mutateGraph;
|
|
1642
|
+
const resourceSet = options?.resourceSet ??
|
|
1643
|
+
new rdfjsResource.MutableResourceSet({
|
|
1644
|
+
dataFactory,
|
|
1645
|
+
dataset: datasetFactory.dataset(),
|
|
1646
|
+
});
|
|
1647
|
+
const resource = resourceSet.mutableResource(_owlOntology.$identifier, {
|
|
1648
|
+
mutateGraph,
|
|
1649
|
+
});
|
|
1650
|
+
if (!ignoreRdfType) {
|
|
1651
|
+
resource.add($RdfVocabularies.rdf.type, resource.dataFactory.namedNode("http://purl.org/shaclmate/ontology#OwlOntology"));
|
|
1652
|
+
resource.add($RdfVocabularies.rdf.type, resource.dataFactory.namedNode("http://www.w3.org/2002/07/owl#Ontology"));
|
|
1653
|
+
}
|
|
1654
|
+
resource.add(OwlOntology.$properties.labels["identifier"], _owlOntology.labels.map((item) => item));
|
|
1655
|
+
return resource;
|
|
832
1656
|
}
|
|
833
|
-
OwlOntology
|
|
834
|
-
OwlOntology
|
|
1657
|
+
OwlOntology.$toRdf = $toRdf;
|
|
1658
|
+
OwlOntology.$properties = {
|
|
1659
|
+
labels: {
|
|
1660
|
+
identifier: dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#label"),
|
|
1661
|
+
},
|
|
1662
|
+
};
|
|
835
1663
|
})(OwlOntology || (OwlOntology = {}));
|
|
836
1664
|
export var ShaclCoreShape;
|
|
837
1665
|
(function (ShaclCoreShape) {
|
|
838
|
-
function fromRdf(
|
|
839
|
-
return ShaclCoreNodeShape
|
|
840
|
-
...
|
|
841
|
-
|
|
1666
|
+
function $fromRdf(resource, options) {
|
|
1667
|
+
return ShaclCoreNodeShape.$fromRdf(resource, {
|
|
1668
|
+
...options,
|
|
1669
|
+
ignoreRdfType: false,
|
|
1670
|
+
}).altLazy(() => ShaclCorePropertyShape.$fromRdf(resource, {
|
|
1671
|
+
...options,
|
|
1672
|
+
ignoreRdfType: false,
|
|
842
1673
|
}));
|
|
843
1674
|
}
|
|
844
|
-
ShaclCoreShape
|
|
1675
|
+
ShaclCoreShape.$fromRdf = $fromRdf;
|
|
1676
|
+
let $Identifier;
|
|
1677
|
+
(function ($Identifier) {
|
|
1678
|
+
function fromString(identifier) {
|
|
1679
|
+
return purify.Either.encase(() => rdfjsResource.Resource.Identifier.fromString({
|
|
1680
|
+
dataFactory,
|
|
1681
|
+
identifier,
|
|
1682
|
+
}));
|
|
1683
|
+
}
|
|
1684
|
+
$Identifier.fromString = fromString;
|
|
1685
|
+
$Identifier.toString = rdfjsResource.Resource.Identifier.toString;
|
|
1686
|
+
})($Identifier = ShaclCoreShape.$Identifier || (ShaclCoreShape.$Identifier = {}));
|
|
1687
|
+
function $toRdf(_shaclCoreShape, _parameters) {
|
|
1688
|
+
switch (_shaclCoreShape.$type) {
|
|
1689
|
+
case "ShaclCoreNodeShape":
|
|
1690
|
+
return ShaclCoreNodeShape.$toRdf(_shaclCoreShape, _parameters);
|
|
1691
|
+
case "ShaclCorePropertyShape":
|
|
1692
|
+
return ShaclCorePropertyShape.$toRdf(_shaclCoreShape, _parameters);
|
|
1693
|
+
default:
|
|
1694
|
+
_shaclCoreShape;
|
|
1695
|
+
throw new Error("unrecognized type");
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
ShaclCoreShape.$toRdf = $toRdf;
|
|
845
1699
|
})(ShaclCoreShape || (ShaclCoreShape = {}));
|
|
1700
|
+
export class $RdfjsDatasetObjectSet {
|
|
1701
|
+
resourceSet;
|
|
1702
|
+
constructor({ dataset }) {
|
|
1703
|
+
this.resourceSet = new rdfjsResource.ResourceSet({ dataset });
|
|
1704
|
+
}
|
|
1705
|
+
async owlOntology(identifier) {
|
|
1706
|
+
return this.owlOntologySync(identifier);
|
|
1707
|
+
}
|
|
1708
|
+
owlOntologySync(identifier) {
|
|
1709
|
+
return this.owlOntologiesSync({
|
|
1710
|
+
where: { identifiers: [identifier], type: "identifiers" },
|
|
1711
|
+
}).map((objects) => objects[0]);
|
|
1712
|
+
}
|
|
1713
|
+
async owlOntologyIdentifiers(query) {
|
|
1714
|
+
return this.owlOntologyIdentifiersSync(query);
|
|
1715
|
+
}
|
|
1716
|
+
owlOntologyIdentifiersSync(query) {
|
|
1717
|
+
return this.$objectIdentifiersSync(OwlOntology, query);
|
|
1718
|
+
}
|
|
1719
|
+
async owlOntologies(query) {
|
|
1720
|
+
return this.owlOntologiesSync(query);
|
|
1721
|
+
}
|
|
1722
|
+
owlOntologiesSync(query) {
|
|
1723
|
+
return this.$objectsSync(OwlOntology, query);
|
|
1724
|
+
}
|
|
1725
|
+
async owlOntologiesCount(query) {
|
|
1726
|
+
return this.owlOntologiesCountSync(query);
|
|
1727
|
+
}
|
|
1728
|
+
owlOntologiesCountSync(query) {
|
|
1729
|
+
return this.$objectsCountSync(OwlOntology, query);
|
|
1730
|
+
}
|
|
1731
|
+
async shaclCoreNodeShape(identifier) {
|
|
1732
|
+
return this.shaclCoreNodeShapeSync(identifier);
|
|
1733
|
+
}
|
|
1734
|
+
shaclCoreNodeShapeSync(identifier) {
|
|
1735
|
+
return this.shaclCoreNodeShapesSync({
|
|
1736
|
+
where: { identifiers: [identifier], type: "identifiers" },
|
|
1737
|
+
}).map((objects) => objects[0]);
|
|
1738
|
+
}
|
|
1739
|
+
async shaclCoreNodeShapeIdentifiers(query) {
|
|
1740
|
+
return this.shaclCoreNodeShapeIdentifiersSync(query);
|
|
1741
|
+
}
|
|
1742
|
+
shaclCoreNodeShapeIdentifiersSync(query) {
|
|
1743
|
+
return this.$objectIdentifiersSync(ShaclCoreNodeShape, query);
|
|
1744
|
+
}
|
|
1745
|
+
async shaclCoreNodeShapes(query) {
|
|
1746
|
+
return this.shaclCoreNodeShapesSync(query);
|
|
1747
|
+
}
|
|
1748
|
+
shaclCoreNodeShapesSync(query) {
|
|
1749
|
+
return this.$objectsSync(ShaclCoreNodeShape, query);
|
|
1750
|
+
}
|
|
1751
|
+
async shaclCoreNodeShapesCount(query) {
|
|
1752
|
+
return this.shaclCoreNodeShapesCountSync(query);
|
|
1753
|
+
}
|
|
1754
|
+
shaclCoreNodeShapesCountSync(query) {
|
|
1755
|
+
return this.$objectsCountSync(ShaclCoreNodeShape, query);
|
|
1756
|
+
}
|
|
1757
|
+
async shaclCorePropertyGroup(identifier) {
|
|
1758
|
+
return this.shaclCorePropertyGroupSync(identifier);
|
|
1759
|
+
}
|
|
1760
|
+
shaclCorePropertyGroupSync(identifier) {
|
|
1761
|
+
return this.shaclCorePropertyGroupsSync({
|
|
1762
|
+
where: { identifiers: [identifier], type: "identifiers" },
|
|
1763
|
+
}).map((objects) => objects[0]);
|
|
1764
|
+
}
|
|
1765
|
+
async shaclCorePropertyGroupIdentifiers(query) {
|
|
1766
|
+
return this.shaclCorePropertyGroupIdentifiersSync(query);
|
|
1767
|
+
}
|
|
1768
|
+
shaclCorePropertyGroupIdentifiersSync(query) {
|
|
1769
|
+
return this.$objectIdentifiersSync(ShaclCorePropertyGroup, query);
|
|
1770
|
+
}
|
|
1771
|
+
async shaclCorePropertyGroups(query) {
|
|
1772
|
+
return this.shaclCorePropertyGroupsSync(query);
|
|
1773
|
+
}
|
|
1774
|
+
shaclCorePropertyGroupsSync(query) {
|
|
1775
|
+
return this.$objectsSync(ShaclCorePropertyGroup, query);
|
|
1776
|
+
}
|
|
1777
|
+
async shaclCorePropertyGroupsCount(query) {
|
|
1778
|
+
return this.shaclCorePropertyGroupsCountSync(query);
|
|
1779
|
+
}
|
|
1780
|
+
shaclCorePropertyGroupsCountSync(query) {
|
|
1781
|
+
return this.$objectsCountSync(ShaclCorePropertyGroup, query);
|
|
1782
|
+
}
|
|
1783
|
+
async shaclCorePropertyShape(identifier) {
|
|
1784
|
+
return this.shaclCorePropertyShapeSync(identifier);
|
|
1785
|
+
}
|
|
1786
|
+
shaclCorePropertyShapeSync(identifier) {
|
|
1787
|
+
return this.shaclCorePropertyShapesSync({
|
|
1788
|
+
where: { identifiers: [identifier], type: "identifiers" },
|
|
1789
|
+
}).map((objects) => objects[0]);
|
|
1790
|
+
}
|
|
1791
|
+
async shaclCorePropertyShapeIdentifiers(query) {
|
|
1792
|
+
return this.shaclCorePropertyShapeIdentifiersSync(query);
|
|
1793
|
+
}
|
|
1794
|
+
shaclCorePropertyShapeIdentifiersSync(query) {
|
|
1795
|
+
return this.$objectIdentifiersSync(ShaclCorePropertyShape, query);
|
|
1796
|
+
}
|
|
1797
|
+
async shaclCorePropertyShapes(query) {
|
|
1798
|
+
return this.shaclCorePropertyShapesSync(query);
|
|
1799
|
+
}
|
|
1800
|
+
shaclCorePropertyShapesSync(query) {
|
|
1801
|
+
return this.$objectsSync(ShaclCorePropertyShape, query);
|
|
1802
|
+
}
|
|
1803
|
+
async shaclCorePropertyShapesCount(query) {
|
|
1804
|
+
return this.shaclCorePropertyShapesCountSync(query);
|
|
1805
|
+
}
|
|
1806
|
+
shaclCorePropertyShapesCountSync(query) {
|
|
1807
|
+
return this.$objectsCountSync(ShaclCorePropertyShape, query);
|
|
1808
|
+
}
|
|
1809
|
+
async shaclCoreShape(identifier) {
|
|
1810
|
+
return this.shaclCoreShapeSync(identifier);
|
|
1811
|
+
}
|
|
1812
|
+
shaclCoreShapeSync(identifier) {
|
|
1813
|
+
return this.shaclCoreShapesSync({
|
|
1814
|
+
where: { identifiers: [identifier], type: "identifiers" },
|
|
1815
|
+
}).map((objects) => objects[0]);
|
|
1816
|
+
}
|
|
1817
|
+
async shaclCoreShapeIdentifiers(query) {
|
|
1818
|
+
return this.shaclCoreShapeIdentifiersSync(query);
|
|
1819
|
+
}
|
|
1820
|
+
shaclCoreShapeIdentifiersSync(query) {
|
|
1821
|
+
return this.$objectUnionIdentifiersSync([ShaclCoreNodeShape, ShaclCorePropertyShape], query);
|
|
1822
|
+
}
|
|
1823
|
+
async shaclCoreShapes(query) {
|
|
1824
|
+
return this.shaclCoreShapesSync(query);
|
|
1825
|
+
}
|
|
1826
|
+
shaclCoreShapesSync(query) {
|
|
1827
|
+
return this.$objectUnionsSync([ShaclCoreNodeShape, ShaclCorePropertyShape], query);
|
|
1828
|
+
}
|
|
1829
|
+
async shaclCoreShapesCount(query) {
|
|
1830
|
+
return this.shaclCoreShapesCountSync(query);
|
|
1831
|
+
}
|
|
1832
|
+
shaclCoreShapesCountSync(query) {
|
|
1833
|
+
return this.$objectUnionsCountSync([ShaclCoreNodeShape, ShaclCorePropertyShape], query);
|
|
1834
|
+
}
|
|
1835
|
+
$objectIdentifiersSync(objectType, query) {
|
|
1836
|
+
return this.$objectsSync(objectType, query).map((objects) => objects.map((object) => object.$identifier));
|
|
1837
|
+
}
|
|
1838
|
+
$objectsSync(objectType, query) {
|
|
1839
|
+
const limit = query?.limit ?? Number.MAX_SAFE_INTEGER;
|
|
1840
|
+
if (limit <= 0) {
|
|
1841
|
+
return purify.Either.of([]);
|
|
1842
|
+
}
|
|
1843
|
+
let offset = query?.offset ?? 0;
|
|
1844
|
+
if (offset < 0) {
|
|
1845
|
+
offset = 0;
|
|
1846
|
+
}
|
|
1847
|
+
if (query?.where) {
|
|
1848
|
+
// Assign identifiers in each case block so the compiler will catch missing cases.
|
|
1849
|
+
let identifiers;
|
|
1850
|
+
switch (query.where.type) {
|
|
1851
|
+
case "identifiers": {
|
|
1852
|
+
identifiers = query.where.identifiers.slice(offset, offset + limit);
|
|
1853
|
+
break;
|
|
1854
|
+
}
|
|
1855
|
+
case "triple-objects": {
|
|
1856
|
+
let identifierI = 0;
|
|
1857
|
+
identifiers = [];
|
|
1858
|
+
for (const quad of this.resourceSet.dataset.match(query.where.subject, query.where.predicate, null)) {
|
|
1859
|
+
if (quad.object.termType === "BlankNode" ||
|
|
1860
|
+
quad.object.termType === "NamedNode") {
|
|
1861
|
+
if (++identifierI >= offset) {
|
|
1862
|
+
identifiers.push(quad.object);
|
|
1863
|
+
if (identifiers.length === limit) {
|
|
1864
|
+
break;
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1868
|
+
else {
|
|
1869
|
+
return purify.Left(new Error(`subject=${query.where.subject.value} predicate=${query.where.predicate.value} pattern matches non-identifier (${quad.object.termType}) triple`));
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
1872
|
+
break;
|
|
1873
|
+
}
|
|
1874
|
+
}
|
|
1875
|
+
const objects = [];
|
|
1876
|
+
for (const identifier of identifiers) {
|
|
1877
|
+
const either = objectType.$fromRdf(this.resourceSet.resource(identifier), { objectSet: this });
|
|
1878
|
+
if (either.isLeft()) {
|
|
1879
|
+
return either;
|
|
1880
|
+
}
|
|
1881
|
+
objects.push(either.unsafeCoerce());
|
|
1882
|
+
}
|
|
1883
|
+
return purify.Either.of(objects);
|
|
1884
|
+
}
|
|
1885
|
+
if (!objectType.$fromRdfType) {
|
|
1886
|
+
return purify.Either.of([]);
|
|
1887
|
+
}
|
|
1888
|
+
const resources = [
|
|
1889
|
+
...this.resourceSet.instancesOf(objectType.$fromRdfType),
|
|
1890
|
+
];
|
|
1891
|
+
// Sort resources by identifier so limit and offset are deterministic
|
|
1892
|
+
resources.sort((left, right) => left.identifier.value.localeCompare(right.identifier.value));
|
|
1893
|
+
const objects = [];
|
|
1894
|
+
let objectI = 0;
|
|
1895
|
+
for (const resource of resources) {
|
|
1896
|
+
const either = objectType.$fromRdf(resource, { objectSet: this });
|
|
1897
|
+
if (either.isLeft()) {
|
|
1898
|
+
return either;
|
|
1899
|
+
}
|
|
1900
|
+
if (objectI++ >= offset) {
|
|
1901
|
+
objects.push(either.unsafeCoerce());
|
|
1902
|
+
if (objects.length === limit) {
|
|
1903
|
+
return purify.Either.of(objects);
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1907
|
+
return purify.Either.of(objects);
|
|
1908
|
+
}
|
|
1909
|
+
$objectsCountSync(objectType, query) {
|
|
1910
|
+
return this.$objectsSync(objectType, query).map((objects) => objects.length);
|
|
1911
|
+
}
|
|
1912
|
+
$objectUnionIdentifiersSync(objectTypes, query) {
|
|
1913
|
+
return this.$objectUnionsSync(objectTypes, query).map((objects) => objects.map((object) => object.$identifier));
|
|
1914
|
+
}
|
|
1915
|
+
$objectUnionsSync(objectTypes, query) {
|
|
1916
|
+
const limit = query?.limit ?? Number.MAX_SAFE_INTEGER;
|
|
1917
|
+
if (limit <= 0) {
|
|
1918
|
+
return purify.Either.of([]);
|
|
1919
|
+
}
|
|
1920
|
+
let offset = query?.offset ?? 0;
|
|
1921
|
+
if (offset < 0) {
|
|
1922
|
+
offset = 0;
|
|
1923
|
+
}
|
|
1924
|
+
if (query?.where) {
|
|
1925
|
+
// Assign identifiers in each case block so the compiler will catch missing cases.
|
|
1926
|
+
let identifiers;
|
|
1927
|
+
switch (query.where.type) {
|
|
1928
|
+
case "identifiers": {
|
|
1929
|
+
identifiers = query.where.identifiers.slice(offset, offset + limit);
|
|
1930
|
+
break;
|
|
1931
|
+
}
|
|
1932
|
+
case "triple-objects": {
|
|
1933
|
+
let identifierI = 0;
|
|
1934
|
+
identifiers = [];
|
|
1935
|
+
for (const quad of this.resourceSet.dataset.match(query.where.subject, query.where.predicate, null)) {
|
|
1936
|
+
if (quad.object.termType === "BlankNode" ||
|
|
1937
|
+
quad.object.termType === "NamedNode") {
|
|
1938
|
+
if (++identifierI >= offset) {
|
|
1939
|
+
identifiers.push(quad.object);
|
|
1940
|
+
if (identifiers.length === limit) {
|
|
1941
|
+
break;
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1944
|
+
}
|
|
1945
|
+
else {
|
|
1946
|
+
return purify.Left(new Error(`subject=${query.where.subject.value} predicate=${query.where.predicate.value} pattern matches non-identifier (${quad.object.termType}) triple`));
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
break;
|
|
1950
|
+
}
|
|
1951
|
+
}
|
|
1952
|
+
const objects = [];
|
|
1953
|
+
for (const identifier of identifiers) {
|
|
1954
|
+
const resource = this.resourceSet.resource(identifier);
|
|
1955
|
+
const lefts = [];
|
|
1956
|
+
for (const objectType of objectTypes) {
|
|
1957
|
+
const either = objectType.$fromRdf(resource, { objectSet: this });
|
|
1958
|
+
if (either.isRight()) {
|
|
1959
|
+
objects.push(either.unsafeCoerce());
|
|
1960
|
+
break;
|
|
1961
|
+
}
|
|
1962
|
+
lefts.push(either);
|
|
1963
|
+
}
|
|
1964
|
+
// Doesn't appear to belong to any of the known object types, just assume the first
|
|
1965
|
+
if (lefts.length === objectTypes.length) {
|
|
1966
|
+
return lefts[0];
|
|
1967
|
+
}
|
|
1968
|
+
}
|
|
1969
|
+
return purify.Either.of(objects);
|
|
1970
|
+
}
|
|
1971
|
+
const resources = [];
|
|
1972
|
+
for (const objectType of objectTypes) {
|
|
1973
|
+
if (!objectType.$fromRdfType) {
|
|
1974
|
+
continue;
|
|
1975
|
+
}
|
|
1976
|
+
for (const resource of this.resourceSet.instancesOf(objectType.$fromRdfType)) {
|
|
1977
|
+
resources.push({ objectType, resource });
|
|
1978
|
+
}
|
|
1979
|
+
}
|
|
1980
|
+
// Sort resources by identifier so limit and offset are deterministic
|
|
1981
|
+
resources.sort((left, right) => left.resource.identifier.value.localeCompare(right.resource.identifier.value));
|
|
1982
|
+
let objectI = 0;
|
|
1983
|
+
const objects = [];
|
|
1984
|
+
for (const { objectType, resource } of resources) {
|
|
1985
|
+
const either = objectType.$fromRdf(resource, { objectSet: this });
|
|
1986
|
+
if (either.isLeft()) {
|
|
1987
|
+
return either;
|
|
1988
|
+
}
|
|
1989
|
+
if (objectI++ >= offset) {
|
|
1990
|
+
objects.push(either.unsafeCoerce());
|
|
1991
|
+
if (objects.length === limit) {
|
|
1992
|
+
return purify.Either.of(objects);
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
}
|
|
1996
|
+
return purify.Either.of(objects);
|
|
1997
|
+
}
|
|
1998
|
+
$objectUnionsCountSync(objectTypes, query) {
|
|
1999
|
+
return this.$objectUnionIdentifiersSync(objectTypes, query).map((objects) => objects.length);
|
|
2000
|
+
}
|
|
2001
|
+
}
|
|
846
2002
|
//# sourceMappingURL=generated.js.map
|