@shaclmate/shacl-ast 4.0.8 → 4.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/generated.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import dataFactory from "@rdfjs/data-model";
2
2
  import datasetFactory from "@rdfjs/dataset";
3
3
  import { Either, Left, Maybe, Right } from "purify-ts";
4
- import { LiteralFactory, PropertyPath, Resource, ResourceSet, } from "rdfjs-resource";
4
+ import { LiteralFactory, PropertyPath as RdfjsResourcePropertyPath, Resource, ResourceSet, } from "rdfjs-resource";
5
5
  function $filterArray(filterItem) {
6
6
  return (filter, values) => {
7
7
  for (const value of values) {
@@ -163,6 +163,19 @@ class $IdentifierSet {
163
163
  }
164
164
  }
165
165
  const $literalFactory = new LiteralFactory({ dataFactory: dataFactory });
166
+ export var $PropertyPath;
167
+ (function ($PropertyPath) {
168
+ function $filter(_filter, _value) {
169
+ return true;
170
+ }
171
+ $PropertyPath.$filter = $filter;
172
+ $PropertyPath.$fromRdfResource = RdfjsResourcePropertyPath.fromResource;
173
+ $PropertyPath.$fromRdfResourceValues = (values, options) => values.chain((values) => values.chainMap((value) => value
174
+ .toResource()
175
+ .chain((resource) => $PropertyPath.$fromRdfResource(resource, options))));
176
+ $PropertyPath.$schema = {};
177
+ $PropertyPath.$toRdfResource = RdfjsResourcePropertyPath.toResource;
178
+ })($PropertyPath || ($PropertyPath = {}));
166
179
  var $RdfVocabularies;
167
180
  (function ($RdfVocabularies) {
168
181
  let rdf;
@@ -329,7 +342,7 @@ export var PropertyShape;
329
342
  return false;
330
343
  }
331
344
  if (filter.path !== undefined &&
332
- !PropertyPath.$filter(filter.path, value.path)) {
345
+ !$PropertyPath.$filter(filter.path, value.path)) {
333
346
  return false;
334
347
  }
335
348
  if (filter.patterns !== undefined &&
@@ -347,20 +360,22 @@ export var PropertyShape;
347
360
  return true;
348
361
  }
349
362
  PropertyShape.$filter = $filter;
350
- function $fromRdf(resource, options) {
351
- let { context, ignoreRdfType = false, objectSet, preferredLanguages, } = options ?? {};
363
+ PropertyShape.$fromRdfResource = (resource, options) => {
364
+ let { context, graph, ignoreRdfType = false, objectSet, preferredLanguages, } = options ?? {};
352
365
  if (!objectSet) {
353
366
  objectSet = new $RdfjsDatasetObjectSet(resource.dataset);
354
367
  }
355
- return PropertyShape.$propertiesFromRdf({
368
+ return PropertyShape.$propertiesFromRdfResource(resource, {
356
369
  context,
370
+ graph,
357
371
  ignoreRdfType,
358
372
  objectSet,
359
373
  preferredLanguages,
360
- resource,
361
374
  });
362
- }
363
- PropertyShape.$fromRdf = $fromRdf;
375
+ };
376
+ PropertyShape.$fromRdfResourceValues = (values, options) => values.chain((values) => values.chainMap((value) => value
377
+ .toResource()
378
+ .chain((resource) => PropertyShape.$fromRdfResource(resource, options))));
364
379
  PropertyShape.$fromRdfType = dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyShape");
365
380
  function isPropertyShape(object) {
366
381
  switch (object.$type) {
@@ -371,10 +386,10 @@ export var PropertyShape;
371
386
  }
372
387
  }
373
388
  PropertyShape.isPropertyShape = isPropertyShape;
374
- function $propertiesFromRdf($parameters) {
375
- return (!$parameters.ignoreRdfType
376
- ? $parameters.resource
377
- .value($RdfVocabularies.rdf.type, { graph: $parameters.graph })
389
+ PropertyShape.$propertiesFromRdfResource = ($resource, _$options) => {
390
+ return (!_$options.ignoreRdfType
391
+ ? $resource
392
+ .value($RdfVocabularies.rdf.type, { graph: _$options.graph })
378
393
  .chain((actualRdfType) => actualRdfType.toIri())
379
394
  .chain((actualRdfType) => {
380
395
  // Check the expected type and its known subtypes
@@ -383,95 +398,95 @@ export var PropertyShape;
383
398
  return Right(true);
384
399
  }
385
400
  // Check arbitrary rdfs:subClassOf's of the expected type
386
- if ($parameters.resource.isInstanceOf(PropertyShape.$fromRdfType, {
387
- graph: $parameters.graph,
401
+ if ($resource.isInstanceOf(PropertyShape.$fromRdfType, {
402
+ graph: _$options.graph,
388
403
  })) {
389
404
  return Right(true);
390
405
  }
391
- return Left(new Error(`${Resource.Identifier.toString($parameters.resource.identifier)} has unexpected RDF type (actual: ${actualRdfType.value}, expected: http://www.w3.org/ns/shacl#PropertyShape)`));
406
+ return Left(new Error(`${Resource.Identifier.toString($resource.identifier)} has unexpected RDF type (actual: ${actualRdfType.value}, expected: http://www.w3.org/ns/shacl#PropertyShape)`));
392
407
  })
393
408
  : Right(true)).chain((_rdfTypeCheck) => Right(new Resource.Value({
394
409
  dataFactory: dataFactory,
395
- focusResource: $parameters.resource,
410
+ focusResource: $resource,
396
411
  propertyPath: $RdfVocabularies.rdf.subject,
397
- term: $parameters.resource.identifier,
412
+ term: $resource.identifier,
398
413
  }).toValues())
399
414
  .chain((values) => values.chainMap((value) => value.toIdentifier()))
400
415
  .chain((values) => values.head())
401
416
  .chain(($identifier) => Right("PropertyShape").chain(($type) => $shaclPropertyFromRdf({
402
- graph: $parameters.graph,
403
- resource: $parameters.resource,
417
+ graph: _$options.graph,
418
+ resource: $resource,
404
419
  propertySchema: PropertyShape.$schema.properties.and,
405
420
  typeFromRdf: (resourceValues) => resourceValues
406
- .chain((values) => values.chainMap((value) => value.toList({ graph: $parameters.graph })))
421
+ .chain((values) => values.chainMap((value) => value.toList({ graph: _$options.graph })))
407
422
  .chain((valueLists) => valueLists.chainMap((valueList) => Right(Resource.Values.fromArray({
408
- focusResource: $parameters.resource,
423
+ focusResource: $resource,
409
424
  propertyPath: PropertyShape.$schema.properties.and.path,
410
425
  values: valueList.toArray(),
411
426
  })).chain((values) => values.chainMap((value) => value.toIdentifier()))))
412
427
  .map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
413
428
  .map((values) => values.toArray())
414
429
  .map((valuesArray) => Resource.Values.fromValue({
415
- focusResource: $parameters.resource,
430
+ focusResource: $resource,
416
431
  propertyPath: PropertyShape.$schema.properties.and.path,
417
432
  value: valuesArray,
418
433
  })),
419
434
  }).chain((and) => $shaclPropertyFromRdf({
420
- graph: $parameters.graph,
421
- resource: $parameters.resource,
435
+ graph: _$options.graph,
436
+ resource: $resource,
422
437
  propertySchema: PropertyShape.$schema.properties.classes,
423
438
  typeFromRdf: (resourceValues) => resourceValues
424
439
  .chain((values) => values.chainMap((value) => value.toIri()))
425
440
  .map((values) => values.toArray())
426
441
  .map((valuesArray) => Resource.Values.fromValue({
427
- focusResource: $parameters.resource,
442
+ focusResource: $resource,
428
443
  propertyPath: PropertyShape.$schema.properties.classes.path,
429
444
  value: valuesArray,
430
445
  })),
431
446
  }).chain((classes) => $shaclPropertyFromRdf({
432
- graph: $parameters.graph,
433
- resource: $parameters.resource,
447
+ graph: _$options.graph,
448
+ resource: $resource,
434
449
  propertySchema: PropertyShape.$schema.properties.comments,
435
450
  typeFromRdf: (resourceValues) => resourceValues
436
- .chain((values) => $fromRdfPreferredLanguages(values, $parameters.preferredLanguages))
451
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
437
452
  .chain((values) => values.chainMap((value) => value.toString()))
438
453
  .map((values) => values.toArray())
439
454
  .map((valuesArray) => Resource.Values.fromValue({
440
- focusResource: $parameters.resource,
455
+ focusResource: $resource,
441
456
  propertyPath: PropertyShape.$schema.properties.comments.path,
442
457
  value: valuesArray,
443
458
  })),
444
459
  }).chain((comments) => $shaclPropertyFromRdf({
445
- graph: $parameters.graph,
446
- resource: $parameters.resource,
460
+ graph: _$options.graph,
461
+ resource: $resource,
447
462
  propertySchema: PropertyShape.$schema.properties.datatype,
448
463
  typeFromRdf: (resourceValues) => resourceValues
449
464
  .chain((values) => values.chainMap((value) => value.toIri()))
450
465
  .map((values) => values.length > 0
451
466
  ? values.map((value) => Maybe.of(value))
452
467
  : Resource.Values.fromValue({
453
- focusResource: $parameters.resource,
468
+ focusResource: $resource,
454
469
  propertyPath: PropertyShape.$schema.properties.datatype
455
470
  .path,
456
471
  value: Maybe.empty(),
457
472
  })),
458
473
  }).chain((datatype) => $shaclPropertyFromRdf({
459
- graph: $parameters.graph,
460
- resource: $parameters.resource,
474
+ graph: _$options.graph,
475
+ resource: $resource,
461
476
  propertySchema: PropertyShape.$schema.properties.deactivated,
462
477
  typeFromRdf: (resourceValues) => resourceValues
463
478
  .chain((values) => values.chainMap((value) => value.toBoolean()))
464
479
  .map((values) => values.length > 0
465
480
  ? values.map((value) => Maybe.of(value))
466
481
  : Resource.Values.fromValue({
467
- focusResource: $parameters.resource,
482
+ focusResource: $resource,
468
483
  propertyPath: PropertyShape.$schema.properties.deactivated
469
484
  .path,
470
485
  value: Maybe.empty(),
471
486
  })),
472
487
  }).chain((deactivated) => $shaclPropertyFromRdf({
473
- graph: $parameters.graph,
474
- resource: $parameters.resource,
488
+ graph: _$options.graph,
489
+ resource: $resource,
475
490
  propertySchema: PropertyShape.$schema.properties.defaultValue,
476
491
  typeFromRdf: (resourceValues) => resourceValues
477
492
  .chain((values) => values.chainMap((value) => value.toTerm().chain((term) => {
@@ -483,7 +498,7 @@ export var PropertyShape;
483
498
  return Left(new Resource.MistypedTermValueError({
484
499
  actualValue: term,
485
500
  expectedValueType: "(NamedNode | Literal)",
486
- focusResource: $parameters.resource,
501
+ focusResource: $resource,
487
502
  propertyPath: PropertyShape.$schema.properties
488
503
  .defaultValue.path,
489
504
  }));
@@ -492,55 +507,55 @@ export var PropertyShape;
492
507
  .map((values) => values.length > 0
493
508
  ? values.map((value) => Maybe.of(value))
494
509
  : Resource.Values.fromValue({
495
- focusResource: $parameters.resource,
510
+ focusResource: $resource,
496
511
  propertyPath: PropertyShape.$schema.properties
497
512
  .defaultValue.path,
498
513
  value: Maybe.empty(),
499
514
  })),
500
515
  }).chain((defaultValue) => $shaclPropertyFromRdf({
501
- graph: $parameters.graph,
502
- resource: $parameters.resource,
516
+ graph: _$options.graph,
517
+ resource: $resource,
503
518
  propertySchema: PropertyShape.$schema.properties.descriptions,
504
519
  typeFromRdf: (resourceValues) => resourceValues
505
- .chain((values) => $fromRdfPreferredLanguages(values, $parameters.preferredLanguages))
520
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
506
521
  .chain((values) => values.chainMap((value) => value.toString()))
507
522
  .map((values) => values.toArray())
508
523
  .map((valuesArray) => Resource.Values.fromValue({
509
- focusResource: $parameters.resource,
524
+ focusResource: $resource,
510
525
  propertyPath: PropertyShape.$schema.properties
511
526
  .descriptions.path,
512
527
  value: valuesArray,
513
528
  })),
514
529
  }).chain((descriptions) => $shaclPropertyFromRdf({
515
- graph: $parameters.graph,
516
- resource: $parameters.resource,
530
+ graph: _$options.graph,
531
+ resource: $resource,
517
532
  propertySchema: PropertyShape.$schema.properties.flags,
518
533
  typeFromRdf: (resourceValues) => resourceValues
519
- .chain((values) => $fromRdfPreferredLanguages(values, $parameters.preferredLanguages))
534
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
520
535
  .chain((values) => values.chainMap((value) => value.toString()))
521
536
  .map((values) => values.toArray())
522
537
  .map((valuesArray) => Resource.Values.fromValue({
523
- focusResource: $parameters.resource,
538
+ focusResource: $resource,
524
539
  propertyPath: PropertyShape.$schema.properties.flags
525
540
  .path,
526
541
  value: valuesArray,
527
542
  })),
528
543
  }).chain((flags) => $shaclPropertyFromRdf({
529
- graph: $parameters.graph,
530
- resource: $parameters.resource,
544
+ graph: _$options.graph,
545
+ resource: $resource,
531
546
  propertySchema: PropertyShape.$schema.properties.groups,
532
547
  typeFromRdf: (resourceValues) => resourceValues
533
548
  .chain((values) => values.chainMap((value) => value.toIdentifier()))
534
549
  .map((values) => values.toArray())
535
550
  .map((valuesArray) => Resource.Values.fromValue({
536
- focusResource: $parameters.resource,
551
+ focusResource: $resource,
537
552
  propertyPath: PropertyShape.$schema.properties.groups
538
553
  .path,
539
554
  value: valuesArray,
540
555
  })),
541
556
  }).chain((groups) => $shaclPropertyFromRdf({
542
- graph: $parameters.graph,
543
- resource: $parameters.resource,
557
+ graph: _$options.graph,
558
+ resource: $resource,
544
559
  propertySchema: PropertyShape.$schema.properties.hasValues,
545
560
  typeFromRdf: (resourceValues) => resourceValues
546
561
  .chain((values) => values.chainMap((value) => value.toTerm().chain((term) => {
@@ -552,7 +567,7 @@ export var PropertyShape;
552
567
  return Left(new Resource.MistypedTermValueError({
553
568
  actualValue: term,
554
569
  expectedValueType: "(NamedNode | Literal)",
555
- focusResource: $parameters.resource,
570
+ focusResource: $resource,
556
571
  propertyPath: PropertyShape.$schema
557
572
  .properties.hasValues
558
573
  .path,
@@ -561,21 +576,21 @@ export var PropertyShape;
561
576
  })))
562
577
  .map((values) => values.toArray())
563
578
  .map((valuesArray) => Resource.Values.fromValue({
564
- focusResource: $parameters.resource,
579
+ focusResource: $resource,
565
580
  propertyPath: PropertyShape.$schema.properties
566
581
  .hasValues.path,
567
582
  value: valuesArray,
568
583
  })),
569
584
  }).chain((hasValues) => $shaclPropertyFromRdf({
570
- graph: $parameters.graph,
571
- resource: $parameters.resource,
585
+ graph: _$options.graph,
586
+ resource: $resource,
572
587
  propertySchema: PropertyShape.$schema.properties.in_,
573
588
  typeFromRdf: (resourceValues) => resourceValues
574
589
  .chain((values) => values.chainMap((value) => value.toList({
575
- graph: $parameters.graph,
590
+ graph: _$options.graph,
576
591
  })))
577
592
  .chain((valueLists) => valueLists.chainMap((valueList) => Right(Resource.Values.fromArray({
578
- focusResource: $parameters.resource,
593
+ focusResource: $resource,
579
594
  propertyPath: PropertyShape.$schema.properties
580
595
  .in_.path,
581
596
  values: valueList.toArray(),
@@ -588,7 +603,7 @@ export var PropertyShape;
588
603
  return Left(new Resource.MistypedTermValueError({
589
604
  actualValue: term,
590
605
  expectedValueType: "(NamedNode | Literal)",
591
- focusResource: $parameters.resource,
606
+ focusResource: $resource,
592
607
  propertyPath: PropertyShape
593
608
  .$schema
594
609
  .properties.in_
@@ -600,109 +615,109 @@ export var PropertyShape;
600
615
  .map((values) => values.length > 0
601
616
  ? values.map((value) => Maybe.of(value))
602
617
  : Resource.Values.fromValue({
603
- focusResource: $parameters.resource,
618
+ focusResource: $resource,
604
619
  propertyPath: PropertyShape.$schema.properties
605
620
  .in_.path,
606
621
  value: Maybe.empty(),
607
622
  })),
608
623
  }).chain((in_) => $shaclPropertyFromRdf({
609
- graph: $parameters.graph,
610
- resource: $parameters.resource,
624
+ graph: _$options.graph,
625
+ resource: $resource,
611
626
  propertySchema: PropertyShape.$schema.properties.isDefinedBy,
612
627
  typeFromRdf: (resourceValues) => resourceValues
613
628
  .chain((values) => values.chainMap((value) => value.toIdentifier()))
614
629
  .map((values) => values.length > 0
615
630
  ? values.map((value) => Maybe.of(value))
616
631
  : Resource.Values.fromValue({
617
- focusResource: $parameters.resource,
632
+ focusResource: $resource,
618
633
  propertyPath: PropertyShape.$schema
619
634
  .properties.isDefinedBy
620
635
  .path,
621
636
  value: Maybe.empty(),
622
637
  })),
623
638
  }).chain((isDefinedBy) => $shaclPropertyFromRdf({
624
- graph: $parameters.graph,
625
- resource: $parameters.resource,
639
+ graph: _$options.graph,
640
+ resource: $resource,
626
641
  propertySchema: PropertyShape.$schema.properties.labels,
627
642
  typeFromRdf: (resourceValues) => resourceValues
628
- .chain((values) => $fromRdfPreferredLanguages(values, $parameters.preferredLanguages))
643
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
629
644
  .chain((values) => values.chainMap((value) => value.toString()))
630
645
  .map((values) => values.toArray())
631
646
  .map((valuesArray) => Resource.Values.fromValue({
632
- focusResource: $parameters.resource,
647
+ focusResource: $resource,
633
648
  propertyPath: PropertyShape.$schema.properties
634
649
  .labels.path,
635
650
  value: valuesArray,
636
651
  })),
637
652
  }).chain((labels) => $shaclPropertyFromRdf({
638
- graph: $parameters.graph,
639
- resource: $parameters.resource,
653
+ graph: _$options.graph,
654
+ resource: $resource,
640
655
  propertySchema: PropertyShape.$schema.properties.languageIn,
641
656
  typeFromRdf: (resourceValues) => resourceValues
642
657
  .chain((values) => values.chainMap((value) => value.toList({
643
- graph: $parameters.graph,
658
+ graph: _$options.graph,
644
659
  })))
645
660
  .chain((valueLists) => valueLists.chainMap((valueList) => Right(Resource.Values.fromArray({
646
- focusResource: $parameters.resource,
661
+ focusResource: $resource,
647
662
  propertyPath: PropertyShape.$schema
648
663
  .properties.languageIn
649
664
  .path,
650
665
  values: valueList.toArray(),
651
666
  }))
652
- .chain((values) => $fromRdfPreferredLanguages(values, $parameters.preferredLanguages))
667
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
653
668
  .chain((values) => values.chainMap((value) => value.toString()))))
654
669
  .map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
655
670
  .map((values) => values.length > 0
656
671
  ? values.map((value) => Maybe.of(value))
657
672
  : Resource.Values.fromValue({
658
- focusResource: $parameters.resource,
673
+ focusResource: $resource,
659
674
  propertyPath: PropertyShape.$schema
660
675
  .properties.languageIn
661
676
  .path,
662
677
  value: Maybe.empty(),
663
678
  })),
664
679
  }).chain((languageIn) => $shaclPropertyFromRdf({
665
- graph: $parameters.graph,
666
- resource: $parameters.resource,
680
+ graph: _$options.graph,
681
+ resource: $resource,
667
682
  propertySchema: PropertyShape.$schema.properties.maxCount,
668
683
  typeFromRdf: (resourceValues) => resourceValues
669
684
  .chain((values) => values.chainMap((value) => value.toInt()))
670
685
  .map((values) => values.length > 0
671
686
  ? values.map((value) => Maybe.of(value))
672
687
  : Resource.Values.fromValue({
673
- focusResource: $parameters.resource,
688
+ focusResource: $resource,
674
689
  propertyPath: PropertyShape.$schema
675
690
  .properties.maxCount
676
691
  .path,
677
692
  value: Maybe.empty(),
678
693
  })),
679
694
  }).chain((maxCount) => $shaclPropertyFromRdf({
680
- graph: $parameters.graph,
681
- resource: $parameters.resource,
695
+ graph: _$options.graph,
696
+ resource: $resource,
682
697
  propertySchema: PropertyShape.$schema.properties.maxExclusive,
683
698
  typeFromRdf: (resourceValues) => resourceValues
684
- .chain((values) => $fromRdfPreferredLanguages(values, $parameters.preferredLanguages))
699
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
685
700
  .chain((values) => values.chainMap((value) => value.toLiteral()))
686
701
  .map((values) => values.length > 0
687
702
  ? values.map((value) => Maybe.of(value))
688
703
  : Resource.Values.fromValue({
689
- focusResource: $parameters.resource,
704
+ focusResource: $resource,
690
705
  propertyPath: PropertyShape.$schema
691
706
  .properties
692
707
  .maxExclusive.path,
693
708
  value: Maybe.empty(),
694
709
  })),
695
710
  }).chain((maxExclusive) => $shaclPropertyFromRdf({
696
- graph: $parameters.graph,
697
- resource: $parameters.resource,
711
+ graph: _$options.graph,
712
+ resource: $resource,
698
713
  propertySchema: PropertyShape.$schema.properties.maxInclusive,
699
714
  typeFromRdf: (resourceValues) => resourceValues
700
- .chain((values) => $fromRdfPreferredLanguages(values, $parameters.preferredLanguages))
715
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
701
716
  .chain((values) => values.chainMap((value) => value.toLiteral()))
702
717
  .map((values) => values.length > 0
703
718
  ? values.map((value) => Maybe.of(value))
704
719
  : Resource.Values.fromValue({
705
- focusResource: $parameters.resource,
720
+ focusResource: $resource,
706
721
  propertyPath: PropertyShape
707
722
  .$schema
708
723
  .properties
@@ -711,15 +726,15 @@ export var PropertyShape;
711
726
  value: Maybe.empty(),
712
727
  })),
713
728
  }).chain((maxInclusive) => $shaclPropertyFromRdf({
714
- graph: $parameters.graph,
715
- resource: $parameters.resource,
729
+ graph: _$options.graph,
730
+ resource: $resource,
716
731
  propertySchema: PropertyShape.$schema.properties.maxLength,
717
732
  typeFromRdf: (resourceValues) => resourceValues
718
733
  .chain((values) => values.chainMap((value) => value.toInt()))
719
734
  .map((values) => values.length > 0
720
735
  ? values.map((value) => Maybe.of(value))
721
736
  : Resource.Values.fromValue({
722
- focusResource: $parameters.resource,
737
+ focusResource: $resource,
723
738
  propertyPath: PropertyShape
724
739
  .$schema
725
740
  .properties
@@ -727,15 +742,15 @@ export var PropertyShape;
727
742
  value: Maybe.empty(),
728
743
  })),
729
744
  }).chain((maxLength) => $shaclPropertyFromRdf({
730
- graph: $parameters.graph,
731
- resource: $parameters.resource,
745
+ graph: _$options.graph,
746
+ resource: $resource,
732
747
  propertySchema: PropertyShape.$schema.properties.minCount,
733
748
  typeFromRdf: (resourceValues) => resourceValues
734
749
  .chain((values) => values.chainMap((value) => value.toInt()))
735
750
  .map((values) => values.length > 0
736
751
  ? values.map((value) => Maybe.of(value))
737
752
  : Resource.Values.fromValue({
738
- focusResource: $parameters.resource,
753
+ focusResource: $resource,
739
754
  propertyPath: PropertyShape
740
755
  .$schema
741
756
  .properties
@@ -744,17 +759,17 @@ export var PropertyShape;
744
759
  value: Maybe.empty(),
745
760
  })),
746
761
  }).chain((minCount) => $shaclPropertyFromRdf({
747
- graph: $parameters.graph,
748
- resource: $parameters.resource,
762
+ graph: _$options.graph,
763
+ resource: $resource,
749
764
  propertySchema: PropertyShape.$schema.properties
750
765
  .minExclusive,
751
766
  typeFromRdf: (resourceValues) => resourceValues
752
- .chain((values) => $fromRdfPreferredLanguages(values, $parameters.preferredLanguages))
767
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
753
768
  .chain((values) => values.chainMap((value) => value.toLiteral()))
754
769
  .map((values) => values.length > 0
755
770
  ? values.map((value) => Maybe.of(value))
756
771
  : Resource.Values.fromValue({
757
- focusResource: $parameters.resource,
772
+ focusResource: $resource,
758
773
  propertyPath: PropertyShape
759
774
  .$schema
760
775
  .properties
@@ -763,17 +778,17 @@ export var PropertyShape;
763
778
  value: Maybe.empty(),
764
779
  })),
765
780
  }).chain((minExclusive) => $shaclPropertyFromRdf({
766
- graph: $parameters.graph,
767
- resource: $parameters.resource,
781
+ graph: _$options.graph,
782
+ resource: $resource,
768
783
  propertySchema: PropertyShape.$schema.properties
769
784
  .minInclusive,
770
785
  typeFromRdf: (resourceValues) => resourceValues
771
- .chain((values) => $fromRdfPreferredLanguages(values, $parameters.preferredLanguages))
786
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
772
787
  .chain((values) => values.chainMap((value) => value.toLiteral()))
773
788
  .map((values) => values.length > 0
774
789
  ? values.map((value) => Maybe.of(value))
775
790
  : Resource.Values.fromValue({
776
- focusResource: $parameters.resource,
791
+ focusResource: $resource,
777
792
  propertyPath: PropertyShape
778
793
  .$schema
779
794
  .properties
@@ -782,8 +797,8 @@ export var PropertyShape;
782
797
  value: Maybe.empty(),
783
798
  })),
784
799
  }).chain((minInclusive) => $shaclPropertyFromRdf({
785
- graph: $parameters.graph,
786
- resource: $parameters.resource,
800
+ graph: _$options.graph,
801
+ resource: $resource,
787
802
  propertySchema: PropertyShape.$schema.properties
788
803
  .minLength,
789
804
  typeFromRdf: (resourceValues) => resourceValues
@@ -791,7 +806,7 @@ export var PropertyShape;
791
806
  .map((values) => values.length > 0
792
807
  ? values.map((value) => Maybe.of(value))
793
808
  : Resource.Values.fromValue({
794
- focusResource: $parameters.resource,
809
+ focusResource: $resource,
795
810
  propertyPath: PropertyShape
796
811
  .$schema
797
812
  .properties
@@ -800,16 +815,16 @@ export var PropertyShape;
800
815
  value: Maybe.empty(),
801
816
  })),
802
817
  }).chain((minLength) => $shaclPropertyFromRdf({
803
- graph: $parameters.graph,
804
- resource: $parameters.resource,
818
+ graph: _$options.graph,
819
+ resource: $resource,
805
820
  propertySchema: PropertyShape.$schema.properties
806
821
  .names,
807
822
  typeFromRdf: (resourceValues) => resourceValues
808
- .chain((values) => $fromRdfPreferredLanguages(values, $parameters.preferredLanguages))
823
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
809
824
  .chain((values) => values.chainMap((value) => value.toString()))
810
825
  .map((values) => values.toArray())
811
826
  .map((valuesArray) => Resource.Values.fromValue({
812
- focusResource: $parameters.resource,
827
+ focusResource: $resource,
813
828
  propertyPath: PropertyShape
814
829
  .$schema
815
830
  .properties
@@ -818,8 +833,8 @@ export var PropertyShape;
818
833
  value: valuesArray,
819
834
  })),
820
835
  }).chain((names) => $shaclPropertyFromRdf({
821
- graph: $parameters.graph,
822
- resource: $parameters.resource,
836
+ graph: _$options.graph,
837
+ resource: $resource,
823
838
  propertySchema: PropertyShape.$schema
824
839
  .properties
825
840
  .nodeKind,
@@ -836,7 +851,7 @@ export var PropertyShape;
836
851
  0
837
852
  ? values.map((value) => Maybe.of(value))
838
853
  : Resource.Values.fromValue({
839
- focusResource: $parameters.resource,
854
+ focusResource: $resource,
840
855
  propertyPath: PropertyShape
841
856
  .$schema
842
857
  .properties
@@ -845,8 +860,8 @@ export var PropertyShape;
845
860
  value: Maybe.empty(),
846
861
  })),
847
862
  }).chain((nodeKind) => $shaclPropertyFromRdf({
848
- graph: $parameters.graph,
849
- resource: $parameters.resource,
863
+ graph: _$options.graph,
864
+ resource: $resource,
850
865
  propertySchema: PropertyShape.$schema
851
866
  .properties
852
867
  .nodes,
@@ -854,7 +869,7 @@ export var PropertyShape;
854
869
  .chain((values) => values.chainMap((value) => value.toIdentifier()))
855
870
  .map((values) => values.toArray())
856
871
  .map((valuesArray) => Resource.Values.fromValue({
857
- focusResource: $parameters.resource,
872
+ focusResource: $resource,
858
873
  propertyPath: PropertyShape
859
874
  .$schema
860
875
  .properties
@@ -863,8 +878,8 @@ export var PropertyShape;
863
878
  value: valuesArray,
864
879
  })),
865
880
  }).chain((nodes) => $shaclPropertyFromRdf({
866
- graph: $parameters.graph,
867
- resource: $parameters.resource,
881
+ graph: _$options.graph,
882
+ resource: $resource,
868
883
  propertySchema: PropertyShape.$schema
869
884
  .properties
870
885
  .not,
@@ -872,7 +887,7 @@ export var PropertyShape;
872
887
  .chain((values) => values.chainMap((value) => value.toIdentifier()))
873
888
  .map((values) => values.toArray())
874
889
  .map((valuesArray) => Resource.Values.fromValue({
875
- focusResource: $parameters.resource,
890
+ focusResource: $resource,
876
891
  propertyPath: PropertyShape
877
892
  .$schema
878
893
  .properties
@@ -881,17 +896,17 @@ export var PropertyShape;
881
896
  value: valuesArray,
882
897
  })),
883
898
  }).chain((not) => $shaclPropertyFromRdf({
884
- graph: $parameters.graph,
885
- resource: $parameters.resource,
899
+ graph: _$options.graph,
900
+ resource: $resource,
886
901
  propertySchema: PropertyShape.$schema
887
902
  .properties
888
903
  .or,
889
904
  typeFromRdf: (resourceValues) => resourceValues
890
905
  .chain((values) => values.chainMap((value) => value.toList({
891
- graph: $parameters.graph,
906
+ graph: _$options.graph,
892
907
  })))
893
908
  .chain((valueLists) => valueLists.chainMap((valueList) => Right(Resource.Values.fromArray({
894
- focusResource: $parameters.resource,
909
+ focusResource: $resource,
895
910
  propertyPath: PropertyShape
896
911
  .$schema
897
912
  .properties
@@ -902,7 +917,7 @@ export var PropertyShape;
902
917
  .map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
903
918
  .map((values) => values.toArray())
904
919
  .map((valuesArray) => Resource.Values.fromValue({
905
- focusResource: $parameters.resource,
920
+ focusResource: $resource,
906
921
  propertyPath: PropertyShape
907
922
  .$schema
908
923
  .properties
@@ -911,8 +926,8 @@ export var PropertyShape;
911
926
  value: valuesArray,
912
927
  })),
913
928
  }).chain((or) => $shaclPropertyFromRdf({
914
- graph: $parameters.graph,
915
- resource: $parameters.resource,
929
+ graph: _$options.graph,
930
+ resource: $resource,
916
931
  propertySchema: PropertyShape.$schema
917
932
  .properties
918
933
  .order,
@@ -922,7 +937,7 @@ export var PropertyShape;
922
937
  0
923
938
  ? values.map((value) => Maybe.of(value))
924
939
  : Resource.Values.fromValue({
925
- focusResource: $parameters.resource,
940
+ focusResource: $resource,
926
941
  propertyPath: PropertyShape
927
942
  .$schema
928
943
  .properties
@@ -931,31 +946,36 @@ export var PropertyShape;
931
946
  value: Maybe.empty(),
932
947
  })),
933
948
  }).chain((order) => $shaclPropertyFromRdf({
934
- graph: $parameters.graph,
935
- resource: $parameters.resource,
949
+ graph: _$options.graph,
950
+ resource: $resource,
936
951
  propertySchema: PropertyShape.$schema
937
952
  .properties
938
953
  .path,
939
- typeFromRdf: (resourceValues) => resourceValues.chain((values) => values.chainMap((value) => value
940
- .toResource()
941
- .chain((resource) => PropertyPath.$fromRdf(resource, {
942
- context: $parameters.context,
954
+ typeFromRdf: (resourceValues) => $PropertyPath.$fromRdfResourceValues(resourceValues, {
955
+ context: _$options.context,
956
+ graph: _$options.graph,
957
+ preferredLanguages: _$options.preferredLanguages,
958
+ objectSet: _$options.objectSet,
959
+ resource: $resource,
943
960
  ignoreRdfType: true,
944
- objectSet: $parameters.objectSet,
945
- preferredLanguages: $parameters.preferredLanguages,
946
- })))),
961
+ propertyPath: PropertyShape
962
+ .$schema
963
+ .properties
964
+ .path
965
+ .path,
966
+ }),
947
967
  }).chain((path) => $shaclPropertyFromRdf({
948
- graph: $parameters.graph,
949
- resource: $parameters.resource,
968
+ graph: _$options.graph,
969
+ resource: $resource,
950
970
  propertySchema: PropertyShape.$schema
951
971
  .properties
952
972
  .patterns,
953
973
  typeFromRdf: (resourceValues) => resourceValues
954
- .chain((values) => $fromRdfPreferredLanguages(values, $parameters.preferredLanguages))
974
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
955
975
  .chain((values) => values.chainMap((value) => value.toString()))
956
976
  .map((values) => values.toArray())
957
977
  .map((valuesArray) => Resource.Values.fromValue({
958
- focusResource: $parameters.resource,
978
+ focusResource: $resource,
959
979
  propertyPath: PropertyShape
960
980
  .$schema
961
981
  .properties
@@ -964,8 +984,8 @@ export var PropertyShape;
964
984
  value: valuesArray,
965
985
  })),
966
986
  }).chain((patterns) => $shaclPropertyFromRdf({
967
- graph: $parameters.graph,
968
- resource: $parameters.resource,
987
+ graph: _$options.graph,
988
+ resource: $resource,
969
989
  propertySchema: PropertyShape.$schema
970
990
  .properties
971
991
  .uniqueLang,
@@ -975,7 +995,7 @@ export var PropertyShape;
975
995
  0
976
996
  ? values.map((value) => Maybe.of(value))
977
997
  : Resource.Values.fromValue({
978
- focusResource: $parameters.resource,
998
+ focusResource: $resource,
979
999
  propertyPath: PropertyShape
980
1000
  .$schema
981
1001
  .properties
@@ -984,17 +1004,17 @@ export var PropertyShape;
984
1004
  value: Maybe.empty(),
985
1005
  })),
986
1006
  }).chain((uniqueLang) => $shaclPropertyFromRdf({
987
- graph: $parameters.graph,
988
- resource: $parameters.resource,
1007
+ graph: _$options.graph,
1008
+ resource: $resource,
989
1009
  propertySchema: PropertyShape.$schema
990
1010
  .properties
991
1011
  .xone,
992
1012
  typeFromRdf: (resourceValues) => resourceValues
993
1013
  .chain((values) => values.chainMap((value) => value.toList({
994
- graph: $parameters.graph,
1014
+ graph: _$options.graph,
995
1015
  })))
996
1016
  .chain((valueLists) => valueLists.chainMap((valueList) => Right(Resource.Values.fromArray({
997
- focusResource: $parameters.resource,
1017
+ focusResource: $resource,
998
1018
  propertyPath: PropertyShape
999
1019
  .$schema
1000
1020
  .properties
@@ -1005,7 +1025,7 @@ export var PropertyShape;
1005
1025
  .map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
1006
1026
  .map((values) => values.toArray())
1007
1027
  .map((valuesArray) => Resource.Values.fromValue({
1008
- focusResource: $parameters.resource,
1028
+ focusResource: $resource,
1009
1029
  propertyPath: PropertyShape
1010
1030
  .$schema
1011
1031
  .properties
@@ -1049,8 +1069,7 @@ export var PropertyShape;
1049
1069
  uniqueLang,
1050
1070
  xone,
1051
1071
  }))))))))))))))))))))))))))))))))))));
1052
- }
1053
- PropertyShape.$propertiesFromRdf = $propertiesFromRdf;
1072
+ };
1054
1073
  PropertyShape.$schema = {
1055
1074
  properties: {
1056
1075
  $identifier: {
@@ -1058,7 +1077,7 @@ export var PropertyShape;
1058
1077
  type: () => ({ kind: "Identifier" }),
1059
1078
  },
1060
1079
  $type: {
1061
- kind: "TypeDiscriminant",
1080
+ kind: "Discriminant",
1062
1081
  type: () => ({
1063
1082
  kind: "TypeDiscriminant",
1064
1083
  ownValues: ["PropertyShape"],
@@ -1312,7 +1331,7 @@ export var PropertyShape;
1312
1331
  },
1313
1332
  path: {
1314
1333
  kind: "Shacl",
1315
- type: () => PropertyPath.$schema,
1334
+ type: () => $PropertyPath.$schema,
1316
1335
  path: dataFactory.namedNode("http://www.w3.org/ns/shacl#path"),
1317
1336
  },
1318
1337
  patterns: {
@@ -1344,7 +1363,7 @@ export var PropertyShape;
1344
1363
  },
1345
1364
  },
1346
1365
  };
1347
- function $toRdf(_propertyShape, options) {
1366
+ function $toRdfResource(_propertyShape, options) {
1348
1367
  const resourceSet = options?.resourceSet ??
1349
1368
  new ResourceSet(datasetFactory.dataset(), { dataFactory: dataFactory });
1350
1369
  const resource = resourceSet.resource(_propertyShape.$identifier);
@@ -1490,7 +1509,7 @@ export var PropertyShape;
1490
1509
  $literalFactory.number(value, $RdfVocabularies.xsd.double),
1491
1510
  ]), options?.graph);
1492
1511
  resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#path"), [
1493
- PropertyPath.$toRdf(_propertyShape.path, {
1512
+ $PropertyPath.$toRdfResource(_propertyShape.path, {
1494
1513
  graph: options?.graph,
1495
1514
  resourceSet: resourceSet,
1496
1515
  }).identifier,
@@ -1525,7 +1544,7 @@ export var PropertyShape;
1525
1544
  ]), options?.graph);
1526
1545
  return resource;
1527
1546
  }
1528
- PropertyShape.$toRdf = $toRdf;
1547
+ PropertyShape.$toRdfResource = $toRdfResource;
1529
1548
  })(PropertyShape || (PropertyShape = {}));
1530
1549
  export var PropertyGroup;
1531
1550
  (function (PropertyGroup) {
@@ -1550,20 +1569,22 @@ export var PropertyGroup;
1550
1569
  return true;
1551
1570
  }
1552
1571
  PropertyGroup.$filter = $filter;
1553
- function $fromRdf(resource, options) {
1554
- let { context, ignoreRdfType = false, objectSet, preferredLanguages, } = options ?? {};
1572
+ PropertyGroup.$fromRdfResource = (resource, options) => {
1573
+ let { context, graph, ignoreRdfType = false, objectSet, preferredLanguages, } = options ?? {};
1555
1574
  if (!objectSet) {
1556
1575
  objectSet = new $RdfjsDatasetObjectSet(resource.dataset);
1557
1576
  }
1558
- return PropertyGroup.$propertiesFromRdf({
1577
+ return PropertyGroup.$propertiesFromRdfResource(resource, {
1559
1578
  context,
1579
+ graph,
1560
1580
  ignoreRdfType,
1561
1581
  objectSet,
1562
1582
  preferredLanguages,
1563
- resource,
1564
1583
  });
1565
- }
1566
- PropertyGroup.$fromRdf = $fromRdf;
1584
+ };
1585
+ PropertyGroup.$fromRdfResourceValues = (values, options) => values.chain((values) => values.chainMap((value) => value
1586
+ .toResource()
1587
+ .chain((resource) => PropertyGroup.$fromRdfResource(resource, options))));
1567
1588
  PropertyGroup.$fromRdfType = dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyGroup");
1568
1589
  function isPropertyGroup(object) {
1569
1590
  switch (object.$type) {
@@ -1574,10 +1595,10 @@ export var PropertyGroup;
1574
1595
  }
1575
1596
  }
1576
1597
  PropertyGroup.isPropertyGroup = isPropertyGroup;
1577
- function $propertiesFromRdf($parameters) {
1578
- return (!$parameters.ignoreRdfType
1579
- ? $parameters.resource
1580
- .value($RdfVocabularies.rdf.type, { graph: $parameters.graph })
1598
+ PropertyGroup.$propertiesFromRdfResource = ($resource, _$options) => {
1599
+ return (!_$options.ignoreRdfType
1600
+ ? $resource
1601
+ .value($RdfVocabularies.rdf.type, { graph: _$options.graph })
1581
1602
  .chain((actualRdfType) => actualRdfType.toIri())
1582
1603
  .chain((actualRdfType) => {
1583
1604
  // Check the expected type and its known subtypes
@@ -1586,50 +1607,49 @@ export var PropertyGroup;
1586
1607
  return Right(true);
1587
1608
  }
1588
1609
  // Check arbitrary rdfs:subClassOf's of the expected type
1589
- if ($parameters.resource.isInstanceOf(PropertyGroup.$fromRdfType, {
1590
- graph: $parameters.graph,
1610
+ if ($resource.isInstanceOf(PropertyGroup.$fromRdfType, {
1611
+ graph: _$options.graph,
1591
1612
  })) {
1592
1613
  return Right(true);
1593
1614
  }
1594
- return Left(new Error(`${Resource.Identifier.toString($parameters.resource.identifier)} has unexpected RDF type (actual: ${actualRdfType.value}, expected: http://www.w3.org/ns/shacl#PropertyGroup)`));
1615
+ return Left(new Error(`${Resource.Identifier.toString($resource.identifier)} has unexpected RDF type (actual: ${actualRdfType.value}, expected: http://www.w3.org/ns/shacl#PropertyGroup)`));
1595
1616
  })
1596
1617
  : Right(true)).chain((_rdfTypeCheck) => Right(new Resource.Value({
1597
1618
  dataFactory: dataFactory,
1598
- focusResource: $parameters.resource,
1619
+ focusResource: $resource,
1599
1620
  propertyPath: $RdfVocabularies.rdf.subject,
1600
- term: $parameters.resource.identifier,
1621
+ term: $resource.identifier,
1601
1622
  }).toValues())
1602
1623
  .chain((values) => values.chainMap((value) => value.toIdentifier()))
1603
1624
  .chain((values) => values.head())
1604
1625
  .chain(($identifier) => Right("PropertyGroup").chain(($type) => $shaclPropertyFromRdf({
1605
- graph: $parameters.graph,
1606
- resource: $parameters.resource,
1626
+ graph: _$options.graph,
1627
+ resource: $resource,
1607
1628
  propertySchema: PropertyGroup.$schema.properties.comments,
1608
1629
  typeFromRdf: (resourceValues) => resourceValues
1609
- .chain((values) => $fromRdfPreferredLanguages(values, $parameters.preferredLanguages))
1630
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
1610
1631
  .chain((values) => values.chainMap((value) => value.toString()))
1611
1632
  .map((values) => values.toArray())
1612
1633
  .map((valuesArray) => Resource.Values.fromValue({
1613
- focusResource: $parameters.resource,
1634
+ focusResource: $resource,
1614
1635
  propertyPath: PropertyGroup.$schema.properties.comments.path,
1615
1636
  value: valuesArray,
1616
1637
  })),
1617
1638
  }).chain((comments) => $shaclPropertyFromRdf({
1618
- graph: $parameters.graph,
1619
- resource: $parameters.resource,
1639
+ graph: _$options.graph,
1640
+ resource: $resource,
1620
1641
  propertySchema: PropertyGroup.$schema.properties.labels,
1621
1642
  typeFromRdf: (resourceValues) => resourceValues
1622
- .chain((values) => $fromRdfPreferredLanguages(values, $parameters.preferredLanguages))
1643
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
1623
1644
  .chain((values) => values.chainMap((value) => value.toString()))
1624
1645
  .map((values) => values.toArray())
1625
1646
  .map((valuesArray) => Resource.Values.fromValue({
1626
- focusResource: $parameters.resource,
1647
+ focusResource: $resource,
1627
1648
  propertyPath: PropertyGroup.$schema.properties.labels.path,
1628
1649
  value: valuesArray,
1629
1650
  })),
1630
1651
  }).map((labels) => ({ $identifier, $type, comments, labels }))))));
1631
- }
1632
- PropertyGroup.$propertiesFromRdf = $propertiesFromRdf;
1652
+ };
1633
1653
  PropertyGroup.$schema = {
1634
1654
  properties: {
1635
1655
  $identifier: {
@@ -1637,7 +1657,7 @@ export var PropertyGroup;
1637
1657
  type: () => ({ kind: "Identifier" }),
1638
1658
  },
1639
1659
  $type: {
1640
- kind: "TypeDiscriminant",
1660
+ kind: "Discriminant",
1641
1661
  type: () => ({
1642
1662
  kind: "TypeDiscriminant",
1643
1663
  ownValues: ["PropertyGroup"],
@@ -1661,7 +1681,7 @@ export var PropertyGroup;
1661
1681
  },
1662
1682
  },
1663
1683
  };
1664
- function $toRdf(_propertyGroup, options) {
1684
+ function $toRdfResource(_propertyGroup, options) {
1665
1685
  const resourceSet = options?.resourceSet ??
1666
1686
  new ResourceSet(datasetFactory.dataset(), { dataFactory: dataFactory });
1667
1687
  const resource = resourceSet.resource(_propertyGroup.$identifier);
@@ -1672,7 +1692,7 @@ export var PropertyGroup;
1672
1692
  resource.add(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#label"), _propertyGroup.labels.flatMap((item) => [$literalFactory.string(item)]), options?.graph);
1673
1693
  return resource;
1674
1694
  }
1675
- PropertyGroup.$toRdf = $toRdf;
1695
+ PropertyGroup.$toRdfResource = $toRdfResource;
1676
1696
  })(PropertyGroup || (PropertyGroup = {}));
1677
1697
  export var Ontology;
1678
1698
  (function (Ontology) {
@@ -1693,20 +1713,22 @@ export var Ontology;
1693
1713
  return true;
1694
1714
  }
1695
1715
  Ontology.$filter = $filter;
1696
- function $fromRdf(resource, options) {
1697
- let { context, ignoreRdfType = false, objectSet, preferredLanguages, } = options ?? {};
1716
+ Ontology.$fromRdfResource = (resource, options) => {
1717
+ let { context, graph, ignoreRdfType = false, objectSet, preferredLanguages, } = options ?? {};
1698
1718
  if (!objectSet) {
1699
1719
  objectSet = new $RdfjsDatasetObjectSet(resource.dataset);
1700
1720
  }
1701
- return Ontology.$propertiesFromRdf({
1721
+ return Ontology.$propertiesFromRdfResource(resource, {
1702
1722
  context,
1723
+ graph,
1703
1724
  ignoreRdfType,
1704
1725
  objectSet,
1705
1726
  preferredLanguages,
1706
- resource,
1707
1727
  });
1708
- }
1709
- Ontology.$fromRdf = $fromRdf;
1728
+ };
1729
+ Ontology.$fromRdfResourceValues = (values, options) => values.chain((values) => values.chainMap((value) => value
1730
+ .toResource()
1731
+ .chain((resource) => Ontology.$fromRdfResource(resource, options))));
1710
1732
  Ontology.$fromRdfType = dataFactory.namedNode("http://www.w3.org/2002/07/owl#Ontology");
1711
1733
  function isOntology(object) {
1712
1734
  switch (object.$type) {
@@ -1717,10 +1739,10 @@ export var Ontology;
1717
1739
  }
1718
1740
  }
1719
1741
  Ontology.isOntology = isOntology;
1720
- function $propertiesFromRdf($parameters) {
1721
- return (!$parameters.ignoreRdfType
1722
- ? $parameters.resource
1723
- .value($RdfVocabularies.rdf.type, { graph: $parameters.graph })
1742
+ Ontology.$propertiesFromRdfResource = ($resource, _$options) => {
1743
+ return (!_$options.ignoreRdfType
1744
+ ? $resource
1745
+ .value($RdfVocabularies.rdf.type, { graph: _$options.graph })
1724
1746
  .chain((actualRdfType) => actualRdfType.toIri())
1725
1747
  .chain((actualRdfType) => {
1726
1748
  // Check the expected type and its known subtypes
@@ -1729,37 +1751,36 @@ export var Ontology;
1729
1751
  return Right(true);
1730
1752
  }
1731
1753
  // Check arbitrary rdfs:subClassOf's of the expected type
1732
- if ($parameters.resource.isInstanceOf(Ontology.$fromRdfType, {
1733
- graph: $parameters.graph,
1754
+ if ($resource.isInstanceOf(Ontology.$fromRdfType, {
1755
+ graph: _$options.graph,
1734
1756
  })) {
1735
1757
  return Right(true);
1736
1758
  }
1737
- return Left(new Error(`${Resource.Identifier.toString($parameters.resource.identifier)} has unexpected RDF type (actual: ${actualRdfType.value}, expected: http://www.w3.org/2002/07/owl#Ontology)`));
1759
+ return Left(new Error(`${Resource.Identifier.toString($resource.identifier)} has unexpected RDF type (actual: ${actualRdfType.value}, expected: http://www.w3.org/2002/07/owl#Ontology)`));
1738
1760
  })
1739
1761
  : Right(true)).chain((_rdfTypeCheck) => Right(new Resource.Value({
1740
1762
  dataFactory: dataFactory,
1741
- focusResource: $parameters.resource,
1763
+ focusResource: $resource,
1742
1764
  propertyPath: $RdfVocabularies.rdf.subject,
1743
- term: $parameters.resource.identifier,
1765
+ term: $resource.identifier,
1744
1766
  }).toValues())
1745
1767
  .chain((values) => values.chainMap((value) => value.toIdentifier()))
1746
1768
  .chain((values) => values.head())
1747
1769
  .chain(($identifier) => Right("Ontology").chain(($type) => $shaclPropertyFromRdf({
1748
- graph: $parameters.graph,
1749
- resource: $parameters.resource,
1770
+ graph: _$options.graph,
1771
+ resource: $resource,
1750
1772
  propertySchema: Ontology.$schema.properties.labels,
1751
1773
  typeFromRdf: (resourceValues) => resourceValues
1752
- .chain((values) => $fromRdfPreferredLanguages(values, $parameters.preferredLanguages))
1774
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
1753
1775
  .chain((values) => values.chainMap((value) => value.toString()))
1754
1776
  .map((values) => values.toArray())
1755
1777
  .map((valuesArray) => Resource.Values.fromValue({
1756
- focusResource: $parameters.resource,
1778
+ focusResource: $resource,
1757
1779
  propertyPath: Ontology.$schema.properties.labels.path,
1758
1780
  value: valuesArray,
1759
1781
  })),
1760
1782
  }).map((labels) => ({ $identifier, $type, labels })))));
1761
- }
1762
- Ontology.$propertiesFromRdf = $propertiesFromRdf;
1783
+ };
1763
1784
  Ontology.$schema = {
1764
1785
  properties: {
1765
1786
  $identifier: {
@@ -1767,7 +1788,7 @@ export var Ontology;
1767
1788
  type: () => ({ kind: "Identifier" }),
1768
1789
  },
1769
1790
  $type: {
1770
- kind: "TypeDiscriminant",
1791
+ kind: "Discriminant",
1771
1792
  type: () => ({
1772
1793
  kind: "TypeDiscriminant",
1773
1794
  ownValues: ["Ontology"],
@@ -1783,7 +1804,7 @@ export var Ontology;
1783
1804
  },
1784
1805
  },
1785
1806
  };
1786
- function $toRdf(_ontology, options) {
1807
+ function $toRdfResource(_ontology, options) {
1787
1808
  const resourceSet = options?.resourceSet ??
1788
1809
  new ResourceSet(datasetFactory.dataset(), { dataFactory: dataFactory });
1789
1810
  const resource = resourceSet.resource(_ontology.$identifier);
@@ -1793,7 +1814,7 @@ export var Ontology;
1793
1814
  resource.add(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#label"), _ontology.labels.flatMap((item) => [$literalFactory.string(item)]), options?.graph);
1794
1815
  return resource;
1795
1816
  }
1796
- Ontology.$toRdf = $toRdf;
1817
+ Ontology.$toRdfResource = $toRdfResource;
1797
1818
  })(Ontology || (Ontology = {}));
1798
1819
  export var NodeShape;
1799
1820
  (function (NodeShape) {
@@ -1922,20 +1943,22 @@ export var NodeShape;
1922
1943
  return true;
1923
1944
  }
1924
1945
  NodeShape.$filter = $filter;
1925
- function $fromRdf(resource, options) {
1926
- let { context, ignoreRdfType = false, objectSet, preferredLanguages, } = options ?? {};
1946
+ NodeShape.$fromRdfResource = (resource, options) => {
1947
+ let { context, graph, ignoreRdfType = false, objectSet, preferredLanguages, } = options ?? {};
1927
1948
  if (!objectSet) {
1928
1949
  objectSet = new $RdfjsDatasetObjectSet(resource.dataset);
1929
1950
  }
1930
- return NodeShape.$propertiesFromRdf({
1951
+ return NodeShape.$propertiesFromRdfResource(resource, {
1931
1952
  context,
1953
+ graph,
1932
1954
  ignoreRdfType,
1933
1955
  objectSet,
1934
1956
  preferredLanguages,
1935
- resource,
1936
1957
  });
1937
- }
1938
- NodeShape.$fromRdf = $fromRdf;
1958
+ };
1959
+ NodeShape.$fromRdfResourceValues = (values, options) => values.chain((values) => values.chainMap((value) => value
1960
+ .toResource()
1961
+ .chain((resource) => NodeShape.$fromRdfResource(resource, options))));
1939
1962
  NodeShape.$fromRdfType = dataFactory.namedNode("http://www.w3.org/ns/shacl#NodeShape");
1940
1963
  function isNodeShape(object) {
1941
1964
  switch (object.$type) {
@@ -1946,10 +1969,10 @@ export var NodeShape;
1946
1969
  }
1947
1970
  }
1948
1971
  NodeShape.isNodeShape = isNodeShape;
1949
- function $propertiesFromRdf($parameters) {
1950
- return (!$parameters.ignoreRdfType
1951
- ? $parameters.resource
1952
- .value($RdfVocabularies.rdf.type, { graph: $parameters.graph })
1972
+ NodeShape.$propertiesFromRdfResource = ($resource, _$options) => {
1973
+ return (!_$options.ignoreRdfType
1974
+ ? $resource
1975
+ .value($RdfVocabularies.rdf.type, { graph: _$options.graph })
1953
1976
  .chain((actualRdfType) => actualRdfType.toIri())
1954
1977
  .chain((actualRdfType) => {
1955
1978
  // Check the expected type and its known subtypes
@@ -1958,121 +1981,121 @@ export var NodeShape;
1958
1981
  return Right(true);
1959
1982
  }
1960
1983
  // Check arbitrary rdfs:subClassOf's of the expected type
1961
- if ($parameters.resource.isInstanceOf(NodeShape.$fromRdfType, {
1962
- graph: $parameters.graph,
1984
+ if ($resource.isInstanceOf(NodeShape.$fromRdfType, {
1985
+ graph: _$options.graph,
1963
1986
  })) {
1964
1987
  return Right(true);
1965
1988
  }
1966
- return Left(new Error(`${Resource.Identifier.toString($parameters.resource.identifier)} has unexpected RDF type (actual: ${actualRdfType.value}, expected: http://www.w3.org/ns/shacl#NodeShape)`));
1989
+ return Left(new Error(`${Resource.Identifier.toString($resource.identifier)} has unexpected RDF type (actual: ${actualRdfType.value}, expected: http://www.w3.org/ns/shacl#NodeShape)`));
1967
1990
  })
1968
1991
  : Right(true)).chain((_rdfTypeCheck) => Right(new Resource.Value({
1969
1992
  dataFactory: dataFactory,
1970
- focusResource: $parameters.resource,
1993
+ focusResource: $resource,
1971
1994
  propertyPath: $RdfVocabularies.rdf.subject,
1972
- term: $parameters.resource.identifier,
1995
+ term: $resource.identifier,
1973
1996
  }).toValues())
1974
1997
  .chain((values) => values.chainMap((value) => value.toIdentifier()))
1975
1998
  .chain((values) => values.head())
1976
1999
  .chain(($identifier) => Right("NodeShape").chain(($type) => $shaclPropertyFromRdf({
1977
- graph: $parameters.graph,
1978
- resource: $parameters.resource,
2000
+ graph: _$options.graph,
2001
+ resource: $resource,
1979
2002
  propertySchema: NodeShape.$schema.properties.and,
1980
2003
  typeFromRdf: (resourceValues) => resourceValues
1981
- .chain((values) => values.chainMap((value) => value.toList({ graph: $parameters.graph })))
2004
+ .chain((values) => values.chainMap((value) => value.toList({ graph: _$options.graph })))
1982
2005
  .chain((valueLists) => valueLists.chainMap((valueList) => Right(Resource.Values.fromArray({
1983
- focusResource: $parameters.resource,
2006
+ focusResource: $resource,
1984
2007
  propertyPath: PropertyShape.$schema.properties.and.path,
1985
2008
  values: valueList.toArray(),
1986
2009
  })).chain((values) => values.chainMap((value) => value.toIdentifier()))))
1987
2010
  .map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
1988
2011
  .map((values) => values.toArray())
1989
2012
  .map((valuesArray) => Resource.Values.fromValue({
1990
- focusResource: $parameters.resource,
2013
+ focusResource: $resource,
1991
2014
  propertyPath: PropertyShape.$schema.properties.and.path,
1992
2015
  value: valuesArray,
1993
2016
  })),
1994
2017
  }).chain((and) => $shaclPropertyFromRdf({
1995
- graph: $parameters.graph,
1996
- resource: $parameters.resource,
2018
+ graph: _$options.graph,
2019
+ resource: $resource,
1997
2020
  propertySchema: NodeShape.$schema.properties.classes,
1998
2021
  typeFromRdf: (resourceValues) => resourceValues
1999
2022
  .chain((values) => values.chainMap((value) => value.toIri()))
2000
2023
  .map((values) => values.toArray())
2001
2024
  .map((valuesArray) => Resource.Values.fromValue({
2002
- focusResource: $parameters.resource,
2025
+ focusResource: $resource,
2003
2026
  propertyPath: PropertyShape.$schema.properties.classes.path,
2004
2027
  value: valuesArray,
2005
2028
  })),
2006
2029
  }).chain((classes) => $shaclPropertyFromRdf({
2007
- graph: $parameters.graph,
2008
- resource: $parameters.resource,
2030
+ graph: _$options.graph,
2031
+ resource: $resource,
2009
2032
  propertySchema: NodeShape.$schema.properties.closed,
2010
2033
  typeFromRdf: (resourceValues) => resourceValues
2011
2034
  .chain((values) => values.chainMap((value) => value.toBoolean()))
2012
2035
  .map((values) => values.length > 0
2013
2036
  ? values.map((value) => Maybe.of(value))
2014
2037
  : Resource.Values.fromValue({
2015
- focusResource: $parameters.resource,
2038
+ focusResource: $resource,
2016
2039
  propertyPath: NodeShape.$schema.properties.closed.path,
2017
2040
  value: Maybe.empty(),
2018
2041
  })),
2019
2042
  }).chain((closed) => $shaclPropertyFromRdf({
2020
- graph: $parameters.graph,
2021
- resource: $parameters.resource,
2043
+ graph: _$options.graph,
2044
+ resource: $resource,
2022
2045
  propertySchema: NodeShape.$schema.properties.comments,
2023
2046
  typeFromRdf: (resourceValues) => resourceValues
2024
- .chain((values) => $fromRdfPreferredLanguages(values, $parameters.preferredLanguages))
2047
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
2025
2048
  .chain((values) => values.chainMap((value) => value.toString()))
2026
2049
  .map((values) => values.toArray())
2027
2050
  .map((valuesArray) => Resource.Values.fromValue({
2028
- focusResource: $parameters.resource,
2051
+ focusResource: $resource,
2029
2052
  propertyPath: PropertyShape.$schema.properties.comments.path,
2030
2053
  value: valuesArray,
2031
2054
  })),
2032
2055
  }).chain((comments) => $shaclPropertyFromRdf({
2033
- graph: $parameters.graph,
2034
- resource: $parameters.resource,
2056
+ graph: _$options.graph,
2057
+ resource: $resource,
2035
2058
  propertySchema: NodeShape.$schema.properties.datatype,
2036
2059
  typeFromRdf: (resourceValues) => resourceValues
2037
2060
  .chain((values) => values.chainMap((value) => value.toIri()))
2038
2061
  .map((values) => values.length > 0
2039
2062
  ? values.map((value) => Maybe.of(value))
2040
2063
  : Resource.Values.fromValue({
2041
- focusResource: $parameters.resource,
2064
+ focusResource: $resource,
2042
2065
  propertyPath: PropertyShape.$schema.properties.datatype
2043
2066
  .path,
2044
2067
  value: Maybe.empty(),
2045
2068
  })),
2046
2069
  }).chain((datatype) => $shaclPropertyFromRdf({
2047
- graph: $parameters.graph,
2048
- resource: $parameters.resource,
2070
+ graph: _$options.graph,
2071
+ resource: $resource,
2049
2072
  propertySchema: NodeShape.$schema.properties.deactivated,
2050
2073
  typeFromRdf: (resourceValues) => resourceValues
2051
2074
  .chain((values) => values.chainMap((value) => value.toBoolean()))
2052
2075
  .map((values) => values.length > 0
2053
2076
  ? values.map((value) => Maybe.of(value))
2054
2077
  : Resource.Values.fromValue({
2055
- focusResource: $parameters.resource,
2078
+ focusResource: $resource,
2056
2079
  propertyPath: PropertyShape.$schema.properties
2057
2080
  .deactivated.path,
2058
2081
  value: Maybe.empty(),
2059
2082
  })),
2060
2083
  }).chain((deactivated) => $shaclPropertyFromRdf({
2061
- graph: $parameters.graph,
2062
- resource: $parameters.resource,
2084
+ graph: _$options.graph,
2085
+ resource: $resource,
2063
2086
  propertySchema: NodeShape.$schema.properties.flags,
2064
2087
  typeFromRdf: (resourceValues) => resourceValues
2065
- .chain((values) => $fromRdfPreferredLanguages(values, $parameters.preferredLanguages))
2088
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
2066
2089
  .chain((values) => values.chainMap((value) => value.toString()))
2067
2090
  .map((values) => values.toArray())
2068
2091
  .map((valuesArray) => Resource.Values.fromValue({
2069
- focusResource: $parameters.resource,
2092
+ focusResource: $resource,
2070
2093
  propertyPath: PropertyShape.$schema.properties.flags.path,
2071
2094
  value: valuesArray,
2072
2095
  })),
2073
2096
  }).chain((flags) => $shaclPropertyFromRdf({
2074
- graph: $parameters.graph,
2075
- resource: $parameters.resource,
2097
+ graph: _$options.graph,
2098
+ resource: $resource,
2076
2099
  propertySchema: NodeShape.$schema.properties.hasValues,
2077
2100
  typeFromRdf: (resourceValues) => resourceValues
2078
2101
  .chain((values) => values.chainMap((value) => value.toTerm().chain((term) => {
@@ -2084,7 +2107,7 @@ export var NodeShape;
2084
2107
  return Left(new Resource.MistypedTermValueError({
2085
2108
  actualValue: term,
2086
2109
  expectedValueType: "(NamedNode | Literal)",
2087
- focusResource: $parameters.resource,
2110
+ focusResource: $resource,
2088
2111
  propertyPath: PropertyShape.$schema
2089
2112
  .properties.hasValues.path,
2090
2113
  }));
@@ -2092,21 +2115,19 @@ export var NodeShape;
2092
2115
  })))
2093
2116
  .map((values) => values.toArray())
2094
2117
  .map((valuesArray) => Resource.Values.fromValue({
2095
- focusResource: $parameters.resource,
2118
+ focusResource: $resource,
2096
2119
  propertyPath: PropertyShape.$schema.properties.hasValues
2097
2120
  .path,
2098
2121
  value: valuesArray,
2099
2122
  })),
2100
2123
  }).chain((hasValues) => $shaclPropertyFromRdf({
2101
- graph: $parameters.graph,
2102
- resource: $parameters.resource,
2124
+ graph: _$options.graph,
2125
+ resource: $resource,
2103
2126
  propertySchema: NodeShape.$schema.properties.ignoredProperties,
2104
2127
  typeFromRdf: (resourceValues) => resourceValues
2105
- .chain((values) => values.chainMap((value) => value.toList({
2106
- graph: $parameters.graph,
2107
- })))
2128
+ .chain((values) => values.chainMap((value) => value.toList({ graph: _$options.graph })))
2108
2129
  .chain((valueLists) => valueLists.chainMap((valueList) => Right(Resource.Values.fromArray({
2109
- focusResource: $parameters.resource,
2130
+ focusResource: $resource,
2110
2131
  propertyPath: NodeShape.$schema.properties
2111
2132
  .ignoredProperties.path,
2112
2133
  values: valueList.toArray(),
@@ -2115,21 +2136,21 @@ export var NodeShape;
2115
2136
  .map((values) => values.length > 0
2116
2137
  ? values.map((value) => Maybe.of(value))
2117
2138
  : Resource.Values.fromValue({
2118
- focusResource: $parameters.resource,
2139
+ focusResource: $resource,
2119
2140
  propertyPath: NodeShape.$schema.properties
2120
2141
  .ignoredProperties.path,
2121
2142
  value: Maybe.empty(),
2122
2143
  })),
2123
2144
  }).chain((ignoredProperties) => $shaclPropertyFromRdf({
2124
- graph: $parameters.graph,
2125
- resource: $parameters.resource,
2145
+ graph: _$options.graph,
2146
+ resource: $resource,
2126
2147
  propertySchema: NodeShape.$schema.properties.in_,
2127
2148
  typeFromRdf: (resourceValues) => resourceValues
2128
2149
  .chain((values) => values.chainMap((value) => value.toList({
2129
- graph: $parameters.graph,
2150
+ graph: _$options.graph,
2130
2151
  })))
2131
2152
  .chain((valueLists) => valueLists.chainMap((valueList) => Right(Resource.Values.fromArray({
2132
- focusResource: $parameters.resource,
2153
+ focusResource: $resource,
2133
2154
  propertyPath: PropertyShape.$schema.properties
2134
2155
  .in_.path,
2135
2156
  values: valueList.toArray(),
@@ -2142,7 +2163,7 @@ export var NodeShape;
2142
2163
  return Left(new Resource.MistypedTermValueError({
2143
2164
  actualValue: term,
2144
2165
  expectedValueType: "(NamedNode | Literal)",
2145
- focusResource: $parameters.resource,
2166
+ focusResource: $resource,
2146
2167
  propertyPath: PropertyShape.$schema
2147
2168
  .properties.in_
2148
2169
  .path,
@@ -2153,123 +2174,123 @@ export var NodeShape;
2153
2174
  .map((values) => values.length > 0
2154
2175
  ? values.map((value) => Maybe.of(value))
2155
2176
  : Resource.Values.fromValue({
2156
- focusResource: $parameters.resource,
2177
+ focusResource: $resource,
2157
2178
  propertyPath: PropertyShape.$schema.properties
2158
2179
  .in_.path,
2159
2180
  value: Maybe.empty(),
2160
2181
  })),
2161
2182
  }).chain((in_) => $shaclPropertyFromRdf({
2162
- graph: $parameters.graph,
2163
- resource: $parameters.resource,
2183
+ graph: _$options.graph,
2184
+ resource: $resource,
2164
2185
  propertySchema: NodeShape.$schema.properties.isDefinedBy,
2165
2186
  typeFromRdf: (resourceValues) => resourceValues
2166
2187
  .chain((values) => values.chainMap((value) => value.toIdentifier()))
2167
2188
  .map((values) => values.length > 0
2168
2189
  ? values.map((value) => Maybe.of(value))
2169
2190
  : Resource.Values.fromValue({
2170
- focusResource: $parameters.resource,
2191
+ focusResource: $resource,
2171
2192
  propertyPath: PropertyShape.$schema.properties
2172
2193
  .isDefinedBy.path,
2173
2194
  value: Maybe.empty(),
2174
2195
  })),
2175
2196
  }).chain((isDefinedBy) => $shaclPropertyFromRdf({
2176
- graph: $parameters.graph,
2177
- resource: $parameters.resource,
2197
+ graph: _$options.graph,
2198
+ resource: $resource,
2178
2199
  propertySchema: NodeShape.$schema.properties.labels,
2179
2200
  typeFromRdf: (resourceValues) => resourceValues
2180
- .chain((values) => $fromRdfPreferredLanguages(values, $parameters.preferredLanguages))
2201
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
2181
2202
  .chain((values) => values.chainMap((value) => value.toString()))
2182
2203
  .map((values) => values.toArray())
2183
2204
  .map((valuesArray) => Resource.Values.fromValue({
2184
- focusResource: $parameters.resource,
2205
+ focusResource: $resource,
2185
2206
  propertyPath: PropertyShape.$schema.properties
2186
2207
  .labels.path,
2187
2208
  value: valuesArray,
2188
2209
  })),
2189
2210
  }).chain((labels) => $shaclPropertyFromRdf({
2190
- graph: $parameters.graph,
2191
- resource: $parameters.resource,
2211
+ graph: _$options.graph,
2212
+ resource: $resource,
2192
2213
  propertySchema: NodeShape.$schema.properties.languageIn,
2193
2214
  typeFromRdf: (resourceValues) => resourceValues
2194
2215
  .chain((values) => values.chainMap((value) => value.toList({
2195
- graph: $parameters.graph,
2216
+ graph: _$options.graph,
2196
2217
  })))
2197
2218
  .chain((valueLists) => valueLists.chainMap((valueList) => Right(Resource.Values.fromArray({
2198
- focusResource: $parameters.resource,
2219
+ focusResource: $resource,
2199
2220
  propertyPath: PropertyShape.$schema
2200
2221
  .properties.languageIn
2201
2222
  .path,
2202
2223
  values: valueList.toArray(),
2203
2224
  }))
2204
- .chain((values) => $fromRdfPreferredLanguages(values, $parameters.preferredLanguages))
2225
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
2205
2226
  .chain((values) => values.chainMap((value) => value.toString()))))
2206
2227
  .map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
2207
2228
  .map((values) => values.length > 0
2208
2229
  ? values.map((value) => Maybe.of(value))
2209
2230
  : Resource.Values.fromValue({
2210
- focusResource: $parameters.resource,
2231
+ focusResource: $resource,
2211
2232
  propertyPath: PropertyShape.$schema
2212
2233
  .properties.languageIn
2213
2234
  .path,
2214
2235
  value: Maybe.empty(),
2215
2236
  })),
2216
2237
  }).chain((languageIn) => $shaclPropertyFromRdf({
2217
- graph: $parameters.graph,
2218
- resource: $parameters.resource,
2238
+ graph: _$options.graph,
2239
+ resource: $resource,
2219
2240
  propertySchema: NodeShape.$schema.properties.maxCount,
2220
2241
  typeFromRdf: (resourceValues) => resourceValues
2221
2242
  .chain((values) => values.chainMap((value) => value.toInt()))
2222
2243
  .map((values) => values.length > 0
2223
2244
  ? values.map((value) => Maybe.of(value))
2224
2245
  : Resource.Values.fromValue({
2225
- focusResource: $parameters.resource,
2246
+ focusResource: $resource,
2226
2247
  propertyPath: PropertyShape.$schema
2227
2248
  .properties.maxCount
2228
2249
  .path,
2229
2250
  value: Maybe.empty(),
2230
2251
  })),
2231
2252
  }).chain((maxCount) => $shaclPropertyFromRdf({
2232
- graph: $parameters.graph,
2233
- resource: $parameters.resource,
2253
+ graph: _$options.graph,
2254
+ resource: $resource,
2234
2255
  propertySchema: NodeShape.$schema.properties.maxExclusive,
2235
2256
  typeFromRdf: (resourceValues) => resourceValues
2236
- .chain((values) => $fromRdfPreferredLanguages(values, $parameters.preferredLanguages))
2257
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
2237
2258
  .chain((values) => values.chainMap((value) => value.toLiteral()))
2238
2259
  .map((values) => values.length > 0
2239
2260
  ? values.map((value) => Maybe.of(value))
2240
2261
  : Resource.Values.fromValue({
2241
- focusResource: $parameters.resource,
2262
+ focusResource: $resource,
2242
2263
  propertyPath: PropertyShape.$schema
2243
2264
  .properties
2244
2265
  .maxExclusive.path,
2245
2266
  value: Maybe.empty(),
2246
2267
  })),
2247
2268
  }).chain((maxExclusive) => $shaclPropertyFromRdf({
2248
- graph: $parameters.graph,
2249
- resource: $parameters.resource,
2269
+ graph: _$options.graph,
2270
+ resource: $resource,
2250
2271
  propertySchema: NodeShape.$schema.properties.maxInclusive,
2251
2272
  typeFromRdf: (resourceValues) => resourceValues
2252
- .chain((values) => $fromRdfPreferredLanguages(values, $parameters.preferredLanguages))
2273
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
2253
2274
  .chain((values) => values.chainMap((value) => value.toLiteral()))
2254
2275
  .map((values) => values.length > 0
2255
2276
  ? values.map((value) => Maybe.of(value))
2256
2277
  : Resource.Values.fromValue({
2257
- focusResource: $parameters.resource,
2278
+ focusResource: $resource,
2258
2279
  propertyPath: PropertyShape.$schema
2259
2280
  .properties
2260
2281
  .maxInclusive.path,
2261
2282
  value: Maybe.empty(),
2262
2283
  })),
2263
2284
  }).chain((maxInclusive) => $shaclPropertyFromRdf({
2264
- graph: $parameters.graph,
2265
- resource: $parameters.resource,
2285
+ graph: _$options.graph,
2286
+ resource: $resource,
2266
2287
  propertySchema: NodeShape.$schema.properties.maxLength,
2267
2288
  typeFromRdf: (resourceValues) => resourceValues
2268
2289
  .chain((values) => values.chainMap((value) => value.toInt()))
2269
2290
  .map((values) => values.length > 0
2270
2291
  ? values.map((value) => Maybe.of(value))
2271
2292
  : Resource.Values.fromValue({
2272
- focusResource: $parameters.resource,
2293
+ focusResource: $resource,
2273
2294
  propertyPath: PropertyShape
2274
2295
  .$schema
2275
2296
  .properties
@@ -2277,15 +2298,15 @@ export var NodeShape;
2277
2298
  value: Maybe.empty(),
2278
2299
  })),
2279
2300
  }).chain((maxLength) => $shaclPropertyFromRdf({
2280
- graph: $parameters.graph,
2281
- resource: $parameters.resource,
2301
+ graph: _$options.graph,
2302
+ resource: $resource,
2282
2303
  propertySchema: NodeShape.$schema.properties.minCount,
2283
2304
  typeFromRdf: (resourceValues) => resourceValues
2284
2305
  .chain((values) => values.chainMap((value) => value.toInt()))
2285
2306
  .map((values) => values.length > 0
2286
2307
  ? values.map((value) => Maybe.of(value))
2287
2308
  : Resource.Values.fromValue({
2288
- focusResource: $parameters.resource,
2309
+ focusResource: $resource,
2289
2310
  propertyPath: PropertyShape
2290
2311
  .$schema
2291
2312
  .properties
@@ -2293,17 +2314,17 @@ export var NodeShape;
2293
2314
  value: Maybe.empty(),
2294
2315
  })),
2295
2316
  }).chain((minCount) => $shaclPropertyFromRdf({
2296
- graph: $parameters.graph,
2297
- resource: $parameters.resource,
2317
+ graph: _$options.graph,
2318
+ resource: $resource,
2298
2319
  propertySchema: NodeShape.$schema.properties
2299
2320
  .minExclusive,
2300
2321
  typeFromRdf: (resourceValues) => resourceValues
2301
- .chain((values) => $fromRdfPreferredLanguages(values, $parameters.preferredLanguages))
2322
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
2302
2323
  .chain((values) => values.chainMap((value) => value.toLiteral()))
2303
2324
  .map((values) => values.length > 0
2304
2325
  ? values.map((value) => Maybe.of(value))
2305
2326
  : Resource.Values.fromValue({
2306
- focusResource: $parameters.resource,
2327
+ focusResource: $resource,
2307
2328
  propertyPath: PropertyShape
2308
2329
  .$schema
2309
2330
  .properties
@@ -2312,17 +2333,17 @@ export var NodeShape;
2312
2333
  value: Maybe.empty(),
2313
2334
  })),
2314
2335
  }).chain((minExclusive) => $shaclPropertyFromRdf({
2315
- graph: $parameters.graph,
2316
- resource: $parameters.resource,
2336
+ graph: _$options.graph,
2337
+ resource: $resource,
2317
2338
  propertySchema: NodeShape.$schema.properties
2318
2339
  .minInclusive,
2319
2340
  typeFromRdf: (resourceValues) => resourceValues
2320
- .chain((values) => $fromRdfPreferredLanguages(values, $parameters.preferredLanguages))
2341
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
2321
2342
  .chain((values) => values.chainMap((value) => value.toLiteral()))
2322
2343
  .map((values) => values.length > 0
2323
2344
  ? values.map((value) => Maybe.of(value))
2324
2345
  : Resource.Values.fromValue({
2325
- focusResource: $parameters.resource,
2346
+ focusResource: $resource,
2326
2347
  propertyPath: PropertyShape
2327
2348
  .$schema
2328
2349
  .properties
@@ -2331,8 +2352,8 @@ export var NodeShape;
2331
2352
  value: Maybe.empty(),
2332
2353
  })),
2333
2354
  }).chain((minInclusive) => $shaclPropertyFromRdf({
2334
- graph: $parameters.graph,
2335
- resource: $parameters.resource,
2355
+ graph: _$options.graph,
2356
+ resource: $resource,
2336
2357
  propertySchema: NodeShape.$schema.properties
2337
2358
  .minLength,
2338
2359
  typeFromRdf: (resourceValues) => resourceValues
@@ -2340,7 +2361,7 @@ export var NodeShape;
2340
2361
  .map((values) => values.length > 0
2341
2362
  ? values.map((value) => Maybe.of(value))
2342
2363
  : Resource.Values.fromValue({
2343
- focusResource: $parameters.resource,
2364
+ focusResource: $resource,
2344
2365
  propertyPath: PropertyShape
2345
2366
  .$schema
2346
2367
  .properties
@@ -2349,8 +2370,8 @@ export var NodeShape;
2349
2370
  value: Maybe.empty(),
2350
2371
  })),
2351
2372
  }).chain((minLength) => $shaclPropertyFromRdf({
2352
- graph: $parameters.graph,
2353
- resource: $parameters.resource,
2373
+ graph: _$options.graph,
2374
+ resource: $resource,
2354
2375
  propertySchema: NodeShape.$schema.properties
2355
2376
  .nodeKind,
2356
2377
  typeFromRdf: (resourceValues) => resourceValues
@@ -2365,7 +2386,7 @@ export var NodeShape;
2365
2386
  .map((values) => values.length > 0
2366
2387
  ? values.map((value) => Maybe.of(value))
2367
2388
  : Resource.Values.fromValue({
2368
- focusResource: $parameters.resource,
2389
+ focusResource: $resource,
2369
2390
  propertyPath: PropertyShape
2370
2391
  .$schema
2371
2392
  .properties
@@ -2374,15 +2395,15 @@ export var NodeShape;
2374
2395
  value: Maybe.empty(),
2375
2396
  })),
2376
2397
  }).chain((nodeKind) => $shaclPropertyFromRdf({
2377
- graph: $parameters.graph,
2378
- resource: $parameters.resource,
2398
+ graph: _$options.graph,
2399
+ resource: $resource,
2379
2400
  propertySchema: NodeShape.$schema.properties
2380
2401
  .nodes,
2381
2402
  typeFromRdf: (resourceValues) => resourceValues
2382
2403
  .chain((values) => values.chainMap((value) => value.toIdentifier()))
2383
2404
  .map((values) => values.toArray())
2384
2405
  .map((valuesArray) => Resource.Values.fromValue({
2385
- focusResource: $parameters.resource,
2406
+ focusResource: $resource,
2386
2407
  propertyPath: PropertyShape
2387
2408
  .$schema
2388
2409
  .properties
@@ -2391,8 +2412,8 @@ export var NodeShape;
2391
2412
  value: valuesArray,
2392
2413
  })),
2393
2414
  }).chain((nodes) => $shaclPropertyFromRdf({
2394
- graph: $parameters.graph,
2395
- resource: $parameters.resource,
2415
+ graph: _$options.graph,
2416
+ resource: $resource,
2396
2417
  propertySchema: NodeShape.$schema
2397
2418
  .properties
2398
2419
  .not,
@@ -2400,7 +2421,7 @@ export var NodeShape;
2400
2421
  .chain((values) => values.chainMap((value) => value.toIdentifier()))
2401
2422
  .map((values) => values.toArray())
2402
2423
  .map((valuesArray) => Resource.Values.fromValue({
2403
- focusResource: $parameters.resource,
2424
+ focusResource: $resource,
2404
2425
  propertyPath: PropertyShape
2405
2426
  .$schema
2406
2427
  .properties
@@ -2409,17 +2430,17 @@ export var NodeShape;
2409
2430
  value: valuesArray,
2410
2431
  })),
2411
2432
  }).chain((not) => $shaclPropertyFromRdf({
2412
- graph: $parameters.graph,
2413
- resource: $parameters.resource,
2433
+ graph: _$options.graph,
2434
+ resource: $resource,
2414
2435
  propertySchema: NodeShape.$schema
2415
2436
  .properties
2416
2437
  .or,
2417
2438
  typeFromRdf: (resourceValues) => resourceValues
2418
2439
  .chain((values) => values.chainMap((value) => value.toList({
2419
- graph: $parameters.graph,
2440
+ graph: _$options.graph,
2420
2441
  })))
2421
2442
  .chain((valueLists) => valueLists.chainMap((valueList) => Right(Resource.Values.fromArray({
2422
- focusResource: $parameters.resource,
2443
+ focusResource: $resource,
2423
2444
  propertyPath: PropertyShape
2424
2445
  .$schema
2425
2446
  .properties
@@ -2430,7 +2451,7 @@ export var NodeShape;
2430
2451
  .map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
2431
2452
  .map((values) => values.toArray())
2432
2453
  .map((valuesArray) => Resource.Values.fromValue({
2433
- focusResource: $parameters.resource,
2454
+ focusResource: $resource,
2434
2455
  propertyPath: PropertyShape
2435
2456
  .$schema
2436
2457
  .properties
@@ -2439,17 +2460,17 @@ export var NodeShape;
2439
2460
  value: valuesArray,
2440
2461
  })),
2441
2462
  }).chain((or) => $shaclPropertyFromRdf({
2442
- graph: $parameters.graph,
2443
- resource: $parameters.resource,
2463
+ graph: _$options.graph,
2464
+ resource: $resource,
2444
2465
  propertySchema: NodeShape.$schema
2445
2466
  .properties
2446
2467
  .patterns,
2447
2468
  typeFromRdf: (resourceValues) => resourceValues
2448
- .chain((values) => $fromRdfPreferredLanguages(values, $parameters.preferredLanguages))
2469
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
2449
2470
  .chain((values) => values.chainMap((value) => value.toString()))
2450
2471
  .map((values) => values.toArray())
2451
2472
  .map((valuesArray) => Resource.Values.fromValue({
2452
- focusResource: $parameters.resource,
2473
+ focusResource: $resource,
2453
2474
  propertyPath: PropertyShape
2454
2475
  .$schema
2455
2476
  .properties
@@ -2458,8 +2479,8 @@ export var NodeShape;
2458
2479
  value: valuesArray,
2459
2480
  })),
2460
2481
  }).chain((patterns) => $shaclPropertyFromRdf({
2461
- graph: $parameters.graph,
2462
- resource: $parameters.resource,
2482
+ graph: _$options.graph,
2483
+ resource: $resource,
2463
2484
  propertySchema: NodeShape.$schema
2464
2485
  .properties
2465
2486
  .properties,
@@ -2467,7 +2488,7 @@ export var NodeShape;
2467
2488
  .chain((values) => values.chainMap((value) => value.toIdentifier()))
2468
2489
  .map((values) => values.toArray())
2469
2490
  .map((valuesArray) => Resource.Values.fromValue({
2470
- focusResource: $parameters.resource,
2491
+ focusResource: $resource,
2471
2492
  propertyPath: NodeShape
2472
2493
  .$schema
2473
2494
  .properties
@@ -2476,17 +2497,17 @@ export var NodeShape;
2476
2497
  value: valuesArray,
2477
2498
  })),
2478
2499
  }).chain((properties) => $shaclPropertyFromRdf({
2479
- graph: $parameters.graph,
2480
- resource: $parameters.resource,
2500
+ graph: _$options.graph,
2501
+ resource: $resource,
2481
2502
  propertySchema: NodeShape.$schema
2482
2503
  .properties
2483
2504
  .xone,
2484
2505
  typeFromRdf: (resourceValues) => resourceValues
2485
2506
  .chain((values) => values.chainMap((value) => value.toList({
2486
- graph: $parameters.graph,
2507
+ graph: _$options.graph,
2487
2508
  })))
2488
2509
  .chain((valueLists) => valueLists.chainMap((valueList) => Right(Resource.Values.fromArray({
2489
- focusResource: $parameters.resource,
2510
+ focusResource: $resource,
2490
2511
  propertyPath: PropertyShape
2491
2512
  .$schema
2492
2513
  .properties
@@ -2497,7 +2518,7 @@ export var NodeShape;
2497
2518
  .map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
2498
2519
  .map((values) => values.toArray())
2499
2520
  .map((valuesArray) => Resource.Values.fromValue({
2500
- focusResource: $parameters.resource,
2521
+ focusResource: $resource,
2501
2522
  propertyPath: PropertyShape
2502
2523
  .$schema
2503
2524
  .properties
@@ -2537,8 +2558,7 @@ export var NodeShape;
2537
2558
  properties,
2538
2559
  xone,
2539
2560
  }))))))))))))))))))))))))))))))));
2540
- }
2541
- NodeShape.$propertiesFromRdf = $propertiesFromRdf;
2561
+ };
2542
2562
  NodeShape.$schema = {
2543
2563
  properties: {
2544
2564
  $identifier: {
@@ -2546,7 +2566,7 @@ export var NodeShape;
2546
2566
  type: () => ({ kind: "Identifier" }),
2547
2567
  },
2548
2568
  $type: {
2549
- kind: "TypeDiscriminant",
2569
+ kind: "Discriminant",
2550
2570
  type: () => ({
2551
2571
  kind: "TypeDiscriminant",
2552
2572
  ownValues: ["NodeShape"],
@@ -2806,7 +2826,7 @@ export var NodeShape;
2806
2826
  },
2807
2827
  },
2808
2828
  };
2809
- function $toRdf(_nodeShape, options) {
2829
+ function $toRdfResource(_nodeShape, options) {
2810
2830
  const resourceSet = options?.resourceSet ??
2811
2831
  new ResourceSet(datasetFactory.dataset(), { dataFactory: dataFactory });
2812
2832
  const resource = resourceSet.resource(_nodeShape.$identifier);
@@ -2993,48 +3013,81 @@ export var NodeShape;
2993
3013
  ]), options?.graph);
2994
3014
  return resource;
2995
3015
  }
2996
- NodeShape.$toRdf = $toRdf;
3016
+ NodeShape.$toRdfResource = $toRdfResource;
2997
3017
  })(NodeShape || (NodeShape = {}));
2998
3018
  export var Shape;
2999
3019
  (function (Shape) {
3000
- let $Identifier;
3001
- (function ($Identifier) {
3002
- $Identifier.fromString = $identifierFromString; // biome-ignore lint/suspicious/noShadowRestrictedNames: allow toString
3003
- $Identifier.toString = Resource.Identifier.toString;
3004
- })($Identifier = Shape.$Identifier || (Shape.$Identifier = {}));
3005
- function $filter(filter, value) {
3020
+ Shape.$toRdfResource = (value, options) => {
3021
+ if (NodeShape.isNodeShape(value)) {
3022
+ return NodeShape.$toRdfResource(value, options);
3023
+ }
3024
+ if (PropertyShape.isPropertyShape(value)) {
3025
+ return PropertyShape.$toRdfResource(value, options);
3026
+ }
3027
+ throw new Error("unrecognized type");
3028
+ };
3029
+ Shape.$filter = (filter, value) => {
3006
3030
  if (filter.$identifier !== undefined &&
3007
3031
  !$filterIdentifier(filter.$identifier, value.$identifier)) {
3008
3032
  return false;
3009
3033
  }
3010
- if (NodeShape.isNodeShape(value) &&
3011
- filter.on?.NodeShape &&
3012
- !NodeShape.$filter(filter.on.NodeShape, value)) {
3013
- return false;
3034
+ if (filter.on?.["NodeShape"] !== undefined &&
3035
+ NodeShape.isNodeShape(value)) {
3036
+ if (!NodeShape.$filter(filter.on["NodeShape"], value)) {
3037
+ return false;
3038
+ }
3014
3039
  }
3015
- if (PropertyShape.isPropertyShape(value) &&
3016
- filter.on?.PropertyShape &&
3017
- !PropertyShape.$filter(filter.on.PropertyShape, value)) {
3018
- return false;
3040
+ if (filter.on?.["PropertyShape"] !== undefined &&
3041
+ PropertyShape.isPropertyShape(value)) {
3042
+ if (!PropertyShape.$filter(filter.on["PropertyShape"], value)) {
3043
+ return false;
3044
+ }
3019
3045
  }
3020
3046
  return true;
3021
- }
3022
- Shape.$filter = $filter;
3023
- function $fromRdf(resource, options) {
3024
- return NodeShape.$fromRdf(resource, {
3025
- ...options,
3047
+ };
3048
+ Shape.$fromRdfResource = (resource, options) => NodeShape.$fromRdfResource(resource, {
3049
+ ...options,
3050
+ ignoreRdfType: false,
3051
+ }).altLazy(() => PropertyShape.$fromRdfResource(resource, {
3052
+ ...options,
3053
+ ignoreRdfType: false,
3054
+ }));
3055
+ Shape.$fromRdfResourceValues = ((values, _options) => values.chain((values) => values.chainMap((value) => {
3056
+ const valueAsValues = Right(value.toValues());
3057
+ return NodeShape.$fromRdfResourceValues(valueAsValues, {
3058
+ context: _options.context,
3059
+ graph: _options.graph,
3026
3060
  ignoreRdfType: false,
3027
- }).altLazy(() => PropertyShape.$fromRdf(resource, {
3028
- ...options,
3061
+ objectSet: _options.objectSet,
3062
+ preferredLanguages: _options.preferredLanguages,
3063
+ propertyPath: _options.propertyPath,
3064
+ resource: _options.resource,
3065
+ })
3066
+ .altLazy(() => PropertyShape.$fromRdfResourceValues(valueAsValues, {
3067
+ context: _options.context,
3068
+ graph: _options.graph,
3029
3069
  ignoreRdfType: false,
3030
- }));
3031
- }
3032
- Shape.$fromRdf = $fromRdf;
3033
- function isShape(object) {
3034
- return (NodeShape.isNodeShape(object) || PropertyShape.isPropertyShape(object));
3035
- }
3036
- Shape.isShape = isShape;
3070
+ objectSet: _options.objectSet,
3071
+ preferredLanguages: _options.preferredLanguages,
3072
+ propertyPath: _options.propertyPath,
3073
+ resource: _options.resource,
3074
+ }))
3075
+ .chain((values) => values.head());
3076
+ })));
3077
+ let $Identifier;
3078
+ (function ($Identifier) {
3079
+ $Identifier.fromString = $identifierFromString; // biome-ignore lint/suspicious/noShadowRestrictedNames: allow toString
3080
+ $Identifier.toString = Resource.Identifier.toString;
3081
+ })($Identifier = Shape.$Identifier || (Shape.$Identifier = {}));
3037
3082
  Shape.$schema = {
3083
+ kind: "NamedObjectUnion",
3084
+ members: {
3085
+ NodeShape: { discriminantValues: ["NodeShape"], type: NodeShape.$schema },
3086
+ PropertyShape: {
3087
+ discriminantValues: ["PropertyShape"],
3088
+ type: PropertyShape.$schema,
3089
+ },
3090
+ },
3038
3091
  properties: {
3039
3092
  and: {
3040
3093
  kind: "Shacl",
@@ -3263,72 +3316,152 @@ export var Shape;
3263
3316
  },
3264
3317
  },
3265
3318
  };
3266
- function $toRdf(_shape, _parameters) {
3267
- if (NodeShape.isNodeShape(_shape)) {
3268
- return NodeShape.$toRdf(_shape, _parameters);
3269
- }
3270
- if (PropertyShape.isPropertyShape(_shape)) {
3271
- return PropertyShape.$toRdf(_shape, _parameters);
3272
- }
3273
- throw new Error("unrecognized type");
3319
+ Shape.$toRdfResourceValues = ((value, _options) => {
3320
+ if (NodeShape.isNodeShape(value)) {
3321
+ return [
3322
+ NodeShape.$toRdfResource(value, {
3323
+ graph: _options.graph,
3324
+ resourceSet: _options.resourceSet,
3325
+ }).identifier,
3326
+ ];
3327
+ }
3328
+ if (PropertyShape.isPropertyShape(value)) {
3329
+ return [
3330
+ PropertyShape.$toRdfResource(value, {
3331
+ graph: _options.graph,
3332
+ resourceSet: _options.resourceSet,
3333
+ }).identifier,
3334
+ ];
3335
+ }
3336
+ throw new Error("unable to serialize to RDF");
3337
+ });
3338
+ function isShape(object) {
3339
+ return (NodeShape.isNodeShape(object) || PropertyShape.isPropertyShape(object));
3274
3340
  }
3275
- Shape.$toRdf = $toRdf;
3341
+ Shape.isShape = isShape;
3276
3342
  })(Shape || (Shape = {}));
3277
3343
  export var $Object;
3278
3344
  (function ($Object) {
3279
- let $Identifier;
3280
- (function ($Identifier) {
3281
- $Identifier.fromString = $identifierFromString; // biome-ignore lint/suspicious/noShadowRestrictedNames: allow toString
3282
- $Identifier.toString = Resource.Identifier.toString;
3283
- })($Identifier = $Object.$Identifier || ($Object.$Identifier = {}));
3284
- function $filter(filter, value) {
3345
+ $Object.$toRdfResource = (value, options) => {
3346
+ if (NodeShape.isNodeShape(value)) {
3347
+ return NodeShape.$toRdfResource(value, options);
3348
+ }
3349
+ if (Ontology.isOntology(value)) {
3350
+ return Ontology.$toRdfResource(value, options);
3351
+ }
3352
+ if (PropertyGroup.isPropertyGroup(value)) {
3353
+ return PropertyGroup.$toRdfResource(value, options);
3354
+ }
3355
+ if (PropertyShape.isPropertyShape(value)) {
3356
+ return PropertyShape.$toRdfResource(value, options);
3357
+ }
3358
+ throw new Error("unrecognized type");
3359
+ };
3360
+ $Object.$filter = (filter, value) => {
3285
3361
  if (filter.$identifier !== undefined &&
3286
3362
  !$filterIdentifier(filter.$identifier, value.$identifier)) {
3287
3363
  return false;
3288
3364
  }
3289
- if (NodeShape.isNodeShape(value) &&
3290
- filter.on?.NodeShape &&
3291
- !NodeShape.$filter(filter.on.NodeShape, value)) {
3292
- return false;
3365
+ if (filter.on?.["NodeShape"] !== undefined &&
3366
+ NodeShape.isNodeShape(value)) {
3367
+ if (!NodeShape.$filter(filter.on["NodeShape"], value)) {
3368
+ return false;
3369
+ }
3293
3370
  }
3294
- if (Ontology.isOntology(value) &&
3295
- filter.on?.Ontology &&
3296
- !Ontology.$filter(filter.on.Ontology, value)) {
3297
- return false;
3371
+ if (filter.on?.["Ontology"] !== undefined && Ontology.isOntology(value)) {
3372
+ if (!Ontology.$filter(filter.on["Ontology"], value)) {
3373
+ return false;
3374
+ }
3298
3375
  }
3299
- if (PropertyGroup.isPropertyGroup(value) &&
3300
- filter.on?.PropertyGroup &&
3301
- !PropertyGroup.$filter(filter.on.PropertyGroup, value)) {
3302
- return false;
3376
+ if (filter.on?.["PropertyGroup"] !== undefined &&
3377
+ PropertyGroup.isPropertyGroup(value)) {
3378
+ if (!PropertyGroup.$filter(filter.on["PropertyGroup"], value)) {
3379
+ return false;
3380
+ }
3303
3381
  }
3304
- if (PropertyShape.isPropertyShape(value) &&
3305
- filter.on?.PropertyShape &&
3306
- !PropertyShape.$filter(filter.on.PropertyShape, value)) {
3307
- return false;
3382
+ if (filter.on?.["PropertyShape"] !== undefined &&
3383
+ PropertyShape.isPropertyShape(value)) {
3384
+ if (!PropertyShape.$filter(filter.on["PropertyShape"], value)) {
3385
+ return false;
3386
+ }
3308
3387
  }
3309
3388
  return true;
3310
- }
3311
- $Object.$filter = $filter;
3312
- function $fromRdf(resource, options) {
3313
- return NodeShape.$fromRdf(resource, {
3314
- ...options,
3389
+ };
3390
+ $Object.$fromRdfResource = (resource, options) => NodeShape.$fromRdfResource(resource, {
3391
+ ...options,
3392
+ ignoreRdfType: false,
3393
+ })
3394
+ .altLazy(() => Ontology.$fromRdfResource(resource, {
3395
+ ...options,
3396
+ ignoreRdfType: false,
3397
+ }))
3398
+ .altLazy(() => PropertyGroup.$fromRdfResource(resource, {
3399
+ ...options,
3400
+ ignoreRdfType: false,
3401
+ }))
3402
+ .altLazy(() => PropertyShape.$fromRdfResource(resource, {
3403
+ ...options,
3404
+ ignoreRdfType: false,
3405
+ }));
3406
+ $Object.$fromRdfResourceValues = ((values, _options) => values.chain((values) => values.chainMap((value) => {
3407
+ const valueAsValues = Right(value.toValues());
3408
+ return NodeShape.$fromRdfResourceValues(valueAsValues, {
3409
+ context: _options.context,
3410
+ graph: _options.graph,
3315
3411
  ignoreRdfType: false,
3412
+ objectSet: _options.objectSet,
3413
+ preferredLanguages: _options.preferredLanguages,
3414
+ propertyPath: _options.propertyPath,
3415
+ resource: _options.resource,
3316
3416
  })
3317
- .altLazy(() => Ontology.$fromRdf(resource, {
3318
- ...options,
3417
+ .altLazy(() => Ontology.$fromRdfResourceValues(valueAsValues, {
3418
+ context: _options.context,
3419
+ graph: _options.graph,
3319
3420
  ignoreRdfType: false,
3421
+ objectSet: _options.objectSet,
3422
+ preferredLanguages: _options.preferredLanguages,
3423
+ propertyPath: _options.propertyPath,
3424
+ resource: _options.resource,
3320
3425
  }))
3321
- .altLazy(() => PropertyGroup.$fromRdf(resource, {
3322
- ...options,
3426
+ .altLazy(() => PropertyGroup.$fromRdfResourceValues(valueAsValues, {
3427
+ context: _options.context,
3428
+ graph: _options.graph,
3323
3429
  ignoreRdfType: false,
3430
+ objectSet: _options.objectSet,
3431
+ preferredLanguages: _options.preferredLanguages,
3432
+ propertyPath: _options.propertyPath,
3433
+ resource: _options.resource,
3324
3434
  }))
3325
- .altLazy(() => PropertyShape.$fromRdf(resource, {
3326
- ...options,
3435
+ .altLazy(() => PropertyShape.$fromRdfResourceValues(valueAsValues, {
3436
+ context: _options.context,
3437
+ graph: _options.graph,
3327
3438
  ignoreRdfType: false,
3328
- }));
3329
- }
3330
- $Object.$fromRdf = $fromRdf;
3439
+ objectSet: _options.objectSet,
3440
+ preferredLanguages: _options.preferredLanguages,
3441
+ propertyPath: _options.propertyPath,
3442
+ resource: _options.resource,
3443
+ }))
3444
+ .chain((values) => values.head());
3445
+ })));
3446
+ let $Identifier;
3447
+ (function ($Identifier) {
3448
+ $Identifier.fromString = $identifierFromString; // biome-ignore lint/suspicious/noShadowRestrictedNames: allow toString
3449
+ $Identifier.toString = Resource.Identifier.toString;
3450
+ })($Identifier = $Object.$Identifier || ($Object.$Identifier = {}));
3331
3451
  $Object.$schema = {
3452
+ kind: "NamedObjectUnion",
3453
+ members: {
3454
+ NodeShape: { discriminantValues: ["NodeShape"], type: NodeShape.$schema },
3455
+ Ontology: { discriminantValues: ["Ontology"], type: Ontology.$schema },
3456
+ PropertyGroup: {
3457
+ discriminantValues: ["PropertyGroup"],
3458
+ type: PropertyGroup.$schema,
3459
+ },
3460
+ PropertyShape: {
3461
+ discriminantValues: ["PropertyShape"],
3462
+ type: PropertyShape.$schema,
3463
+ },
3464
+ },
3332
3465
  properties: {
3333
3466
  labels: {
3334
3467
  kind: "Shacl",
@@ -3340,22 +3473,41 @@ export var $Object;
3340
3473
  },
3341
3474
  },
3342
3475
  };
3343
- function $toRdf(_object, _parameters) {
3344
- if (NodeShape.isNodeShape(_object)) {
3345
- return NodeShape.$toRdf(_object, _parameters);
3346
- }
3347
- if (Ontology.isOntology(_object)) {
3348
- return Ontology.$toRdf(_object, _parameters);
3349
- }
3350
- if (PropertyGroup.isPropertyGroup(_object)) {
3351
- return PropertyGroup.$toRdf(_object, _parameters);
3352
- }
3353
- if (PropertyShape.isPropertyShape(_object)) {
3354
- return PropertyShape.$toRdf(_object, _parameters);
3355
- }
3356
- throw new Error("unrecognized type");
3357
- }
3358
- $Object.$toRdf = $toRdf;
3476
+ $Object.$toRdfResourceValues = ((value, _options) => {
3477
+ if (NodeShape.isNodeShape(value)) {
3478
+ return [
3479
+ NodeShape.$toRdfResource(value, {
3480
+ graph: _options.graph,
3481
+ resourceSet: _options.resourceSet,
3482
+ }).identifier,
3483
+ ];
3484
+ }
3485
+ if (Ontology.isOntology(value)) {
3486
+ return [
3487
+ Ontology.$toRdfResource(value, {
3488
+ graph: _options.graph,
3489
+ resourceSet: _options.resourceSet,
3490
+ }).identifier,
3491
+ ];
3492
+ }
3493
+ if (PropertyGroup.isPropertyGroup(value)) {
3494
+ return [
3495
+ PropertyGroup.$toRdfResource(value, {
3496
+ graph: _options.graph,
3497
+ resourceSet: _options.resourceSet,
3498
+ }).identifier,
3499
+ ];
3500
+ }
3501
+ if (PropertyShape.isPropertyShape(value)) {
3502
+ return [
3503
+ PropertyShape.$toRdfResource(value, {
3504
+ graph: _options.graph,
3505
+ resourceSet: _options.resourceSet,
3506
+ }).identifier,
3507
+ ];
3508
+ }
3509
+ throw new Error("unable to serialize to RDF");
3510
+ });
3359
3511
  })($Object || ($Object = {}));
3360
3512
  export class $RdfjsDatasetObjectSet {
3361
3513
  $graph;
@@ -3400,7 +3552,7 @@ export class $RdfjsDatasetObjectSet {
3400
3552
  nodeShapesSync(query) {
3401
3553
  return this.$objectsSync({
3402
3554
  $filter: NodeShape.$filter,
3403
- $fromRdf: NodeShape.$fromRdf,
3555
+ $fromRdfResource: NodeShape.$fromRdfResource,
3404
3556
  $fromRdfTypes: [NodeShape.$fromRdfType],
3405
3557
  }, query);
3406
3558
  }
@@ -3431,7 +3583,7 @@ export class $RdfjsDatasetObjectSet {
3431
3583
  ontologiesSync(query) {
3432
3584
  return this.$objectsSync({
3433
3585
  $filter: Ontology.$filter,
3434
- $fromRdf: Ontology.$fromRdf,
3586
+ $fromRdfResource: Ontology.$fromRdfResource,
3435
3587
  $fromRdfTypes: [Ontology.$fromRdfType],
3436
3588
  }, query);
3437
3589
  }
@@ -3462,7 +3614,7 @@ export class $RdfjsDatasetObjectSet {
3462
3614
  propertyGroupsSync(query) {
3463
3615
  return this.$objectsSync({
3464
3616
  $filter: PropertyGroup.$filter,
3465
- $fromRdf: PropertyGroup.$fromRdf,
3617
+ $fromRdfResource: PropertyGroup.$fromRdfResource,
3466
3618
  $fromRdfTypes: [PropertyGroup.$fromRdfType],
3467
3619
  }, query);
3468
3620
  }
@@ -3493,7 +3645,7 @@ export class $RdfjsDatasetObjectSet {
3493
3645
  propertyShapesSync(query) {
3494
3646
  return this.$objectsSync({
3495
3647
  $filter: PropertyShape.$filter,
3496
- $fromRdf: PropertyShape.$fromRdf,
3648
+ $fromRdfResource: PropertyShape.$fromRdfResource,
3497
3649
  $fromRdfTypes: [PropertyShape.$fromRdfType],
3498
3650
  }, query);
3499
3651
  }
@@ -3525,12 +3677,12 @@ export class $RdfjsDatasetObjectSet {
3525
3677
  return this.$objectUnionsSync([
3526
3678
  {
3527
3679
  $filter: Shape.$filter,
3528
- $fromRdf: NodeShape.$fromRdf,
3680
+ $fromRdfResource: NodeShape.$fromRdfResource,
3529
3681
  $fromRdfTypes: [NodeShape.$fromRdfType],
3530
3682
  },
3531
3683
  {
3532
3684
  $filter: Shape.$filter,
3533
- $fromRdf: PropertyShape.$fromRdf,
3685
+ $fromRdfResource: PropertyShape.$fromRdfResource,
3534
3686
  $fromRdfTypes: [PropertyShape.$fromRdfType],
3535
3687
  },
3536
3688
  ], query);
@@ -3563,22 +3715,22 @@ export class $RdfjsDatasetObjectSet {
3563
3715
  return this.$objectUnionsSync([
3564
3716
  {
3565
3717
  $filter: $Object.$filter,
3566
- $fromRdf: NodeShape.$fromRdf,
3718
+ $fromRdfResource: NodeShape.$fromRdfResource,
3567
3719
  $fromRdfTypes: [NodeShape.$fromRdfType],
3568
3720
  },
3569
3721
  {
3570
3722
  $filter: $Object.$filter,
3571
- $fromRdf: Ontology.$fromRdf,
3723
+ $fromRdfResource: Ontology.$fromRdfResource,
3572
3724
  $fromRdfTypes: [Ontology.$fromRdfType],
3573
3725
  },
3574
3726
  {
3575
3727
  $filter: $Object.$filter,
3576
- $fromRdf: PropertyGroup.$fromRdf,
3728
+ $fromRdfResource: PropertyGroup.$fromRdfResource,
3577
3729
  $fromRdfTypes: [PropertyGroup.$fromRdfType],
3578
3730
  },
3579
3731
  {
3580
3732
  $filter: $Object.$filter,
3581
- $fromRdf: PropertyShape.$fromRdf,
3733
+ $fromRdfResource: PropertyShape.$fromRdfResource,
3582
3734
  $fromRdfTypes: [PropertyShape.$fromRdfType],
3583
3735
  },
3584
3736
  ], query);
@@ -3593,7 +3745,7 @@ export class $RdfjsDatasetObjectSet {
3593
3745
  if (offset < 0) {
3594
3746
  offset = 0;
3595
3747
  }
3596
- const fromRdfOptions = {
3748
+ const fromRdfResourceOptions = {
3597
3749
  graph,
3598
3750
  objectSet: this,
3599
3751
  preferredLanguages: query?.preferredLanguages,
@@ -3643,7 +3795,9 @@ export class $RdfjsDatasetObjectSet {
3643
3795
  identifierSet.add(quad.subject);
3644
3796
  const resource = resourceSet.resource(quad.subject);
3645
3797
  // Eagerly eliminate the majority of resources that won't match the object type
3646
- objectType.$fromRdf(resource, fromRdfOptions).ifRight((object) => {
3798
+ objectType
3799
+ .$fromRdfResource(resource, fromRdfResourceOptions)
3800
+ .ifRight((object) => {
3647
3801
  resources.push({ object, resource });
3648
3802
  });
3649
3803
  }
@@ -3656,7 +3810,7 @@ export class $RdfjsDatasetObjectSet {
3656
3810
  const objects = [];
3657
3811
  for (let { object, resource } of resources) {
3658
3812
  if (!object) {
3659
- const objectEither = objectType.$fromRdf(resource, fromRdfOptions);
3813
+ const objectEither = objectType.$fromRdfResource(resource, fromRdfResourceOptions);
3660
3814
  if (objectEither.isLeft()) {
3661
3815
  return objectEither;
3662
3816
  }
@@ -3684,7 +3838,7 @@ export class $RdfjsDatasetObjectSet {
3684
3838
  if (offset < 0) {
3685
3839
  offset = 0;
3686
3840
  }
3687
- const fromRdfOptions = {
3841
+ const fromRdfResourceOptions = {
3688
3842
  graph,
3689
3843
  objectSet: this,
3690
3844
  preferredLanguages: query?.preferredLanguages,
@@ -3738,7 +3892,7 @@ export class $RdfjsDatasetObjectSet {
3738
3892
  const resource = resourceSet.resource(quad.subject);
3739
3893
  for (const objectType of objectTypes) {
3740
3894
  if (objectType
3741
- .$fromRdf(resource, fromRdfOptions)
3895
+ .$fromRdfResource(resource, fromRdfResourceOptions)
3742
3896
  .ifRight((object) => {
3743
3897
  resources.push({ object, objectType, resource });
3744
3898
  })
@@ -3758,12 +3912,12 @@ export class $RdfjsDatasetObjectSet {
3758
3912
  if (!object) {
3759
3913
  let objectEither;
3760
3914
  if (objectType) {
3761
- objectEither = objectType.$fromRdf(resource, fromRdfOptions);
3915
+ objectEither = objectType.$fromRdfResource(resource, fromRdfResourceOptions);
3762
3916
  }
3763
3917
  else {
3764
3918
  objectEither = Left(new Error("no object types"));
3765
3919
  for (const tryObjectType of objectTypes) {
3766
- objectEither = tryObjectType.$fromRdf(resource, fromRdfOptions);
3920
+ objectEither = tryObjectType.$fromRdfResource(resource, fromRdfResourceOptions);
3767
3921
  if (objectEither.isRight()) {
3768
3922
  objectType = tryObjectType;
3769
3923
  break;