@shaclmate/compiler 3.0.2 → 3.0.4

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