@shaclmate/compiler 3.0.1 → 3.0.3

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.
@@ -1,7 +1,4 @@
1
- import { StoreFactory as _DatasetFactory, DataFactory as dataFactory, } from "n3";
2
- const datasetFactory = new _DatasetFactory();
3
- import * as purify from "purify-ts";
4
- import * as rdfjsResource from "rdfjs-resource";
1
+ import { dataFactory, datasetFactory, purify, rdfjsResource, } from "@shaclmate/runtime";
5
2
  import { PropertyPath } from "./PropertyPath.js";
6
3
  export var $RdfVocabularies;
7
4
  (function ($RdfVocabularies) {
@@ -39,7 +36,7 @@ export var BaseShaclCoreShapeStatic;
39
36
  $Identifier.toString = rdfjsResource.Resource.Identifier.toString;
40
37
  })($Identifier = BaseShaclCoreShapeStatic.$Identifier || (BaseShaclCoreShapeStatic.$Identifier = {}));
41
38
  function $fromRdf(resource, options) {
42
- let { ignoreRdfType = false, languageIn, objectSet, ...context } = options ?? {};
39
+ let { ignoreRdfType = false, objectSet, preferredLanguages, ...context } = options ?? {};
43
40
  if (!objectSet) {
44
41
  objectSet = new $RdfjsDatasetObjectSet({ dataset: resource.dataset });
45
42
  }
@@ -54,7 +51,7 @@ export var BaseShaclCoreShapeStatic;
54
51
  }));
55
52
  }
56
53
  BaseShaclCoreShapeStatic.$fromRdf = $fromRdf;
57
- function $propertiesFromRdf({ ignoreRdfType: $ignoreRdfType, languageIn: $languageIn, objectSet: $objectSet, resource: $resource,
54
+ function $propertiesFromRdf({ ignoreRdfType: $ignoreRdfType, objectSet: $objectSet, preferredLanguages: $preferredLanguages, resource: $resource,
58
55
  // @ts-ignore
59
56
  ...$context }) {
60
57
  const $identifier = $resource.identifier;
@@ -92,42 +89,34 @@ export var BaseShaclCoreShapeStatic;
92
89
  const classes = _classesEither.unsafeCoerce();
93
90
  const _commentsEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.comments["identifier"], { unique: true }))
94
91
  .chain((values) => {
92
+ if (!$preferredLanguages || $preferredLanguages.length === 0) {
93
+ return purify.Either.of(values);
94
+ }
95
95
  const literalValuesEither = values.chainMap((value) => value.toLiteral());
96
96
  if (literalValuesEither.isLeft()) {
97
97
  return literalValuesEither;
98
98
  }
99
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.
100
+ // Return all literals for the first preferredLanguage, then all literals for the second preferredLanguage, etc.
101
+ // Within a preferredLanguage the literals may be in any order.
118
102
  let filteredLiteralValues;
119
- for (const languageIn of uniqueLanguageIn) {
103
+ for (const preferredLanguage of $preferredLanguages) {
120
104
  if (!filteredLiteralValues) {
121
- filteredLiteralValues = literalValues.filter((value) => value.language === languageIn);
105
+ filteredLiteralValues = literalValues.filter((value) => value.language === preferredLanguage);
122
106
  }
123
107
  else {
124
108
  filteredLiteralValues = filteredLiteralValues.concat(...literalValues
125
- .filter((value) => value.language === languageIn)
109
+ .filter((value) => value.language === preferredLanguage)
126
110
  .toArray());
127
111
  }
128
112
  }
129
- return purify.Either.of(filteredLiteralValues);
113
+ return purify.Either.of(filteredLiteralValues.map((literalValue) => new rdfjsResource.Resource.Value({
114
+ object: literalValue,
115
+ predicate: BaseShaclCoreShapeStatic.$properties.comments["identifier"],
116
+ subject: $resource,
117
+ })));
130
118
  })
119
+ .chain((values) => values.chainMap((value) => value.toLiteral()))
131
120
  .map((values) => values.toArray())
132
121
  .map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
133
122
  object: valuesArray,
@@ -168,6 +157,34 @@ export var BaseShaclCoreShapeStatic;
168
157
  }
169
158
  const deactivated = _deactivatedEither.unsafeCoerce();
170
159
  const _flagsEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.flags["identifier"], { unique: true }))
160
+ .chain((values) => {
161
+ if (!$preferredLanguages || $preferredLanguages.length === 0) {
162
+ return purify.Either.of(values);
163
+ }
164
+ const literalValuesEither = values.chainMap((value) => value.toLiteral());
165
+ if (literalValuesEither.isLeft()) {
166
+ return literalValuesEither;
167
+ }
168
+ const literalValues = literalValuesEither.unsafeCoerce();
169
+ // Return all literals for the first preferredLanguage, then all literals for the second preferredLanguage, etc.
170
+ // Within a preferredLanguage the literals may be in any order.
171
+ let filteredLiteralValues;
172
+ for (const preferredLanguage of $preferredLanguages) {
173
+ if (!filteredLiteralValues) {
174
+ filteredLiteralValues = literalValues.filter((value) => value.language === preferredLanguage);
175
+ }
176
+ else {
177
+ filteredLiteralValues = filteredLiteralValues.concat(...literalValues
178
+ .filter((value) => value.language === preferredLanguage)
179
+ .toArray());
180
+ }
181
+ }
182
+ return purify.Either.of(filteredLiteralValues.map((literalValue) => new rdfjsResource.Resource.Value({
183
+ object: literalValue,
184
+ predicate: BaseShaclCoreShapeStatic.$properties.flags["identifier"],
185
+ subject: $resource,
186
+ })));
187
+ })
171
188
  .chain((values) => values.chainMap((value) => value.toString()))
172
189
  .map((values) => values.toArray())
173
190
  .map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
@@ -255,42 +272,34 @@ export var BaseShaclCoreShapeStatic;
255
272
  const isDefinedBy = _isDefinedByEither.unsafeCoerce();
256
273
  const _labelsEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.labels["identifier"], { unique: true }))
257
274
  .chain((values) => {
275
+ if (!$preferredLanguages || $preferredLanguages.length === 0) {
276
+ return purify.Either.of(values);
277
+ }
258
278
  const literalValuesEither = values.chainMap((value) => value.toLiteral());
259
279
  if (literalValuesEither.isLeft()) {
260
280
  return literalValuesEither;
261
281
  }
262
282
  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.
283
+ // Return all literals for the first preferredLanguage, then all literals for the second preferredLanguage, etc.
284
+ // Within a preferredLanguage the literals may be in any order.
281
285
  let filteredLiteralValues;
282
- for (const languageIn of uniqueLanguageIn) {
286
+ for (const preferredLanguage of $preferredLanguages) {
283
287
  if (!filteredLiteralValues) {
284
- filteredLiteralValues = literalValues.filter((value) => value.language === languageIn);
288
+ filteredLiteralValues = literalValues.filter((value) => value.language === preferredLanguage);
285
289
  }
286
290
  else {
287
291
  filteredLiteralValues = filteredLiteralValues.concat(...literalValues
288
- .filter((value) => value.language === languageIn)
292
+ .filter((value) => value.language === preferredLanguage)
289
293
  .toArray());
290
294
  }
291
295
  }
292
- return purify.Either.of(filteredLiteralValues);
296
+ return purify.Either.of(filteredLiteralValues.map((literalValue) => new rdfjsResource.Resource.Value({
297
+ object: literalValue,
298
+ predicate: BaseShaclCoreShapeStatic.$properties.labels["identifier"],
299
+ subject: $resource,
300
+ })));
293
301
  })
302
+ .chain((values) => values.chainMap((value) => value.toLiteral()))
294
303
  .map((values) => values.toArray())
295
304
  .map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
296
305
  object: valuesArray,
@@ -308,7 +317,36 @@ export var BaseShaclCoreShapeStatic;
308
317
  objects: valueList,
309
318
  predicate: BaseShaclCoreShapeStatic.$properties.languageIn["identifier"],
310
319
  subject: $resource,
311
- })).chain((values) => values.chainMap((value) => value.toString()))))
320
+ }))
321
+ .chain((values) => {
322
+ if (!$preferredLanguages || $preferredLanguages.length === 0) {
323
+ return purify.Either.of(values);
324
+ }
325
+ const literalValuesEither = values.chainMap((value) => value.toLiteral());
326
+ if (literalValuesEither.isLeft()) {
327
+ return literalValuesEither;
328
+ }
329
+ const literalValues = literalValuesEither.unsafeCoerce();
330
+ // Return all literals for the first preferredLanguage, then all literals for the second preferredLanguage, etc.
331
+ // Within a preferredLanguage the literals may be in any order.
332
+ let filteredLiteralValues;
333
+ for (const preferredLanguage of $preferredLanguages) {
334
+ if (!filteredLiteralValues) {
335
+ filteredLiteralValues = literalValues.filter((value) => value.language === preferredLanguage);
336
+ }
337
+ else {
338
+ filteredLiteralValues = filteredLiteralValues.concat(...literalValues
339
+ .filter((value) => value.language === preferredLanguage)
340
+ .toArray());
341
+ }
342
+ }
343
+ return purify.Either.of(filteredLiteralValues.map((literalValue) => new rdfjsResource.Resource.Value({
344
+ object: literalValue,
345
+ predicate: BaseShaclCoreShapeStatic.$properties.languageIn["identifier"],
346
+ subject: $resource,
347
+ })));
348
+ })
349
+ .chain((values) => values.chainMap((value) => value.toString()))))
312
350
  .map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
313
351
  .map((values) => values.length > 0
314
352
  ? values.map((value) => purify.Maybe.of(value))
@@ -340,42 +378,34 @@ export var BaseShaclCoreShapeStatic;
340
378
  unique: true,
341
379
  }))
342
380
  .chain((values) => {
381
+ if (!$preferredLanguages || $preferredLanguages.length === 0) {
382
+ return purify.Either.of(values);
383
+ }
343
384
  const literalValuesEither = values.chainMap((value) => value.toLiteral());
344
385
  if (literalValuesEither.isLeft()) {
345
386
  return literalValuesEither;
346
387
  }
347
388
  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.
389
+ // Return all literals for the first preferredLanguage, then all literals for the second preferredLanguage, etc.
390
+ // Within a preferredLanguage the literals may be in any order.
366
391
  let filteredLiteralValues;
367
- for (const languageIn of uniqueLanguageIn) {
392
+ for (const preferredLanguage of $preferredLanguages) {
368
393
  if (!filteredLiteralValues) {
369
- filteredLiteralValues = literalValues.filter((value) => value.language === languageIn);
394
+ filteredLiteralValues = literalValues.filter((value) => value.language === preferredLanguage);
370
395
  }
371
396
  else {
372
397
  filteredLiteralValues = filteredLiteralValues.concat(...literalValues
373
- .filter((value) => value.language === languageIn)
398
+ .filter((value) => value.language === preferredLanguage)
374
399
  .toArray());
375
400
  }
376
401
  }
377
- return purify.Either.of(filteredLiteralValues);
402
+ return purify.Either.of(filteredLiteralValues.map((literalValue) => new rdfjsResource.Resource.Value({
403
+ object: literalValue,
404
+ predicate: BaseShaclCoreShapeStatic.$properties.maxExclusive["identifier"],
405
+ subject: $resource,
406
+ })));
378
407
  })
408
+ .chain((values) => values.chainMap((value) => value.toLiteral()))
379
409
  .map((values) => values.length > 0
380
410
  ? values.map((value) => purify.Maybe.of(value))
381
411
  : rdfjsResource.Resource.Values.fromValue({
@@ -392,42 +422,34 @@ export var BaseShaclCoreShapeStatic;
392
422
  unique: true,
393
423
  }))
394
424
  .chain((values) => {
425
+ if (!$preferredLanguages || $preferredLanguages.length === 0) {
426
+ return purify.Either.of(values);
427
+ }
395
428
  const literalValuesEither = values.chainMap((value) => value.toLiteral());
396
429
  if (literalValuesEither.isLeft()) {
397
430
  return literalValuesEither;
398
431
  }
399
432
  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.
433
+ // Return all literals for the first preferredLanguage, then all literals for the second preferredLanguage, etc.
434
+ // Within a preferredLanguage the literals may be in any order.
418
435
  let filteredLiteralValues;
419
- for (const languageIn of uniqueLanguageIn) {
436
+ for (const preferredLanguage of $preferredLanguages) {
420
437
  if (!filteredLiteralValues) {
421
- filteredLiteralValues = literalValues.filter((value) => value.language === languageIn);
438
+ filteredLiteralValues = literalValues.filter((value) => value.language === preferredLanguage);
422
439
  }
423
440
  else {
424
441
  filteredLiteralValues = filteredLiteralValues.concat(...literalValues
425
- .filter((value) => value.language === languageIn)
442
+ .filter((value) => value.language === preferredLanguage)
426
443
  .toArray());
427
444
  }
428
445
  }
429
- return purify.Either.of(filteredLiteralValues);
446
+ return purify.Either.of(filteredLiteralValues.map((literalValue) => new rdfjsResource.Resource.Value({
447
+ object: literalValue,
448
+ predicate: BaseShaclCoreShapeStatic.$properties.maxInclusive["identifier"],
449
+ subject: $resource,
450
+ })));
430
451
  })
452
+ .chain((values) => values.chainMap((value) => value.toLiteral()))
431
453
  .map((values) => values.length > 0
432
454
  ? values.map((value) => purify.Maybe.of(value))
433
455
  : rdfjsResource.Resource.Values.fromValue({
@@ -472,42 +494,34 @@ export var BaseShaclCoreShapeStatic;
472
494
  unique: true,
473
495
  }))
474
496
  .chain((values) => {
497
+ if (!$preferredLanguages || $preferredLanguages.length === 0) {
498
+ return purify.Either.of(values);
499
+ }
475
500
  const literalValuesEither = values.chainMap((value) => value.toLiteral());
476
501
  if (literalValuesEither.isLeft()) {
477
502
  return literalValuesEither;
478
503
  }
479
504
  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.
505
+ // Return all literals for the first preferredLanguage, then all literals for the second preferredLanguage, etc.
506
+ // Within a preferredLanguage the literals may be in any order.
498
507
  let filteredLiteralValues;
499
- for (const languageIn of uniqueLanguageIn) {
508
+ for (const preferredLanguage of $preferredLanguages) {
500
509
  if (!filteredLiteralValues) {
501
- filteredLiteralValues = literalValues.filter((value) => value.language === languageIn);
510
+ filteredLiteralValues = literalValues.filter((value) => value.language === preferredLanguage);
502
511
  }
503
512
  else {
504
513
  filteredLiteralValues = filteredLiteralValues.concat(...literalValues
505
- .filter((value) => value.language === languageIn)
514
+ .filter((value) => value.language === preferredLanguage)
506
515
  .toArray());
507
516
  }
508
517
  }
509
- return purify.Either.of(filteredLiteralValues);
518
+ return purify.Either.of(filteredLiteralValues.map((literalValue) => new rdfjsResource.Resource.Value({
519
+ object: literalValue,
520
+ predicate: BaseShaclCoreShapeStatic.$properties.minExclusive["identifier"],
521
+ subject: $resource,
522
+ })));
510
523
  })
524
+ .chain((values) => values.chainMap((value) => value.toLiteral()))
511
525
  .map((values) => values.length > 0
512
526
  ? values.map((value) => purify.Maybe.of(value))
513
527
  : rdfjsResource.Resource.Values.fromValue({
@@ -524,42 +538,34 @@ export var BaseShaclCoreShapeStatic;
524
538
  unique: true,
525
539
  }))
526
540
  .chain((values) => {
541
+ if (!$preferredLanguages || $preferredLanguages.length === 0) {
542
+ return purify.Either.of(values);
543
+ }
527
544
  const literalValuesEither = values.chainMap((value) => value.toLiteral());
528
545
  if (literalValuesEither.isLeft()) {
529
546
  return literalValuesEither;
530
547
  }
531
548
  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.
549
+ // Return all literals for the first preferredLanguage, then all literals for the second preferredLanguage, etc.
550
+ // Within a preferredLanguage the literals may be in any order.
550
551
  let filteredLiteralValues;
551
- for (const languageIn of uniqueLanguageIn) {
552
+ for (const preferredLanguage of $preferredLanguages) {
552
553
  if (!filteredLiteralValues) {
553
- filteredLiteralValues = literalValues.filter((value) => value.language === languageIn);
554
+ filteredLiteralValues = literalValues.filter((value) => value.language === preferredLanguage);
554
555
  }
555
556
  else {
556
557
  filteredLiteralValues = filteredLiteralValues.concat(...literalValues
557
- .filter((value) => value.language === languageIn)
558
+ .filter((value) => value.language === preferredLanguage)
558
559
  .toArray());
559
560
  }
560
561
  }
561
- return purify.Either.of(filteredLiteralValues);
562
+ return purify.Either.of(filteredLiteralValues.map((literalValue) => new rdfjsResource.Resource.Value({
563
+ object: literalValue,
564
+ predicate: BaseShaclCoreShapeStatic.$properties.minInclusive["identifier"],
565
+ subject: $resource,
566
+ })));
562
567
  })
568
+ .chain((values) => values.chainMap((value) => value.toLiteral()))
563
569
  .map((values) => values.length > 0
564
570
  ? values.map((value) => purify.Maybe.of(value))
565
571
  : rdfjsResource.Resource.Values.fromValue({
@@ -668,6 +674,34 @@ export var BaseShaclCoreShapeStatic;
668
674
  }
669
675
  const or = _orEither.unsafeCoerce();
670
676
  const _patternsEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.patterns["identifier"], { unique: true }))
677
+ .chain((values) => {
678
+ if (!$preferredLanguages || $preferredLanguages.length === 0) {
679
+ return purify.Either.of(values);
680
+ }
681
+ const literalValuesEither = values.chainMap((value) => value.toLiteral());
682
+ if (literalValuesEither.isLeft()) {
683
+ return literalValuesEither;
684
+ }
685
+ const literalValues = literalValuesEither.unsafeCoerce();
686
+ // Return all literals for the first preferredLanguage, then all literals for the second preferredLanguage, etc.
687
+ // Within a preferredLanguage the literals may be in any order.
688
+ let filteredLiteralValues;
689
+ for (const preferredLanguage of $preferredLanguages) {
690
+ if (!filteredLiteralValues) {
691
+ filteredLiteralValues = literalValues.filter((value) => value.language === preferredLanguage);
692
+ }
693
+ else {
694
+ filteredLiteralValues = filteredLiteralValues.concat(...literalValues
695
+ .filter((value) => value.language === preferredLanguage)
696
+ .toArray());
697
+ }
698
+ }
699
+ return purify.Either.of(filteredLiteralValues.map((literalValue) => new rdfjsResource.Resource.Value({
700
+ object: literalValue,
701
+ predicate: BaseShaclCoreShapeStatic.$properties.patterns["identifier"],
702
+ subject: $resource,
703
+ })));
704
+ })
671
705
  .chain((values) => values.chainMap((value) => value.toString()))
672
706
  .map((values) => values.toArray())
673
707
  .map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
@@ -737,126 +771,136 @@ export var BaseShaclCoreShapeStatic;
737
771
  dataset: datasetFactory.dataset(),
738
772
  });
739
773
  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));
774
+ resource.add(BaseShaclCoreShapeStatic.$properties.and["identifier"], ..._baseShaclCoreShape.and.flatMap((item) => [
775
+ item.length > 0
776
+ ? item.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
777
+ if (itemIndex === 0) {
778
+ currentSubListResource = listResource;
779
+ }
780
+ else {
781
+ const newSubListResource = resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph });
782
+ currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier);
783
+ currentSubListResource = newSubListResource;
784
+ }
785
+ currentSubListResource.add($RdfVocabularies.rdf.first, ...[item]);
786
+ if (itemIndex + 1 === list.length) {
787
+ currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil);
788
+ }
789
+ return { currentSubListResource, listResource };
790
+ }, {
791
+ currentSubListResource: null,
792
+ listResource: resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph }),
793
+ }).listResource.identifier
794
+ : $RdfVocabularies.rdf.nil,
795
+ ]));
796
+ resource.add(BaseShaclCoreShapeStatic.$properties.classes["identifier"], ..._baseShaclCoreShape.classes.flatMap((item) => [item]));
797
+ resource.add(BaseShaclCoreShapeStatic.$properties.comments["identifier"], ..._baseShaclCoreShape.comments.flatMap((item) => [item]));
798
+ resource.add(BaseShaclCoreShapeStatic.$properties.datatype["identifier"], ..._baseShaclCoreShape.datatype.toList());
799
+ resource.add(BaseShaclCoreShapeStatic.$properties.deactivated["identifier"], ..._baseShaclCoreShape.deactivated.toList().flat());
800
+ resource.add(BaseShaclCoreShapeStatic.$properties.flags["identifier"], ..._baseShaclCoreShape.flags.flatMap((item) => [item]));
801
+ resource.add(BaseShaclCoreShapeStatic.$properties.hasValues["identifier"], ..._baseShaclCoreShape.hasValues.flatMap((item) => [item]));
802
+ resource.add(BaseShaclCoreShapeStatic.$properties.in_["identifier"], ..._baseShaclCoreShape.in_.toList().flatMap((value) => [
803
+ value.length > 0
804
+ ? value.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
805
+ if (itemIndex === 0) {
806
+ currentSubListResource = listResource;
807
+ }
808
+ else {
809
+ const newSubListResource = resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph });
810
+ currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier);
811
+ currentSubListResource = newSubListResource;
812
+ }
813
+ currentSubListResource.add($RdfVocabularies.rdf.first, ...[item]);
814
+ if (itemIndex + 1 === list.length) {
815
+ currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil);
816
+ }
817
+ return { currentSubListResource, listResource };
818
+ }, {
819
+ currentSubListResource: null,
820
+ listResource: resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph }),
821
+ }).listResource.identifier
822
+ : $RdfVocabularies.rdf.nil,
823
+ ]));
824
+ resource.add(BaseShaclCoreShapeStatic.$properties.isDefinedBy["identifier"], ..._baseShaclCoreShape.isDefinedBy.toList());
825
+ resource.add(BaseShaclCoreShapeStatic.$properties.labels["identifier"], ..._baseShaclCoreShape.labels.flatMap((item) => [item]));
826
+ resource.add(BaseShaclCoreShapeStatic.$properties.languageIn["identifier"], ..._baseShaclCoreShape.languageIn.toList().flatMap((value) => [
827
+ value.length > 0
828
+ ? value.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
829
+ if (itemIndex === 0) {
830
+ currentSubListResource = listResource;
831
+ }
832
+ else {
833
+ const newSubListResource = resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph });
834
+ currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier);
835
+ currentSubListResource = newSubListResource;
836
+ }
837
+ currentSubListResource.add($RdfVocabularies.rdf.first, ...[item]);
838
+ if (itemIndex + 1 === list.length) {
839
+ currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil);
840
+ }
841
+ return { currentSubListResource, listResource };
842
+ }, {
843
+ currentSubListResource: null,
844
+ listResource: resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph }),
845
+ }).listResource.identifier
846
+ : $RdfVocabularies.rdf.nil,
847
+ ]));
848
+ resource.add(BaseShaclCoreShapeStatic.$properties.maxCount["identifier"], ..._baseShaclCoreShape.maxCount.toList());
849
+ resource.add(BaseShaclCoreShapeStatic.$properties.maxExclusive["identifier"], ..._baseShaclCoreShape.maxExclusive.toList());
850
+ resource.add(BaseShaclCoreShapeStatic.$properties.maxInclusive["identifier"], ..._baseShaclCoreShape.maxInclusive.toList());
851
+ resource.add(BaseShaclCoreShapeStatic.$properties.maxLength["identifier"], ..._baseShaclCoreShape.maxLength.toList());
852
+ resource.add(BaseShaclCoreShapeStatic.$properties.minCount["identifier"], ..._baseShaclCoreShape.minCount.toList());
853
+ resource.add(BaseShaclCoreShapeStatic.$properties.minExclusive["identifier"], ..._baseShaclCoreShape.minExclusive.toList());
854
+ resource.add(BaseShaclCoreShapeStatic.$properties.minInclusive["identifier"], ..._baseShaclCoreShape.minInclusive.toList());
855
+ resource.add(BaseShaclCoreShapeStatic.$properties.minLength["identifier"], ..._baseShaclCoreShape.minLength.toList());
856
+ resource.add(BaseShaclCoreShapeStatic.$properties.nodeKind["identifier"], ..._baseShaclCoreShape.nodeKind.toList());
857
+ resource.add(BaseShaclCoreShapeStatic.$properties.nodes["identifier"], ..._baseShaclCoreShape.nodes.flatMap((item) => [item]));
858
+ resource.add(BaseShaclCoreShapeStatic.$properties.not["identifier"], ..._baseShaclCoreShape.not.flatMap((item) => [item]));
859
+ resource.add(BaseShaclCoreShapeStatic.$properties.or["identifier"], ..._baseShaclCoreShape.or.flatMap((item) => [
860
+ item.length > 0
861
+ ? item.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
862
+ if (itemIndex === 0) {
863
+ currentSubListResource = listResource;
864
+ }
865
+ else {
866
+ const newSubListResource = resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph });
867
+ currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier);
868
+ currentSubListResource = newSubListResource;
869
+ }
870
+ currentSubListResource.add($RdfVocabularies.rdf.first, ...[item]);
871
+ if (itemIndex + 1 === list.length) {
872
+ currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil);
873
+ }
874
+ return { currentSubListResource, listResource };
875
+ }, {
876
+ currentSubListResource: null,
877
+ listResource: resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph }),
878
+ }).listResource.identifier
879
+ : $RdfVocabularies.rdf.nil,
880
+ ]));
881
+ resource.add(BaseShaclCoreShapeStatic.$properties.patterns["identifier"], ..._baseShaclCoreShape.patterns.flatMap((item) => [item]));
882
+ resource.add(BaseShaclCoreShapeStatic.$properties.xone["identifier"], ..._baseShaclCoreShape.xone.flatMap((item) => [
883
+ item.length > 0
884
+ ? item.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
885
+ if (itemIndex === 0) {
886
+ currentSubListResource = listResource;
887
+ }
888
+ else {
889
+ const newSubListResource = resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph });
890
+ currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier);
891
+ currentSubListResource = newSubListResource;
892
+ }
893
+ currentSubListResource.add($RdfVocabularies.rdf.first, ...[item]);
894
+ if (itemIndex + 1 === list.length) {
895
+ currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil);
896
+ }
897
+ return { currentSubListResource, listResource };
898
+ }, {
899
+ currentSubListResource: null,
900
+ listResource: resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph }),
901
+ }).listResource.identifier
902
+ : $RdfVocabularies.rdf.nil,
903
+ ]));
860
904
  return resource;
861
905
  }
862
906
  BaseShaclCoreShapeStatic.$toRdf = $toRdf;
@@ -939,7 +983,7 @@ export var ShaclCorePropertyShapeStatic;
939
983
  ShaclCorePropertyShapeStatic.$fromRdfType = dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyShape");
940
984
  ShaclCorePropertyShapeStatic.$Identifier = BaseShaclCoreShapeStatic.$Identifier;
941
985
  function $fromRdf(resource, options) {
942
- let { ignoreRdfType = false, languageIn, objectSet, ...context } = options ?? {};
986
+ let { ignoreRdfType = false, objectSet, preferredLanguages, ...context } = options ?? {};
943
987
  if (!objectSet) {
944
988
  objectSet = new $RdfjsDatasetObjectSet({ dataset: resource.dataset });
945
989
  }
@@ -950,31 +994,45 @@ export var ShaclCorePropertyShapeStatic;
950
994
  }).altLazy(() => ShaclCorePropertyShapeStatic.$propertiesFromRdf({
951
995
  ...context,
952
996
  ignoreRdfType,
953
- languageIn,
954
997
  objectSet,
998
+ preferredLanguages,
955
999
  resource,
956
1000
  }));
957
1001
  }
958
1002
  ShaclCorePropertyShapeStatic.$fromRdf = $fromRdf;
959
- function $propertiesFromRdf({ ignoreRdfType: $ignoreRdfType, languageIn: $languageIn, objectSet: $objectSet, resource: $resource,
1003
+ function $propertiesFromRdf({ ignoreRdfType: $ignoreRdfType, objectSet: $objectSet, preferredLanguages: $preferredLanguages, resource: $resource,
960
1004
  // @ts-ignore
961
1005
  ...$context }) {
962
1006
  const $super0Either = BaseShaclCoreShapeStatic.$propertiesFromRdf({
963
1007
  ...$context,
964
1008
  ignoreRdfType: true,
965
- languageIn: $languageIn,
966
1009
  objectSet: $objectSet,
1010
+ preferredLanguages: $preferredLanguages,
967
1011
  resource: $resource,
968
1012
  });
969
1013
  if ($super0Either.isLeft()) {
970
1014
  return $super0Either;
971
1015
  }
972
1016
  const $super0 = $super0Either.unsafeCoerce();
973
- if (!$ignoreRdfType && !$resource.isInstanceOf(ShaclCorePropertyShapeStatic.$fromRdfType)) {
974
- return $resource
1017
+ if (!$ignoreRdfType) {
1018
+ const $rdfTypeCheck = $resource
975
1019
  .value($RdfVocabularies.rdf.type)
976
1020
  .chain((actualRdfType) => actualRdfType.toIri())
977
- .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)`)));
1021
+ .chain((actualRdfType) => {
1022
+ // Check the expected type and its known subtypes
1023
+ switch (actualRdfType.value) {
1024
+ case "http://www.w3.org/ns/shacl#PropertyShape":
1025
+ return purify.Either.of(true);
1026
+ }
1027
+ // Check arbitrary rdfs:subClassOf's of the expected type
1028
+ if ($resource.isInstanceOf(ShaclCorePropertyShapeStatic.$fromRdfType)) {
1029
+ return purify.Either.of(true);
1030
+ }
1031
+ return 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)`));
1032
+ });
1033
+ if ($rdfTypeCheck.isLeft()) {
1034
+ return $rdfTypeCheck;
1035
+ }
978
1036
  }
979
1037
  const $identifier = $resource.identifier;
980
1038
  const $type = "ShaclCorePropertyShape";
@@ -1011,42 +1069,34 @@ export var ShaclCorePropertyShapeStatic;
1011
1069
  unique: true,
1012
1070
  }))
1013
1071
  .chain((values) => {
1072
+ if (!$preferredLanguages || $preferredLanguages.length === 0) {
1073
+ return purify.Either.of(values);
1074
+ }
1014
1075
  const literalValuesEither = values.chainMap((value) => value.toLiteral());
1015
1076
  if (literalValuesEither.isLeft()) {
1016
1077
  return literalValuesEither;
1017
1078
  }
1018
1079
  const literalValues = literalValuesEither.unsafeCoerce();
1019
- const nonUniqueLanguageIn = $languageIn ?? [];
1020
- if (nonUniqueLanguageIn.length === 0) {
1021
- return purify.Either.of(literalValues);
1022
- }
1023
- let uniqueLanguageIn;
1024
- if (nonUniqueLanguageIn.length === 1) {
1025
- uniqueLanguageIn = [nonUniqueLanguageIn[0]];
1026
- }
1027
- else {
1028
- uniqueLanguageIn = [];
1029
- for (const languageIn of nonUniqueLanguageIn) {
1030
- if (uniqueLanguageIn.indexOf(languageIn) === -1) {
1031
- uniqueLanguageIn.push(languageIn);
1032
- }
1033
- }
1034
- }
1035
- // Return all literals for the first languageIn, then all literals for the second languageIn, etc.
1036
- // Within a languageIn the literals may be in any order.
1080
+ // Return all literals for the first preferredLanguage, then all literals for the second preferredLanguage, etc.
1081
+ // Within a preferredLanguage the literals may be in any order.
1037
1082
  let filteredLiteralValues;
1038
- for (const languageIn of uniqueLanguageIn) {
1083
+ for (const preferredLanguage of $preferredLanguages) {
1039
1084
  if (!filteredLiteralValues) {
1040
- filteredLiteralValues = literalValues.filter((value) => value.language === languageIn);
1085
+ filteredLiteralValues = literalValues.filter((value) => value.language === preferredLanguage);
1041
1086
  }
1042
1087
  else {
1043
1088
  filteredLiteralValues = filteredLiteralValues.concat(...literalValues
1044
- .filter((value) => value.language === languageIn)
1089
+ .filter((value) => value.language === preferredLanguage)
1045
1090
  .toArray());
1046
1091
  }
1047
1092
  }
1048
- return purify.Either.of(filteredLiteralValues);
1093
+ return purify.Either.of(filteredLiteralValues.map((literalValue) => new rdfjsResource.Resource.Value({
1094
+ object: literalValue,
1095
+ predicate: ShaclCorePropertyShapeStatic.$properties.descriptions["identifier"],
1096
+ subject: $resource,
1097
+ })));
1049
1098
  })
1099
+ .chain((values) => values.chainMap((value) => value.toLiteral()))
1050
1100
  .map((values) => values.toArray())
1051
1101
  .map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
1052
1102
  object: valuesArray,
@@ -1073,42 +1123,34 @@ export var ShaclCorePropertyShapeStatic;
1073
1123
  const groups = _groupsEither.unsafeCoerce();
1074
1124
  const _namesEither = purify.Either.of($resource.values(ShaclCorePropertyShapeStatic.$properties.names["identifier"], { unique: true }))
1075
1125
  .chain((values) => {
1126
+ if (!$preferredLanguages || $preferredLanguages.length === 0) {
1127
+ return purify.Either.of(values);
1128
+ }
1076
1129
  const literalValuesEither = values.chainMap((value) => value.toLiteral());
1077
1130
  if (literalValuesEither.isLeft()) {
1078
1131
  return literalValuesEither;
1079
1132
  }
1080
1133
  const literalValues = literalValuesEither.unsafeCoerce();
1081
- const nonUniqueLanguageIn = $languageIn ?? [];
1082
- if (nonUniqueLanguageIn.length === 0) {
1083
- return purify.Either.of(literalValues);
1084
- }
1085
- let uniqueLanguageIn;
1086
- if (nonUniqueLanguageIn.length === 1) {
1087
- uniqueLanguageIn = [nonUniqueLanguageIn[0]];
1088
- }
1089
- else {
1090
- uniqueLanguageIn = [];
1091
- for (const languageIn of nonUniqueLanguageIn) {
1092
- if (uniqueLanguageIn.indexOf(languageIn) === -1) {
1093
- uniqueLanguageIn.push(languageIn);
1094
- }
1095
- }
1096
- }
1097
- // Return all literals for the first languageIn, then all literals for the second languageIn, etc.
1098
- // Within a languageIn the literals may be in any order.
1134
+ // Return all literals for the first preferredLanguage, then all literals for the second preferredLanguage, etc.
1135
+ // Within a preferredLanguage the literals may be in any order.
1099
1136
  let filteredLiteralValues;
1100
- for (const languageIn of uniqueLanguageIn) {
1137
+ for (const preferredLanguage of $preferredLanguages) {
1101
1138
  if (!filteredLiteralValues) {
1102
- filteredLiteralValues = literalValues.filter((value) => value.language === languageIn);
1139
+ filteredLiteralValues = literalValues.filter((value) => value.language === preferredLanguage);
1103
1140
  }
1104
1141
  else {
1105
1142
  filteredLiteralValues = filteredLiteralValues.concat(...literalValues
1106
- .filter((value) => value.language === languageIn)
1143
+ .filter((value) => value.language === preferredLanguage)
1107
1144
  .toArray());
1108
1145
  }
1109
1146
  }
1110
- return purify.Either.of(filteredLiteralValues);
1147
+ return purify.Either.of(filteredLiteralValues.map((literalValue) => new rdfjsResource.Resource.Value({
1148
+ object: literalValue,
1149
+ predicate: ShaclCorePropertyShapeStatic.$properties.names["identifier"],
1150
+ subject: $resource,
1151
+ })));
1111
1152
  })
1153
+ .chain((values) => values.chainMap((value) => value.toLiteral()))
1112
1154
  .map((values) => values.toArray())
1113
1155
  .map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
1114
1156
  object: valuesArray,
@@ -1138,8 +1180,8 @@ export var ShaclCorePropertyShapeStatic;
1138
1180
  .chain((values) => values.chainMap((value) => value.toResource().chain((resource) => PropertyPath.$fromRdf(resource, {
1139
1181
  ...$context,
1140
1182
  ignoreRdfType: true,
1141
- languageIn: $languageIn,
1142
1183
  objectSet: $objectSet,
1184
+ preferredLanguages: $preferredLanguages,
1143
1185
  }))))
1144
1186
  .chain((values) => values.head());
1145
1187
  if (_pathEither.isLeft()) {
@@ -1191,16 +1233,18 @@ export var ShaclCorePropertyShapeStatic;
1191
1233
  resource.add($RdfVocabularies.rdf.type, resource.dataFactory.namedNode("http://purl.org/shaclmate/ontology#ShaclCorePropertyShape"));
1192
1234
  resource.add($RdfVocabularies.rdf.type, resource.dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyShape"));
1193
1235
  }
1194
- resource.add(ShaclCorePropertyShapeStatic.$properties.defaultValue["identifier"], _shaclCorePropertyShape.defaultValue);
1195
- resource.add(ShaclCorePropertyShapeStatic.$properties.descriptions["identifier"], _shaclCorePropertyShape.descriptions.map((item) => item));
1196
- resource.add(ShaclCorePropertyShapeStatic.$properties.groups["identifier"], _shaclCorePropertyShape.groups.map((item) => item));
1197
- resource.add(ShaclCorePropertyShapeStatic.$properties.names["identifier"], _shaclCorePropertyShape.names.map((item) => item));
1198
- resource.add(ShaclCorePropertyShapeStatic.$properties.order["identifier"], _shaclCorePropertyShape.order);
1199
- resource.add(ShaclCorePropertyShapeStatic.$properties.path["identifier"], PropertyPath.$toRdf(_shaclCorePropertyShape.path, {
1200
- mutateGraph: mutateGraph,
1201
- resourceSet: resourceSet,
1202
- }));
1203
- resource.add(ShaclCorePropertyShapeStatic.$properties.uniqueLang["identifier"], _shaclCorePropertyShape.uniqueLang);
1236
+ resource.add(ShaclCorePropertyShapeStatic.$properties.defaultValue["identifier"], ..._shaclCorePropertyShape.defaultValue.toList());
1237
+ resource.add(ShaclCorePropertyShapeStatic.$properties.descriptions["identifier"], ..._shaclCorePropertyShape.descriptions.flatMap((item) => [item]));
1238
+ resource.add(ShaclCorePropertyShapeStatic.$properties.groups["identifier"], ..._shaclCorePropertyShape.groups.flatMap((item) => [item]));
1239
+ resource.add(ShaclCorePropertyShapeStatic.$properties.names["identifier"], ..._shaclCorePropertyShape.names.flatMap((item) => [item]));
1240
+ resource.add(ShaclCorePropertyShapeStatic.$properties.order["identifier"], ..._shaclCorePropertyShape.order.toList());
1241
+ resource.add(ShaclCorePropertyShapeStatic.$properties.path["identifier"], ...[
1242
+ PropertyPath.$toRdf(_shaclCorePropertyShape.path, {
1243
+ mutateGraph: mutateGraph,
1244
+ resourceSet: resourceSet,
1245
+ }).identifier,
1246
+ ]);
1247
+ resource.add(ShaclCorePropertyShapeStatic.$properties.uniqueLang["identifier"], ..._shaclCorePropertyShape.uniqueLang.toList().flat());
1204
1248
  return resource;
1205
1249
  }
1206
1250
  ShaclCorePropertyShapeStatic.$toRdf = $toRdf;
@@ -1234,38 +1278,52 @@ export var ShaclmatePropertyShape;
1234
1278
  ShaclmatePropertyShape.$fromRdfType = dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyShape");
1235
1279
  ShaclmatePropertyShape.$Identifier = ShaclCorePropertyShapeStatic.$Identifier;
1236
1280
  function $fromRdf(resource, options) {
1237
- let { ignoreRdfType = false, languageIn, objectSet, ...context } = options ?? {};
1281
+ let { ignoreRdfType = false, objectSet, preferredLanguages, ...context } = options ?? {};
1238
1282
  if (!objectSet) {
1239
1283
  objectSet = new $RdfjsDatasetObjectSet({ dataset: resource.dataset });
1240
1284
  }
1241
1285
  return ShaclmatePropertyShape.$propertiesFromRdf({
1242
1286
  ...context,
1243
1287
  ignoreRdfType,
1244
- languageIn,
1245
1288
  objectSet,
1289
+ preferredLanguages,
1246
1290
  resource,
1247
1291
  });
1248
1292
  }
1249
1293
  ShaclmatePropertyShape.$fromRdf = $fromRdf;
1250
- function $propertiesFromRdf({ ignoreRdfType: $ignoreRdfType, languageIn: $languageIn, objectSet: $objectSet, resource: $resource,
1294
+ function $propertiesFromRdf({ ignoreRdfType: $ignoreRdfType, objectSet: $objectSet, preferredLanguages: $preferredLanguages, resource: $resource,
1251
1295
  // @ts-ignore
1252
1296
  ...$context }) {
1253
1297
  const $super0Either = ShaclCorePropertyShapeStatic.$propertiesFromRdf({
1254
1298
  ...$context,
1255
1299
  ignoreRdfType: true,
1256
- languageIn: $languageIn,
1257
1300
  objectSet: $objectSet,
1301
+ preferredLanguages: $preferredLanguages,
1258
1302
  resource: $resource,
1259
1303
  });
1260
1304
  if ($super0Either.isLeft()) {
1261
1305
  return $super0Either;
1262
1306
  }
1263
1307
  const $super0 = $super0Either.unsafeCoerce();
1264
- if (!$ignoreRdfType && !$resource.isInstanceOf(ShaclmatePropertyShape.$fromRdfType)) {
1265
- return $resource
1308
+ if (!$ignoreRdfType) {
1309
+ const $rdfTypeCheck = $resource
1266
1310
  .value($RdfVocabularies.rdf.type)
1267
1311
  .chain((actualRdfType) => actualRdfType.toIri())
1268
- .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)`)));
1312
+ .chain((actualRdfType) => {
1313
+ // Check the expected type and its known subtypes
1314
+ switch (actualRdfType.value) {
1315
+ case "http://www.w3.org/ns/shacl#PropertyShape":
1316
+ return purify.Either.of(true);
1317
+ }
1318
+ // Check arbitrary rdfs:subClassOf's of the expected type
1319
+ if ($resource.isInstanceOf(ShaclmatePropertyShape.$fromRdfType)) {
1320
+ return purify.Either.of(true);
1321
+ }
1322
+ return 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)`));
1323
+ });
1324
+ if ($rdfTypeCheck.isLeft()) {
1325
+ return $rdfTypeCheck;
1326
+ }
1269
1327
  }
1270
1328
  const $identifier = $resource.identifier;
1271
1329
  const $type = "ShaclmatePropertyShape";
@@ -1298,6 +1356,34 @@ export var ShaclmatePropertyShape;
1298
1356
  }
1299
1357
  const mutable = _mutableEither.unsafeCoerce();
1300
1358
  const _nameEither = purify.Either.of($resource.values(ShaclmatePropertyShape.$properties.name["identifier"], { unique: true }))
1359
+ .chain((values) => {
1360
+ if (!$preferredLanguages || $preferredLanguages.length === 0) {
1361
+ return purify.Either.of(values);
1362
+ }
1363
+ const literalValuesEither = values.chainMap((value) => value.toLiteral());
1364
+ if (literalValuesEither.isLeft()) {
1365
+ return literalValuesEither;
1366
+ }
1367
+ const literalValues = literalValuesEither.unsafeCoerce();
1368
+ // Return all literals for the first preferredLanguage, then all literals for the second preferredLanguage, etc.
1369
+ // Within a preferredLanguage the literals may be in any order.
1370
+ let filteredLiteralValues;
1371
+ for (const preferredLanguage of $preferredLanguages) {
1372
+ if (!filteredLiteralValues) {
1373
+ filteredLiteralValues = literalValues.filter((value) => value.language === preferredLanguage);
1374
+ }
1375
+ else {
1376
+ filteredLiteralValues = filteredLiteralValues.concat(...literalValues
1377
+ .filter((value) => value.language === preferredLanguage)
1378
+ .toArray());
1379
+ }
1380
+ }
1381
+ return purify.Either.of(filteredLiteralValues.map((literalValue) => new rdfjsResource.Resource.Value({
1382
+ object: literalValue,
1383
+ predicate: ShaclmateNodeShape.$properties.name["identifier"],
1384
+ subject: $resource,
1385
+ })));
1386
+ })
1301
1387
  .chain((values) => values.chainMap((value) => value.toString()))
1302
1388
  .map((values) => values.length > 0
1303
1389
  ? values.map((value) => purify.Maybe.of(value))
@@ -1394,12 +1480,12 @@ export var ShaclmatePropertyShape;
1394
1480
  if (!ignoreRdfType) {
1395
1481
  resource.add($RdfVocabularies.rdf.type, resource.dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyShape"));
1396
1482
  }
1397
- resource.add(ShaclmatePropertyShape.$properties.lazy["identifier"], _shaclmatePropertyShape.lazy);
1398
- resource.add(ShaclmateNodeShape.$properties.mutable["identifier"], _shaclmatePropertyShape.mutable);
1399
- resource.add(ShaclmateNodeShape.$properties.name["identifier"], _shaclmatePropertyShape.name);
1400
- resource.add(ShaclmatePropertyShape.$properties.stub["identifier"], _shaclmatePropertyShape.stub);
1401
- resource.add(ShaclmatePropertyShape.$properties.visibility["identifier"], _shaclmatePropertyShape.visibility);
1402
- resource.add(ShaclmatePropertyShape.$properties.widen["identifier"], _shaclmatePropertyShape.widen);
1483
+ resource.add(ShaclmatePropertyShape.$properties.lazy["identifier"], ..._shaclmatePropertyShape.lazy.toList().flat());
1484
+ resource.add(ShaclmateNodeShape.$properties.mutable["identifier"], ..._shaclmatePropertyShape.mutable.toList().flat());
1485
+ resource.add(ShaclmateNodeShape.$properties.name["identifier"], ..._shaclmatePropertyShape.name.toList());
1486
+ resource.add(ShaclmatePropertyShape.$properties.stub["identifier"], ..._shaclmatePropertyShape.stub.toList());
1487
+ resource.add(ShaclmatePropertyShape.$properties.visibility["identifier"], ..._shaclmatePropertyShape.visibility.toList());
1488
+ resource.add(ShaclmatePropertyShape.$properties.widen["identifier"], ..._shaclmatePropertyShape.widen.toList().flat());
1403
1489
  return resource;
1404
1490
  }
1405
1491
  ShaclmatePropertyShape.$toRdf = $toRdf;
@@ -1440,7 +1526,7 @@ export var OwlOntologyStatic;
1440
1526
  $Identifier.toString = rdfjsResource.Resource.Identifier.toString;
1441
1527
  })($Identifier = OwlOntologyStatic.$Identifier || (OwlOntologyStatic.$Identifier = {}));
1442
1528
  function $fromRdf(resource, options) {
1443
- let { ignoreRdfType = false, languageIn, objectSet, ...context } = options ?? {};
1529
+ let { ignoreRdfType = false, objectSet, preferredLanguages, ...context } = options ?? {};
1444
1530
  if (!objectSet) {
1445
1531
  objectSet = new $RdfjsDatasetObjectSet({ dataset: resource.dataset });
1446
1532
  }
@@ -1451,61 +1537,67 @@ export var OwlOntologyStatic;
1451
1537
  }).altLazy(() => OwlOntologyStatic.$propertiesFromRdf({
1452
1538
  ...context,
1453
1539
  ignoreRdfType,
1454
- languageIn,
1455
1540
  objectSet,
1541
+ preferredLanguages,
1456
1542
  resource,
1457
1543
  }));
1458
1544
  }
1459
1545
  OwlOntologyStatic.$fromRdf = $fromRdf;
1460
- function $propertiesFromRdf({ ignoreRdfType: $ignoreRdfType, languageIn: $languageIn, objectSet: $objectSet, resource: $resource,
1546
+ function $propertiesFromRdf({ ignoreRdfType: $ignoreRdfType, objectSet: $objectSet, preferredLanguages: $preferredLanguages, resource: $resource,
1461
1547
  // @ts-ignore
1462
1548
  ...$context }) {
1463
- if (!$ignoreRdfType && !$resource.isInstanceOf(OwlOntologyStatic.$fromRdfType)) {
1464
- return $resource
1549
+ if (!$ignoreRdfType) {
1550
+ const $rdfTypeCheck = $resource
1465
1551
  .value($RdfVocabularies.rdf.type)
1466
1552
  .chain((actualRdfType) => actualRdfType.toIri())
1467
- .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)`)));
1553
+ .chain((actualRdfType) => {
1554
+ // Check the expected type and its known subtypes
1555
+ switch (actualRdfType.value) {
1556
+ case "http://www.w3.org/2002/07/owl#Ontology":
1557
+ return purify.Either.of(true);
1558
+ }
1559
+ // Check arbitrary rdfs:subClassOf's of the expected type
1560
+ if ($resource.isInstanceOf(OwlOntologyStatic.$fromRdfType)) {
1561
+ return purify.Either.of(true);
1562
+ }
1563
+ return 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)`));
1564
+ });
1565
+ if ($rdfTypeCheck.isLeft()) {
1566
+ return $rdfTypeCheck;
1567
+ }
1468
1568
  }
1469
1569
  const $identifier = $resource.identifier;
1470
1570
  const $type = "OwlOntology";
1471
1571
  const _labelsEither = purify.Either.of($resource.values(OwlOntologyStatic.$properties.labels["identifier"], { unique: true }))
1472
1572
  .chain((values) => {
1573
+ if (!$preferredLanguages || $preferredLanguages.length === 0) {
1574
+ return purify.Either.of(values);
1575
+ }
1473
1576
  const literalValuesEither = values.chainMap((value) => value.toLiteral());
1474
1577
  if (literalValuesEither.isLeft()) {
1475
1578
  return literalValuesEither;
1476
1579
  }
1477
1580
  const literalValues = literalValuesEither.unsafeCoerce();
1478
- const nonUniqueLanguageIn = $languageIn ?? [];
1479
- if (nonUniqueLanguageIn.length === 0) {
1480
- return purify.Either.of(literalValues);
1481
- }
1482
- let uniqueLanguageIn;
1483
- if (nonUniqueLanguageIn.length === 1) {
1484
- uniqueLanguageIn = [nonUniqueLanguageIn[0]];
1485
- }
1486
- else {
1487
- uniqueLanguageIn = [];
1488
- for (const languageIn of nonUniqueLanguageIn) {
1489
- if (uniqueLanguageIn.indexOf(languageIn) === -1) {
1490
- uniqueLanguageIn.push(languageIn);
1491
- }
1492
- }
1493
- }
1494
- // Return all literals for the first languageIn, then all literals for the second languageIn, etc.
1495
- // Within a languageIn the literals may be in any order.
1581
+ // Return all literals for the first preferredLanguage, then all literals for the second preferredLanguage, etc.
1582
+ // Within a preferredLanguage the literals may be in any order.
1496
1583
  let filteredLiteralValues;
1497
- for (const languageIn of uniqueLanguageIn) {
1584
+ for (const preferredLanguage of $preferredLanguages) {
1498
1585
  if (!filteredLiteralValues) {
1499
- filteredLiteralValues = literalValues.filter((value) => value.language === languageIn);
1586
+ filteredLiteralValues = literalValues.filter((value) => value.language === preferredLanguage);
1500
1587
  }
1501
1588
  else {
1502
1589
  filteredLiteralValues = filteredLiteralValues.concat(...literalValues
1503
- .filter((value) => value.language === languageIn)
1590
+ .filter((value) => value.language === preferredLanguage)
1504
1591
  .toArray());
1505
1592
  }
1506
1593
  }
1507
- return purify.Either.of(filteredLiteralValues);
1594
+ return purify.Either.of(filteredLiteralValues.map((literalValue) => new rdfjsResource.Resource.Value({
1595
+ object: literalValue,
1596
+ predicate: OwlOntologyStatic.$properties.labels["identifier"],
1597
+ subject: $resource,
1598
+ })));
1508
1599
  })
1600
+ .chain((values) => values.chainMap((value) => value.toLiteral()))
1509
1601
  .map((values) => values.toArray())
1510
1602
  .map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
1511
1603
  object: valuesArray,
@@ -1535,7 +1627,7 @@ export var OwlOntologyStatic;
1535
1627
  resource.add($RdfVocabularies.rdf.type, resource.dataFactory.namedNode("http://purl.org/shaclmate/ontology#OwlOntology"));
1536
1628
  resource.add($RdfVocabularies.rdf.type, resource.dataFactory.namedNode("http://www.w3.org/2002/07/owl#Ontology"));
1537
1629
  }
1538
- resource.add(OwlOntologyStatic.$properties.labels["identifier"], _owlOntology.labels.map((item) => item));
1630
+ resource.add(OwlOntologyStatic.$properties.labels["identifier"], ..._owlOntology.labels.flatMap((item) => [item]));
1539
1631
  return resource;
1540
1632
  }
1541
1633
  OwlOntologyStatic.$toRdf = $toRdf;
@@ -1550,38 +1642,52 @@ export var ShaclmateOntology;
1550
1642
  ShaclmateOntology.$fromRdfType = dataFactory.namedNode("http://www.w3.org/2002/07/owl#Ontology");
1551
1643
  ShaclmateOntology.$Identifier = OwlOntologyStatic.$Identifier;
1552
1644
  function $fromRdf(resource, options) {
1553
- let { ignoreRdfType = false, languageIn, objectSet, ...context } = options ?? {};
1645
+ let { ignoreRdfType = false, objectSet, preferredLanguages, ...context } = options ?? {};
1554
1646
  if (!objectSet) {
1555
1647
  objectSet = new $RdfjsDatasetObjectSet({ dataset: resource.dataset });
1556
1648
  }
1557
1649
  return ShaclmateOntology.$propertiesFromRdf({
1558
1650
  ...context,
1559
1651
  ignoreRdfType,
1560
- languageIn,
1561
1652
  objectSet,
1653
+ preferredLanguages,
1562
1654
  resource,
1563
1655
  });
1564
1656
  }
1565
1657
  ShaclmateOntology.$fromRdf = $fromRdf;
1566
- function $propertiesFromRdf({ ignoreRdfType: $ignoreRdfType, languageIn: $languageIn, objectSet: $objectSet, resource: $resource,
1658
+ function $propertiesFromRdf({ ignoreRdfType: $ignoreRdfType, objectSet: $objectSet, preferredLanguages: $preferredLanguages, resource: $resource,
1567
1659
  // @ts-ignore
1568
1660
  ...$context }) {
1569
1661
  const $super0Either = OwlOntologyStatic.$propertiesFromRdf({
1570
1662
  ...$context,
1571
1663
  ignoreRdfType: true,
1572
- languageIn: $languageIn,
1573
1664
  objectSet: $objectSet,
1665
+ preferredLanguages: $preferredLanguages,
1574
1666
  resource: $resource,
1575
1667
  });
1576
1668
  if ($super0Either.isLeft()) {
1577
1669
  return $super0Either;
1578
1670
  }
1579
1671
  const $super0 = $super0Either.unsafeCoerce();
1580
- if (!$ignoreRdfType && !$resource.isInstanceOf(ShaclmateOntology.$fromRdfType)) {
1581
- return $resource
1672
+ if (!$ignoreRdfType) {
1673
+ const $rdfTypeCheck = $resource
1582
1674
  .value($RdfVocabularies.rdf.type)
1583
1675
  .chain((actualRdfType) => actualRdfType.toIri())
1584
- .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)`)));
1676
+ .chain((actualRdfType) => {
1677
+ // Check the expected type and its known subtypes
1678
+ switch (actualRdfType.value) {
1679
+ case "http://www.w3.org/2002/07/owl#Ontology":
1680
+ return purify.Either.of(true);
1681
+ }
1682
+ // Check arbitrary rdfs:subClassOf's of the expected type
1683
+ if ($resource.isInstanceOf(ShaclmateOntology.$fromRdfType)) {
1684
+ return purify.Either.of(true);
1685
+ }
1686
+ return 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)`));
1687
+ });
1688
+ if ($rdfTypeCheck.isLeft()) {
1689
+ return $rdfTypeCheck;
1690
+ }
1585
1691
  }
1586
1692
  const $identifier = $resource.identifier;
1587
1693
  const $type = "ShaclmateOntology";
@@ -1676,6 +1782,34 @@ export var ShaclmateOntology;
1676
1782
  }
1677
1783
  const tsFeatureIncludes = _tsFeatureIncludesEither.unsafeCoerce();
1678
1784
  const _tsImportsEither = purify.Either.of($resource.values(ShaclmateOntology.$properties.tsImports["identifier"], { unique: true }))
1785
+ .chain((values) => {
1786
+ if (!$preferredLanguages || $preferredLanguages.length === 0) {
1787
+ return purify.Either.of(values);
1788
+ }
1789
+ const literalValuesEither = values.chainMap((value) => value.toLiteral());
1790
+ if (literalValuesEither.isLeft()) {
1791
+ return literalValuesEither;
1792
+ }
1793
+ const literalValues = literalValuesEither.unsafeCoerce();
1794
+ // Return all literals for the first preferredLanguage, then all literals for the second preferredLanguage, etc.
1795
+ // Within a preferredLanguage the literals may be in any order.
1796
+ let filteredLiteralValues;
1797
+ for (const preferredLanguage of $preferredLanguages) {
1798
+ if (!filteredLiteralValues) {
1799
+ filteredLiteralValues = literalValues.filter((value) => value.language === preferredLanguage);
1800
+ }
1801
+ else {
1802
+ filteredLiteralValues = filteredLiteralValues.concat(...literalValues
1803
+ .filter((value) => value.language === preferredLanguage)
1804
+ .toArray());
1805
+ }
1806
+ }
1807
+ return purify.Either.of(filteredLiteralValues.map((literalValue) => new rdfjsResource.Resource.Value({
1808
+ object: literalValue,
1809
+ predicate: ShaclmateNodeShape.$properties.tsImports["identifier"],
1810
+ subject: $resource,
1811
+ })));
1812
+ })
1679
1813
  .chain((values) => values.chainMap((value) => value.toString()))
1680
1814
  .map((values) => values.toArray())
1681
1815
  .map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
@@ -1745,10 +1879,10 @@ export var ShaclmateOntology;
1745
1879
  if (!ignoreRdfType) {
1746
1880
  resource.add($RdfVocabularies.rdf.type, resource.dataFactory.namedNode("http://www.w3.org/2002/07/owl#Ontology"));
1747
1881
  }
1748
- resource.add(ShaclmateNodeShape.$properties.tsFeatureExcludes["identifier"], _shaclmateOntology.tsFeatureExcludes.map((item) => item));
1749
- resource.add(ShaclmateNodeShape.$properties.tsFeatureIncludes["identifier"], _shaclmateOntology.tsFeatureIncludes.map((item) => item));
1750
- resource.add(ShaclmateNodeShape.$properties.tsImports["identifier"], _shaclmateOntology.tsImports.map((item) => item));
1751
- resource.add(ShaclmateNodeShape.$properties.tsObjectDeclarationType["identifier"], _shaclmateOntology.tsObjectDeclarationType);
1882
+ resource.add(ShaclmateNodeShape.$properties.tsFeatureExcludes["identifier"], ..._shaclmateOntology.tsFeatureExcludes.flatMap((item) => [item]));
1883
+ resource.add(ShaclmateNodeShape.$properties.tsFeatureIncludes["identifier"], ..._shaclmateOntology.tsFeatureIncludes.flatMap((item) => [item]));
1884
+ resource.add(ShaclmateNodeShape.$properties.tsImports["identifier"], ..._shaclmateOntology.tsImports.flatMap((item) => [item]));
1885
+ resource.add(ShaclmateNodeShape.$properties.tsObjectDeclarationType["identifier"], ..._shaclmateOntology.tsObjectDeclarationType.toList());
1752
1886
  return resource;
1753
1887
  }
1754
1888
  ShaclmateOntology.$toRdf = $toRdf;
@@ -1773,7 +1907,7 @@ export var ShaclCoreNodeShapeStatic;
1773
1907
  ShaclCoreNodeShapeStatic.$fromRdfType = dataFactory.namedNode("http://www.w3.org/ns/shacl#NodeShape");
1774
1908
  ShaclCoreNodeShapeStatic.$Identifier = BaseShaclCoreShapeStatic.$Identifier;
1775
1909
  function $fromRdf(resource, options) {
1776
- let { ignoreRdfType = false, languageIn, objectSet, ...context } = options ?? {};
1910
+ let { ignoreRdfType = false, objectSet, preferredLanguages, ...context } = options ?? {};
1777
1911
  if (!objectSet) {
1778
1912
  objectSet = new $RdfjsDatasetObjectSet({ dataset: resource.dataset });
1779
1913
  }
@@ -1784,31 +1918,45 @@ export var ShaclCoreNodeShapeStatic;
1784
1918
  }).altLazy(() => ShaclCoreNodeShapeStatic.$propertiesFromRdf({
1785
1919
  ...context,
1786
1920
  ignoreRdfType,
1787
- languageIn,
1788
1921
  objectSet,
1922
+ preferredLanguages,
1789
1923
  resource,
1790
1924
  }));
1791
1925
  }
1792
1926
  ShaclCoreNodeShapeStatic.$fromRdf = $fromRdf;
1793
- function $propertiesFromRdf({ ignoreRdfType: $ignoreRdfType, languageIn: $languageIn, objectSet: $objectSet, resource: $resource,
1927
+ function $propertiesFromRdf({ ignoreRdfType: $ignoreRdfType, objectSet: $objectSet, preferredLanguages: $preferredLanguages, resource: $resource,
1794
1928
  // @ts-ignore
1795
1929
  ...$context }) {
1796
1930
  const $super0Either = BaseShaclCoreShapeStatic.$propertiesFromRdf({
1797
1931
  ...$context,
1798
1932
  ignoreRdfType: true,
1799
- languageIn: $languageIn,
1800
1933
  objectSet: $objectSet,
1934
+ preferredLanguages: $preferredLanguages,
1801
1935
  resource: $resource,
1802
1936
  });
1803
1937
  if ($super0Either.isLeft()) {
1804
1938
  return $super0Either;
1805
1939
  }
1806
1940
  const $super0 = $super0Either.unsafeCoerce();
1807
- if (!$ignoreRdfType && !$resource.isInstanceOf(ShaclCoreNodeShapeStatic.$fromRdfType)) {
1808
- return $resource
1941
+ if (!$ignoreRdfType) {
1942
+ const $rdfTypeCheck = $resource
1809
1943
  .value($RdfVocabularies.rdf.type)
1810
1944
  .chain((actualRdfType) => actualRdfType.toIri())
1811
- .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)`)));
1945
+ .chain((actualRdfType) => {
1946
+ // Check the expected type and its known subtypes
1947
+ switch (actualRdfType.value) {
1948
+ case "http://www.w3.org/ns/shacl#NodeShape":
1949
+ return purify.Either.of(true);
1950
+ }
1951
+ // Check arbitrary rdfs:subClassOf's of the expected type
1952
+ if ($resource.isInstanceOf(ShaclCoreNodeShapeStatic.$fromRdfType)) {
1953
+ return purify.Either.of(true);
1954
+ }
1955
+ return 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)`));
1956
+ });
1957
+ if ($rdfTypeCheck.isLeft()) {
1958
+ return $rdfTypeCheck;
1959
+ }
1812
1960
  }
1813
1961
  const $identifier = $resource.identifier;
1814
1962
  const $type = "ShaclCoreNodeShape";
@@ -1888,28 +2036,30 @@ export var ShaclCoreNodeShapeStatic;
1888
2036
  resource.add($RdfVocabularies.rdf.type, resource.dataFactory.namedNode("http://purl.org/shaclmate/ontology#ShaclCoreNodeShape"));
1889
2037
  resource.add($RdfVocabularies.rdf.type, resource.dataFactory.namedNode("http://www.w3.org/ns/shacl#NodeShape"));
1890
2038
  }
1891
- resource.add(ShaclCoreNodeShapeStatic.$properties.closed["identifier"], _shaclCoreNodeShape.closed);
1892
- resource.add(ShaclCoreNodeShapeStatic.$properties.ignoredProperties["identifier"], _shaclCoreNodeShape.ignoredProperties.map((value) => value.length > 0
1893
- ? value.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
1894
- if (itemIndex === 0) {
1895
- currentSubListResource = listResource;
1896
- }
1897
- else {
1898
- const newSubListResource = resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph });
1899
- currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier);
1900
- currentSubListResource = newSubListResource;
1901
- }
1902
- currentSubListResource.add($RdfVocabularies.rdf.first, item);
1903
- if (itemIndex + 1 === list.length) {
1904
- currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil);
1905
- }
1906
- return { currentSubListResource, listResource };
1907
- }, {
1908
- currentSubListResource: null,
1909
- listResource: resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph }),
1910
- }).listResource.identifier
1911
- : $RdfVocabularies.rdf.nil));
1912
- resource.add(ShaclCoreNodeShapeStatic.$properties.properties["identifier"], _shaclCoreNodeShape.properties.map((item) => item));
2039
+ resource.add(ShaclCoreNodeShapeStatic.$properties.closed["identifier"], ..._shaclCoreNodeShape.closed.toList().flat());
2040
+ resource.add(ShaclCoreNodeShapeStatic.$properties.ignoredProperties["identifier"], ..._shaclCoreNodeShape.ignoredProperties.toList().flatMap((value) => [
2041
+ value.length > 0
2042
+ ? value.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
2043
+ if (itemIndex === 0) {
2044
+ currentSubListResource = listResource;
2045
+ }
2046
+ else {
2047
+ const newSubListResource = resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph });
2048
+ currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier);
2049
+ currentSubListResource = newSubListResource;
2050
+ }
2051
+ currentSubListResource.add($RdfVocabularies.rdf.first, ...[item]);
2052
+ if (itemIndex + 1 === list.length) {
2053
+ currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil);
2054
+ }
2055
+ return { currentSubListResource, listResource };
2056
+ }, {
2057
+ currentSubListResource: null,
2058
+ listResource: resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph }),
2059
+ }).listResource.identifier
2060
+ : $RdfVocabularies.rdf.nil,
2061
+ ]));
2062
+ resource.add(ShaclCoreNodeShapeStatic.$properties.properties["identifier"], ..._shaclCoreNodeShape.properties.flatMap((item) => [item]));
1913
2063
  return resource;
1914
2064
  }
1915
2065
  ShaclCoreNodeShapeStatic.$toRdf = $toRdf;
@@ -1931,38 +2081,52 @@ export var ShaclmateNodeShape;
1931
2081
  ShaclmateNodeShape.$fromRdfType = dataFactory.namedNode("http://www.w3.org/ns/shacl#NodeShape");
1932
2082
  ShaclmateNodeShape.$Identifier = ShaclCoreNodeShapeStatic.$Identifier;
1933
2083
  function $fromRdf(resource, options) {
1934
- let { ignoreRdfType = false, languageIn, objectSet, ...context } = options ?? {};
2084
+ let { ignoreRdfType = false, objectSet, preferredLanguages, ...context } = options ?? {};
1935
2085
  if (!objectSet) {
1936
2086
  objectSet = new $RdfjsDatasetObjectSet({ dataset: resource.dataset });
1937
2087
  }
1938
2088
  return ShaclmateNodeShape.$propertiesFromRdf({
1939
2089
  ...context,
1940
2090
  ignoreRdfType,
1941
- languageIn,
1942
2091
  objectSet,
2092
+ preferredLanguages,
1943
2093
  resource,
1944
2094
  });
1945
2095
  }
1946
2096
  ShaclmateNodeShape.$fromRdf = $fromRdf;
1947
- function $propertiesFromRdf({ ignoreRdfType: $ignoreRdfType, languageIn: $languageIn, objectSet: $objectSet, resource: $resource,
2097
+ function $propertiesFromRdf({ ignoreRdfType: $ignoreRdfType, objectSet: $objectSet, preferredLanguages: $preferredLanguages, resource: $resource,
1948
2098
  // @ts-ignore
1949
2099
  ...$context }) {
1950
2100
  const $super0Either = ShaclCoreNodeShapeStatic.$propertiesFromRdf({
1951
2101
  ...$context,
1952
2102
  ignoreRdfType: true,
1953
- languageIn: $languageIn,
1954
2103
  objectSet: $objectSet,
2104
+ preferredLanguages: $preferredLanguages,
1955
2105
  resource: $resource,
1956
2106
  });
1957
2107
  if ($super0Either.isLeft()) {
1958
2108
  return $super0Either;
1959
2109
  }
1960
2110
  const $super0 = $super0Either.unsafeCoerce();
1961
- if (!$ignoreRdfType && !$resource.isInstanceOf(ShaclmateNodeShape.$fromRdfType)) {
1962
- return $resource
2111
+ if (!$ignoreRdfType) {
2112
+ const $rdfTypeCheck = $resource
1963
2113
  .value($RdfVocabularies.rdf.type)
1964
2114
  .chain((actualRdfType) => actualRdfType.toIri())
1965
- .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)`)));
2115
+ .chain((actualRdfType) => {
2116
+ // Check the expected type and its known subtypes
2117
+ switch (actualRdfType.value) {
2118
+ case "http://www.w3.org/ns/shacl#NodeShape":
2119
+ return purify.Either.of(true);
2120
+ }
2121
+ // Check arbitrary rdfs:subClassOf's of the expected type
2122
+ if ($resource.isInstanceOf(ShaclmateNodeShape.$fromRdfType)) {
2123
+ return purify.Either.of(true);
2124
+ }
2125
+ return 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)`));
2126
+ });
2127
+ if ($rdfTypeCheck.isLeft()) {
2128
+ return $rdfTypeCheck;
2129
+ }
1966
2130
  }
1967
2131
  const $identifier = $resource.identifier;
1968
2132
  const $type = "ShaclmateNodeShape";
@@ -2069,6 +2233,34 @@ export var ShaclmateNodeShape;
2069
2233
  }
2070
2234
  const mutable = _mutableEither.unsafeCoerce();
2071
2235
  const _nameEither = purify.Either.of($resource.values(ShaclmateNodeShape.$properties.name["identifier"], { unique: true }))
2236
+ .chain((values) => {
2237
+ if (!$preferredLanguages || $preferredLanguages.length === 0) {
2238
+ return purify.Either.of(values);
2239
+ }
2240
+ const literalValuesEither = values.chainMap((value) => value.toLiteral());
2241
+ if (literalValuesEither.isLeft()) {
2242
+ return literalValuesEither;
2243
+ }
2244
+ const literalValues = literalValuesEither.unsafeCoerce();
2245
+ // Return all literals for the first preferredLanguage, then all literals for the second preferredLanguage, etc.
2246
+ // Within a preferredLanguage the literals may be in any order.
2247
+ let filteredLiteralValues;
2248
+ for (const preferredLanguage of $preferredLanguages) {
2249
+ if (!filteredLiteralValues) {
2250
+ filteredLiteralValues = literalValues.filter((value) => value.language === preferredLanguage);
2251
+ }
2252
+ else {
2253
+ filteredLiteralValues = filteredLiteralValues.concat(...literalValues
2254
+ .filter((value) => value.language === preferredLanguage)
2255
+ .toArray());
2256
+ }
2257
+ }
2258
+ return purify.Either.of(filteredLiteralValues.map((literalValue) => new rdfjsResource.Resource.Value({
2259
+ object: literalValue,
2260
+ predicate: ShaclmateNodeShape.$properties.name["identifier"],
2261
+ subject: $resource,
2262
+ })));
2263
+ })
2072
2264
  .chain((values) => values.chainMap((value) => value.toString()))
2073
2265
  .map((values) => values.length > 0
2074
2266
  ? values.map((value) => purify.Maybe.of(value))
@@ -2202,6 +2394,34 @@ export var ShaclmateNodeShape;
2202
2394
  }
2203
2395
  const tsFeatureIncludes = _tsFeatureIncludesEither.unsafeCoerce();
2204
2396
  const _tsImportsEither = purify.Either.of($resource.values(ShaclmateNodeShape.$properties.tsImports["identifier"], { unique: true }))
2397
+ .chain((values) => {
2398
+ if (!$preferredLanguages || $preferredLanguages.length === 0) {
2399
+ return purify.Either.of(values);
2400
+ }
2401
+ const literalValuesEither = values.chainMap((value) => value.toLiteral());
2402
+ if (literalValuesEither.isLeft()) {
2403
+ return literalValuesEither;
2404
+ }
2405
+ const literalValues = literalValuesEither.unsafeCoerce();
2406
+ // Return all literals for the first preferredLanguage, then all literals for the second preferredLanguage, etc.
2407
+ // Within a preferredLanguage the literals may be in any order.
2408
+ let filteredLiteralValues;
2409
+ for (const preferredLanguage of $preferredLanguages) {
2410
+ if (!filteredLiteralValues) {
2411
+ filteredLiteralValues = literalValues.filter((value) => value.language === preferredLanguage);
2412
+ }
2413
+ else {
2414
+ filteredLiteralValues = filteredLiteralValues.concat(...literalValues
2415
+ .filter((value) => value.language === preferredLanguage)
2416
+ .toArray());
2417
+ }
2418
+ }
2419
+ return purify.Either.of(filteredLiteralValues.map((literalValue) => new rdfjsResource.Resource.Value({
2420
+ object: literalValue,
2421
+ predicate: ShaclmateNodeShape.$properties.tsImports["identifier"],
2422
+ subject: $resource,
2423
+ })));
2424
+ })
2205
2425
  .chain((values) => values.chainMap((value) => value.toString()))
2206
2426
  .map((values) => values.toArray())
2207
2427
  .map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
@@ -2280,19 +2500,19 @@ export var ShaclmateNodeShape;
2280
2500
  if (!ignoreRdfType) {
2281
2501
  resource.add($RdfVocabularies.rdf.type, resource.dataFactory.namedNode("http://www.w3.org/ns/shacl#NodeShape"));
2282
2502
  }
2283
- resource.add(ShaclmateNodeShape.$properties.abstract["identifier"], _shaclmateNodeShape.abstract);
2284
- resource.add(ShaclmateNodeShape.$properties.export_["identifier"], _shaclmateNodeShape.export_);
2285
- resource.add(ShaclmateNodeShape.$properties.extern["identifier"], _shaclmateNodeShape.extern);
2286
- resource.add(ShaclmateNodeShape.$properties.fromRdfType["identifier"], _shaclmateNodeShape.fromRdfType);
2287
- resource.add(ShaclmateNodeShape.$properties.identifierMintingStrategy["identifier"], _shaclmateNodeShape.identifierMintingStrategy);
2288
- resource.add(ShaclmateNodeShape.$properties.mutable["identifier"], _shaclmateNodeShape.mutable);
2289
- resource.add(ShaclmateNodeShape.$properties.name["identifier"], _shaclmateNodeShape.name);
2290
- resource.add(ShaclmateNodeShape.$properties.rdfType["identifier"], _shaclmateNodeShape.rdfType);
2291
- resource.add(ShaclmateNodeShape.$properties.toRdfTypes["identifier"], _shaclmateNodeShape.toRdfTypes.map((item) => item));
2292
- resource.add(ShaclmateNodeShape.$properties.tsFeatureExcludes["identifier"], _shaclmateNodeShape.tsFeatureExcludes.map((item) => item));
2293
- resource.add(ShaclmateNodeShape.$properties.tsFeatureIncludes["identifier"], _shaclmateNodeShape.tsFeatureIncludes.map((item) => item));
2294
- resource.add(ShaclmateNodeShape.$properties.tsImports["identifier"], _shaclmateNodeShape.tsImports.map((item) => item));
2295
- resource.add(ShaclmateNodeShape.$properties.tsObjectDeclarationType["identifier"], _shaclmateNodeShape.tsObjectDeclarationType);
2503
+ resource.add(ShaclmateNodeShape.$properties.abstract["identifier"], ..._shaclmateNodeShape.abstract.toList().flat());
2504
+ resource.add(ShaclmateNodeShape.$properties.export_["identifier"], ..._shaclmateNodeShape.export_.toList().flat());
2505
+ resource.add(ShaclmateNodeShape.$properties.extern["identifier"], ..._shaclmateNodeShape.extern.toList().flat());
2506
+ resource.add(ShaclmateNodeShape.$properties.fromRdfType["identifier"], ..._shaclmateNodeShape.fromRdfType.toList());
2507
+ resource.add(ShaclmateNodeShape.$properties.identifierMintingStrategy["identifier"], ..._shaclmateNodeShape.identifierMintingStrategy.toList());
2508
+ resource.add(ShaclmateNodeShape.$properties.mutable["identifier"], ..._shaclmateNodeShape.mutable.toList().flat());
2509
+ resource.add(ShaclmateNodeShape.$properties.name["identifier"], ..._shaclmateNodeShape.name.toList());
2510
+ resource.add(ShaclmateNodeShape.$properties.rdfType["identifier"], ..._shaclmateNodeShape.rdfType.toList());
2511
+ resource.add(ShaclmateNodeShape.$properties.toRdfTypes["identifier"], ..._shaclmateNodeShape.toRdfTypes.flatMap((item) => [item]));
2512
+ resource.add(ShaclmateNodeShape.$properties.tsFeatureExcludes["identifier"], ..._shaclmateNodeShape.tsFeatureExcludes.flatMap((item) => [item]));
2513
+ resource.add(ShaclmateNodeShape.$properties.tsFeatureIncludes["identifier"], ..._shaclmateNodeShape.tsFeatureIncludes.flatMap((item) => [item]));
2514
+ resource.add(ShaclmateNodeShape.$properties.tsImports["identifier"], ..._shaclmateNodeShape.tsImports.flatMap((item) => [item]));
2515
+ resource.add(ShaclmateNodeShape.$properties.tsObjectDeclarationType["identifier"], ..._shaclmateNodeShape.tsObjectDeclarationType.toList());
2296
2516
  return resource;
2297
2517
  }
2298
2518
  ShaclmateNodeShape.$toRdf = $toRdf;
@@ -2354,68 +2574,74 @@ export var ShaclCorePropertyGroup;
2354
2574
  $Identifier.toString = rdfjsResource.Resource.Identifier.toString;
2355
2575
  })($Identifier = ShaclCorePropertyGroup.$Identifier || (ShaclCorePropertyGroup.$Identifier = {}));
2356
2576
  function $fromRdf(resource, options) {
2357
- let { ignoreRdfType = false, languageIn, objectSet, ...context } = options ?? {};
2577
+ let { ignoreRdfType = false, objectSet, preferredLanguages, ...context } = options ?? {};
2358
2578
  if (!objectSet) {
2359
2579
  objectSet = new $RdfjsDatasetObjectSet({ dataset: resource.dataset });
2360
2580
  }
2361
2581
  return ShaclCorePropertyGroup.$propertiesFromRdf({
2362
2582
  ...context,
2363
2583
  ignoreRdfType,
2364
- languageIn,
2365
2584
  objectSet,
2585
+ preferredLanguages,
2366
2586
  resource,
2367
2587
  });
2368
2588
  }
2369
2589
  ShaclCorePropertyGroup.$fromRdf = $fromRdf;
2370
- function $propertiesFromRdf({ ignoreRdfType: $ignoreRdfType, languageIn: $languageIn, objectSet: $objectSet, resource: $resource,
2590
+ function $propertiesFromRdf({ ignoreRdfType: $ignoreRdfType, objectSet: $objectSet, preferredLanguages: $preferredLanguages, resource: $resource,
2371
2591
  // @ts-ignore
2372
2592
  ...$context }) {
2373
- if (!$ignoreRdfType && !$resource.isInstanceOf(ShaclCorePropertyGroup.$fromRdfType)) {
2374
- return $resource
2593
+ if (!$ignoreRdfType) {
2594
+ const $rdfTypeCheck = $resource
2375
2595
  .value($RdfVocabularies.rdf.type)
2376
2596
  .chain((actualRdfType) => actualRdfType.toIri())
2377
- .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)`)));
2597
+ .chain((actualRdfType) => {
2598
+ // Check the expected type and its known subtypes
2599
+ switch (actualRdfType.value) {
2600
+ case "http://www.w3.org/ns/shacl#PropertyGroup":
2601
+ return purify.Either.of(true);
2602
+ }
2603
+ // Check arbitrary rdfs:subClassOf's of the expected type
2604
+ if ($resource.isInstanceOf(ShaclCorePropertyGroup.$fromRdfType)) {
2605
+ return purify.Either.of(true);
2606
+ }
2607
+ return 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)`));
2608
+ });
2609
+ if ($rdfTypeCheck.isLeft()) {
2610
+ return $rdfTypeCheck;
2611
+ }
2378
2612
  }
2379
2613
  const $identifier = $resource.identifier;
2380
2614
  const $type = "ShaclCorePropertyGroup";
2381
2615
  const _commentsEither = purify.Either.of($resource.values(ShaclCorePropertyGroup.$properties.comments["identifier"], { unique: true }))
2382
2616
  .chain((values) => {
2617
+ if (!$preferredLanguages || $preferredLanguages.length === 0) {
2618
+ return purify.Either.of(values);
2619
+ }
2383
2620
  const literalValuesEither = values.chainMap((value) => value.toLiteral());
2384
2621
  if (literalValuesEither.isLeft()) {
2385
2622
  return literalValuesEither;
2386
2623
  }
2387
2624
  const literalValues = literalValuesEither.unsafeCoerce();
2388
- const nonUniqueLanguageIn = $languageIn ?? [];
2389
- if (nonUniqueLanguageIn.length === 0) {
2390
- return purify.Either.of(literalValues);
2391
- }
2392
- let uniqueLanguageIn;
2393
- if (nonUniqueLanguageIn.length === 1) {
2394
- uniqueLanguageIn = [nonUniqueLanguageIn[0]];
2395
- }
2396
- else {
2397
- uniqueLanguageIn = [];
2398
- for (const languageIn of nonUniqueLanguageIn) {
2399
- if (uniqueLanguageIn.indexOf(languageIn) === -1) {
2400
- uniqueLanguageIn.push(languageIn);
2401
- }
2402
- }
2403
- }
2404
- // Return all literals for the first languageIn, then all literals for the second languageIn, etc.
2405
- // Within a languageIn the literals may be in any order.
2625
+ // Return all literals for the first preferredLanguage, then all literals for the second preferredLanguage, etc.
2626
+ // Within a preferredLanguage the literals may be in any order.
2406
2627
  let filteredLiteralValues;
2407
- for (const languageIn of uniqueLanguageIn) {
2628
+ for (const preferredLanguage of $preferredLanguages) {
2408
2629
  if (!filteredLiteralValues) {
2409
- filteredLiteralValues = literalValues.filter((value) => value.language === languageIn);
2630
+ filteredLiteralValues = literalValues.filter((value) => value.language === preferredLanguage);
2410
2631
  }
2411
2632
  else {
2412
2633
  filteredLiteralValues = filteredLiteralValues.concat(...literalValues
2413
- .filter((value) => value.language === languageIn)
2634
+ .filter((value) => value.language === preferredLanguage)
2414
2635
  .toArray());
2415
2636
  }
2416
2637
  }
2417
- return purify.Either.of(filteredLiteralValues);
2638
+ return purify.Either.of(filteredLiteralValues.map((literalValue) => new rdfjsResource.Resource.Value({
2639
+ object: literalValue,
2640
+ predicate: ShaclCorePropertyGroup.$properties.comments["identifier"],
2641
+ subject: $resource,
2642
+ })));
2418
2643
  })
2644
+ .chain((values) => values.chainMap((value) => value.toLiteral()))
2419
2645
  .map((values) => values.toArray())
2420
2646
  .map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
2421
2647
  object: valuesArray,
@@ -2429,42 +2655,34 @@ export var ShaclCorePropertyGroup;
2429
2655
  const comments = _commentsEither.unsafeCoerce();
2430
2656
  const _labelsEither = purify.Either.of($resource.values(ShaclCorePropertyGroup.$properties.labels["identifier"], { unique: true }))
2431
2657
  .chain((values) => {
2658
+ if (!$preferredLanguages || $preferredLanguages.length === 0) {
2659
+ return purify.Either.of(values);
2660
+ }
2432
2661
  const literalValuesEither = values.chainMap((value) => value.toLiteral());
2433
2662
  if (literalValuesEither.isLeft()) {
2434
2663
  return literalValuesEither;
2435
2664
  }
2436
2665
  const literalValues = literalValuesEither.unsafeCoerce();
2437
- const nonUniqueLanguageIn = $languageIn ?? [];
2438
- if (nonUniqueLanguageIn.length === 0) {
2439
- return purify.Either.of(literalValues);
2440
- }
2441
- let uniqueLanguageIn;
2442
- if (nonUniqueLanguageIn.length === 1) {
2443
- uniqueLanguageIn = [nonUniqueLanguageIn[0]];
2444
- }
2445
- else {
2446
- uniqueLanguageIn = [];
2447
- for (const languageIn of nonUniqueLanguageIn) {
2448
- if (uniqueLanguageIn.indexOf(languageIn) === -1) {
2449
- uniqueLanguageIn.push(languageIn);
2450
- }
2451
- }
2452
- }
2453
- // Return all literals for the first languageIn, then all literals for the second languageIn, etc.
2454
- // Within a languageIn the literals may be in any order.
2666
+ // Return all literals for the first preferredLanguage, then all literals for the second preferredLanguage, etc.
2667
+ // Within a preferredLanguage the literals may be in any order.
2455
2668
  let filteredLiteralValues;
2456
- for (const languageIn of uniqueLanguageIn) {
2669
+ for (const preferredLanguage of $preferredLanguages) {
2457
2670
  if (!filteredLiteralValues) {
2458
- filteredLiteralValues = literalValues.filter((value) => value.language === languageIn);
2671
+ filteredLiteralValues = literalValues.filter((value) => value.language === preferredLanguage);
2459
2672
  }
2460
2673
  else {
2461
2674
  filteredLiteralValues = filteredLiteralValues.concat(...literalValues
2462
- .filter((value) => value.language === languageIn)
2675
+ .filter((value) => value.language === preferredLanguage)
2463
2676
  .toArray());
2464
2677
  }
2465
2678
  }
2466
- return purify.Either.of(filteredLiteralValues);
2679
+ return purify.Either.of(filteredLiteralValues.map((literalValue) => new rdfjsResource.Resource.Value({
2680
+ object: literalValue,
2681
+ predicate: ShaclCorePropertyGroup.$properties.labels["identifier"],
2682
+ subject: $resource,
2683
+ })));
2467
2684
  })
2685
+ .chain((values) => values.chainMap((value) => value.toLiteral()))
2468
2686
  .map((values) => values.toArray())
2469
2687
  .map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
2470
2688
  object: valuesArray,
@@ -2491,8 +2709,8 @@ export var ShaclCorePropertyGroup;
2491
2709
  if (!ignoreRdfType) {
2492
2710
  resource.add($RdfVocabularies.rdf.type, resource.dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyGroup"));
2493
2711
  }
2494
- resource.add(ShaclCorePropertyGroup.$properties.comments["identifier"], _shaclCorePropertyGroup.comments.map((item) => item));
2495
- resource.add(ShaclCorePropertyGroup.$properties.labels["identifier"], _shaclCorePropertyGroup.labels.map((item) => item));
2712
+ resource.add(ShaclCorePropertyGroup.$properties.comments["identifier"], ..._shaclCorePropertyGroup.comments.flatMap((item) => [item]));
2713
+ resource.add(ShaclCorePropertyGroup.$properties.labels["identifier"], ..._shaclCorePropertyGroup.labels.flatMap((item) => [item]));
2496
2714
  return resource;
2497
2715
  }
2498
2716
  ShaclCorePropertyGroup.$toRdf = $toRdf;
@@ -2580,6 +2798,116 @@ export var ShaclmateShape;
2580
2798
  }
2581
2799
  ShaclmateShape.$toRdf = $toRdf;
2582
2800
  })(ShaclmateShape || (ShaclmateShape = {}));
2801
+ export class $ForwardingObjectSet {
2802
+ owlOntology(identifier) {
2803
+ return this.$delegate.owlOntology(identifier);
2804
+ }
2805
+ owlOntologyIdentifiers(query) {
2806
+ return this.$delegate.owlOntologyIdentifiers(query);
2807
+ }
2808
+ owlOntologies(query) {
2809
+ return this.$delegate.owlOntologies(query);
2810
+ }
2811
+ owlOntologiesCount(query) {
2812
+ return this.$delegate.owlOntologiesCount(query);
2813
+ }
2814
+ shaclCoreNodeShape(identifier) {
2815
+ return this.$delegate.shaclCoreNodeShape(identifier);
2816
+ }
2817
+ shaclCoreNodeShapeIdentifiers(query) {
2818
+ return this.$delegate.shaclCoreNodeShapeIdentifiers(query);
2819
+ }
2820
+ shaclCoreNodeShapes(query) {
2821
+ return this.$delegate.shaclCoreNodeShapes(query);
2822
+ }
2823
+ shaclCoreNodeShapesCount(query) {
2824
+ return this.$delegate.shaclCoreNodeShapesCount(query);
2825
+ }
2826
+ shaclCorePropertyGroup(identifier) {
2827
+ return this.$delegate.shaclCorePropertyGroup(identifier);
2828
+ }
2829
+ shaclCorePropertyGroupIdentifiers(query) {
2830
+ return this.$delegate.shaclCorePropertyGroupIdentifiers(query);
2831
+ }
2832
+ shaclCorePropertyGroups(query) {
2833
+ return this.$delegate.shaclCorePropertyGroups(query);
2834
+ }
2835
+ shaclCorePropertyGroupsCount(query) {
2836
+ return this.$delegate.shaclCorePropertyGroupsCount(query);
2837
+ }
2838
+ shaclCorePropertyShape(identifier) {
2839
+ return this.$delegate.shaclCorePropertyShape(identifier);
2840
+ }
2841
+ shaclCorePropertyShapeIdentifiers(query) {
2842
+ return this.$delegate.shaclCorePropertyShapeIdentifiers(query);
2843
+ }
2844
+ shaclCorePropertyShapes(query) {
2845
+ return this.$delegate.shaclCorePropertyShapes(query);
2846
+ }
2847
+ shaclCorePropertyShapesCount(query) {
2848
+ return this.$delegate.shaclCorePropertyShapesCount(query);
2849
+ }
2850
+ shaclmateNodeShape(identifier) {
2851
+ return this.$delegate.shaclmateNodeShape(identifier);
2852
+ }
2853
+ shaclmateNodeShapeIdentifiers(query) {
2854
+ return this.$delegate.shaclmateNodeShapeIdentifiers(query);
2855
+ }
2856
+ shaclmateNodeShapes(query) {
2857
+ return this.$delegate.shaclmateNodeShapes(query);
2858
+ }
2859
+ shaclmateNodeShapesCount(query) {
2860
+ return this.$delegate.shaclmateNodeShapesCount(query);
2861
+ }
2862
+ shaclmateOntology(identifier) {
2863
+ return this.$delegate.shaclmateOntology(identifier);
2864
+ }
2865
+ shaclmateOntologyIdentifiers(query) {
2866
+ return this.$delegate.shaclmateOntologyIdentifiers(query);
2867
+ }
2868
+ shaclmateOntologies(query) {
2869
+ return this.$delegate.shaclmateOntologies(query);
2870
+ }
2871
+ shaclmateOntologiesCount(query) {
2872
+ return this.$delegate.shaclmateOntologiesCount(query);
2873
+ }
2874
+ shaclmatePropertyShape(identifier) {
2875
+ return this.$delegate.shaclmatePropertyShape(identifier);
2876
+ }
2877
+ shaclmatePropertyShapeIdentifiers(query) {
2878
+ return this.$delegate.shaclmatePropertyShapeIdentifiers(query);
2879
+ }
2880
+ shaclmatePropertyShapes(query) {
2881
+ return this.$delegate.shaclmatePropertyShapes(query);
2882
+ }
2883
+ shaclmatePropertyShapesCount(query) {
2884
+ return this.$delegate.shaclmatePropertyShapesCount(query);
2885
+ }
2886
+ shaclCoreShape(identifier) {
2887
+ return this.$delegate.shaclCoreShape(identifier);
2888
+ }
2889
+ shaclCoreShapeIdentifiers(query) {
2890
+ return this.$delegate.shaclCoreShapeIdentifiers(query);
2891
+ }
2892
+ shaclCoreShapes(query) {
2893
+ return this.$delegate.shaclCoreShapes(query);
2894
+ }
2895
+ shaclCoreShapesCount(query) {
2896
+ return this.$delegate.shaclCoreShapesCount(query);
2897
+ }
2898
+ shaclmateShape(identifier) {
2899
+ return this.$delegate.shaclmateShape(identifier);
2900
+ }
2901
+ shaclmateShapeIdentifiers(query) {
2902
+ return this.$delegate.shaclmateShapeIdentifiers(query);
2903
+ }
2904
+ shaclmateShapes(query) {
2905
+ return this.$delegate.shaclmateShapes(query);
2906
+ }
2907
+ shaclmateShapesCount(query) {
2908
+ return this.$delegate.shaclmateShapesCount(query);
2909
+ }
2910
+ }
2583
2911
  export class $RdfjsDatasetObjectSet {
2584
2912
  resourceSet;
2585
2913
  constructor({ dataset }) {
@@ -2597,19 +2925,37 @@ export class $RdfjsDatasetObjectSet {
2597
2925
  return this.owlOntologyIdentifiersSync(query);
2598
2926
  }
2599
2927
  owlOntologyIdentifiersSync(query) {
2600
- return this.$objectIdentifiersSync(OwlOntologyStatic, query);
2928
+ return this.$objectIdentifiersSync({
2929
+ $fromRdf: OwlOntologyStatic.$fromRdf,
2930
+ $fromRdfTypes: [
2931
+ OwlOntologyStatic.$fromRdfType,
2932
+ ShaclmateOntology.$fromRdfType,
2933
+ ],
2934
+ }, query);
2601
2935
  }
2602
2936
  async owlOntologies(query) {
2603
2937
  return this.owlOntologiesSync(query);
2604
2938
  }
2605
2939
  owlOntologiesSync(query) {
2606
- return this.$objectsSync(OwlOntologyStatic, query);
2940
+ return this.$objectsSync({
2941
+ $fromRdf: OwlOntologyStatic.$fromRdf,
2942
+ $fromRdfTypes: [
2943
+ OwlOntologyStatic.$fromRdfType,
2944
+ ShaclmateOntology.$fromRdfType,
2945
+ ],
2946
+ }, query);
2607
2947
  }
2608
2948
  async owlOntologiesCount(query) {
2609
2949
  return this.owlOntologiesCountSync(query);
2610
2950
  }
2611
2951
  owlOntologiesCountSync(query) {
2612
- return this.$objectsCountSync(OwlOntologyStatic, query);
2952
+ return this.$objectsCountSync({
2953
+ $fromRdf: OwlOntologyStatic.$fromRdf,
2954
+ $fromRdfTypes: [
2955
+ OwlOntologyStatic.$fromRdfType,
2956
+ ShaclmateOntology.$fromRdfType,
2957
+ ],
2958
+ }, query);
2613
2959
  }
2614
2960
  async shaclCoreNodeShape(identifier) {
2615
2961
  return this.shaclCoreNodeShapeSync(identifier);
@@ -2623,19 +2969,37 @@ export class $RdfjsDatasetObjectSet {
2623
2969
  return this.shaclCoreNodeShapeIdentifiersSync(query);
2624
2970
  }
2625
2971
  shaclCoreNodeShapeIdentifiersSync(query) {
2626
- return this.$objectIdentifiersSync(ShaclCoreNodeShapeStatic, query);
2972
+ return this.$objectIdentifiersSync({
2973
+ $fromRdf: ShaclCoreNodeShapeStatic.$fromRdf,
2974
+ $fromRdfTypes: [
2975
+ ShaclCoreNodeShapeStatic.$fromRdfType,
2976
+ ShaclmateNodeShape.$fromRdfType,
2977
+ ],
2978
+ }, query);
2627
2979
  }
2628
2980
  async shaclCoreNodeShapes(query) {
2629
2981
  return this.shaclCoreNodeShapesSync(query);
2630
2982
  }
2631
2983
  shaclCoreNodeShapesSync(query) {
2632
- return this.$objectsSync(ShaclCoreNodeShapeStatic, query);
2984
+ return this.$objectsSync({
2985
+ $fromRdf: ShaclCoreNodeShapeStatic.$fromRdf,
2986
+ $fromRdfTypes: [
2987
+ ShaclCoreNodeShapeStatic.$fromRdfType,
2988
+ ShaclmateNodeShape.$fromRdfType,
2989
+ ],
2990
+ }, query);
2633
2991
  }
2634
2992
  async shaclCoreNodeShapesCount(query) {
2635
2993
  return this.shaclCoreNodeShapesCountSync(query);
2636
2994
  }
2637
2995
  shaclCoreNodeShapesCountSync(query) {
2638
- return this.$objectsCountSync(ShaclCoreNodeShapeStatic, query);
2996
+ return this.$objectsCountSync({
2997
+ $fromRdf: ShaclCoreNodeShapeStatic.$fromRdf,
2998
+ $fromRdfTypes: [
2999
+ ShaclCoreNodeShapeStatic.$fromRdfType,
3000
+ ShaclmateNodeShape.$fromRdfType,
3001
+ ],
3002
+ }, query);
2639
3003
  }
2640
3004
  async shaclCorePropertyGroup(identifier) {
2641
3005
  return this.shaclCorePropertyGroupSync(identifier);
@@ -2649,19 +3013,28 @@ export class $RdfjsDatasetObjectSet {
2649
3013
  return this.shaclCorePropertyGroupIdentifiersSync(query);
2650
3014
  }
2651
3015
  shaclCorePropertyGroupIdentifiersSync(query) {
2652
- return this.$objectIdentifiersSync(ShaclCorePropertyGroup, query);
3016
+ return this.$objectIdentifiersSync({
3017
+ $fromRdf: ShaclCorePropertyGroup.$fromRdf,
3018
+ $fromRdfTypes: [ShaclCorePropertyGroup.$fromRdfType],
3019
+ }, query);
2653
3020
  }
2654
3021
  async shaclCorePropertyGroups(query) {
2655
3022
  return this.shaclCorePropertyGroupsSync(query);
2656
3023
  }
2657
3024
  shaclCorePropertyGroupsSync(query) {
2658
- return this.$objectsSync(ShaclCorePropertyGroup, query);
3025
+ return this.$objectsSync({
3026
+ $fromRdf: ShaclCorePropertyGroup.$fromRdf,
3027
+ $fromRdfTypes: [ShaclCorePropertyGroup.$fromRdfType],
3028
+ }, query);
2659
3029
  }
2660
3030
  async shaclCorePropertyGroupsCount(query) {
2661
3031
  return this.shaclCorePropertyGroupsCountSync(query);
2662
3032
  }
2663
3033
  shaclCorePropertyGroupsCountSync(query) {
2664
- return this.$objectsCountSync(ShaclCorePropertyGroup, query);
3034
+ return this.$objectsCountSync({
3035
+ $fromRdf: ShaclCorePropertyGroup.$fromRdf,
3036
+ $fromRdfTypes: [ShaclCorePropertyGroup.$fromRdfType],
3037
+ }, query);
2665
3038
  }
2666
3039
  async shaclCorePropertyShape(identifier) {
2667
3040
  return this.shaclCorePropertyShapeSync(identifier);
@@ -2675,19 +3048,37 @@ export class $RdfjsDatasetObjectSet {
2675
3048
  return this.shaclCorePropertyShapeIdentifiersSync(query);
2676
3049
  }
2677
3050
  shaclCorePropertyShapeIdentifiersSync(query) {
2678
- return this.$objectIdentifiersSync(ShaclCorePropertyShapeStatic, query);
3051
+ return this.$objectIdentifiersSync({
3052
+ $fromRdf: ShaclCorePropertyShapeStatic.$fromRdf,
3053
+ $fromRdfTypes: [
3054
+ ShaclCorePropertyShapeStatic.$fromRdfType,
3055
+ ShaclmatePropertyShape.$fromRdfType,
3056
+ ],
3057
+ }, query);
2679
3058
  }
2680
3059
  async shaclCorePropertyShapes(query) {
2681
3060
  return this.shaclCorePropertyShapesSync(query);
2682
3061
  }
2683
3062
  shaclCorePropertyShapesSync(query) {
2684
- return this.$objectsSync(ShaclCorePropertyShapeStatic, query);
3063
+ return this.$objectsSync({
3064
+ $fromRdf: ShaclCorePropertyShapeStatic.$fromRdf,
3065
+ $fromRdfTypes: [
3066
+ ShaclCorePropertyShapeStatic.$fromRdfType,
3067
+ ShaclmatePropertyShape.$fromRdfType,
3068
+ ],
3069
+ }, query);
2685
3070
  }
2686
3071
  async shaclCorePropertyShapesCount(query) {
2687
3072
  return this.shaclCorePropertyShapesCountSync(query);
2688
3073
  }
2689
3074
  shaclCorePropertyShapesCountSync(query) {
2690
- return this.$objectsCountSync(ShaclCorePropertyShapeStatic, query);
3075
+ return this.$objectsCountSync({
3076
+ $fromRdf: ShaclCorePropertyShapeStatic.$fromRdf,
3077
+ $fromRdfTypes: [
3078
+ ShaclCorePropertyShapeStatic.$fromRdfType,
3079
+ ShaclmatePropertyShape.$fromRdfType,
3080
+ ],
3081
+ }, query);
2691
3082
  }
2692
3083
  async shaclmateNodeShape(identifier) {
2693
3084
  return this.shaclmateNodeShapeSync(identifier);
@@ -2701,19 +3092,28 @@ export class $RdfjsDatasetObjectSet {
2701
3092
  return this.shaclmateNodeShapeIdentifiersSync(query);
2702
3093
  }
2703
3094
  shaclmateNodeShapeIdentifiersSync(query) {
2704
- return this.$objectIdentifiersSync(ShaclmateNodeShape, query);
3095
+ return this.$objectIdentifiersSync({
3096
+ $fromRdf: ShaclmateNodeShape.$fromRdf,
3097
+ $fromRdfTypes: [ShaclmateNodeShape.$fromRdfType],
3098
+ }, query);
2705
3099
  }
2706
3100
  async shaclmateNodeShapes(query) {
2707
3101
  return this.shaclmateNodeShapesSync(query);
2708
3102
  }
2709
3103
  shaclmateNodeShapesSync(query) {
2710
- return this.$objectsSync(ShaclmateNodeShape, query);
3104
+ return this.$objectsSync({
3105
+ $fromRdf: ShaclmateNodeShape.$fromRdf,
3106
+ $fromRdfTypes: [ShaclmateNodeShape.$fromRdfType],
3107
+ }, query);
2711
3108
  }
2712
3109
  async shaclmateNodeShapesCount(query) {
2713
3110
  return this.shaclmateNodeShapesCountSync(query);
2714
3111
  }
2715
3112
  shaclmateNodeShapesCountSync(query) {
2716
- return this.$objectsCountSync(ShaclmateNodeShape, query);
3113
+ return this.$objectsCountSync({
3114
+ $fromRdf: ShaclmateNodeShape.$fromRdf,
3115
+ $fromRdfTypes: [ShaclmateNodeShape.$fromRdfType],
3116
+ }, query);
2717
3117
  }
2718
3118
  async shaclmateOntology(identifier) {
2719
3119
  return this.shaclmateOntologySync(identifier);
@@ -2727,19 +3127,28 @@ export class $RdfjsDatasetObjectSet {
2727
3127
  return this.shaclmateOntologyIdentifiersSync(query);
2728
3128
  }
2729
3129
  shaclmateOntologyIdentifiersSync(query) {
2730
- return this.$objectIdentifiersSync(ShaclmateOntology, query);
3130
+ return this.$objectIdentifiersSync({
3131
+ $fromRdf: ShaclmateOntology.$fromRdf,
3132
+ $fromRdfTypes: [ShaclmateOntology.$fromRdfType],
3133
+ }, query);
2731
3134
  }
2732
3135
  async shaclmateOntologies(query) {
2733
3136
  return this.shaclmateOntologiesSync(query);
2734
3137
  }
2735
3138
  shaclmateOntologiesSync(query) {
2736
- return this.$objectsSync(ShaclmateOntology, query);
3139
+ return this.$objectsSync({
3140
+ $fromRdf: ShaclmateOntology.$fromRdf,
3141
+ $fromRdfTypes: [ShaclmateOntology.$fromRdfType],
3142
+ }, query);
2737
3143
  }
2738
3144
  async shaclmateOntologiesCount(query) {
2739
3145
  return this.shaclmateOntologiesCountSync(query);
2740
3146
  }
2741
3147
  shaclmateOntologiesCountSync(query) {
2742
- return this.$objectsCountSync(ShaclmateOntology, query);
3148
+ return this.$objectsCountSync({
3149
+ $fromRdf: ShaclmateOntology.$fromRdf,
3150
+ $fromRdfTypes: [ShaclmateOntology.$fromRdfType],
3151
+ }, query);
2743
3152
  }
2744
3153
  async shaclmatePropertyShape(identifier) {
2745
3154
  return this.shaclmatePropertyShapeSync(identifier);
@@ -2753,19 +3162,28 @@ export class $RdfjsDatasetObjectSet {
2753
3162
  return this.shaclmatePropertyShapeIdentifiersSync(query);
2754
3163
  }
2755
3164
  shaclmatePropertyShapeIdentifiersSync(query) {
2756
- return this.$objectIdentifiersSync(ShaclmatePropertyShape, query);
3165
+ return this.$objectIdentifiersSync({
3166
+ $fromRdf: ShaclmatePropertyShape.$fromRdf,
3167
+ $fromRdfTypes: [ShaclmatePropertyShape.$fromRdfType],
3168
+ }, query);
2757
3169
  }
2758
3170
  async shaclmatePropertyShapes(query) {
2759
3171
  return this.shaclmatePropertyShapesSync(query);
2760
3172
  }
2761
3173
  shaclmatePropertyShapesSync(query) {
2762
- return this.$objectsSync(ShaclmatePropertyShape, query);
3174
+ return this.$objectsSync({
3175
+ $fromRdf: ShaclmatePropertyShape.$fromRdf,
3176
+ $fromRdfTypes: [ShaclmatePropertyShape.$fromRdfType],
3177
+ }, query);
2763
3178
  }
2764
3179
  async shaclmatePropertyShapesCount(query) {
2765
3180
  return this.shaclmatePropertyShapesCountSync(query);
2766
3181
  }
2767
3182
  shaclmatePropertyShapesCountSync(query) {
2768
- return this.$objectsCountSync(ShaclmatePropertyShape, query);
3183
+ return this.$objectsCountSync({
3184
+ $fromRdf: ShaclmatePropertyShape.$fromRdf,
3185
+ $fromRdfTypes: [ShaclmatePropertyShape.$fromRdfType],
3186
+ }, query);
2769
3187
  }
2770
3188
  async shaclCoreShape(identifier) {
2771
3189
  return this.shaclCoreShapeSync(identifier);
@@ -2779,19 +3197,64 @@ export class $RdfjsDatasetObjectSet {
2779
3197
  return this.shaclCoreShapeIdentifiersSync(query);
2780
3198
  }
2781
3199
  shaclCoreShapeIdentifiersSync(query) {
2782
- return this.$objectUnionIdentifiersSync([ShaclCoreNodeShapeStatic, ShaclCorePropertyShapeStatic], query);
3200
+ return this.$objectUnionIdentifiersSync([
3201
+ {
3202
+ $fromRdf: ShaclCoreNodeShapeStatic.$fromRdf,
3203
+ $fromRdfTypes: [
3204
+ ShaclCoreNodeShapeStatic.$fromRdfType,
3205
+ ShaclmateNodeShape.$fromRdfType,
3206
+ ],
3207
+ },
3208
+ {
3209
+ $fromRdf: ShaclCorePropertyShapeStatic.$fromRdf,
3210
+ $fromRdfTypes: [
3211
+ ShaclCorePropertyShapeStatic.$fromRdfType,
3212
+ ShaclmatePropertyShape.$fromRdfType,
3213
+ ],
3214
+ },
3215
+ ], query);
2783
3216
  }
2784
3217
  async shaclCoreShapes(query) {
2785
3218
  return this.shaclCoreShapesSync(query);
2786
3219
  }
2787
3220
  shaclCoreShapesSync(query) {
2788
- return this.$objectUnionsSync([ShaclCoreNodeShapeStatic, ShaclCorePropertyShapeStatic], query);
3221
+ return this.$objectUnionsSync([
3222
+ {
3223
+ $fromRdf: ShaclCoreNodeShapeStatic.$fromRdf,
3224
+ $fromRdfTypes: [
3225
+ ShaclCoreNodeShapeStatic.$fromRdfType,
3226
+ ShaclmateNodeShape.$fromRdfType,
3227
+ ],
3228
+ },
3229
+ {
3230
+ $fromRdf: ShaclCorePropertyShapeStatic.$fromRdf,
3231
+ $fromRdfTypes: [
3232
+ ShaclCorePropertyShapeStatic.$fromRdfType,
3233
+ ShaclmatePropertyShape.$fromRdfType,
3234
+ ],
3235
+ },
3236
+ ], query);
2789
3237
  }
2790
3238
  async shaclCoreShapesCount(query) {
2791
3239
  return this.shaclCoreShapesCountSync(query);
2792
3240
  }
2793
3241
  shaclCoreShapesCountSync(query) {
2794
- return this.$objectUnionsCountSync([ShaclCoreNodeShapeStatic, ShaclCorePropertyShapeStatic], query);
3242
+ return this.$objectUnionsCountSync([
3243
+ {
3244
+ $fromRdf: ShaclCoreNodeShapeStatic.$fromRdf,
3245
+ $fromRdfTypes: [
3246
+ ShaclCoreNodeShapeStatic.$fromRdfType,
3247
+ ShaclmateNodeShape.$fromRdfType,
3248
+ ],
3249
+ },
3250
+ {
3251
+ $fromRdf: ShaclCorePropertyShapeStatic.$fromRdf,
3252
+ $fromRdfTypes: [
3253
+ ShaclCorePropertyShapeStatic.$fromRdfType,
3254
+ ShaclmatePropertyShape.$fromRdfType,
3255
+ ],
3256
+ },
3257
+ ], query);
2795
3258
  }
2796
3259
  async shaclmateShape(identifier) {
2797
3260
  return this.shaclmateShapeSync(identifier);
@@ -2805,19 +3268,55 @@ export class $RdfjsDatasetObjectSet {
2805
3268
  return this.shaclmateShapeIdentifiersSync(query);
2806
3269
  }
2807
3270
  shaclmateShapeIdentifiersSync(query) {
2808
- return this.$objectUnionIdentifiersSync([ShaclmateNodeShape, ShaclCorePropertyShapeStatic], query);
3271
+ return this.$objectUnionIdentifiersSync([
3272
+ {
3273
+ $fromRdf: ShaclmateNodeShape.$fromRdf,
3274
+ $fromRdfTypes: [ShaclmateNodeShape.$fromRdfType],
3275
+ },
3276
+ {
3277
+ $fromRdf: ShaclCorePropertyShapeStatic.$fromRdf,
3278
+ $fromRdfTypes: [
3279
+ ShaclCorePropertyShapeStatic.$fromRdfType,
3280
+ ShaclmatePropertyShape.$fromRdfType,
3281
+ ],
3282
+ },
3283
+ ], query);
2809
3284
  }
2810
3285
  async shaclmateShapes(query) {
2811
3286
  return this.shaclmateShapesSync(query);
2812
3287
  }
2813
3288
  shaclmateShapesSync(query) {
2814
- return this.$objectUnionsSync([ShaclmateNodeShape, ShaclCorePropertyShapeStatic], query);
3289
+ return this.$objectUnionsSync([
3290
+ {
3291
+ $fromRdf: ShaclmateNodeShape.$fromRdf,
3292
+ $fromRdfTypes: [ShaclmateNodeShape.$fromRdfType],
3293
+ },
3294
+ {
3295
+ $fromRdf: ShaclCorePropertyShapeStatic.$fromRdf,
3296
+ $fromRdfTypes: [
3297
+ ShaclCorePropertyShapeStatic.$fromRdfType,
3298
+ ShaclmatePropertyShape.$fromRdfType,
3299
+ ],
3300
+ },
3301
+ ], query);
2815
3302
  }
2816
3303
  async shaclmateShapesCount(query) {
2817
3304
  return this.shaclmateShapesCountSync(query);
2818
3305
  }
2819
3306
  shaclmateShapesCountSync(query) {
2820
- return this.$objectUnionsCountSync([ShaclmateNodeShape, ShaclCorePropertyShapeStatic], query);
3307
+ return this.$objectUnionsCountSync([
3308
+ {
3309
+ $fromRdf: ShaclmateNodeShape.$fromRdf,
3310
+ $fromRdfTypes: [ShaclmateNodeShape.$fromRdfType],
3311
+ },
3312
+ {
3313
+ $fromRdf: ShaclCorePropertyShapeStatic.$fromRdf,
3314
+ $fromRdfTypes: [
3315
+ ShaclCorePropertyShapeStatic.$fromRdfType,
3316
+ ShaclmatePropertyShape.$fromRdfType,
3317
+ ],
3318
+ },
3319
+ ], query);
2821
3320
  }
2822
3321
  $objectIdentifiersSync(objectType, query) {
2823
3322
  return this.$objectsSync(objectType, query).map((objects) => objects.map((object) => object.$identifier));
@@ -2869,12 +3368,17 @@ export class $RdfjsDatasetObjectSet {
2869
3368
  }
2870
3369
  return purify.Either.of(objects);
2871
3370
  }
2872
- if (!objectType.$fromRdfType) {
3371
+ if (objectType.$fromRdfTypes.length === 0) {
2873
3372
  return purify.Either.of([]);
2874
3373
  }
2875
- const resources = [
2876
- ...this.resourceSet.instancesOf(objectType.$fromRdfType),
2877
- ];
3374
+ const resources = [];
3375
+ for (const fromRdfType of objectType.$fromRdfTypes) {
3376
+ for (const resource of this.resourceSet.instancesOf(fromRdfType)) {
3377
+ if (!resources.some((existingResource) => existingResource.identifier.equals(resource.identifier))) {
3378
+ resources.push(resource);
3379
+ }
3380
+ }
3381
+ }
2878
3382
  // Sort resources by identifier so limit and offset are deterministic
2879
3383
  resources.sort((left, right) => left.identifier.value.localeCompare(right.identifier.value));
2880
3384
  const objects = [];
@@ -2957,11 +3461,15 @@ export class $RdfjsDatasetObjectSet {
2957
3461
  }
2958
3462
  const resources = [];
2959
3463
  for (const objectType of objectTypes) {
2960
- if (!objectType.$fromRdfType) {
3464
+ if (objectType.$fromRdfTypes.length === 0) {
2961
3465
  continue;
2962
3466
  }
2963
- for (const resource of this.resourceSet.instancesOf(objectType.$fromRdfType)) {
2964
- resources.push({ objectType, resource });
3467
+ for (const fromRdfType of objectType.$fromRdfTypes) {
3468
+ for (const resource of this.resourceSet.instancesOf(fromRdfType)) {
3469
+ if (!resources.some(({ resource: existingResource }) => existingResource.identifier.equals(resource.identifier))) {
3470
+ resources.push({ objectType, resource });
3471
+ }
3472
+ }
2965
3473
  }
2966
3474
  }
2967
3475
  // Sort resources by identifier so limit and offset are deterministic