@shaclmate/shacl-ast 2.0.17 → 2.0.19

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.
@@ -2,7 +2,10 @@ import type * as rdfjs from "@rdfjs/types";
2
2
  import * as purify from "purify-ts";
3
3
  import * as rdfjsResource from "rdfjs-resource";
4
4
  import { PropertyPath } from "./PropertyPath.js";
5
+ type UnwrapR<T> = T extends purify.Either<any, infer R> ? R : never;
5
6
  export interface BaseShaclCoreShape {
7
+ readonly identifier: rdfjs.BlankNode | rdfjs.NamedNode;
8
+ readonly type: "ShaclCoreNodeShape" | "ShaclCorePropertyShape";
6
9
  readonly and: readonly (readonly (rdfjs.BlankNode | rdfjs.NamedNode)[])[];
7
10
  readonly classes: readonly rdfjs.NamedNode[];
8
11
  readonly comments: readonly rdfjs.Literal[];
@@ -10,7 +13,6 @@ export interface BaseShaclCoreShape {
10
13
  readonly deactivated: purify.Maybe<boolean>;
11
14
  readonly flags: readonly string[];
12
15
  readonly hasValues: readonly (rdfjs.BlankNode | rdfjs.NamedNode | rdfjs.Literal)[];
13
- readonly identifier: rdfjs.BlankNode | rdfjs.NamedNode;
14
16
  readonly in_: purify.Maybe<readonly (rdfjs.BlankNode | rdfjs.NamedNode | rdfjs.Literal)[]>;
15
17
  readonly isDefinedBy: purify.Maybe<rdfjs.BlankNode | rdfjs.NamedNode>;
16
18
  readonly labels: readonly rdfjs.Literal[];
@@ -28,16 +30,16 @@ export interface BaseShaclCoreShape {
28
30
  readonly not: readonly (rdfjs.BlankNode | rdfjs.NamedNode)[];
29
31
  readonly or: readonly (readonly (rdfjs.BlankNode | rdfjs.NamedNode)[])[];
30
32
  readonly patterns: readonly string[];
31
- readonly type: "ShaclCoreNodeShape" | "ShaclCorePropertyShape";
32
33
  readonly xone: readonly (readonly (rdfjs.BlankNode | rdfjs.NamedNode)[])[];
33
34
  }
34
35
  export declare namespace BaseShaclCoreShape {
35
- function fromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource, ..._context }: {
36
+ function _propertiesFromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource, ..._context }: {
36
37
  [_index: string]: any;
37
38
  ignoreRdfType?: boolean;
38
39
  languageIn?: readonly string[];
39
40
  resource: rdfjsResource.Resource;
40
41
  }): purify.Either<rdfjsResource.Resource.ValueError, {
42
+ identifier: rdfjs.BlankNode | rdfjs.NamedNode;
41
43
  and: readonly (readonly (rdfjs.BlankNode | rdfjs.NamedNode)[])[];
42
44
  classes: readonly rdfjs.NamedNode[];
43
45
  comments: readonly rdfjs.Literal[];
@@ -45,7 +47,6 @@ export declare namespace BaseShaclCoreShape {
45
47
  deactivated: purify.Maybe<boolean>;
46
48
  flags: readonly string[];
47
49
  hasValues: readonly (rdfjs.BlankNode | rdfjs.NamedNode | rdfjs.Literal)[];
48
- identifier: rdfjs.BlankNode | rdfjs.NamedNode;
49
50
  in_: purify.Maybe<readonly (rdfjs.BlankNode | rdfjs.NamedNode | rdfjs.Literal)[]>;
50
51
  isDefinedBy: purify.Maybe<rdfjs.BlankNode | rdfjs.NamedNode>;
51
52
  labels: readonly rdfjs.Literal[];
@@ -67,72 +68,106 @@ export declare namespace BaseShaclCoreShape {
67
68
  }>;
68
69
  }
69
70
  export interface ShaclCorePropertyShape extends BaseShaclCoreShape {
71
+ readonly identifier: rdfjs.BlankNode | rdfjs.NamedNode;
72
+ readonly type: "ShaclCorePropertyShape";
70
73
  readonly defaultValue: purify.Maybe<rdfjs.BlankNode | rdfjs.NamedNode | rdfjs.Literal>;
71
74
  readonly descriptions: readonly rdfjs.Literal[];
72
75
  readonly groups: readonly (rdfjs.BlankNode | rdfjs.NamedNode)[];
73
- readonly identifier: rdfjs.BlankNode | rdfjs.NamedNode;
74
76
  readonly names: readonly rdfjs.Literal[];
75
77
  readonly order: purify.Maybe<number>;
76
78
  readonly path: PropertyPath;
77
- readonly type: "ShaclCorePropertyShape";
78
79
  readonly uniqueLang: purify.Maybe<boolean>;
79
80
  }
80
81
  export declare namespace ShaclCorePropertyShape {
81
- function fromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource, ..._context }: {
82
+ function _propertiesFromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource, ..._context }: {
82
83
  [_index: string]: any;
83
84
  ignoreRdfType?: boolean;
84
85
  languageIn?: readonly string[];
85
86
  resource: rdfjsResource.Resource;
86
- }): purify.Either<rdfjsResource.Resource.ValueError, ShaclCorePropertyShape>;
87
+ }): purify.Either<rdfjsResource.Resource.ValueError, {
88
+ identifier: rdfjs.BlankNode | rdfjs.NamedNode;
89
+ type: "ShaclCorePropertyShape";
90
+ defaultValue: purify.Maybe<rdfjs.BlankNode | rdfjs.NamedNode | rdfjs.Literal>;
91
+ descriptions: readonly rdfjs.Literal[];
92
+ groups: readonly (rdfjs.BlankNode | rdfjs.NamedNode)[];
93
+ names: readonly rdfjs.Literal[];
94
+ order: purify.Maybe<number>;
95
+ path: PropertyPath;
96
+ uniqueLang: purify.Maybe<boolean>;
97
+ } & UnwrapR<ReturnType<typeof BaseShaclCoreShape._propertiesFromRdf>>>;
98
+ function fromRdf(parameters: Parameters<typeof ShaclCorePropertyShape._propertiesFromRdf>[0]): purify.Either<rdfjsResource.Resource.ValueError, ShaclCorePropertyShape>;
99
+ const fromRdfType: rdfjs.NamedNode<string>;
87
100
  }
88
101
  export interface ShaclCorePropertyGroup {
89
- readonly comments: readonly rdfjs.Literal[];
90
102
  readonly identifier: rdfjs.BlankNode | rdfjs.NamedNode;
91
- readonly labels: readonly rdfjs.Literal[];
92
103
  readonly type: "ShaclCorePropertyGroup";
104
+ readonly comments: readonly rdfjs.Literal[];
105
+ readonly labels: readonly rdfjs.Literal[];
93
106
  }
94
107
  export declare namespace ShaclCorePropertyGroup {
95
- function fromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource, ..._context }: {
108
+ function _propertiesFromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource, ..._context }: {
96
109
  [_index: string]: any;
97
110
  ignoreRdfType?: boolean;
98
111
  languageIn?: readonly string[];
99
112
  resource: rdfjsResource.Resource;
100
- }): purify.Either<rdfjsResource.Resource.ValueError, ShaclCorePropertyGroup>;
113
+ }): purify.Either<rdfjsResource.Resource.ValueError, {
114
+ identifier: rdfjs.BlankNode | rdfjs.NamedNode;
115
+ type: "ShaclCorePropertyGroup";
116
+ comments: readonly rdfjs.Literal[];
117
+ labels: readonly rdfjs.Literal[];
118
+ }>;
119
+ function fromRdf(parameters: Parameters<typeof ShaclCorePropertyGroup._propertiesFromRdf>[0]): purify.Either<rdfjsResource.Resource.ValueError, ShaclCorePropertyGroup>;
120
+ const fromRdfType: rdfjs.NamedNode<string>;
101
121
  }
102
122
  export interface ShaclCoreNodeShape extends BaseShaclCoreShape {
103
- readonly closed: purify.Maybe<boolean>;
104
123
  readonly identifier: rdfjs.BlankNode | rdfjs.NamedNode;
124
+ readonly type: "ShaclCoreNodeShape";
125
+ readonly closed: purify.Maybe<boolean>;
105
126
  readonly ignoredProperties: purify.Maybe<readonly rdfjs.NamedNode[]>;
106
127
  readonly properties: readonly (rdfjs.BlankNode | rdfjs.NamedNode)[];
107
- readonly type: "ShaclCoreNodeShape";
108
128
  }
109
129
  export declare namespace ShaclCoreNodeShape {
110
- function fromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource, ..._context }: {
130
+ function _propertiesFromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource, ..._context }: {
111
131
  [_index: string]: any;
112
132
  ignoreRdfType?: boolean;
113
133
  languageIn?: readonly string[];
114
134
  resource: rdfjsResource.Resource;
115
- }): purify.Either<rdfjsResource.Resource.ValueError, ShaclCoreNodeShape>;
135
+ }): purify.Either<rdfjsResource.Resource.ValueError, {
136
+ identifier: rdfjs.BlankNode | rdfjs.NamedNode;
137
+ type: "ShaclCoreNodeShape";
138
+ closed: purify.Maybe<boolean>;
139
+ ignoredProperties: purify.Maybe<readonly rdfjs.NamedNode[]>;
140
+ properties: readonly (rdfjs.BlankNode | rdfjs.NamedNode)[];
141
+ } & UnwrapR<ReturnType<typeof BaseShaclCoreShape._propertiesFromRdf>>>;
142
+ function fromRdf(parameters: Parameters<typeof ShaclCoreNodeShape._propertiesFromRdf>[0]): purify.Either<rdfjsResource.Resource.ValueError, ShaclCoreNodeShape>;
143
+ const fromRdfType: rdfjs.NamedNode<string>;
116
144
  }
117
145
  export interface OwlOntology {
118
146
  readonly identifier: rdfjs.BlankNode | rdfjs.NamedNode;
119
- readonly labels: readonly rdfjs.Literal[];
120
147
  readonly type: "OwlOntology";
148
+ readonly labels: readonly rdfjs.Literal[];
121
149
  }
122
150
  export declare namespace OwlOntology {
123
- function fromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource, ..._context }: {
151
+ function _propertiesFromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource, ..._context }: {
124
152
  [_index: string]: any;
125
153
  ignoreRdfType?: boolean;
126
154
  languageIn?: readonly string[];
127
155
  resource: rdfjsResource.Resource;
128
- }): purify.Either<rdfjsResource.Resource.ValueError, OwlOntology>;
156
+ }): purify.Either<rdfjsResource.Resource.ValueError, {
157
+ identifier: rdfjs.BlankNode | rdfjs.NamedNode;
158
+ type: "OwlOntology";
159
+ labels: readonly rdfjs.Literal[];
160
+ }>;
161
+ function fromRdf(parameters: Parameters<typeof OwlOntology._propertiesFromRdf>[0]): purify.Either<rdfjsResource.Resource.ValueError, OwlOntology>;
162
+ const fromRdfType: rdfjs.NamedNode<string>;
129
163
  }
130
164
  export type ShaclCoreShape = ShaclCoreNodeShape | ShaclCorePropertyShape;
131
165
  export declare namespace ShaclCoreShape {
132
- function fromRdf(parameters: {
166
+ function fromRdf({ ignoreRdfType, resource, ...context }: {
133
167
  [_index: string]: any;
134
168
  ignoreRdfType?: boolean;
135
169
  resource: rdfjsResource.Resource;
136
170
  }): purify.Either<rdfjsResource.Resource.ValueError, ShaclCoreShape>;
137
171
  }
172
+ export {};
138
173
  //# sourceMappingURL=generated.d.ts.map
package/dist/generated.js CHANGED
@@ -4,9 +4,10 @@ import * as rdfjsResource from "rdfjs-resource";
4
4
  import { PropertyPath } from "./PropertyPath.js";
5
5
  export var BaseShaclCoreShape;
6
6
  (function (BaseShaclCoreShape) {
7
- function fromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource,
7
+ function _propertiesFromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource,
8
8
  // @ts-ignore
9
9
  ..._context }) {
10
+ const identifier = _resource.identifier;
10
11
  const _andEither = purify.Either.of([
11
12
  ..._resource
12
13
  .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#and"), {
@@ -122,7 +123,6 @@ export var BaseShaclCoreShape;
122
123
  return _hasValuesEither;
123
124
  }
124
125
  const hasValues = _hasValuesEither.unsafeCoerce();
125
- const identifier = _resource.identifier;
126
126
  const _in_Either = purify.Either.of(_resource
127
127
  .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#in"), {
128
128
  unique: true,
@@ -439,6 +439,7 @@ export var BaseShaclCoreShape;
439
439
  }
440
440
  const xone = _xoneEither.unsafeCoerce();
441
441
  return purify.Either.of({
442
+ identifier,
442
443
  and,
443
444
  classes,
444
445
  comments,
@@ -446,7 +447,6 @@ export var BaseShaclCoreShape;
446
447
  deactivated,
447
448
  flags,
448
449
  hasValues,
449
- identifier,
450
450
  in_,
451
451
  isDefinedBy,
452
452
  labels,
@@ -467,185 +467,169 @@ export var BaseShaclCoreShape;
467
467
  xone,
468
468
  });
469
469
  }
470
- BaseShaclCoreShape.fromRdf = fromRdf;
470
+ BaseShaclCoreShape._propertiesFromRdf = _propertiesFromRdf;
471
471
  })(BaseShaclCoreShape || (BaseShaclCoreShape = {}));
472
472
  export var ShaclCorePropertyShape;
473
473
  (function (ShaclCorePropertyShape) {
474
- function fromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource,
474
+ function _propertiesFromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource,
475
475
  // @ts-ignore
476
476
  ..._context }) {
477
- return BaseShaclCoreShape.fromRdf({
477
+ const _super0Either = BaseShaclCoreShape._propertiesFromRdf({
478
478
  ..._context,
479
479
  ignoreRdfType: true,
480
480
  languageIn: _languageIn,
481
481
  resource: _resource,
482
- }).chain((_super) => {
483
- if (!_ignoreRdfType &&
484
- !_resource.isInstanceOf(dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyShape"))) {
485
- return purify.Left(new rdfjsResource.Resource.ValueError({
486
- focusResource: _resource,
487
- message: `${rdfjsResource.Resource.Identifier.toString(_resource.identifier)} has unexpected RDF type`,
488
- predicate: dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyShape"),
489
- }));
490
- }
491
- const _defaultValueEither = purify.Either.of(_resource
492
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#defaultValue"), { unique: true })
482
+ });
483
+ if (_super0Either.isLeft()) {
484
+ return _super0Either;
485
+ }
486
+ const _super0 = _super0Either.unsafeCoerce();
487
+ if (!_ignoreRdfType &&
488
+ !_resource.isInstanceOf(dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyShape"))) {
489
+ return purify.Left(new rdfjsResource.Resource.ValueError({
490
+ focusResource: _resource,
491
+ message: `${rdfjsResource.Resource.Identifier.toString(_resource.identifier)} has unexpected RDF type`,
492
+ predicate: dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyShape"),
493
+ }));
494
+ }
495
+ const identifier = _resource.identifier;
496
+ const type = "ShaclCorePropertyShape";
497
+ const _defaultValueEither = purify.Either.of(_resource
498
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#defaultValue"), { unique: true })
499
+ .head()
500
+ .chain((_value) => purify.Either.of(_value.toTerm()))
501
+ .toMaybe());
502
+ if (_defaultValueEither.isLeft()) {
503
+ return _defaultValueEither;
504
+ }
505
+ const defaultValue = _defaultValueEither.unsafeCoerce();
506
+ const _descriptionsEither = purify.Either.of([
507
+ ..._resource
508
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#description"), { unique: true })
509
+ .flatMap((_item) => _item
510
+ .toValues()
511
+ .filter((_value) => {
512
+ const _languageInOrDefault = _languageIn ?? [];
513
+ if (_languageInOrDefault.length === 0) {
514
+ return true;
515
+ }
516
+ const _valueLiteral = _value.toLiteral().toMaybe().extract();
517
+ if (typeof _valueLiteral === "undefined") {
518
+ return false;
519
+ }
520
+ return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
521
+ })
493
522
  .head()
494
- .chain((_value) => purify.Either.of(_value.toTerm()))
495
- .toMaybe());
496
- if (_defaultValueEither.isLeft()) {
497
- return _defaultValueEither;
498
- }
499
- const defaultValue = _defaultValueEither.unsafeCoerce();
500
- const _descriptionsEither = purify.Either.of([
501
- ..._resource
502
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#description"), { unique: true })
503
- .flatMap((_item) => _item
504
- .toValues()
505
- .filter((_value) => {
506
- const _languageInOrDefault = _languageIn ?? [];
507
- if (_languageInOrDefault.length === 0) {
508
- return true;
509
- }
510
- const _valueLiteral = _value.toLiteral().toMaybe().extract();
511
- if (typeof _valueLiteral === "undefined") {
512
- return false;
513
- }
514
- return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
515
- })
516
- .head()
517
- .chain((_value) => _value.toLiteral())
518
- .toMaybe()
519
- .toList()),
520
- ]);
521
- if (_descriptionsEither.isLeft()) {
522
- return _descriptionsEither;
523
- }
524
- const descriptions = _descriptionsEither.unsafeCoerce();
525
- const _groupsEither = purify.Either.of([
526
- ..._resource
527
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#group"), {
528
- unique: true,
529
- })
530
- .flatMap((_item) => _item
531
- .toValues()
532
- .head()
533
- .chain((_value) => _value.toIdentifier())
534
- .toMaybe()
535
- .toList()),
536
- ]);
537
- if (_groupsEither.isLeft()) {
538
- return _groupsEither;
539
- }
540
- const groups = _groupsEither.unsafeCoerce();
541
- const identifier = _resource.identifier;
542
- const _namesEither = purify.Either.of([
543
- ..._resource
544
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#name"), {
545
- unique: true,
546
- })
547
- .flatMap((_item) => _item
548
- .toValues()
549
- .filter((_value) => {
550
- const _languageInOrDefault = _languageIn ?? [];
551
- if (_languageInOrDefault.length === 0) {
552
- return true;
553
- }
554
- const _valueLiteral = _value.toLiteral().toMaybe().extract();
555
- if (typeof _valueLiteral === "undefined") {
556
- return false;
557
- }
558
- return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
559
- })
560
- .head()
561
- .chain((_value) => _value.toLiteral())
562
- .toMaybe()
563
- .toList()),
564
- ]);
565
- if (_namesEither.isLeft()) {
566
- return _namesEither;
567
- }
568
- const names = _namesEither.unsafeCoerce();
569
- const _orderEither = purify.Either.of(_resource
570
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#order"), {
523
+ .chain((_value) => _value.toLiteral())
524
+ .toMaybe()
525
+ .toList()),
526
+ ]);
527
+ if (_descriptionsEither.isLeft()) {
528
+ return _descriptionsEither;
529
+ }
530
+ const descriptions = _descriptionsEither.unsafeCoerce();
531
+ const _groupsEither = purify.Either.of([
532
+ ..._resource
533
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#group"), {
571
534
  unique: true,
572
535
  })
536
+ .flatMap((_item) => _item
537
+ .toValues()
573
538
  .head()
574
- .chain((_value) => _value.toNumber())
575
- .toMaybe());
576
- if (_orderEither.isLeft()) {
577
- return _orderEither;
578
- }
579
- const order = _orderEither.unsafeCoerce();
580
- const _pathEither = _resource
581
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#path"), {
539
+ .chain((_value) => _value.toIdentifier())
540
+ .toMaybe()
541
+ .toList()),
542
+ ]);
543
+ if (_groupsEither.isLeft()) {
544
+ return _groupsEither;
545
+ }
546
+ const groups = _groupsEither.unsafeCoerce();
547
+ const _namesEither = purify.Either.of([
548
+ ..._resource
549
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#name"), {
582
550
  unique: true,
551
+ })
552
+ .flatMap((_item) => _item
553
+ .toValues()
554
+ .filter((_value) => {
555
+ const _languageInOrDefault = _languageIn ?? [];
556
+ if (_languageInOrDefault.length === 0) {
557
+ return true;
558
+ }
559
+ const _valueLiteral = _value.toLiteral().toMaybe().extract();
560
+ if (typeof _valueLiteral === "undefined") {
561
+ return false;
562
+ }
563
+ return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
583
564
  })
584
565
  .head()
585
- .chain((value) => value.toResource())
586
- .chain((_resource) => PropertyPath.fromRdf({
587
- ..._context,
588
- ignoreRdfType: true,
589
- languageIn: _languageIn,
590
- resource: _resource,
591
- }));
592
- if (_pathEither.isLeft()) {
593
- return _pathEither;
594
- }
595
- const path = _pathEither.unsafeCoerce();
596
- const type = "ShaclCorePropertyShape";
597
- const _uniqueLangEither = purify.Either.of(_resource
598
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#uniqueLang"), { unique: true })
599
- .head()
600
- .chain((_value) => _value.toBoolean())
601
- .toMaybe());
602
- if (_uniqueLangEither.isLeft()) {
603
- return _uniqueLangEither;
604
- }
605
- const uniqueLang = _uniqueLangEither.unsafeCoerce();
606
- return purify.Either.of({
607
- and: _super.and,
608
- classes: _super.classes,
609
- comments: _super.comments,
610
- datatype: _super.datatype,
611
- deactivated: _super.deactivated,
612
- flags: _super.flags,
613
- hasValues: _super.hasValues,
614
- identifier,
615
- in_: _super.in_,
616
- isDefinedBy: _super.isDefinedBy,
617
- labels: _super.labels,
618
- languageIn: _super.languageIn,
619
- maxCount: _super.maxCount,
620
- maxExclusive: _super.maxExclusive,
621
- maxInclusive: _super.maxInclusive,
622
- maxLength: _super.maxLength,
623
- minCount: _super.minCount,
624
- minExclusive: _super.minExclusive,
625
- minInclusive: _super.minInclusive,
626
- minLength: _super.minLength,
627
- nodeKind: _super.nodeKind,
628
- nodes: _super.nodes,
629
- not: _super.not,
630
- or: _super.or,
631
- patterns: _super.patterns,
632
- xone: _super.xone,
633
- defaultValue,
634
- descriptions,
635
- groups,
636
- names,
637
- order,
638
- path,
639
- type,
640
- uniqueLang,
641
- });
566
+ .chain((_value) => _value.toLiteral())
567
+ .toMaybe()
568
+ .toList()),
569
+ ]);
570
+ if (_namesEither.isLeft()) {
571
+ return _namesEither;
572
+ }
573
+ const names = _namesEither.unsafeCoerce();
574
+ const _orderEither = purify.Either.of(_resource
575
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#order"), {
576
+ unique: true,
577
+ })
578
+ .head()
579
+ .chain((_value) => _value.toNumber())
580
+ .toMaybe());
581
+ if (_orderEither.isLeft()) {
582
+ return _orderEither;
583
+ }
584
+ const order = _orderEither.unsafeCoerce();
585
+ const _pathEither = _resource
586
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#path"), {
587
+ unique: true,
588
+ })
589
+ .head()
590
+ .chain((value) => value.toResource())
591
+ .chain((_resource) => PropertyPath.fromRdf({
592
+ ..._context,
593
+ ignoreRdfType: true,
594
+ languageIn: _languageIn,
595
+ resource: _resource,
596
+ }));
597
+ if (_pathEither.isLeft()) {
598
+ return _pathEither;
599
+ }
600
+ const path = _pathEither.unsafeCoerce();
601
+ const _uniqueLangEither = purify.Either.of(_resource
602
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#uniqueLang"), { unique: true })
603
+ .head()
604
+ .chain((_value) => _value.toBoolean())
605
+ .toMaybe());
606
+ if (_uniqueLangEither.isLeft()) {
607
+ return _uniqueLangEither;
608
+ }
609
+ const uniqueLang = _uniqueLangEither.unsafeCoerce();
610
+ return purify.Either.of({
611
+ ..._super0,
612
+ identifier,
613
+ type,
614
+ defaultValue,
615
+ descriptions,
616
+ groups,
617
+ names,
618
+ order,
619
+ path,
620
+ uniqueLang,
642
621
  });
643
622
  }
623
+ ShaclCorePropertyShape._propertiesFromRdf = _propertiesFromRdf;
624
+ function fromRdf(parameters) {
625
+ return ShaclCorePropertyShape._propertiesFromRdf(parameters);
626
+ }
644
627
  ShaclCorePropertyShape.fromRdf = fromRdf;
628
+ ShaclCorePropertyShape.fromRdfType = dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyShape");
645
629
  })(ShaclCorePropertyShape || (ShaclCorePropertyShape = {}));
646
630
  export var ShaclCorePropertyGroup;
647
631
  (function (ShaclCorePropertyGroup) {
648
- function fromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource,
632
+ function _propertiesFromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource,
649
633
  // @ts-ignore
650
634
  ..._context }) {
651
635
  if (!_ignoreRdfType &&
@@ -656,6 +640,8 @@ export var ShaclCorePropertyGroup;
656
640
  predicate: dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyGroup"),
657
641
  }));
658
642
  }
643
+ const identifier = _resource.identifier;
644
+ const type = "ShaclCorePropertyGroup";
659
645
  const _commentsEither = purify.Either.of([
660
646
  ..._resource
661
647
  .values(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#comment"), { unique: true })
@@ -681,7 +667,6 @@ export var ShaclCorePropertyGroup;
681
667
  return _commentsEither;
682
668
  }
683
669
  const comments = _commentsEither.unsafeCoerce();
684
- const identifier = _resource.identifier;
685
670
  const _labelsEither = purify.Either.of([
686
671
  ..._resource
687
672
  .values(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#label"), { unique: true })
@@ -707,111 +692,101 @@ export var ShaclCorePropertyGroup;
707
692
  return _labelsEither;
708
693
  }
709
694
  const labels = _labelsEither.unsafeCoerce();
710
- const type = "ShaclCorePropertyGroup";
711
- return purify.Either.of({ comments, identifier, labels, type });
695
+ return purify.Either.of({ identifier, type, comments, labels });
696
+ }
697
+ ShaclCorePropertyGroup._propertiesFromRdf = _propertiesFromRdf;
698
+ function fromRdf(parameters) {
699
+ return ShaclCorePropertyGroup._propertiesFromRdf(parameters);
712
700
  }
713
701
  ShaclCorePropertyGroup.fromRdf = fromRdf;
702
+ ShaclCorePropertyGroup.fromRdfType = dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyGroup");
714
703
  })(ShaclCorePropertyGroup || (ShaclCorePropertyGroup = {}));
715
704
  export var ShaclCoreNodeShape;
716
705
  (function (ShaclCoreNodeShape) {
717
- function fromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource,
706
+ function _propertiesFromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource,
718
707
  // @ts-ignore
719
708
  ..._context }) {
720
- return BaseShaclCoreShape.fromRdf({
709
+ const _super0Either = BaseShaclCoreShape._propertiesFromRdf({
721
710
  ..._context,
722
711
  ignoreRdfType: true,
723
712
  languageIn: _languageIn,
724
713
  resource: _resource,
725
- }).chain((_super) => {
726
- if (!_ignoreRdfType &&
727
- !_resource.isInstanceOf(dataFactory.namedNode("http://www.w3.org/ns/shacl#NodeShape"))) {
728
- return purify.Left(new rdfjsResource.Resource.ValueError({
729
- focusResource: _resource,
730
- message: `${rdfjsResource.Resource.Identifier.toString(_resource.identifier)} has unexpected RDF type`,
731
- predicate: dataFactory.namedNode("http://www.w3.org/ns/shacl#NodeShape"),
732
- }));
733
- }
734
- const _closedEither = purify.Either.of(_resource
735
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#closed"), {
714
+ });
715
+ if (_super0Either.isLeft()) {
716
+ return _super0Either;
717
+ }
718
+ const _super0 = _super0Either.unsafeCoerce();
719
+ if (!_ignoreRdfType &&
720
+ !_resource.isInstanceOf(dataFactory.namedNode("http://www.w3.org/ns/shacl#NodeShape"))) {
721
+ return purify.Left(new rdfjsResource.Resource.ValueError({
722
+ focusResource: _resource,
723
+ message: `${rdfjsResource.Resource.Identifier.toString(_resource.identifier)} has unexpected RDF type`,
724
+ predicate: dataFactory.namedNode("http://www.w3.org/ns/shacl#NodeShape"),
725
+ }));
726
+ }
727
+ const identifier = _resource.identifier;
728
+ const type = "ShaclCoreNodeShape";
729
+ const _closedEither = purify.Either.of(_resource
730
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#closed"), {
731
+ unique: true,
732
+ })
733
+ .head()
734
+ .chain((_value) => _value.toBoolean())
735
+ .toMaybe());
736
+ if (_closedEither.isLeft()) {
737
+ return _closedEither;
738
+ }
739
+ const closed = _closedEither.unsafeCoerce();
740
+ const _ignoredPropertiesEither = purify.Either.of(_resource
741
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#ignoredProperties"), { unique: true })
742
+ .head()
743
+ .chain((value) => value.toList())
744
+ .map((values) => values.flatMap((_value) => _value
745
+ .toValues()
746
+ .head()
747
+ .chain((_value) => _value.toIri())
748
+ .toMaybe()
749
+ .toList()))
750
+ .toMaybe());
751
+ if (_ignoredPropertiesEither.isLeft()) {
752
+ return _ignoredPropertiesEither;
753
+ }
754
+ const ignoredProperties = _ignoredPropertiesEither.unsafeCoerce();
755
+ const _propertiesEither = purify.Either.of([
756
+ ..._resource
757
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#property"), {
736
758
  unique: true,
737
759
  })
738
- .head()
739
- .chain((_value) => _value.toBoolean())
740
- .toMaybe());
741
- if (_closedEither.isLeft()) {
742
- return _closedEither;
743
- }
744
- const closed = _closedEither.unsafeCoerce();
745
- const identifier = _resource.identifier;
746
- const _ignoredPropertiesEither = purify.Either.of(_resource
747
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#ignoredProperties"), { unique: true })
748
- .head()
749
- .chain((value) => value.toList())
750
- .map((values) => values.flatMap((_value) => _value
760
+ .flatMap((_item) => _item
751
761
  .toValues()
752
762
  .head()
753
- .chain((_value) => _value.toIri())
763
+ .chain((_value) => _value.toIdentifier())
754
764
  .toMaybe()
755
- .toList()))
756
- .toMaybe());
757
- if (_ignoredPropertiesEither.isLeft()) {
758
- return _ignoredPropertiesEither;
759
- }
760
- const ignoredProperties = _ignoredPropertiesEither.unsafeCoerce();
761
- const _propertiesEither = purify.Either.of([
762
- ..._resource
763
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#property"), { unique: true })
764
- .flatMap((_item) => _item
765
- .toValues()
766
- .head()
767
- .chain((_value) => _value.toIdentifier())
768
- .toMaybe()
769
- .toList()),
770
- ]);
771
- if (_propertiesEither.isLeft()) {
772
- return _propertiesEither;
773
- }
774
- const properties = _propertiesEither.unsafeCoerce();
775
- const type = "ShaclCoreNodeShape";
776
- return purify.Either.of({
777
- and: _super.and,
778
- classes: _super.classes,
779
- comments: _super.comments,
780
- datatype: _super.datatype,
781
- deactivated: _super.deactivated,
782
- flags: _super.flags,
783
- hasValues: _super.hasValues,
784
- identifier,
785
- in_: _super.in_,
786
- isDefinedBy: _super.isDefinedBy,
787
- labels: _super.labels,
788
- languageIn: _super.languageIn,
789
- maxCount: _super.maxCount,
790
- maxExclusive: _super.maxExclusive,
791
- maxInclusive: _super.maxInclusive,
792
- maxLength: _super.maxLength,
793
- minCount: _super.minCount,
794
- minExclusive: _super.minExclusive,
795
- minInclusive: _super.minInclusive,
796
- minLength: _super.minLength,
797
- nodeKind: _super.nodeKind,
798
- nodes: _super.nodes,
799
- not: _super.not,
800
- or: _super.or,
801
- patterns: _super.patterns,
802
- xone: _super.xone,
803
- closed,
804
- ignoredProperties,
805
- properties,
806
- type,
807
- });
765
+ .toList()),
766
+ ]);
767
+ if (_propertiesEither.isLeft()) {
768
+ return _propertiesEither;
769
+ }
770
+ const properties = _propertiesEither.unsafeCoerce();
771
+ return purify.Either.of({
772
+ ..._super0,
773
+ identifier,
774
+ type,
775
+ closed,
776
+ ignoredProperties,
777
+ properties,
808
778
  });
809
779
  }
780
+ ShaclCoreNodeShape._propertiesFromRdf = _propertiesFromRdf;
781
+ function fromRdf(parameters) {
782
+ return ShaclCoreNodeShape._propertiesFromRdf(parameters);
783
+ }
810
784
  ShaclCoreNodeShape.fromRdf = fromRdf;
785
+ ShaclCoreNodeShape.fromRdfType = dataFactory.namedNode("http://www.w3.org/ns/shacl#NodeShape");
811
786
  })(ShaclCoreNodeShape || (ShaclCoreNodeShape = {}));
812
787
  export var OwlOntology;
813
788
  (function (OwlOntology) {
814
- function fromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource,
789
+ function _propertiesFromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource,
815
790
  // @ts-ignore
816
791
  ..._context }) {
817
792
  if (!_ignoreRdfType &&
@@ -823,6 +798,7 @@ export var OwlOntology;
823
798
  }));
824
799
  }
825
800
  const identifier = _resource.identifier;
801
+ const type = "OwlOntology";
826
802
  const _labelsEither = purify.Either.of([
827
803
  ..._resource
828
804
  .values(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#label"), { unique: true })
@@ -848,15 +824,22 @@ export var OwlOntology;
848
824
  return _labelsEither;
849
825
  }
850
826
  const labels = _labelsEither.unsafeCoerce();
851
- const type = "OwlOntology";
852
- return purify.Either.of({ identifier, labels, type });
827
+ return purify.Either.of({ identifier, type, labels });
828
+ }
829
+ OwlOntology._propertiesFromRdf = _propertiesFromRdf;
830
+ function fromRdf(parameters) {
831
+ return OwlOntology._propertiesFromRdf(parameters);
853
832
  }
854
833
  OwlOntology.fromRdf = fromRdf;
834
+ OwlOntology.fromRdfType = dataFactory.namedNode("http://www.w3.org/2002/07/owl#Ontology");
855
835
  })(OwlOntology || (OwlOntology = {}));
856
836
  export var ShaclCoreShape;
857
837
  (function (ShaclCoreShape) {
858
- function fromRdf(parameters) {
859
- return ShaclCoreNodeShape.fromRdf(parameters).altLazy(() => ShaclCorePropertyShape.fromRdf(parameters));
838
+ function fromRdf({ ignoreRdfType, resource, ...context }) {
839
+ return ShaclCoreNodeShape.fromRdf({ ...context, resource }).altLazy(() => ShaclCorePropertyShape.fromRdf({
840
+ ...context,
841
+ resource,
842
+ }));
860
843
  }
861
844
  ShaclCoreShape.fromRdf = fromRdf;
862
845
  })(ShaclCoreShape || (ShaclCoreShape = {}));
package/package.json CHANGED
@@ -25,6 +25,10 @@
25
25
  ],
26
26
  "license": "Apache-2.0",
27
27
  "name": "@shaclmate/shacl-ast",
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/minorg/shaclmate"
31
+ },
28
32
  "scripts": {
29
33
  "build": "tsc -b",
30
34
  "check": "biome check",
@@ -46,10 +50,6 @@
46
50
  "watch": "tsc -w --preserveWatchOutput",
47
51
  "watch:noEmit": "tsc --noEmit -w --preserveWatchOutput"
48
52
  },
49
- "repository": {
50
- "type": "git",
51
- "url": "git+https://github.com/minorg/shaclmate"
52
- },
53
53
  "type": "module",
54
- "version": "2.0.17"
54
+ "version": "2.0.19"
55
55
  }