@shaclmate/shacl-ast 2.0.20 → 2.0.23

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/generated.js CHANGED
@@ -2,208 +2,241 @@ import { DataFactory as dataFactory } from "n3";
2
2
  import * as purify from "purify-ts";
3
3
  import * as rdfjsResource from "rdfjs-resource";
4
4
  import { PropertyPath } from "./PropertyPath.js";
5
- export var BaseShaclCoreShape;
6
- (function (BaseShaclCoreShape) {
7
- function _propertiesFromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource,
5
+ export var $RdfVocabularies;
6
+ (function ($RdfVocabularies) {
7
+ let rdf;
8
+ (function (rdf) {
9
+ rdf.first = dataFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#first");
10
+ rdf.nil = dataFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#nil");
11
+ rdf.rest = dataFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#rest");
12
+ rdf.subject = dataFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#subject");
13
+ rdf.type = dataFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
14
+ })(rdf = $RdfVocabularies.rdf || ($RdfVocabularies.rdf = {}));
15
+ let rdfs;
16
+ (function (rdfs) {
17
+ rdfs.subClassOf = dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#subClassOf");
18
+ })(rdfs = $RdfVocabularies.rdfs || ($RdfVocabularies.rdfs = {}));
19
+ let xsd;
20
+ (function (xsd) {
21
+ xsd.boolean = dataFactory.namedNode("http://www.w3.org/2001/XMLSchema#boolean");
22
+ xsd.date = dataFactory.namedNode("http://www.w3.org/2001/XMLSchema#date");
23
+ xsd.dateTime = dataFactory.namedNode("http://www.w3.org/2001/XMLSchema#dateTime");
24
+ xsd.integer = dataFactory.namedNode("http://www.w3.org/2001/XMLSchema#integer");
25
+ })(xsd = $RdfVocabularies.xsd || ($RdfVocabularies.xsd = {}));
26
+ })($RdfVocabularies || ($RdfVocabularies = {}));
27
+ export var BaseShaclCoreShapeStatic;
28
+ (function (BaseShaclCoreShapeStatic) {
29
+ let $Identifier;
30
+ (function ($Identifier) {
31
+ function fromString(identifier) {
32
+ return purify.Either.encase(() => rdfjsResource.Resource.Identifier.fromString({
33
+ dataFactory,
34
+ identifier,
35
+ }));
36
+ }
37
+ $Identifier.fromString = fromString;
38
+ $Identifier.toString = rdfjsResource.Resource.Identifier.toString;
39
+ })($Identifier = BaseShaclCoreShapeStatic.$Identifier || (BaseShaclCoreShapeStatic.$Identifier = {}));
40
+ function $propertiesFromRdf({ ignoreRdfType: $ignoreRdfType, languageIn: $languageIn, objectSet: $objectSetParameter, resource: $resource,
8
41
  // @ts-ignore
9
- ..._context }) {
10
- const identifier = _resource.identifier;
11
- const _andEither = purify.Either.of([
12
- ..._resource
13
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#and"), {
14
- unique: true,
15
- })
16
- .flatMap((_item) => _item
17
- .toValues()
18
- .head()
19
- .chain((value) => value.toList())
20
- .map((values) => values.flatMap((_value) => _value
21
- .toValues()
22
- .head()
23
- .chain((_value) => _value.toIdentifier())
24
- .toMaybe()
25
- .toList()))
26
- .toMaybe()
27
- .toList()),
28
- ]);
42
+ ...$context }) {
43
+ const $identifier = $resource.identifier;
44
+ const _andEither = purify.Either.sequence($resource
45
+ .values(BaseShaclCoreShapeStatic.$properties.and["identifier"], { unique: true })
46
+ .map((item) => item
47
+ .toValues()
48
+ .head()
49
+ .chain((value) => value.toList())
50
+ .chain((values) => purify.Either.sequence(values.map((value) => value
51
+ .toValues()
52
+ .head()
53
+ .chain((value) => value.toIdentifier()))))));
29
54
  if (_andEither.isLeft()) {
30
55
  return _andEither;
31
56
  }
32
57
  const and = _andEither.unsafeCoerce();
33
- const _classesEither = purify.Either.of([
34
- ..._resource
35
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#class"), {
36
- unique: true,
37
- })
38
- .flatMap((_item) => _item
39
- .toValues()
40
- .head()
41
- .chain((_value) => _value.toIri())
42
- .toMaybe()
43
- .toList()),
44
- ]);
58
+ const _classesEither = purify.Either.sequence($resource
59
+ .values(BaseShaclCoreShapeStatic.$properties.classes["identifier"], { unique: true })
60
+ .map((item) => item
61
+ .toValues()
62
+ .head()
63
+ .chain((value) => value.toIri())));
45
64
  if (_classesEither.isLeft()) {
46
65
  return _classesEither;
47
66
  }
48
67
  const classes = _classesEither.unsafeCoerce();
49
- const _commentsEither = purify.Either.of([
50
- ..._resource
51
- .values(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#comment"), { unique: true })
52
- .flatMap((_item) => _item
53
- .toValues()
54
- .filter((_value) => {
55
- const _languageInOrDefault = _languageIn ?? [];
56
- if (_languageInOrDefault.length === 0) {
57
- return true;
58
- }
59
- const _valueLiteral = _value.toLiteral().toMaybe().extract();
60
- if (typeof _valueLiteral === "undefined") {
61
- return false;
62
- }
63
- return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
64
- })
65
- .head()
66
- .chain((_value) => _value.toLiteral())
67
- .toMaybe()
68
- .toList()),
69
- ]);
68
+ const _commentsEither = purify.Either.sequence($resource
69
+ .values(BaseShaclCoreShapeStatic.$properties.comments["identifier"], { unique: true })
70
+ .map((item) => item
71
+ .toValues()
72
+ .filter((_value) => {
73
+ const _languageInOrDefault = $languageIn ?? [];
74
+ if (_languageInOrDefault.length === 0) {
75
+ return true;
76
+ }
77
+ const _valueLiteral = _value.toLiteral().toMaybe().extract();
78
+ if (typeof _valueLiteral === "undefined") {
79
+ return false;
80
+ }
81
+ return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
82
+ })
83
+ .head()
84
+ .chain((value) => value.toLiteral())));
70
85
  if (_commentsEither.isLeft()) {
71
86
  return _commentsEither;
72
87
  }
73
88
  const comments = _commentsEither.unsafeCoerce();
74
- const _datatypeEither = purify.Either.of(_resource
75
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#datatype"), {
76
- unique: true,
77
- })
89
+ const _datatypeEither = $resource
90
+ .values(BaseShaclCoreShapeStatic.$properties.datatype["identifier"], { unique: true })
78
91
  .head()
79
- .chain((_value) => _value.toIri())
80
- .toMaybe());
92
+ .chain((value) => value.toIri())
93
+ .map((value) => purify.Maybe.of(value))
94
+ .chainLeft((error) => error instanceof rdfjsResource.Resource.MissingValueError
95
+ ? purify.Right(purify.Maybe.empty())
96
+ : purify.Left(error));
81
97
  if (_datatypeEither.isLeft()) {
82
98
  return _datatypeEither;
83
99
  }
84
100
  const datatype = _datatypeEither.unsafeCoerce();
85
- const _deactivatedEither = purify.Either.of(_resource
86
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#deactivated"), { unique: true })
101
+ const _deactivatedEither = $resource
102
+ .values(BaseShaclCoreShapeStatic.$properties.deactivated["identifier"], { unique: true })
87
103
  .head()
88
- .chain((_value) => _value.toBoolean())
89
- .toMaybe());
104
+ .chain((value) => value.toBoolean())
105
+ .map((value) => purify.Maybe.of(value))
106
+ .chainLeft((error) => error instanceof rdfjsResource.Resource.MissingValueError
107
+ ? purify.Right(purify.Maybe.empty())
108
+ : purify.Left(error));
90
109
  if (_deactivatedEither.isLeft()) {
91
110
  return _deactivatedEither;
92
111
  }
93
112
  const deactivated = _deactivatedEither.unsafeCoerce();
94
- const _flagsEither = purify.Either.of([
95
- ..._resource
96
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#flags"), {
97
- unique: true,
98
- })
99
- .flatMap((_item) => _item
100
- .toValues()
101
- .head()
102
- .chain((_value) => _value.toString())
103
- .toMaybe()
104
- .toList()),
105
- ]);
113
+ const _flagsEither = purify.Either.sequence($resource
114
+ .values(BaseShaclCoreShapeStatic.$properties.flags["identifier"], { unique: true })
115
+ .map((item) => item
116
+ .toValues()
117
+ .head()
118
+ .chain((value) => value.toString())));
106
119
  if (_flagsEither.isLeft()) {
107
120
  return _flagsEither;
108
121
  }
109
122
  const flags = _flagsEither.unsafeCoerce();
110
- const _hasValuesEither = purify.Either.of([
111
- ..._resource
112
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#hasValue"), {
113
- unique: true,
114
- })
115
- .flatMap((_item) => _item
116
- .toValues()
117
- .head()
118
- .chain((_value) => purify.Either.of(_value.toTerm()))
119
- .toMaybe()
120
- .toList()),
121
- ]);
123
+ const _hasValuesEither = purify.Either.sequence($resource
124
+ .values(BaseShaclCoreShapeStatic.$properties.hasValues["identifier"], { unique: true })
125
+ .map((item) => item
126
+ .toValues()
127
+ .head()
128
+ .chain((value) => purify.Either.of(value.toTerm()).chain((term) => {
129
+ switch (term.termType) {
130
+ case "Literal":
131
+ case "NamedNode":
132
+ return purify.Either.of(term);
133
+ default:
134
+ return purify.Left(new rdfjsResource.Resource.MistypedValueError({
135
+ actualValue: term,
136
+ expectedValueType: "(rdfjs.Literal | rdfjs.NamedNode)",
137
+ focusResource: $resource,
138
+ predicate: BaseShaclCoreShapeStatic.$properties.hasValues["identifier"],
139
+ }));
140
+ }
141
+ }))));
122
142
  if (_hasValuesEither.isLeft()) {
123
143
  return _hasValuesEither;
124
144
  }
125
145
  const hasValues = _hasValuesEither.unsafeCoerce();
126
- const _in_Either = purify.Either.of(_resource
127
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#in"), {
128
- unique: true,
129
- })
146
+ const _in_Either = $resource
147
+ .values(BaseShaclCoreShapeStatic.$properties.in_["identifier"], { unique: true })
130
148
  .head()
131
149
  .chain((value) => value.toList())
132
- .map((values) => values.flatMap((_value) => _value
150
+ .chain((values) => purify.Either.sequence(values.map((value) => value
133
151
  .toValues()
134
152
  .head()
135
- .chain((_value) => purify.Either.of(_value.toTerm()))
136
- .toMaybe()
137
- .toList()))
138
- .toMaybe());
153
+ .chain((value) => purify.Either.of(value.toTerm()).chain((term) => {
154
+ switch (term.termType) {
155
+ case "Literal":
156
+ case "NamedNode":
157
+ return purify.Either.of(term);
158
+ default:
159
+ return purify.Left(new rdfjsResource.Resource.MistypedValueError({
160
+ actualValue: term,
161
+ expectedValueType: "(rdfjs.Literal | rdfjs.NamedNode)",
162
+ focusResource: $resource,
163
+ predicate: BaseShaclCoreShapeStatic.$properties.in_["identifier"],
164
+ }));
165
+ }
166
+ })))))
167
+ .map((value) => purify.Maybe.of(value))
168
+ .chainLeft((error) => error instanceof rdfjsResource.Resource.MissingValueError
169
+ ? purify.Right(purify.Maybe.empty())
170
+ : purify.Left(error));
139
171
  if (_in_Either.isLeft()) {
140
172
  return _in_Either;
141
173
  }
142
174
  const in_ = _in_Either.unsafeCoerce();
143
- const _isDefinedByEither = purify.Either.of(_resource
144
- .values(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#isDefinedBy"), { unique: true })
175
+ const _isDefinedByEither = $resource
176
+ .values(BaseShaclCoreShapeStatic.$properties.isDefinedBy["identifier"], { unique: true })
145
177
  .head()
146
- .chain((_value) => _value.toIdentifier())
147
- .toMaybe());
178
+ .chain((value) => value.toIdentifier())
179
+ .map((value) => purify.Maybe.of(value))
180
+ .chainLeft((error) => error instanceof rdfjsResource.Resource.MissingValueError
181
+ ? purify.Right(purify.Maybe.empty())
182
+ : purify.Left(error));
148
183
  if (_isDefinedByEither.isLeft()) {
149
184
  return _isDefinedByEither;
150
185
  }
151
186
  const isDefinedBy = _isDefinedByEither.unsafeCoerce();
152
- const _labelsEither = purify.Either.of([
153
- ..._resource
154
- .values(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#label"), { unique: true })
155
- .flatMap((_item) => _item
156
- .toValues()
157
- .filter((_value) => {
158
- const _languageInOrDefault = _languageIn ?? [];
159
- if (_languageInOrDefault.length === 0) {
160
- return true;
161
- }
162
- const _valueLiteral = _value.toLiteral().toMaybe().extract();
163
- if (typeof _valueLiteral === "undefined") {
164
- return false;
165
- }
166
- return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
167
- })
168
- .head()
169
- .chain((_value) => _value.toLiteral())
170
- .toMaybe()
171
- .toList()),
172
- ]);
187
+ const _labelsEither = purify.Either.sequence($resource
188
+ .values(BaseShaclCoreShapeStatic.$properties.labels["identifier"], { unique: true })
189
+ .map((item) => item
190
+ .toValues()
191
+ .filter((_value) => {
192
+ const _languageInOrDefault = $languageIn ?? [];
193
+ if (_languageInOrDefault.length === 0) {
194
+ return true;
195
+ }
196
+ const _valueLiteral = _value.toLiteral().toMaybe().extract();
197
+ if (typeof _valueLiteral === "undefined") {
198
+ return false;
199
+ }
200
+ return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
201
+ })
202
+ .head()
203
+ .chain((value) => value.toLiteral())));
173
204
  if (_labelsEither.isLeft()) {
174
205
  return _labelsEither;
175
206
  }
176
207
  const labels = _labelsEither.unsafeCoerce();
177
- const _languageInEither = purify.Either.of(_resource
178
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#languageIn"), { unique: true })
208
+ const _languageInEither = $resource
209
+ .values(BaseShaclCoreShapeStatic.$properties.languageIn["identifier"], { unique: true })
179
210
  .head()
180
211
  .chain((value) => value.toList())
181
- .map((values) => values.flatMap((_value) => _value
212
+ .chain((values) => purify.Either.sequence(values.map((value) => value
182
213
  .toValues()
183
214
  .head()
184
- .chain((_value) => _value.toString())
185
- .toMaybe()
186
- .toList()))
187
- .toMaybe());
215
+ .chain((value) => value.toString()))))
216
+ .map((value) => purify.Maybe.of(value))
217
+ .chainLeft((error) => error instanceof rdfjsResource.Resource.MissingValueError
218
+ ? purify.Right(purify.Maybe.empty())
219
+ : purify.Left(error));
188
220
  if (_languageInEither.isLeft()) {
189
221
  return _languageInEither;
190
222
  }
191
223
  const languageIn = _languageInEither.unsafeCoerce();
192
- const _maxCountEither = purify.Either.of(_resource
193
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#maxCount"), {
194
- unique: true,
195
- })
224
+ const _maxCountEither = $resource
225
+ .values(BaseShaclCoreShapeStatic.$properties.maxCount["identifier"], { unique: true })
196
226
  .head()
197
- .chain((_value) => _value.toNumber())
198
- .toMaybe());
227
+ .chain((value) => value.toNumber())
228
+ .map((value) => purify.Maybe.of(value))
229
+ .chainLeft((error) => error instanceof rdfjsResource.Resource.MissingValueError
230
+ ? purify.Right(purify.Maybe.empty())
231
+ : purify.Left(error));
199
232
  if (_maxCountEither.isLeft()) {
200
233
  return _maxCountEither;
201
234
  }
202
235
  const maxCount = _maxCountEither.unsafeCoerce();
203
- const _maxExclusiveEither = purify.Either.of(_resource
204
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#maxExclusive"), { unique: true })
236
+ const _maxExclusiveEither = $resource
237
+ .values(BaseShaclCoreShapeStatic.$properties.maxExclusive["identifier"], { unique: true })
205
238
  .filter((_value) => {
206
- const _languageInOrDefault = _languageIn ?? [];
239
+ const _languageInOrDefault = $languageIn ?? [];
207
240
  if (_languageInOrDefault.length === 0) {
208
241
  return true;
209
242
  }
@@ -214,16 +247,19 @@ export var BaseShaclCoreShape;
214
247
  return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
215
248
  })
216
249
  .head()
217
- .chain((_value) => _value.toLiteral())
218
- .toMaybe());
250
+ .chain((value) => value.toLiteral())
251
+ .map((value) => purify.Maybe.of(value))
252
+ .chainLeft((error) => error instanceof rdfjsResource.Resource.MissingValueError
253
+ ? purify.Right(purify.Maybe.empty())
254
+ : purify.Left(error));
219
255
  if (_maxExclusiveEither.isLeft()) {
220
256
  return _maxExclusiveEither;
221
257
  }
222
258
  const maxExclusive = _maxExclusiveEither.unsafeCoerce();
223
- const _maxInclusiveEither = purify.Either.of(_resource
224
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#maxInclusive"), { unique: true })
259
+ const _maxInclusiveEither = $resource
260
+ .values(BaseShaclCoreShapeStatic.$properties.maxInclusive["identifier"], { unique: true })
225
261
  .filter((_value) => {
226
- const _languageInOrDefault = _languageIn ?? [];
262
+ const _languageInOrDefault = $languageIn ?? [];
227
263
  if (_languageInOrDefault.length === 0) {
228
264
  return true;
229
265
  }
@@ -234,38 +270,43 @@ export var BaseShaclCoreShape;
234
270
  return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
235
271
  })
236
272
  .head()
237
- .chain((_value) => _value.toLiteral())
238
- .toMaybe());
273
+ .chain((value) => value.toLiteral())
274
+ .map((value) => purify.Maybe.of(value))
275
+ .chainLeft((error) => error instanceof rdfjsResource.Resource.MissingValueError
276
+ ? purify.Right(purify.Maybe.empty())
277
+ : purify.Left(error));
239
278
  if (_maxInclusiveEither.isLeft()) {
240
279
  return _maxInclusiveEither;
241
280
  }
242
281
  const maxInclusive = _maxInclusiveEither.unsafeCoerce();
243
- const _maxLengthEither = purify.Either.of(_resource
244
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#maxLength"), {
245
- unique: true,
246
- })
282
+ const _maxLengthEither = $resource
283
+ .values(BaseShaclCoreShapeStatic.$properties.maxLength["identifier"], { unique: true })
247
284
  .head()
248
- .chain((_value) => _value.toNumber())
249
- .toMaybe());
285
+ .chain((value) => value.toNumber())
286
+ .map((value) => purify.Maybe.of(value))
287
+ .chainLeft((error) => error instanceof rdfjsResource.Resource.MissingValueError
288
+ ? purify.Right(purify.Maybe.empty())
289
+ : purify.Left(error));
250
290
  if (_maxLengthEither.isLeft()) {
251
291
  return _maxLengthEither;
252
292
  }
253
293
  const maxLength = _maxLengthEither.unsafeCoerce();
254
- const _minCountEither = purify.Either.of(_resource
255
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#minCount"), {
256
- unique: true,
257
- })
294
+ const _minCountEither = $resource
295
+ .values(BaseShaclCoreShapeStatic.$properties.minCount["identifier"], { unique: true })
258
296
  .head()
259
- .chain((_value) => _value.toNumber())
260
- .toMaybe());
297
+ .chain((value) => value.toNumber())
298
+ .map((value) => purify.Maybe.of(value))
299
+ .chainLeft((error) => error instanceof rdfjsResource.Resource.MissingValueError
300
+ ? purify.Right(purify.Maybe.empty())
301
+ : purify.Left(error));
261
302
  if (_minCountEither.isLeft()) {
262
303
  return _minCountEither;
263
304
  }
264
305
  const minCount = _minCountEither.unsafeCoerce();
265
- const _minExclusiveEither = purify.Either.of(_resource
266
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#minExclusive"), { unique: true })
306
+ const _minExclusiveEither = $resource
307
+ .values(BaseShaclCoreShapeStatic.$properties.minExclusive["identifier"], { unique: true })
267
308
  .filter((_value) => {
268
- const _languageInOrDefault = _languageIn ?? [];
309
+ const _languageInOrDefault = $languageIn ?? [];
269
310
  if (_languageInOrDefault.length === 0) {
270
311
  return true;
271
312
  }
@@ -276,16 +317,19 @@ export var BaseShaclCoreShape;
276
317
  return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
277
318
  })
278
319
  .head()
279
- .chain((_value) => _value.toLiteral())
280
- .toMaybe());
320
+ .chain((value) => value.toLiteral())
321
+ .map((value) => purify.Maybe.of(value))
322
+ .chainLeft((error) => error instanceof rdfjsResource.Resource.MissingValueError
323
+ ? purify.Right(purify.Maybe.empty())
324
+ : purify.Left(error));
281
325
  if (_minExclusiveEither.isLeft()) {
282
326
  return _minExclusiveEither;
283
327
  }
284
328
  const minExclusive = _minExclusiveEither.unsafeCoerce();
285
- const _minInclusiveEither = purify.Either.of(_resource
286
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#minInclusive"), { unique: true })
329
+ const _minInclusiveEither = $resource
330
+ .values(BaseShaclCoreShapeStatic.$properties.minInclusive["identifier"], { unique: true })
287
331
  .filter((_value) => {
288
- const _languageInOrDefault = _languageIn ?? [];
332
+ const _languageInOrDefault = $languageIn ?? [];
289
333
  if (_languageInOrDefault.length === 0) {
290
334
  return true;
291
335
  }
@@ -296,29 +340,31 @@ export var BaseShaclCoreShape;
296
340
  return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
297
341
  })
298
342
  .head()
299
- .chain((_value) => _value.toLiteral())
300
- .toMaybe());
343
+ .chain((value) => value.toLiteral())
344
+ .map((value) => purify.Maybe.of(value))
345
+ .chainLeft((error) => error instanceof rdfjsResource.Resource.MissingValueError
346
+ ? purify.Right(purify.Maybe.empty())
347
+ : purify.Left(error));
301
348
  if (_minInclusiveEither.isLeft()) {
302
349
  return _minInclusiveEither;
303
350
  }
304
351
  const minInclusive = _minInclusiveEither.unsafeCoerce();
305
- const _minLengthEither = purify.Either.of(_resource
306
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#minLength"), {
307
- unique: true,
308
- })
352
+ const _minLengthEither = $resource
353
+ .values(BaseShaclCoreShapeStatic.$properties.minLength["identifier"], { unique: true })
309
354
  .head()
310
- .chain((_value) => _value.toNumber())
311
- .toMaybe());
355
+ .chain((value) => value.toNumber())
356
+ .map((value) => purify.Maybe.of(value))
357
+ .chainLeft((error) => error instanceof rdfjsResource.Resource.MissingValueError
358
+ ? purify.Right(purify.Maybe.empty())
359
+ : purify.Left(error));
312
360
  if (_minLengthEither.isLeft()) {
313
361
  return _minLengthEither;
314
362
  }
315
363
  const minLength = _minLengthEither.unsafeCoerce();
316
- const _nodeKindEither = purify.Either.of(_resource
317
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#nodeKind"), {
318
- unique: true,
319
- })
364
+ const _nodeKindEither = $resource
365
+ .values(BaseShaclCoreShapeStatic.$properties.nodeKind["identifier"], { unique: true })
320
366
  .head()
321
- .chain((_value) => _value.toIri().chain((iri) => {
367
+ .chain((value) => value.toIri().chain((iri) => {
322
368
  switch (iri.value) {
323
369
  case "http://www.w3.org/ns/shacl#BlankNode":
324
370
  return purify.Either.of(iri);
@@ -336,110 +382,79 @@ export var BaseShaclCoreShape;
336
382
  return purify.Left(new rdfjsResource.Resource.MistypedValueError({
337
383
  actualValue: iri,
338
384
  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: _resource,
340
- predicate: dataFactory.namedNode("http://www.w3.org/ns/shacl#nodeKind"),
385
+ focusResource: $resource,
386
+ predicate: BaseShaclCoreShapeStatic.$properties.nodeKind["identifier"],
341
387
  }));
342
388
  }
343
389
  }))
344
- .toMaybe());
390
+ .map((value) => purify.Maybe.of(value))
391
+ .chainLeft((error) => error instanceof rdfjsResource.Resource.MissingValueError
392
+ ? purify.Right(purify.Maybe.empty())
393
+ : purify.Left(error));
345
394
  if (_nodeKindEither.isLeft()) {
346
395
  return _nodeKindEither;
347
396
  }
348
397
  const nodeKind = _nodeKindEither.unsafeCoerce();
349
- const _nodesEither = purify.Either.of([
350
- ..._resource
351
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#node"), {
352
- unique: true,
353
- })
354
- .flatMap((_item) => _item
355
- .toValues()
356
- .head()
357
- .chain((_value) => _value.toIdentifier())
358
- .toMaybe()
359
- .toList()),
360
- ]);
398
+ const _nodesEither = purify.Either.sequence($resource
399
+ .values(BaseShaclCoreShapeStatic.$properties.nodes["identifier"], { unique: true })
400
+ .map((item) => item
401
+ .toValues()
402
+ .head()
403
+ .chain((value) => value.toIdentifier())));
361
404
  if (_nodesEither.isLeft()) {
362
405
  return _nodesEither;
363
406
  }
364
407
  const nodes = _nodesEither.unsafeCoerce();
365
- const _notEither = purify.Either.of([
366
- ..._resource
367
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#not"), {
368
- unique: true,
369
- })
370
- .flatMap((_item) => _item
371
- .toValues()
372
- .head()
373
- .chain((_value) => _value.toIdentifier())
374
- .toMaybe()
375
- .toList()),
376
- ]);
408
+ const _notEither = purify.Either.sequence($resource
409
+ .values(BaseShaclCoreShapeStatic.$properties.not["identifier"], { unique: true })
410
+ .map((item) => item
411
+ .toValues()
412
+ .head()
413
+ .chain((value) => value.toIdentifier())));
377
414
  if (_notEither.isLeft()) {
378
415
  return _notEither;
379
416
  }
380
417
  const not = _notEither.unsafeCoerce();
381
- const _orEither = purify.Either.of([
382
- ..._resource
383
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#or"), {
384
- unique: true,
385
- })
386
- .flatMap((_item) => _item
387
- .toValues()
388
- .head()
389
- .chain((value) => value.toList())
390
- .map((values) => values.flatMap((_value) => _value
391
- .toValues()
392
- .head()
393
- .chain((_value) => _value.toIdentifier())
394
- .toMaybe()
395
- .toList()))
396
- .toMaybe()
397
- .toList()),
398
- ]);
418
+ const _orEither = purify.Either.sequence($resource
419
+ .values(BaseShaclCoreShapeStatic.$properties.or["identifier"], { unique: true })
420
+ .map((item) => item
421
+ .toValues()
422
+ .head()
423
+ .chain((value) => value.toList())
424
+ .chain((values) => purify.Either.sequence(values.map((value) => value
425
+ .toValues()
426
+ .head()
427
+ .chain((value) => value.toIdentifier()))))));
399
428
  if (_orEither.isLeft()) {
400
429
  return _orEither;
401
430
  }
402
431
  const or = _orEither.unsafeCoerce();
403
- const _patternsEither = purify.Either.of([
404
- ..._resource
405
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#pattern"), {
406
- unique: true,
407
- })
408
- .flatMap((_item) => _item
409
- .toValues()
410
- .head()
411
- .chain((_value) => _value.toString())
412
- .toMaybe()
413
- .toList()),
414
- ]);
432
+ const _patternsEither = purify.Either.sequence($resource
433
+ .values(BaseShaclCoreShapeStatic.$properties.patterns["identifier"], { unique: true })
434
+ .map((item) => item
435
+ .toValues()
436
+ .head()
437
+ .chain((value) => value.toString())));
415
438
  if (_patternsEither.isLeft()) {
416
439
  return _patternsEither;
417
440
  }
418
441
  const patterns = _patternsEither.unsafeCoerce();
419
- const _xoneEither = purify.Either.of([
420
- ..._resource
421
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#xone"), {
422
- unique: true,
423
- })
424
- .flatMap((_item) => _item
425
- .toValues()
426
- .head()
427
- .chain((value) => value.toList())
428
- .map((values) => values.flatMap((_value) => _value
429
- .toValues()
430
- .head()
431
- .chain((_value) => _value.toIdentifier())
432
- .toMaybe()
433
- .toList()))
434
- .toMaybe()
435
- .toList()),
436
- ]);
442
+ const _xoneEither = purify.Either.sequence($resource
443
+ .values(BaseShaclCoreShapeStatic.$properties.xone["identifier"], { unique: true })
444
+ .map((item) => item
445
+ .toValues()
446
+ .head()
447
+ .chain((value) => value.toList())
448
+ .chain((values) => purify.Either.sequence(values.map((value) => value
449
+ .toValues()
450
+ .head()
451
+ .chain((value) => value.toIdentifier()))))));
437
452
  if (_xoneEither.isLeft()) {
438
453
  return _xoneEither;
439
454
  }
440
455
  const xone = _xoneEither.unsafeCoerce();
441
456
  return purify.Either.of({
442
- identifier,
457
+ $identifier,
443
458
  and,
444
459
  classes,
445
460
  comments,
@@ -467,150 +482,355 @@ export var BaseShaclCoreShape;
467
482
  xone,
468
483
  });
469
484
  }
470
- BaseShaclCoreShape._propertiesFromRdf = _propertiesFromRdf;
471
- })(BaseShaclCoreShape || (BaseShaclCoreShape = {}));
485
+ BaseShaclCoreShapeStatic.$propertiesFromRdf = $propertiesFromRdf;
486
+ function $fromRdf(parameters) {
487
+ const { ignoreRdfType: _, ...otherParameters } = parameters;
488
+ return ShaclCoreNodeShape.$fromRdf(otherParameters).altLazy(() => ShaclCorePropertyShape.$fromRdf(otherParameters));
489
+ }
490
+ BaseShaclCoreShapeStatic.$fromRdf = $fromRdf;
491
+ function $toRdf(_baseShaclCoreShape, { mutateGraph, resourceSet, }) {
492
+ const _resource = resourceSet.mutableResource(_baseShaclCoreShape.$identifier, { mutateGraph });
493
+ _resource.add(BaseShaclCoreShapeStatic.$properties.and["identifier"], _baseShaclCoreShape.and.map((item) => item.length > 0
494
+ ? item.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
495
+ if (itemIndex === 0) {
496
+ currentSubListResource = listResource;
497
+ }
498
+ else {
499
+ const newSubListResource = resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph });
500
+ currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier);
501
+ currentSubListResource = newSubListResource;
502
+ }
503
+ currentSubListResource.add($RdfVocabularies.rdf.first, item);
504
+ if (itemIndex + 1 === list.length) {
505
+ currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil);
506
+ }
507
+ return { currentSubListResource, listResource };
508
+ }, {
509
+ currentSubListResource: null,
510
+ listResource: resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph }),
511
+ }).listResource.identifier
512
+ : $RdfVocabularies.rdf.nil));
513
+ _resource.add(BaseShaclCoreShapeStatic.$properties.classes["identifier"], _baseShaclCoreShape.classes.map((item) => item));
514
+ _resource.add(BaseShaclCoreShapeStatic.$properties.comments["identifier"], _baseShaclCoreShape.comments.map((item) => item));
515
+ _resource.add(BaseShaclCoreShapeStatic.$properties.datatype["identifier"], _baseShaclCoreShape.datatype);
516
+ _resource.add(BaseShaclCoreShapeStatic.$properties.deactivated["identifier"], _baseShaclCoreShape.deactivated);
517
+ _resource.add(BaseShaclCoreShapeStatic.$properties.flags["identifier"], _baseShaclCoreShape.flags.map((item) => item));
518
+ _resource.add(BaseShaclCoreShapeStatic.$properties.hasValues["identifier"], _baseShaclCoreShape.hasValues.map((item) => item));
519
+ _resource.add(BaseShaclCoreShapeStatic.$properties.in_["identifier"], _baseShaclCoreShape.in_.map((value) => value.length > 0
520
+ ? value.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
521
+ if (itemIndex === 0) {
522
+ currentSubListResource = listResource;
523
+ }
524
+ else {
525
+ const newSubListResource = resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph });
526
+ currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier);
527
+ currentSubListResource = newSubListResource;
528
+ }
529
+ currentSubListResource.add($RdfVocabularies.rdf.first, item);
530
+ if (itemIndex + 1 === list.length) {
531
+ currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil);
532
+ }
533
+ return { currentSubListResource, listResource };
534
+ }, {
535
+ currentSubListResource: null,
536
+ listResource: resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph }),
537
+ }).listResource.identifier
538
+ : $RdfVocabularies.rdf.nil));
539
+ _resource.add(BaseShaclCoreShapeStatic.$properties.isDefinedBy["identifier"], _baseShaclCoreShape.isDefinedBy);
540
+ _resource.add(BaseShaclCoreShapeStatic.$properties.labels["identifier"], _baseShaclCoreShape.labels.map((item) => item));
541
+ _resource.add(BaseShaclCoreShapeStatic.$properties.languageIn["identifier"], _baseShaclCoreShape.languageIn.map((value) => value.length > 0
542
+ ? value.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
543
+ if (itemIndex === 0) {
544
+ currentSubListResource = listResource;
545
+ }
546
+ else {
547
+ const newSubListResource = resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph });
548
+ currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier);
549
+ currentSubListResource = newSubListResource;
550
+ }
551
+ currentSubListResource.add($RdfVocabularies.rdf.first, item);
552
+ if (itemIndex + 1 === list.length) {
553
+ currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil);
554
+ }
555
+ return { currentSubListResource, listResource };
556
+ }, {
557
+ currentSubListResource: null,
558
+ listResource: resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph }),
559
+ }).listResource.identifier
560
+ : $RdfVocabularies.rdf.nil));
561
+ _resource.add(BaseShaclCoreShapeStatic.$properties.maxCount["identifier"], _baseShaclCoreShape.maxCount);
562
+ _resource.add(BaseShaclCoreShapeStatic.$properties.maxExclusive["identifier"], _baseShaclCoreShape.maxExclusive);
563
+ _resource.add(BaseShaclCoreShapeStatic.$properties.maxInclusive["identifier"], _baseShaclCoreShape.maxInclusive);
564
+ _resource.add(BaseShaclCoreShapeStatic.$properties.maxLength["identifier"], _baseShaclCoreShape.maxLength);
565
+ _resource.add(BaseShaclCoreShapeStatic.$properties.minCount["identifier"], _baseShaclCoreShape.minCount);
566
+ _resource.add(BaseShaclCoreShapeStatic.$properties.minExclusive["identifier"], _baseShaclCoreShape.minExclusive);
567
+ _resource.add(BaseShaclCoreShapeStatic.$properties.minInclusive["identifier"], _baseShaclCoreShape.minInclusive);
568
+ _resource.add(BaseShaclCoreShapeStatic.$properties.minLength["identifier"], _baseShaclCoreShape.minLength);
569
+ _resource.add(BaseShaclCoreShapeStatic.$properties.nodeKind["identifier"], _baseShaclCoreShape.nodeKind);
570
+ _resource.add(BaseShaclCoreShapeStatic.$properties.nodes["identifier"], _baseShaclCoreShape.nodes.map((item) => item));
571
+ _resource.add(BaseShaclCoreShapeStatic.$properties.not["identifier"], _baseShaclCoreShape.not.map((item) => item));
572
+ _resource.add(BaseShaclCoreShapeStatic.$properties.or["identifier"], _baseShaclCoreShape.or.map((item) => item.length > 0
573
+ ? item.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
574
+ if (itemIndex === 0) {
575
+ currentSubListResource = listResource;
576
+ }
577
+ else {
578
+ const newSubListResource = resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph });
579
+ currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier);
580
+ currentSubListResource = newSubListResource;
581
+ }
582
+ currentSubListResource.add($RdfVocabularies.rdf.first, item);
583
+ if (itemIndex + 1 === list.length) {
584
+ currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil);
585
+ }
586
+ return { currentSubListResource, listResource };
587
+ }, {
588
+ currentSubListResource: null,
589
+ listResource: resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph }),
590
+ }).listResource.identifier
591
+ : $RdfVocabularies.rdf.nil));
592
+ _resource.add(BaseShaclCoreShapeStatic.$properties.patterns["identifier"], _baseShaclCoreShape.patterns.map((item) => item));
593
+ _resource.add(BaseShaclCoreShapeStatic.$properties.xone["identifier"], _baseShaclCoreShape.xone.map((item) => item.length > 0
594
+ ? item.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
595
+ if (itemIndex === 0) {
596
+ currentSubListResource = listResource;
597
+ }
598
+ else {
599
+ const newSubListResource = resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph });
600
+ currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier);
601
+ currentSubListResource = newSubListResource;
602
+ }
603
+ currentSubListResource.add($RdfVocabularies.rdf.first, item);
604
+ if (itemIndex + 1 === list.length) {
605
+ currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil);
606
+ }
607
+ return { currentSubListResource, listResource };
608
+ }, {
609
+ currentSubListResource: null,
610
+ listResource: resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph }),
611
+ }).listResource.identifier
612
+ : $RdfVocabularies.rdf.nil));
613
+ return _resource;
614
+ }
615
+ BaseShaclCoreShapeStatic.$toRdf = $toRdf;
616
+ BaseShaclCoreShapeStatic.$properties = {
617
+ and: {
618
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#and"),
619
+ },
620
+ classes: {
621
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#class"),
622
+ },
623
+ comments: {
624
+ identifier: dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#comment"),
625
+ },
626
+ datatype: {
627
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#datatype"),
628
+ },
629
+ deactivated: {
630
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#deactivated"),
631
+ },
632
+ flags: {
633
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#flags"),
634
+ },
635
+ hasValues: {
636
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#hasValue"),
637
+ },
638
+ in_: { identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#in") },
639
+ isDefinedBy: {
640
+ identifier: dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#isDefinedBy"),
641
+ },
642
+ labels: {
643
+ identifier: dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#label"),
644
+ },
645
+ languageIn: {
646
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#languageIn"),
647
+ },
648
+ maxCount: {
649
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#maxCount"),
650
+ },
651
+ maxExclusive: {
652
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#maxExclusive"),
653
+ },
654
+ maxInclusive: {
655
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#maxInclusive"),
656
+ },
657
+ maxLength: {
658
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#maxLength"),
659
+ },
660
+ minCount: {
661
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#minCount"),
662
+ },
663
+ minExclusive: {
664
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#minExclusive"),
665
+ },
666
+ minInclusive: {
667
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#minInclusive"),
668
+ },
669
+ minLength: {
670
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#minLength"),
671
+ },
672
+ nodeKind: {
673
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#nodeKind"),
674
+ },
675
+ nodes: {
676
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#node"),
677
+ },
678
+ not: {
679
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#not"),
680
+ },
681
+ or: { identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#or") },
682
+ patterns: {
683
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#pattern"),
684
+ },
685
+ xone: {
686
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#xone"),
687
+ },
688
+ };
689
+ })(BaseShaclCoreShapeStatic || (BaseShaclCoreShapeStatic = {}));
472
690
  export var ShaclCorePropertyShape;
473
691
  (function (ShaclCorePropertyShape) {
474
- function _propertiesFromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource,
692
+ ShaclCorePropertyShape.$fromRdfType = dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyShape");
693
+ ShaclCorePropertyShape.$Identifier = BaseShaclCoreShapeStatic.$Identifier;
694
+ function $propertiesFromRdf({ ignoreRdfType: $ignoreRdfType, languageIn: $languageIn, objectSet: $objectSetParameter, resource: $resource,
475
695
  // @ts-ignore
476
- ..._context }) {
477
- const _super0Either = BaseShaclCoreShape._propertiesFromRdf({
478
- ..._context,
696
+ ...$context }) {
697
+ const $super0Either = BaseShaclCoreShapeStatic.$propertiesFromRdf({
698
+ ...$context,
479
699
  ignoreRdfType: true,
480
- languageIn: _languageIn,
481
- resource: _resource,
700
+ languageIn: $languageIn,
701
+ resource: $resource,
482
702
  });
483
- if (_super0Either.isLeft()) {
484
- return _super0Either;
485
- }
486
- const _super0 = _super0Either.unsafeCoerce();
487
- if (!_ignoreRdfType &&
488
- !_resource.isInstanceOf(dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyShape"))) {
489
- return purify.Left(new rdfjsResource.Resource.ValueError({
490
- focusResource: _resource,
491
- message: `${rdfjsResource.Resource.Identifier.toString(_resource.identifier)} has unexpected RDF type`,
492
- predicate: dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyShape"),
493
- }));
703
+ if ($super0Either.isLeft()) {
704
+ return $super0Either;
494
705
  }
495
- const identifier = _resource.identifier;
496
- const type = "ShaclCorePropertyShape";
497
- const _defaultValueEither = purify.Either.of(_resource
498
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#defaultValue"), { unique: true })
706
+ const $super0 = $super0Either.unsafeCoerce();
707
+ if (!$ignoreRdfType && !$resource.isInstanceOf(ShaclCorePropertyShape.$fromRdfType)) {
708
+ return $resource
709
+ .value($RdfVocabularies.rdf.type)
710
+ .chain((actualRdfType) => actualRdfType.toIri())
711
+ .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)`)));
712
+ }
713
+ const $identifier = $resource.identifier;
714
+ const $type = "ShaclCorePropertyShape";
715
+ const _defaultValueEither = $resource
716
+ .values(ShaclCorePropertyShape.$properties.defaultValue["identifier"], { unique: true })
499
717
  .head()
500
- .chain((_value) => purify.Either.of(_value.toTerm()))
501
- .toMaybe());
718
+ .chain((value) => purify.Either.of(value.toTerm()).chain((term) => {
719
+ switch (term.termType) {
720
+ case "Literal":
721
+ case "NamedNode":
722
+ return purify.Either.of(term);
723
+ default:
724
+ return purify.Left(new rdfjsResource.Resource.MistypedValueError({
725
+ actualValue: term,
726
+ expectedValueType: "(rdfjs.Literal | rdfjs.NamedNode)",
727
+ focusResource: $resource,
728
+ predicate: ShaclCorePropertyShape.$properties.defaultValue["identifier"],
729
+ }));
730
+ }
731
+ }))
732
+ .map((value) => purify.Maybe.of(value))
733
+ .chainLeft((error) => error instanceof rdfjsResource.Resource.MissingValueError
734
+ ? purify.Right(purify.Maybe.empty())
735
+ : purify.Left(error));
502
736
  if (_defaultValueEither.isLeft()) {
503
737
  return _defaultValueEither;
504
738
  }
505
739
  const defaultValue = _defaultValueEither.unsafeCoerce();
506
- const _descriptionsEither = purify.Either.of([
507
- ..._resource
508
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#description"), { unique: true })
509
- .flatMap((_item) => _item
510
- .toValues()
511
- .filter((_value) => {
512
- const _languageInOrDefault = _languageIn ?? [];
513
- if (_languageInOrDefault.length === 0) {
514
- return true;
515
- }
516
- const _valueLiteral = _value.toLiteral().toMaybe().extract();
517
- if (typeof _valueLiteral === "undefined") {
518
- return false;
519
- }
520
- return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
521
- })
522
- .head()
523
- .chain((_value) => _value.toLiteral())
524
- .toMaybe()
525
- .toList()),
526
- ]);
740
+ const _descriptionsEither = purify.Either.sequence($resource
741
+ .values(ShaclCorePropertyShape.$properties.descriptions["identifier"], { unique: true })
742
+ .map((item) => item
743
+ .toValues()
744
+ .filter((_value) => {
745
+ const _languageInOrDefault = $languageIn ?? [];
746
+ if (_languageInOrDefault.length === 0) {
747
+ return true;
748
+ }
749
+ const _valueLiteral = _value.toLiteral().toMaybe().extract();
750
+ if (typeof _valueLiteral === "undefined") {
751
+ return false;
752
+ }
753
+ return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
754
+ })
755
+ .head()
756
+ .chain((value) => value.toLiteral())));
527
757
  if (_descriptionsEither.isLeft()) {
528
758
  return _descriptionsEither;
529
759
  }
530
760
  const descriptions = _descriptionsEither.unsafeCoerce();
531
- const _groupsEither = purify.Either.of([
532
- ..._resource
533
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#group"), {
534
- unique: true,
535
- })
536
- .flatMap((_item) => _item
537
- .toValues()
538
- .head()
539
- .chain((_value) => _value.toIdentifier())
540
- .toMaybe()
541
- .toList()),
542
- ]);
761
+ const _groupsEither = purify.Either.sequence($resource
762
+ .values(ShaclCorePropertyShape.$properties.groups["identifier"], { unique: true })
763
+ .map((item) => item
764
+ .toValues()
765
+ .head()
766
+ .chain((value) => value.toIdentifier())));
543
767
  if (_groupsEither.isLeft()) {
544
768
  return _groupsEither;
545
769
  }
546
770
  const groups = _groupsEither.unsafeCoerce();
547
- const _namesEither = purify.Either.of([
548
- ..._resource
549
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#name"), {
550
- unique: true,
551
- })
552
- .flatMap((_item) => _item
553
- .toValues()
554
- .filter((_value) => {
555
- const _languageInOrDefault = _languageIn ?? [];
556
- if (_languageInOrDefault.length === 0) {
557
- return true;
558
- }
559
- const _valueLiteral = _value.toLiteral().toMaybe().extract();
560
- if (typeof _valueLiteral === "undefined") {
561
- return false;
562
- }
563
- return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
564
- })
565
- .head()
566
- .chain((_value) => _value.toLiteral())
567
- .toMaybe()
568
- .toList()),
569
- ]);
771
+ const _namesEither = purify.Either.sequence($resource
772
+ .values(ShaclCorePropertyShape.$properties.names["identifier"], { unique: true })
773
+ .map((item) => item
774
+ .toValues()
775
+ .filter((_value) => {
776
+ const _languageInOrDefault = $languageIn ?? [];
777
+ if (_languageInOrDefault.length === 0) {
778
+ return true;
779
+ }
780
+ const _valueLiteral = _value.toLiteral().toMaybe().extract();
781
+ if (typeof _valueLiteral === "undefined") {
782
+ return false;
783
+ }
784
+ return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
785
+ })
786
+ .head()
787
+ .chain((value) => value.toLiteral())));
570
788
  if (_namesEither.isLeft()) {
571
789
  return _namesEither;
572
790
  }
573
791
  const names = _namesEither.unsafeCoerce();
574
- const _orderEither = purify.Either.of(_resource
575
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#order"), {
576
- unique: true,
577
- })
792
+ const _orderEither = $resource
793
+ .values(ShaclCorePropertyShape.$properties.order["identifier"], { unique: true })
578
794
  .head()
579
- .chain((_value) => _value.toNumber())
580
- .toMaybe());
795
+ .chain((value) => value.toNumber())
796
+ .map((value) => purify.Maybe.of(value))
797
+ .chainLeft((error) => error instanceof rdfjsResource.Resource.MissingValueError
798
+ ? purify.Right(purify.Maybe.empty())
799
+ : purify.Left(error));
581
800
  if (_orderEither.isLeft()) {
582
801
  return _orderEither;
583
802
  }
584
803
  const order = _orderEither.unsafeCoerce();
585
- const _pathEither = _resource
586
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#path"), {
587
- unique: true,
588
- })
804
+ const _pathEither = $resource
805
+ .values(ShaclCorePropertyShape.$properties.path["identifier"], { unique: true })
589
806
  .head()
590
807
  .chain((value) => value.toResource())
591
- .chain((_resource) => PropertyPath.fromRdf({
592
- ..._context,
808
+ .chain((_resource) => PropertyPath.$fromRdf({
809
+ ...$context,
593
810
  ignoreRdfType: true,
594
- languageIn: _languageIn,
811
+ languageIn: $languageIn,
595
812
  resource: _resource,
596
813
  }));
597
814
  if (_pathEither.isLeft()) {
598
815
  return _pathEither;
599
816
  }
600
817
  const path = _pathEither.unsafeCoerce();
601
- const _uniqueLangEither = purify.Either.of(_resource
602
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#uniqueLang"), { unique: true })
818
+ const _uniqueLangEither = $resource
819
+ .values(ShaclCorePropertyShape.$properties.uniqueLang["identifier"], { unique: true })
603
820
  .head()
604
- .chain((_value) => _value.toBoolean())
605
- .toMaybe());
821
+ .chain((value) => value.toBoolean())
822
+ .map((value) => purify.Maybe.of(value))
823
+ .chainLeft((error) => error instanceof rdfjsResource.Resource.MissingValueError
824
+ ? purify.Right(purify.Maybe.empty())
825
+ : purify.Left(error));
606
826
  if (_uniqueLangEither.isLeft()) {
607
827
  return _uniqueLangEither;
608
828
  }
609
829
  const uniqueLang = _uniqueLangEither.unsafeCoerce();
610
830
  return purify.Either.of({
611
- ..._super0,
612
- identifier,
613
- type,
831
+ ...$super0,
832
+ $identifier,
833
+ $type,
614
834
  defaultValue,
615
835
  descriptions,
616
836
  groups,
@@ -620,227 +840,683 @@ export var ShaclCorePropertyShape;
620
840
  uniqueLang,
621
841
  });
622
842
  }
623
- ShaclCorePropertyShape._propertiesFromRdf = _propertiesFromRdf;
624
- function fromRdf(parameters) {
625
- return ShaclCorePropertyShape._propertiesFromRdf(parameters);
843
+ ShaclCorePropertyShape.$propertiesFromRdf = $propertiesFromRdf;
844
+ function $fromRdf(parameters) {
845
+ return ShaclCorePropertyShape.$propertiesFromRdf(parameters);
626
846
  }
627
- ShaclCorePropertyShape.fromRdf = fromRdf;
628
- ShaclCorePropertyShape.fromRdfType = dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyShape");
847
+ ShaclCorePropertyShape.$fromRdf = $fromRdf;
848
+ function $toRdf(_shaclCorePropertyShape, { ignoreRdfType, mutateGraph, resourceSet, }) {
849
+ const _resource = BaseShaclCoreShapeStatic.$toRdf(_shaclCorePropertyShape, {
850
+ ignoreRdfType: true,
851
+ mutateGraph,
852
+ resourceSet,
853
+ });
854
+ if (!ignoreRdfType) {
855
+ _resource.add($RdfVocabularies.rdf.type, _resource.dataFactory.namedNode("http://purl.org/shaclmate/ontology#ShaclCorePropertyShape"));
856
+ _resource.add($RdfVocabularies.rdf.type, _resource.dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyShape"));
857
+ }
858
+ _resource.add(ShaclCorePropertyShape.$properties.defaultValue["identifier"], _shaclCorePropertyShape.defaultValue);
859
+ _resource.add(ShaclCorePropertyShape.$properties.descriptions["identifier"], _shaclCorePropertyShape.descriptions.map((item) => item));
860
+ _resource.add(ShaclCorePropertyShape.$properties.groups["identifier"], _shaclCorePropertyShape.groups.map((item) => item));
861
+ _resource.add(ShaclCorePropertyShape.$properties.names["identifier"], _shaclCorePropertyShape.names.map((item) => item));
862
+ _resource.add(ShaclCorePropertyShape.$properties.order["identifier"], _shaclCorePropertyShape.order);
863
+ _resource.add(ShaclCorePropertyShape.$properties.path["identifier"], PropertyPath.$toRdf(_shaclCorePropertyShape.path, {
864
+ mutateGraph: mutateGraph,
865
+ resourceSet: resourceSet,
866
+ }));
867
+ _resource.add(ShaclCorePropertyShape.$properties.uniqueLang["identifier"], _shaclCorePropertyShape.uniqueLang);
868
+ return _resource;
869
+ }
870
+ ShaclCorePropertyShape.$toRdf = $toRdf;
871
+ ShaclCorePropertyShape.$properties = {
872
+ ...BaseShaclCoreShapeStatic.$properties,
873
+ defaultValue: {
874
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#defaultValue"),
875
+ },
876
+ descriptions: {
877
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#description"),
878
+ },
879
+ groups: {
880
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#group"),
881
+ },
882
+ names: {
883
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#name"),
884
+ },
885
+ order: {
886
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#order"),
887
+ },
888
+ path: {
889
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#path"),
890
+ },
891
+ uniqueLang: {
892
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#uniqueLang"),
893
+ },
894
+ };
629
895
  })(ShaclCorePropertyShape || (ShaclCorePropertyShape = {}));
630
896
  export var ShaclCorePropertyGroup;
631
897
  (function (ShaclCorePropertyGroup) {
632
- function _propertiesFromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource,
633
- // @ts-ignore
634
- ..._context }) {
635
- if (!_ignoreRdfType &&
636
- !_resource.isInstanceOf(dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyGroup"))) {
637
- return purify.Left(new rdfjsResource.Resource.ValueError({
638
- focusResource: _resource,
639
- message: `${rdfjsResource.Resource.Identifier.toString(_resource.identifier)} has unexpected RDF type`,
640
- predicate: dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyGroup"),
898
+ ShaclCorePropertyGroup.$fromRdfType = dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyGroup");
899
+ let $Identifier;
900
+ (function ($Identifier) {
901
+ function fromString(identifier) {
902
+ return purify.Either.encase(() => rdfjsResource.Resource.Identifier.fromString({
903
+ dataFactory,
904
+ identifier,
641
905
  }));
642
906
  }
643
- const identifier = _resource.identifier;
644
- const type = "ShaclCorePropertyGroup";
645
- const _commentsEither = purify.Either.of([
646
- ..._resource
647
- .values(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#comment"), { unique: true })
648
- .flatMap((_item) => _item
649
- .toValues()
650
- .filter((_value) => {
651
- const _languageInOrDefault = _languageIn ?? [];
652
- if (_languageInOrDefault.length === 0) {
653
- return true;
654
- }
655
- const _valueLiteral = _value.toLiteral().toMaybe().extract();
656
- if (typeof _valueLiteral === "undefined") {
657
- return false;
658
- }
659
- return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
660
- })
661
- .head()
662
- .chain((_value) => _value.toLiteral())
663
- .toMaybe()
664
- .toList()),
665
- ]);
907
+ $Identifier.fromString = fromString;
908
+ $Identifier.toString = rdfjsResource.Resource.Identifier.toString;
909
+ })($Identifier = ShaclCorePropertyGroup.$Identifier || (ShaclCorePropertyGroup.$Identifier = {}));
910
+ function $propertiesFromRdf({ ignoreRdfType: $ignoreRdfType, languageIn: $languageIn, objectSet: $objectSetParameter, resource: $resource,
911
+ // @ts-ignore
912
+ ...$context }) {
913
+ if (!$ignoreRdfType && !$resource.isInstanceOf(ShaclCorePropertyGroup.$fromRdfType)) {
914
+ return $resource
915
+ .value($RdfVocabularies.rdf.type)
916
+ .chain((actualRdfType) => actualRdfType.toIri())
917
+ .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)`)));
918
+ }
919
+ const $identifier = $resource.identifier;
920
+ const $type = "ShaclCorePropertyGroup";
921
+ const _commentsEither = purify.Either.sequence($resource
922
+ .values(ShaclCorePropertyGroup.$properties.comments["identifier"], { unique: true })
923
+ .map((item) => item
924
+ .toValues()
925
+ .filter((_value) => {
926
+ const _languageInOrDefault = $languageIn ?? [];
927
+ if (_languageInOrDefault.length === 0) {
928
+ return true;
929
+ }
930
+ const _valueLiteral = _value.toLiteral().toMaybe().extract();
931
+ if (typeof _valueLiteral === "undefined") {
932
+ return false;
933
+ }
934
+ return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
935
+ })
936
+ .head()
937
+ .chain((value) => value.toLiteral())));
666
938
  if (_commentsEither.isLeft()) {
667
939
  return _commentsEither;
668
940
  }
669
941
  const comments = _commentsEither.unsafeCoerce();
670
- const _labelsEither = purify.Either.of([
671
- ..._resource
672
- .values(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#label"), { unique: true })
673
- .flatMap((_item) => _item
674
- .toValues()
675
- .filter((_value) => {
676
- const _languageInOrDefault = _languageIn ?? [];
677
- if (_languageInOrDefault.length === 0) {
678
- return true;
679
- }
680
- const _valueLiteral = _value.toLiteral().toMaybe().extract();
681
- if (typeof _valueLiteral === "undefined") {
682
- return false;
683
- }
684
- return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
685
- })
686
- .head()
687
- .chain((_value) => _value.toLiteral())
688
- .toMaybe()
689
- .toList()),
690
- ]);
942
+ const _labelsEither = purify.Either.sequence($resource
943
+ .values(ShaclCorePropertyGroup.$properties.labels["identifier"], { unique: true })
944
+ .map((item) => item
945
+ .toValues()
946
+ .filter((_value) => {
947
+ const _languageInOrDefault = $languageIn ?? [];
948
+ if (_languageInOrDefault.length === 0) {
949
+ return true;
950
+ }
951
+ const _valueLiteral = _value.toLiteral().toMaybe().extract();
952
+ if (typeof _valueLiteral === "undefined") {
953
+ return false;
954
+ }
955
+ return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
956
+ })
957
+ .head()
958
+ .chain((value) => value.toLiteral())));
691
959
  if (_labelsEither.isLeft()) {
692
960
  return _labelsEither;
693
961
  }
694
962
  const labels = _labelsEither.unsafeCoerce();
695
- return purify.Either.of({ identifier, type, comments, labels });
963
+ return purify.Either.of({ $identifier, $type, comments, labels });
696
964
  }
697
- ShaclCorePropertyGroup._propertiesFromRdf = _propertiesFromRdf;
698
- function fromRdf(parameters) {
699
- return ShaclCorePropertyGroup._propertiesFromRdf(parameters);
965
+ ShaclCorePropertyGroup.$propertiesFromRdf = $propertiesFromRdf;
966
+ function $fromRdf(parameters) {
967
+ return ShaclCorePropertyGroup.$propertiesFromRdf(parameters);
968
+ }
969
+ ShaclCorePropertyGroup.$fromRdf = $fromRdf;
970
+ function $toRdf(_shaclCorePropertyGroup, { ignoreRdfType, mutateGraph, resourceSet, }) {
971
+ const _resource = resourceSet.mutableResource(_shaclCorePropertyGroup.$identifier, { mutateGraph });
972
+ if (!ignoreRdfType) {
973
+ _resource.add($RdfVocabularies.rdf.type, _resource.dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyGroup"));
974
+ }
975
+ _resource.add(ShaclCorePropertyGroup.$properties.comments["identifier"], _shaclCorePropertyGroup.comments.map((item) => item));
976
+ _resource.add(ShaclCorePropertyGroup.$properties.labels["identifier"], _shaclCorePropertyGroup.labels.map((item) => item));
977
+ return _resource;
700
978
  }
701
- ShaclCorePropertyGroup.fromRdf = fromRdf;
702
- ShaclCorePropertyGroup.fromRdfType = dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyGroup");
979
+ ShaclCorePropertyGroup.$toRdf = $toRdf;
980
+ ShaclCorePropertyGroup.$properties = {
981
+ comments: {
982
+ identifier: dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#comment"),
983
+ },
984
+ labels: {
985
+ identifier: dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#label"),
986
+ },
987
+ };
703
988
  })(ShaclCorePropertyGroup || (ShaclCorePropertyGroup = {}));
704
989
  export var ShaclCoreNodeShape;
705
990
  (function (ShaclCoreNodeShape) {
706
- function _propertiesFromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource,
991
+ ShaclCoreNodeShape.$fromRdfType = dataFactory.namedNode("http://www.w3.org/ns/shacl#NodeShape");
992
+ ShaclCoreNodeShape.$Identifier = BaseShaclCoreShapeStatic.$Identifier;
993
+ function $propertiesFromRdf({ ignoreRdfType: $ignoreRdfType, languageIn: $languageIn, objectSet: $objectSetParameter, resource: $resource,
707
994
  // @ts-ignore
708
- ..._context }) {
709
- const _super0Either = BaseShaclCoreShape._propertiesFromRdf({
710
- ..._context,
995
+ ...$context }) {
996
+ const $super0Either = BaseShaclCoreShapeStatic.$propertiesFromRdf({
997
+ ...$context,
711
998
  ignoreRdfType: true,
712
- languageIn: _languageIn,
713
- resource: _resource,
999
+ languageIn: $languageIn,
1000
+ resource: $resource,
714
1001
  });
715
- if (_super0Either.isLeft()) {
716
- return _super0Either;
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
- }));
1002
+ if ($super0Either.isLeft()) {
1003
+ return $super0Either;
726
1004
  }
727
- const identifier = _resource.identifier;
728
- const type = "ShaclCoreNodeShape";
729
- const _closedEither = purify.Either.of(_resource
730
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#closed"), {
731
- unique: true,
732
- })
1005
+ const $super0 = $super0Either.unsafeCoerce();
1006
+ if (!$ignoreRdfType && !$resource.isInstanceOf(ShaclCoreNodeShape.$fromRdfType)) {
1007
+ return $resource
1008
+ .value($RdfVocabularies.rdf.type)
1009
+ .chain((actualRdfType) => actualRdfType.toIri())
1010
+ .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)`)));
1011
+ }
1012
+ const $identifier = $resource.identifier;
1013
+ const $type = "ShaclCoreNodeShape";
1014
+ const _closedEither = $resource
1015
+ .values(ShaclCoreNodeShape.$properties.closed["identifier"], { unique: true })
733
1016
  .head()
734
- .chain((_value) => _value.toBoolean())
735
- .toMaybe());
1017
+ .chain((value) => value.toBoolean())
1018
+ .map((value) => purify.Maybe.of(value))
1019
+ .chainLeft((error) => error instanceof rdfjsResource.Resource.MissingValueError
1020
+ ? purify.Right(purify.Maybe.empty())
1021
+ : purify.Left(error));
736
1022
  if (_closedEither.isLeft()) {
737
1023
  return _closedEither;
738
1024
  }
739
1025
  const closed = _closedEither.unsafeCoerce();
740
- const _ignoredPropertiesEither = purify.Either.of(_resource
741
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#ignoredProperties"), { unique: true })
1026
+ const _ignoredPropertiesEither = $resource
1027
+ .values(ShaclCoreNodeShape.$properties.ignoredProperties["identifier"], { unique: true })
742
1028
  .head()
743
1029
  .chain((value) => value.toList())
744
- .map((values) => values.flatMap((_value) => _value
1030
+ .chain((values) => purify.Either.sequence(values.map((value) => value
745
1031
  .toValues()
746
1032
  .head()
747
- .chain((_value) => _value.toIri())
748
- .toMaybe()
749
- .toList()))
750
- .toMaybe());
1033
+ .chain((value) => value.toIri()))))
1034
+ .map((value) => purify.Maybe.of(value))
1035
+ .chainLeft((error) => error instanceof rdfjsResource.Resource.MissingValueError
1036
+ ? purify.Right(purify.Maybe.empty())
1037
+ : purify.Left(error));
751
1038
  if (_ignoredPropertiesEither.isLeft()) {
752
1039
  return _ignoredPropertiesEither;
753
1040
  }
754
1041
  const ignoredProperties = _ignoredPropertiesEither.unsafeCoerce();
755
- const _propertiesEither = purify.Either.of([
756
- ..._resource
757
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#property"), {
758
- unique: true,
759
- })
760
- .flatMap((_item) => _item
761
- .toValues()
762
- .head()
763
- .chain((_value) => _value.toIdentifier())
764
- .toMaybe()
765
- .toList()),
766
- ]);
1042
+ const _propertiesEither = purify.Either.sequence($resource
1043
+ .values(ShaclCoreNodeShape.$properties.properties["identifier"], { unique: true })
1044
+ .map((item) => item
1045
+ .toValues()
1046
+ .head()
1047
+ .chain((value) => value.toIdentifier())));
767
1048
  if (_propertiesEither.isLeft()) {
768
1049
  return _propertiesEither;
769
1050
  }
770
1051
  const properties = _propertiesEither.unsafeCoerce();
771
1052
  return purify.Either.of({
772
- ..._super0,
773
- identifier,
774
- type,
1053
+ ...$super0,
1054
+ $identifier,
1055
+ $type,
775
1056
  closed,
776
1057
  ignoredProperties,
777
1058
  properties,
778
1059
  });
779
1060
  }
780
- ShaclCoreNodeShape._propertiesFromRdf = _propertiesFromRdf;
781
- function fromRdf(parameters) {
782
- return ShaclCoreNodeShape._propertiesFromRdf(parameters);
1061
+ ShaclCoreNodeShape.$propertiesFromRdf = $propertiesFromRdf;
1062
+ function $fromRdf(parameters) {
1063
+ return ShaclCoreNodeShape.$propertiesFromRdf(parameters);
1064
+ }
1065
+ ShaclCoreNodeShape.$fromRdf = $fromRdf;
1066
+ function $toRdf(_shaclCoreNodeShape, { ignoreRdfType, mutateGraph, resourceSet, }) {
1067
+ const _resource = BaseShaclCoreShapeStatic.$toRdf(_shaclCoreNodeShape, {
1068
+ ignoreRdfType: true,
1069
+ mutateGraph,
1070
+ resourceSet,
1071
+ });
1072
+ if (!ignoreRdfType) {
1073
+ _resource.add($RdfVocabularies.rdf.type, _resource.dataFactory.namedNode("http://purl.org/shaclmate/ontology#ShaclCoreNodeShape"));
1074
+ _resource.add($RdfVocabularies.rdf.type, _resource.dataFactory.namedNode("http://www.w3.org/ns/shacl#NodeShape"));
1075
+ }
1076
+ _resource.add(ShaclCoreNodeShape.$properties.closed["identifier"], _shaclCoreNodeShape.closed);
1077
+ _resource.add(ShaclCoreNodeShape.$properties.ignoredProperties["identifier"], _shaclCoreNodeShape.ignoredProperties.map((value) => value.length > 0
1078
+ ? value.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
1079
+ if (itemIndex === 0) {
1080
+ currentSubListResource = listResource;
1081
+ }
1082
+ else {
1083
+ const newSubListResource = resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph });
1084
+ currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier);
1085
+ currentSubListResource = newSubListResource;
1086
+ }
1087
+ currentSubListResource.add($RdfVocabularies.rdf.first, item);
1088
+ if (itemIndex + 1 === list.length) {
1089
+ currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil);
1090
+ }
1091
+ return { currentSubListResource, listResource };
1092
+ }, {
1093
+ currentSubListResource: null,
1094
+ listResource: resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph }),
1095
+ }).listResource.identifier
1096
+ : $RdfVocabularies.rdf.nil));
1097
+ _resource.add(ShaclCoreNodeShape.$properties.properties["identifier"], _shaclCoreNodeShape.properties.map((item) => item));
1098
+ return _resource;
783
1099
  }
784
- ShaclCoreNodeShape.fromRdf = fromRdf;
785
- ShaclCoreNodeShape.fromRdfType = dataFactory.namedNode("http://www.w3.org/ns/shacl#NodeShape");
1100
+ ShaclCoreNodeShape.$toRdf = $toRdf;
1101
+ ShaclCoreNodeShape.$properties = {
1102
+ ...BaseShaclCoreShapeStatic.$properties,
1103
+ closed: {
1104
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#closed"),
1105
+ },
1106
+ ignoredProperties: {
1107
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#ignoredProperties"),
1108
+ },
1109
+ properties: {
1110
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#property"),
1111
+ },
1112
+ };
786
1113
  })(ShaclCoreNodeShape || (ShaclCoreNodeShape = {}));
787
1114
  export var OwlOntology;
788
1115
  (function (OwlOntology) {
789
- function _propertiesFromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource,
790
- // @ts-ignore
791
- ..._context }) {
792
- if (!_ignoreRdfType &&
793
- !_resource.isInstanceOf(dataFactory.namedNode("http://www.w3.org/2002/07/owl#Ontology"))) {
794
- return purify.Left(new rdfjsResource.Resource.ValueError({
795
- focusResource: _resource,
796
- message: `${rdfjsResource.Resource.Identifier.toString(_resource.identifier)} has unexpected RDF type`,
797
- predicate: dataFactory.namedNode("http://www.w3.org/2002/07/owl#Ontology"),
1116
+ OwlOntology.$fromRdfType = dataFactory.namedNode("http://www.w3.org/2002/07/owl#Ontology");
1117
+ let $Identifier;
1118
+ (function ($Identifier) {
1119
+ function fromString(identifier) {
1120
+ return purify.Either.encase(() => rdfjsResource.Resource.Identifier.fromString({
1121
+ dataFactory,
1122
+ identifier,
798
1123
  }));
799
1124
  }
800
- const identifier = _resource.identifier;
801
- const type = "OwlOntology";
802
- const _labelsEither = purify.Either.of([
803
- ..._resource
804
- .values(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#label"), { unique: true })
805
- .flatMap((_item) => _item
806
- .toValues()
807
- .filter((_value) => {
808
- const _languageInOrDefault = _languageIn ?? [];
809
- if (_languageInOrDefault.length === 0) {
810
- return true;
811
- }
812
- const _valueLiteral = _value.toLiteral().toMaybe().extract();
813
- if (typeof _valueLiteral === "undefined") {
814
- return false;
815
- }
816
- return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
817
- })
818
- .head()
819
- .chain((_value) => _value.toLiteral())
820
- .toMaybe()
821
- .toList()),
822
- ]);
1125
+ $Identifier.fromString = fromString;
1126
+ $Identifier.toString = rdfjsResource.Resource.Identifier.toString;
1127
+ })($Identifier = OwlOntology.$Identifier || (OwlOntology.$Identifier = {}));
1128
+ function $propertiesFromRdf({ ignoreRdfType: $ignoreRdfType, languageIn: $languageIn, objectSet: $objectSetParameter, resource: $resource,
1129
+ // @ts-ignore
1130
+ ...$context }) {
1131
+ if (!$ignoreRdfType && !$resource.isInstanceOf(OwlOntology.$fromRdfType)) {
1132
+ return $resource
1133
+ .value($RdfVocabularies.rdf.type)
1134
+ .chain((actualRdfType) => actualRdfType.toIri())
1135
+ .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)`)));
1136
+ }
1137
+ const $identifier = $resource.identifier;
1138
+ const $type = "OwlOntology";
1139
+ const _labelsEither = purify.Either.sequence($resource
1140
+ .values(OwlOntology.$properties.labels["identifier"], { unique: true })
1141
+ .map((item) => item
1142
+ .toValues()
1143
+ .filter((_value) => {
1144
+ const _languageInOrDefault = $languageIn ?? [];
1145
+ if (_languageInOrDefault.length === 0) {
1146
+ return true;
1147
+ }
1148
+ const _valueLiteral = _value.toLiteral().toMaybe().extract();
1149
+ if (typeof _valueLiteral === "undefined") {
1150
+ return false;
1151
+ }
1152
+ return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
1153
+ })
1154
+ .head()
1155
+ .chain((value) => value.toLiteral())));
823
1156
  if (_labelsEither.isLeft()) {
824
1157
  return _labelsEither;
825
1158
  }
826
1159
  const labels = _labelsEither.unsafeCoerce();
827
- return purify.Either.of({ identifier, type, labels });
1160
+ return purify.Either.of({ $identifier, $type, labels });
828
1161
  }
829
- OwlOntology._propertiesFromRdf = _propertiesFromRdf;
830
- function fromRdf(parameters) {
831
- return OwlOntology._propertiesFromRdf(parameters);
1162
+ OwlOntology.$propertiesFromRdf = $propertiesFromRdf;
1163
+ function $fromRdf(parameters) {
1164
+ return OwlOntology.$propertiesFromRdf(parameters);
832
1165
  }
833
- OwlOntology.fromRdf = fromRdf;
834
- OwlOntology.fromRdfType = dataFactory.namedNode("http://www.w3.org/2002/07/owl#Ontology");
1166
+ OwlOntology.$fromRdf = $fromRdf;
1167
+ function $toRdf(_owlOntology, { ignoreRdfType, mutateGraph, resourceSet, }) {
1168
+ const _resource = resourceSet.mutableResource(_owlOntology.$identifier, {
1169
+ mutateGraph,
1170
+ });
1171
+ if (!ignoreRdfType) {
1172
+ _resource.add($RdfVocabularies.rdf.type, _resource.dataFactory.namedNode("http://purl.org/shaclmate/ontology#OwlOntology"));
1173
+ _resource.add($RdfVocabularies.rdf.type, _resource.dataFactory.namedNode("http://www.w3.org/2002/07/owl#Ontology"));
1174
+ }
1175
+ _resource.add(OwlOntology.$properties.labels["identifier"], _owlOntology.labels.map((item) => item));
1176
+ return _resource;
1177
+ }
1178
+ OwlOntology.$toRdf = $toRdf;
1179
+ OwlOntology.$properties = {
1180
+ labels: {
1181
+ identifier: dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#label"),
1182
+ },
1183
+ };
835
1184
  })(OwlOntology || (OwlOntology = {}));
836
1185
  export var ShaclCoreShape;
837
1186
  (function (ShaclCoreShape) {
838
- function fromRdf({ ignoreRdfType, resource, ...context }) {
839
- return ShaclCoreNodeShape.fromRdf({ ...context, resource }).altLazy(() => ShaclCorePropertyShape.fromRdf({
1187
+ function $fromRdf({ ignoreRdfType, resource, ...context }) {
1188
+ return ShaclCoreNodeShape.$fromRdf({ ...context, resource }).altLazy(() => ShaclCorePropertyShape.$fromRdf({
840
1189
  ...context,
841
1190
  resource,
842
1191
  }));
843
1192
  }
844
- ShaclCoreShape.fromRdf = fromRdf;
1193
+ ShaclCoreShape.$fromRdf = $fromRdf;
1194
+ let $Identifier;
1195
+ (function ($Identifier) {
1196
+ function fromString(identifier) {
1197
+ return purify.Either.encase(() => rdfjsResource.Resource.Identifier.fromString({
1198
+ dataFactory,
1199
+ identifier,
1200
+ }));
1201
+ }
1202
+ $Identifier.fromString = fromString;
1203
+ $Identifier.toString = rdfjsResource.Resource.Identifier.toString;
1204
+ })($Identifier = ShaclCoreShape.$Identifier || (ShaclCoreShape.$Identifier = {}));
1205
+ function $toRdf(_shaclCoreShape, _parameters) {
1206
+ switch (_shaclCoreShape.$type) {
1207
+ case "ShaclCoreNodeShape":
1208
+ return ShaclCoreNodeShape.$toRdf(_shaclCoreShape, _parameters);
1209
+ case "ShaclCorePropertyShape":
1210
+ return ShaclCorePropertyShape.$toRdf(_shaclCoreShape, _parameters);
1211
+ default:
1212
+ _shaclCoreShape;
1213
+ throw new Error("unrecognized type");
1214
+ }
1215
+ }
1216
+ ShaclCoreShape.$toRdf = $toRdf;
845
1217
  })(ShaclCoreShape || (ShaclCoreShape = {}));
1218
+ export class $RdfjsDatasetObjectSet {
1219
+ resourceSet;
1220
+ constructor({ dataset }) {
1221
+ this.resourceSet = new rdfjsResource.ResourceSet({ dataset });
1222
+ }
1223
+ async owlOntology(identifier) {
1224
+ return this.owlOntologySync(identifier);
1225
+ }
1226
+ owlOntologySync(identifier) {
1227
+ return this.owlOntologiesSync({
1228
+ where: { identifiers: [identifier], type: "identifiers" },
1229
+ }).map((objects) => objects[0]);
1230
+ }
1231
+ async owlOntologyIdentifiers(query) {
1232
+ return this.owlOntologyIdentifiersSync(query);
1233
+ }
1234
+ owlOntologyIdentifiersSync(query) {
1235
+ return this.$objectIdentifiersSync(OwlOntology, query);
1236
+ }
1237
+ async owlOntologies(query) {
1238
+ return this.owlOntologiesSync(query);
1239
+ }
1240
+ owlOntologiesSync(query) {
1241
+ return this.$objectsSync(OwlOntology, query);
1242
+ }
1243
+ async owlOntologiesCount(query) {
1244
+ return this.owlOntologiesCountSync(query);
1245
+ }
1246
+ owlOntologiesCountSync(query) {
1247
+ return this.$objectsCountSync(OwlOntology, query);
1248
+ }
1249
+ async shaclCoreNodeShape(identifier) {
1250
+ return this.shaclCoreNodeShapeSync(identifier);
1251
+ }
1252
+ shaclCoreNodeShapeSync(identifier) {
1253
+ return this.shaclCoreNodeShapesSync({
1254
+ where: { identifiers: [identifier], type: "identifiers" },
1255
+ }).map((objects) => objects[0]);
1256
+ }
1257
+ async shaclCoreNodeShapeIdentifiers(query) {
1258
+ return this.shaclCoreNodeShapeIdentifiersSync(query);
1259
+ }
1260
+ shaclCoreNodeShapeIdentifiersSync(query) {
1261
+ return this.$objectIdentifiersSync(ShaclCoreNodeShape, query);
1262
+ }
1263
+ async shaclCoreNodeShapes(query) {
1264
+ return this.shaclCoreNodeShapesSync(query);
1265
+ }
1266
+ shaclCoreNodeShapesSync(query) {
1267
+ return this.$objectsSync(ShaclCoreNodeShape, query);
1268
+ }
1269
+ async shaclCoreNodeShapesCount(query) {
1270
+ return this.shaclCoreNodeShapesCountSync(query);
1271
+ }
1272
+ shaclCoreNodeShapesCountSync(query) {
1273
+ return this.$objectsCountSync(ShaclCoreNodeShape, query);
1274
+ }
1275
+ async shaclCorePropertyGroup(identifier) {
1276
+ return this.shaclCorePropertyGroupSync(identifier);
1277
+ }
1278
+ shaclCorePropertyGroupSync(identifier) {
1279
+ return this.shaclCorePropertyGroupsSync({
1280
+ where: { identifiers: [identifier], type: "identifiers" },
1281
+ }).map((objects) => objects[0]);
1282
+ }
1283
+ async shaclCorePropertyGroupIdentifiers(query) {
1284
+ return this.shaclCorePropertyGroupIdentifiersSync(query);
1285
+ }
1286
+ shaclCorePropertyGroupIdentifiersSync(query) {
1287
+ return this.$objectIdentifiersSync(ShaclCorePropertyGroup, query);
1288
+ }
1289
+ async shaclCorePropertyGroups(query) {
1290
+ return this.shaclCorePropertyGroupsSync(query);
1291
+ }
1292
+ shaclCorePropertyGroupsSync(query) {
1293
+ return this.$objectsSync(ShaclCorePropertyGroup, query);
1294
+ }
1295
+ async shaclCorePropertyGroupsCount(query) {
1296
+ return this.shaclCorePropertyGroupsCountSync(query);
1297
+ }
1298
+ shaclCorePropertyGroupsCountSync(query) {
1299
+ return this.$objectsCountSync(ShaclCorePropertyGroup, query);
1300
+ }
1301
+ async shaclCorePropertyShape(identifier) {
1302
+ return this.shaclCorePropertyShapeSync(identifier);
1303
+ }
1304
+ shaclCorePropertyShapeSync(identifier) {
1305
+ return this.shaclCorePropertyShapesSync({
1306
+ where: { identifiers: [identifier], type: "identifiers" },
1307
+ }).map((objects) => objects[0]);
1308
+ }
1309
+ async shaclCorePropertyShapeIdentifiers(query) {
1310
+ return this.shaclCorePropertyShapeIdentifiersSync(query);
1311
+ }
1312
+ shaclCorePropertyShapeIdentifiersSync(query) {
1313
+ return this.$objectIdentifiersSync(ShaclCorePropertyShape, query);
1314
+ }
1315
+ async shaclCorePropertyShapes(query) {
1316
+ return this.shaclCorePropertyShapesSync(query);
1317
+ }
1318
+ shaclCorePropertyShapesSync(query) {
1319
+ return this.$objectsSync(ShaclCorePropertyShape, query);
1320
+ }
1321
+ async shaclCorePropertyShapesCount(query) {
1322
+ return this.shaclCorePropertyShapesCountSync(query);
1323
+ }
1324
+ shaclCorePropertyShapesCountSync(query) {
1325
+ return this.$objectsCountSync(ShaclCorePropertyShape, query);
1326
+ }
1327
+ async shaclCoreShape(identifier) {
1328
+ return this.shaclCoreShapeSync(identifier);
1329
+ }
1330
+ shaclCoreShapeSync(identifier) {
1331
+ return this.shaclCoreShapesSync({
1332
+ where: { identifiers: [identifier], type: "identifiers" },
1333
+ }).map((objects) => objects[0]);
1334
+ }
1335
+ async shaclCoreShapeIdentifiers(query) {
1336
+ return this.shaclCoreShapeIdentifiersSync(query);
1337
+ }
1338
+ shaclCoreShapeIdentifiersSync(query) {
1339
+ return this.$objectUnionIdentifiersSync([ShaclCoreNodeShape, ShaclCorePropertyShape], query);
1340
+ }
1341
+ async shaclCoreShapes(query) {
1342
+ return this.shaclCoreShapesSync(query);
1343
+ }
1344
+ shaclCoreShapesSync(query) {
1345
+ return this.$objectUnionsSync([ShaclCoreNodeShape, ShaclCorePropertyShape], query);
1346
+ }
1347
+ async shaclCoreShapesCount(query) {
1348
+ return this.shaclCoreShapesCountSync(query);
1349
+ }
1350
+ shaclCoreShapesCountSync(query) {
1351
+ return this.$objectUnionsCountSync([ShaclCoreNodeShape, ShaclCorePropertyShape], query);
1352
+ }
1353
+ $objectIdentifiersSync(objectType, query) {
1354
+ return this.$objectsSync(objectType, query).map((objects) => objects.map((object) => object.$identifier));
1355
+ }
1356
+ $objectsSync(objectType, query) {
1357
+ const limit = query?.limit ?? Number.MAX_SAFE_INTEGER;
1358
+ if (limit <= 0) {
1359
+ return purify.Either.of([]);
1360
+ }
1361
+ let offset = query?.offset ?? 0;
1362
+ if (offset < 0) {
1363
+ offset = 0;
1364
+ }
1365
+ if (query?.where) {
1366
+ // Assign identifiers in each case block so the compiler will catch missing cases.
1367
+ let identifiers;
1368
+ switch (query.where.type) {
1369
+ case "identifiers": {
1370
+ identifiers = query.where.identifiers.slice(offset, offset + limit);
1371
+ break;
1372
+ }
1373
+ case "triple-objects": {
1374
+ let identifierI = 0;
1375
+ identifiers = [];
1376
+ for (const quad of this.resourceSet.dataset.match(query.where.subject, query.where.predicate, null)) {
1377
+ if (quad.object.termType === "BlankNode" ||
1378
+ quad.object.termType === "NamedNode") {
1379
+ if (++identifierI >= offset) {
1380
+ identifiers.push(quad.object);
1381
+ if (identifiers.length === limit) {
1382
+ break;
1383
+ }
1384
+ }
1385
+ }
1386
+ else {
1387
+ return purify.Left(new Error(`subject=${query.where.subject.value} predicate=${query.where.predicate.value} pattern matches non-identifier (${quad.object.termType}) triple`));
1388
+ }
1389
+ }
1390
+ break;
1391
+ }
1392
+ }
1393
+ const objects = [];
1394
+ for (const identifier of identifiers) {
1395
+ const either = objectType.$fromRdf({
1396
+ resource: this.resourceSet.resource(identifier),
1397
+ });
1398
+ if (either.isLeft()) {
1399
+ return either;
1400
+ }
1401
+ objects.push(either.unsafeCoerce());
1402
+ }
1403
+ return purify.Either.of(objects);
1404
+ }
1405
+ if (!objectType.$fromRdfType) {
1406
+ return purify.Either.of([]);
1407
+ }
1408
+ const resources = [
1409
+ ...this.resourceSet.instancesOf(objectType.$fromRdfType),
1410
+ ];
1411
+ // Sort resources by identifier so limit and offset are deterministic
1412
+ resources.sort((left, right) => left.identifier.value.localeCompare(right.identifier.value));
1413
+ const objects = [];
1414
+ let objectI = 0;
1415
+ for (const resource of resources) {
1416
+ const either = objectType.$fromRdf({ resource });
1417
+ if (either.isLeft()) {
1418
+ return either;
1419
+ }
1420
+ if (objectI++ >= offset) {
1421
+ objects.push(either.unsafeCoerce());
1422
+ if (objects.length === limit) {
1423
+ return purify.Either.of(objects);
1424
+ }
1425
+ }
1426
+ }
1427
+ return purify.Either.of(objects);
1428
+ }
1429
+ $objectsCountSync(objectType, query) {
1430
+ return this.$objectsSync(objectType, query).map((objects) => objects.length);
1431
+ }
1432
+ $objectUnionIdentifiersSync(objectTypes, query) {
1433
+ return this.$objectUnionsSync(objectTypes, query).map((objects) => objects.map((object) => object.$identifier));
1434
+ }
1435
+ $objectUnionsSync(objectTypes, query) {
1436
+ const limit = query?.limit ?? Number.MAX_SAFE_INTEGER;
1437
+ if (limit <= 0) {
1438
+ return purify.Either.of([]);
1439
+ }
1440
+ let offset = query?.offset ?? 0;
1441
+ if (offset < 0) {
1442
+ offset = 0;
1443
+ }
1444
+ if (query?.where) {
1445
+ // Assign identifiers in each case block so the compiler will catch missing cases.
1446
+ let identifiers;
1447
+ switch (query.where.type) {
1448
+ case "identifiers": {
1449
+ identifiers = query.where.identifiers.slice(offset, offset + limit);
1450
+ break;
1451
+ }
1452
+ case "triple-objects": {
1453
+ let identifierI = 0;
1454
+ identifiers = [];
1455
+ for (const quad of this.resourceSet.dataset.match(query.where.subject, query.where.predicate, null)) {
1456
+ if (quad.object.termType === "BlankNode" ||
1457
+ quad.object.termType === "NamedNode") {
1458
+ if (++identifierI >= offset) {
1459
+ identifiers.push(quad.object);
1460
+ if (identifiers.length === limit) {
1461
+ break;
1462
+ }
1463
+ }
1464
+ }
1465
+ else {
1466
+ return purify.Left(new Error(`subject=${query.where.subject.value} predicate=${query.where.predicate.value} pattern matches non-identifier (${quad.object.termType}) triple`));
1467
+ }
1468
+ }
1469
+ break;
1470
+ }
1471
+ }
1472
+ const objects = [];
1473
+ for (const identifier of identifiers) {
1474
+ const resource = this.resourceSet.resource(identifier);
1475
+ const lefts = [];
1476
+ for (const objectType of objectTypes) {
1477
+ const either = objectType.$fromRdf({ resource });
1478
+ if (either.isRight()) {
1479
+ objects.push(either.unsafeCoerce());
1480
+ break;
1481
+ }
1482
+ lefts.push(either);
1483
+ }
1484
+ // Doesn't appear to belong to any of the known object types, just assume the first
1485
+ if (lefts.length === objectTypes.length) {
1486
+ return lefts[0];
1487
+ }
1488
+ }
1489
+ return purify.Either.of(objects);
1490
+ }
1491
+ const resources = [];
1492
+ for (const objectType of objectTypes) {
1493
+ if (!objectType.$fromRdfType) {
1494
+ continue;
1495
+ }
1496
+ for (const resource of this.resourceSet.instancesOf(objectType.$fromRdfType)) {
1497
+ resources.push({ objectType, resource });
1498
+ }
1499
+ }
1500
+ // Sort resources by identifier so limit and offset are deterministic
1501
+ resources.sort((left, right) => left.resource.identifier.value.localeCompare(right.resource.identifier.value));
1502
+ let objectI = 0;
1503
+ const objects = [];
1504
+ for (const { objectType, resource } of resources) {
1505
+ const either = objectType.$fromRdf({ resource });
1506
+ if (either.isLeft()) {
1507
+ return either;
1508
+ }
1509
+ if (objectI++ >= offset) {
1510
+ objects.push(either.unsafeCoerce());
1511
+ if (objects.length === limit) {
1512
+ return purify.Either.of(objects);
1513
+ }
1514
+ }
1515
+ }
1516
+ return purify.Either.of(objects);
1517
+ }
1518
+ $objectUnionsCountSync(objectTypes, query) {
1519
+ return this.$objectUnionIdentifiersSync(objectTypes, query).map((objects) => objects.length);
1520
+ }
1521
+ }
846
1522
  //# sourceMappingURL=generated.js.map