@faubulous/mentor-rdf 1.3.0 → 1.3.1
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/index.js +678 -661
- package/dist/index.js.map +4 -4
- package/dist/rdf/index.d.ts +1 -0
- package/dist/rdf/store.d.ts +7 -0
- package/package.json +9 -8
package/dist/index.js
CHANGED
|
@@ -3168,6 +3168,9 @@ var IndividualRepository = class extends PropertyRepository {
|
|
|
3168
3168
|
if (p.object.equals(owl.NamedIndividual)) {
|
|
3169
3169
|
continue;
|
|
3170
3170
|
}
|
|
3171
|
+
if (p.object.termType !== "NamedNode") {
|
|
3172
|
+
continue;
|
|
3173
|
+
}
|
|
3171
3174
|
if (!yielded.has(p.object.value)) {
|
|
3172
3175
|
yielded.add(p.object.value);
|
|
3173
3176
|
yield p.object.value;
|
|
@@ -3892,260 +3895,562 @@ var OwlReasoner = class extends ShaclReasoner {
|
|
|
3892
3895
|
}
|
|
3893
3896
|
};
|
|
3894
3897
|
|
|
3895
|
-
// src/rdf/
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
@
|
|
3904
|
-
@
|
|
3905
|
-
@
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
3898
|
+
// src/rdf/shape-repository.ts
|
|
3899
|
+
var { namedNode: namedNode6 } = dataFactory;
|
|
3900
|
+
var ShapeRepository = class extends IndividualRepository {
|
|
3901
|
+
constructor(store) {
|
|
3902
|
+
super(store);
|
|
3903
|
+
}
|
|
3904
|
+
/**
|
|
3905
|
+
* Get all shapes in the repository.
|
|
3906
|
+
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
3907
|
+
* @param options Optional query parameters.
|
|
3908
|
+
* @returns An iterable of all shapes in the repository.
|
|
3909
|
+
*/
|
|
3910
|
+
*getShapes(graphUris, subjectUri, options) {
|
|
3911
|
+
const yielded = /* @__PURE__ */ new Set();
|
|
3912
|
+
if (!subjectUri) {
|
|
3913
|
+
for (let q of this.store.matchAll(graphUris, null, rdf.type, sh.Shape, options?.includeInferred)) {
|
|
3914
|
+
if (!yielded.has(q.subject.value) && !this.skip(graphUris, q.subject, options)) {
|
|
3915
|
+
yielded.add(q.subject.value);
|
|
3916
|
+
yield q.subject.value;
|
|
3917
|
+
}
|
|
3918
|
+
}
|
|
3919
|
+
} else {
|
|
3920
|
+
const s = namedNode6(subjectUri);
|
|
3921
|
+
for (let q of this.store.matchAll(graphUris, s, rdf.type, sh.Shape, options?.includeInferred)) {
|
|
3922
|
+
if (!yielded.has(q.subject.value) && !this.skip(graphUris, q.subject, options)) {
|
|
3923
|
+
yielded.add(q.subject.value);
|
|
3924
|
+
yield q.subject.value;
|
|
3925
|
+
}
|
|
3926
|
+
}
|
|
3927
|
+
for (let q of this.store.matchAll(graphUris, null, sh.targetClass, s, options?.includeInferred)) {
|
|
3928
|
+
if (!yielded.has(q.subject.value) && !this.skip(graphUris, q.subject, options)) {
|
|
3929
|
+
yielded.add(q.subject.value);
|
|
3930
|
+
yield q.subject.value;
|
|
3931
|
+
}
|
|
3932
|
+
}
|
|
3933
|
+
for (let q of this.store.matchAll(graphUris, null, sh.path, s, options?.includeInferred)) {
|
|
3934
|
+
if (!yielded.has(q.subject.value) && !this.skip(graphUris, q.subject, options)) {
|
|
3935
|
+
yielded.add(q.subject.value);
|
|
3936
|
+
yield q.subject.value;
|
|
3937
|
+
}
|
|
3938
|
+
}
|
|
3939
|
+
}
|
|
3940
|
+
}
|
|
3941
|
+
/**
|
|
3942
|
+
* Get all shape types in the repository.
|
|
3943
|
+
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
3944
|
+
* @param options Optional query parameters.
|
|
3945
|
+
* @returns A list of all shape types in the repository.
|
|
3946
|
+
*/
|
|
3947
|
+
*getShapeTypes(graphUris, options) {
|
|
3948
|
+
for (let q of this.store.matchAll(graphUris, null, rdf.type, sh.NodeShape)) {
|
|
3949
|
+
if (!this.skip(graphUris, q.subject, options, { includeBlankNodes: true })) {
|
|
3950
|
+
yield SH.NodeShape;
|
|
3951
|
+
break;
|
|
3952
|
+
}
|
|
3953
|
+
}
|
|
3954
|
+
for (let q of this.store.matchAll(graphUris, null, rdf.type, sh.PropertyShape)) {
|
|
3955
|
+
if (!this.skip(graphUris, q.subject, options, { includeBlankNodes: true })) {
|
|
3956
|
+
yield SH.PropertyShape;
|
|
3957
|
+
break;
|
|
3958
|
+
}
|
|
3959
|
+
}
|
|
3960
|
+
}
|
|
3961
|
+
/**
|
|
3962
|
+
* Get all validator types in the repository.
|
|
3963
|
+
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
3964
|
+
* @param options Optional query parameters.
|
|
3965
|
+
* @returns An iterable of all shape types in the repository.
|
|
3966
|
+
*/
|
|
3967
|
+
*getValidatorTypes(graphUris, options) {
|
|
3968
|
+
if (this.store.any(graphUris, null, rdf.type, sh.Validator, options?.includeInferred)) {
|
|
3969
|
+
yield SH.Validator;
|
|
3970
|
+
}
|
|
3971
|
+
if (this.store.any(graphUris, null, rdf.type, sh.JSValidator, false)) {
|
|
3972
|
+
yield SH.JSValidator;
|
|
3973
|
+
}
|
|
3974
|
+
if (this.store.any(graphUris, null, rdf.type, sh.SPARQLAskValidator, false)) {
|
|
3975
|
+
yield SH.SPARQLAskValidator;
|
|
3976
|
+
}
|
|
3977
|
+
if (this.store.any(graphUris, null, rdf.type, sh.SPARQLSelectValidator, false)) {
|
|
3978
|
+
yield SH.SPARQLSelectValidator;
|
|
3979
|
+
}
|
|
3980
|
+
}
|
|
3981
|
+
/**
|
|
3982
|
+
* Get all target classes, nodes or properties of a given shape in the repository.
|
|
3983
|
+
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
3984
|
+
* @param shape The URI or blank id of the shape.
|
|
3985
|
+
* @param options Optional query parameters.
|
|
3986
|
+
* @returns An iterable of all targeted resources in the repository.
|
|
3987
|
+
*/
|
|
3988
|
+
*getShapeTargets(graphUris, shape, options) {
|
|
3989
|
+
const yielded = /* @__PURE__ */ new Set();
|
|
3990
|
+
for (let q of this.store.matchAll(graphUris, shape, rdf.type, rdfs.Class, true)) {
|
|
3991
|
+
if (!yielded.has(q.subject.value)) {
|
|
3992
|
+
yielded.add(q.subject.value);
|
|
3993
|
+
yield q.subject.value;
|
|
3994
|
+
}
|
|
3995
|
+
}
|
|
3996
|
+
for (let q of this.store.matchAll(graphUris, shape, sh.targetClass, null, options?.includeInferred)) {
|
|
3997
|
+
if (!yielded.has(q.object.value)) {
|
|
3998
|
+
yielded.add(q.object.value);
|
|
3999
|
+
yield q.object.value;
|
|
4000
|
+
}
|
|
4001
|
+
}
|
|
4002
|
+
for (let q of this.store.matchAll(graphUris, shape, sh.targetNode, null, options?.includeInferred)) {
|
|
4003
|
+
if (!yielded.has(q.object.value)) {
|
|
4004
|
+
yielded.add(q.object.value);
|
|
4005
|
+
yield q.object.value;
|
|
4006
|
+
}
|
|
4007
|
+
}
|
|
4008
|
+
for (let q of this.store.matchAll(graphUris, shape, sh.path, null, options?.includeInferred)) {
|
|
4009
|
+
if (!yielded.has(q.object.value)) {
|
|
4010
|
+
yielded.add(q.object.value);
|
|
4011
|
+
yield q.object.value;
|
|
4012
|
+
}
|
|
4013
|
+
}
|
|
4014
|
+
}
|
|
4015
|
+
/**
|
|
4016
|
+
* Indicate if there are shapes for a subject in the repository.
|
|
4017
|
+
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
4018
|
+
* @param subjectUri The URI of the subject.
|
|
4019
|
+
* @param options Optional query parameters.
|
|
4020
|
+
* @returns `true` if there are shapes for the subject, `false` otherwise.
|
|
4021
|
+
*/
|
|
4022
|
+
hasShapes(graphUris, subjectUri, options) {
|
|
4023
|
+
const s = namedNode6(subjectUri);
|
|
4024
|
+
for (let q of this.store.matchAll(graphUris, s, rdf.type, sh.Shape)) {
|
|
4025
|
+
if (!this.skip(graphUris, q.subject, options, { includeBlankNodes: true })) {
|
|
4026
|
+
return true;
|
|
4027
|
+
}
|
|
4028
|
+
}
|
|
4029
|
+
for (let q of this.store.matchAll(graphUris, null, sh.targetClass, s)) {
|
|
4030
|
+
if (!this.skip(graphUris, q.subject, options, { includeBlankNodes: true })) {
|
|
4031
|
+
return true;
|
|
4032
|
+
}
|
|
4033
|
+
}
|
|
4034
|
+
for (let q of this.store.matchAll(graphUris, null, sh.path, s)) {
|
|
4035
|
+
if (!this.skip(graphUris, q.subject, options, { includeBlankNodes: true })) {
|
|
4036
|
+
return true;
|
|
4037
|
+
}
|
|
4038
|
+
}
|
|
4039
|
+
return false;
|
|
4040
|
+
}
|
|
4041
|
+
/**
|
|
4042
|
+
* Indicate if there validators defined in the vocabulary.
|
|
4043
|
+
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
4044
|
+
* @param options Optional query parameters.
|
|
4045
|
+
* @returns A list of all validators in the repository.
|
|
4046
|
+
*/
|
|
4047
|
+
hasValidators(graphUris, options) {
|
|
4048
|
+
return this.hasSubjectsOfType(graphUris, SH.Validator, options);
|
|
4049
|
+
}
|
|
4050
|
+
/**
|
|
4051
|
+
* Get all validators in the repository.
|
|
4052
|
+
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
4053
|
+
* @param options Optional query parameters.
|
|
4054
|
+
* @returns A list of all validators in the repository.
|
|
4055
|
+
*/
|
|
4056
|
+
*getValidators(graphUris, options) {
|
|
4057
|
+
yield* this.getSubjectsOfType(graphUris, SH.Validator, options);
|
|
4058
|
+
}
|
|
4059
|
+
/**
|
|
4060
|
+
* Indicate if there are rules in the repository.
|
|
4061
|
+
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
4062
|
+
* @param subjectUri The URI of the subject.
|
|
4063
|
+
* @param options Optional query parameters.
|
|
4064
|
+
* @returns `true` if there are rules for the subject, `false` otherwise.
|
|
4065
|
+
*/
|
|
4066
|
+
hasRules(graphUris, options) {
|
|
4067
|
+
return this.hasSubjectsOfType(graphUris, SH.Rule, options);
|
|
4068
|
+
}
|
|
4069
|
+
/**
|
|
4070
|
+
* Get all rules in the repository.
|
|
4071
|
+
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
4072
|
+
* @param options Optional query parameters.
|
|
4073
|
+
* @returns A list of all rules in the repository.
|
|
4074
|
+
*/
|
|
4075
|
+
*getRules(graphUris, options) {
|
|
4076
|
+
yield* this.getSubjectsOfType(graphUris, SH.Rule, options);
|
|
4077
|
+
}
|
|
4078
|
+
/**
|
|
4079
|
+
* Get the SHACL datatype of a given property.
|
|
4080
|
+
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
4081
|
+
* @param subjectUri The URI of the subject.
|
|
4082
|
+
* @param options Optional query parameters.
|
|
4083
|
+
* @returns A datatype URI on success, `xsd:anyURI` otherwise.
|
|
4084
|
+
*/
|
|
4085
|
+
getDatatype(graphUris, subjectUri, options) {
|
|
4086
|
+
for (let q of this.store.matchAll(graphUris, null, sh.path, namedNode6(subjectUri), options?.includeInferred)) {
|
|
4087
|
+
for (let x of this.store.matchAll(graphUris, q.subject, sh.datatype, null, options?.includeInferred)) {
|
|
4088
|
+
return x.object.value;
|
|
4089
|
+
}
|
|
4090
|
+
}
|
|
4091
|
+
}
|
|
4092
|
+
/**
|
|
4093
|
+
* Get the SHACL cardinality constraints of a given property.
|
|
4094
|
+
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
4095
|
+
* @param subjectUri The URI of the subject.
|
|
4096
|
+
* @param options Optional query parameters.
|
|
4097
|
+
* @returns An object with the minimum and maximum cardinalities; values are `-1` if not found.
|
|
4098
|
+
*/
|
|
4099
|
+
getCardinalites(graphUris, subjectUri, options) {
|
|
4100
|
+
let minCount = -1;
|
|
4101
|
+
let maxCount = -1;
|
|
4102
|
+
for (let q of this.store.matchAll(graphUris, null, sh.path, namedNode6(subjectUri), options?.includeInferred)) {
|
|
4103
|
+
for (let x of this.store.matchAll(graphUris, q.subject, sh.minCount, null, options?.includeInferred)) {
|
|
4104
|
+
minCount = parseInt(x.object.value);
|
|
4105
|
+
break;
|
|
4106
|
+
}
|
|
4107
|
+
for (let x of this.store.matchAll(graphUris, q.subject, sh.maxCount, null, options?.includeInferred)) {
|
|
4108
|
+
maxCount = parseInt(x.object.value);
|
|
4109
|
+
break;
|
|
4110
|
+
}
|
|
4111
|
+
}
|
|
4112
|
+
return { minCount, maxCount };
|
|
4113
|
+
}
|
|
4114
|
+
/**
|
|
4115
|
+
* Get the RDF property path representation of the given SHACL property path. This method parses the SHACL property path and
|
|
4116
|
+
* returns the RDF property path as a combination of nodes and strings.
|
|
4117
|
+
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
4118
|
+
* @param subject The URI or blank id of the node referred to by sh:path.
|
|
4119
|
+
* @param options Optional query parameters.
|
|
4120
|
+
* @returns A flattened list of all path components, either as URIs or as strings.
|
|
4121
|
+
*/
|
|
4122
|
+
getPropertyPathTokens(graphUris, subject) {
|
|
4123
|
+
const visitedNodes = /* @__PURE__ */ new Set();
|
|
4124
|
+
const parse = (subject2, level, separator = "/", i = 0) => {
|
|
4125
|
+
if (visitedNodes.has(subject2.value)) {
|
|
4126
|
+
return [];
|
|
4127
|
+
}
|
|
4128
|
+
visitedNodes.add(subject2.value);
|
|
4129
|
+
if (subject2.termType === "NamedNode") {
|
|
4130
|
+
return [subject2];
|
|
4131
|
+
} else {
|
|
4132
|
+
const first = this.store.matchAll(graphUris, subject2, rdf.first, null, false).next().value;
|
|
4133
|
+
if (first) {
|
|
4134
|
+
const path = parse(first.object, level + 1);
|
|
4135
|
+
const rest = this.store.matchAll(graphUris, subject2, rdf.rest, null, false).next().value;
|
|
4136
|
+
if (rest && rest.object.value !== rdf.nil.value) {
|
|
4137
|
+
const tail = parse(rest.object, level, separator, i + 1);
|
|
4138
|
+
if (tail.length === 0) {
|
|
4139
|
+
return path;
|
|
4140
|
+
}
|
|
4141
|
+
if (i === 0 && level > 0) {
|
|
4142
|
+
return ["(", ...path, separator, ...tail, ")"];
|
|
4143
|
+
} else {
|
|
4144
|
+
return [...path, separator, ...tail];
|
|
4145
|
+
}
|
|
4146
|
+
}
|
|
4147
|
+
return path;
|
|
4148
|
+
} else {
|
|
4149
|
+
for (let q of this.store.matchAll(graphUris, subject2, null, null, false)) {
|
|
4150
|
+
switch (q.predicate.value) {
|
|
4151
|
+
case sh.inversePath.value: {
|
|
4152
|
+
return ["^", ...parse(q.object, level)];
|
|
4153
|
+
}
|
|
4154
|
+
case sh.zeroOrOnePath.value: {
|
|
4155
|
+
return [...parse(q.object, level), "?"];
|
|
4156
|
+
}
|
|
4157
|
+
case sh.zeroOrMorePath.value: {
|
|
4158
|
+
return [...parse(q.object, level), "*"];
|
|
4159
|
+
}
|
|
4160
|
+
case sh.oneOrMorePath.value: {
|
|
4161
|
+
return [...parse(q.object, level), "+"];
|
|
4162
|
+
}
|
|
4163
|
+
case sh.alternativePath.value: {
|
|
4164
|
+
return parse(q.object, level, "|");
|
|
4165
|
+
}
|
|
4166
|
+
default:
|
|
4167
|
+
throw new Error(`Unsupported path predicate: ${q.predicate.value}`);
|
|
4168
|
+
}
|
|
4169
|
+
}
|
|
4170
|
+
throw new Error(`Unsupported path subject: ${subject2}`);
|
|
4171
|
+
}
|
|
4172
|
+
}
|
|
4173
|
+
};
|
|
4174
|
+
return parse(subject, 0);
|
|
4175
|
+
}
|
|
4176
|
+
/**
|
|
4177
|
+
* Get the first discovered path from a given shape class to the sh:Shape root.
|
|
4178
|
+
* @param graphUris URIs of the graphs to search (should include the SHACL ontology graph).
|
|
4179
|
+
* @param subjectUri URI of a shape class.
|
|
4180
|
+
* @param options Optional query parameters.
|
|
4181
|
+
* @returns An iterator containing the path from the given class up to sh:Shape.
|
|
4182
|
+
*/
|
|
4183
|
+
*getRootShapePath(graphUris, subjectUri, options) {
|
|
4184
|
+
yield* this._getRootShapePath(graphUris, subjectUri, [], /* @__PURE__ */ new Set(), options);
|
|
4185
|
+
}
|
|
4186
|
+
_getRootShapePath(graphUris, subjectUri, path, backtrack, options) {
|
|
4187
|
+
for (let o of this.getSuperClasses(graphUris, subjectUri, options)) {
|
|
4188
|
+
if (o === SH.Shape) {
|
|
4189
|
+
return path;
|
|
4190
|
+
}
|
|
4191
|
+
if (!backtrack.has(o)) {
|
|
4192
|
+
backtrack.add(o);
|
|
4193
|
+
return this._getRootShapePath(graphUris, o, [...path, o], backtrack, options);
|
|
4194
|
+
}
|
|
4195
|
+
}
|
|
4196
|
+
return path;
|
|
4197
|
+
}
|
|
4198
|
+
};
|
|
4199
|
+
|
|
4200
|
+
// src/rdf/store.ts
|
|
4201
|
+
import * as n3 from "n3";
|
|
4202
|
+
|
|
4203
|
+
// src/ontologies/src.ts
|
|
4204
|
+
var owl2 = `@prefix dc: <http://purl.org/dc/elements/1.1/> .
|
|
4205
|
+
@prefix grddl: <http://www.w3.org/2003/g/data-view#> .
|
|
4206
|
+
@prefix owl: <http://www.w3.org/2002/07/owl#> .
|
|
4207
|
+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
|
4208
|
+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
|
4209
|
+
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
|
|
4210
|
+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
|
|
4211
|
+
|
|
4212
|
+
<http://www.w3.org/2002/07/owl#> a owl:Ontology ;
|
|
4213
|
+
dc:title "The OWL 2 Schema vocabulary (OWL 2)" ;
|
|
4214
|
+
rdfs:comment """
|
|
4215
|
+
This ontology partially describes the built-in classes and
|
|
4216
|
+
properties that together form the basis of the RDF/XML syntax of OWL 2.
|
|
4217
|
+
The content of this ontology is based on Tables 6.1 and 6.2
|
|
4218
|
+
in Section 6.4 of the OWL 2 RDF-Based Semantics specification,
|
|
4219
|
+
available at http://www.w3.org/TR/owl2-rdf-based-semantics/.
|
|
4220
|
+
Please note that those tables do not include the different annotations
|
|
4221
|
+
(labels, comments and rdfs:isDefinedBy links) used in this file.
|
|
4222
|
+
Also note that the descriptions provided in this ontology do not
|
|
4223
|
+
provide a complete and correct formal description of either the syntax
|
|
4224
|
+
or the semantics of the introduced terms (please see the OWL 2
|
|
4225
|
+
recommendations for the complete and normative specifications).
|
|
4226
|
+
Furthermore, the information provided by this ontology may be
|
|
4227
|
+
misleading if not used with care. This ontology SHOULD NOT be imported
|
|
4228
|
+
into OWL ontologies. Importing this file into an OWL 2 DL ontology
|
|
4229
|
+
will cause it to become an OWL 2 Full ontology and may have other,
|
|
4230
|
+
unexpected, consequences.
|
|
4231
|
+
""" ;
|
|
4232
|
+
rdfs:isDefinedBy
|
|
4233
|
+
<http://www.w3.org/TR/owl2-mapping-to-rdf/>,
|
|
4234
|
+
<http://www.w3.org/TR/owl2-rdf-based-semantics/>,
|
|
4235
|
+
<http://www.w3.org/TR/owl2-syntax/> ;
|
|
4236
|
+
rdfs:seeAlso <http://www.w3.org/TR/owl2-rdf-based-semantics/#table-axiomatic-classes>,
|
|
4237
|
+
<http://www.w3.org/TR/owl2-rdf-based-semantics/#table-axiomatic-properties> ;
|
|
4238
|
+
owl:imports <http://www.w3.org/2000/01/rdf-schema> ;
|
|
4239
|
+
owl:versionIRI <http://www.w3.org/2002/07/owl> ;
|
|
4240
|
+
owl:versionInfo "$Date: 2009/11/15 10:54:12 $" ;
|
|
4241
|
+
grddl:namespaceTransformation <http://dev.w3.org/cvsweb/2009/owl-grddl/owx2rdf.xsl> .
|
|
4242
|
+
|
|
4243
|
+
|
|
4244
|
+
owl:AllDifferent a rdfs:Class ;
|
|
4245
|
+
rdfs:label "AllDifferent" ;
|
|
4246
|
+
rdfs:comment "The class of collections of pairwise different individuals." ;
|
|
4247
|
+
rdfs:isDefinedBy <http://www.w3.org/2002/07/owl#> ;
|
|
4248
|
+
rdfs:subClassOf rdfs:Resource .
|
|
4249
|
+
|
|
4250
|
+
owl:AllDisjointClasses a rdfs:Class ;
|
|
4251
|
+
rdfs:label "AllDisjointClasses" ;
|
|
4252
|
+
rdfs:comment "The class of collections of pairwise disjoint classes." ;
|
|
4253
|
+
rdfs:isDefinedBy <http://www.w3.org/2002/07/owl#> ;
|
|
4254
|
+
rdfs:subClassOf rdfs:Resource .
|
|
4255
|
+
|
|
4256
|
+
owl:AllDisjointProperties a rdfs:Class ;
|
|
4257
|
+
rdfs:label "AllDisjointProperties" ;
|
|
4258
|
+
rdfs:comment "The class of collections of pairwise disjoint properties." ;
|
|
4259
|
+
rdfs:isDefinedBy <http://www.w3.org/2002/07/owl#> ;
|
|
4260
|
+
rdfs:subClassOf rdfs:Resource .
|
|
4261
|
+
|
|
4262
|
+
owl:Annotation a rdfs:Class ;
|
|
4263
|
+
rdfs:label "Annotation" ;
|
|
4264
|
+
rdfs:comment "The class of annotated annotations for which the RDF serialization consists of an annotated subject, predicate and object." ;
|
|
4265
|
+
rdfs:isDefinedBy <http://www.w3.org/2002/07/owl#> ;
|
|
4266
|
+
rdfs:subClassOf rdfs:Resource .
|
|
4267
|
+
|
|
4268
|
+
owl:AnnotationProperty a rdfs:Class ;
|
|
4269
|
+
rdfs:label "AnnotationProperty" ;
|
|
4270
|
+
rdfs:comment "The class of annotation properties." ;
|
|
4271
|
+
rdfs:isDefinedBy <http://www.w3.org/2002/07/owl#> ;
|
|
4272
|
+
rdfs:subClassOf rdf:Property .
|
|
4273
|
+
|
|
4274
|
+
owl:AsymmetricProperty a rdfs:Class ;
|
|
4275
|
+
rdfs:label "AsymmetricProperty" ;
|
|
4276
|
+
rdfs:comment "The class of asymmetric properties." ;
|
|
4277
|
+
rdfs:isDefinedBy <http://www.w3.org/2002/07/owl#> ;
|
|
4278
|
+
rdfs:subClassOf owl:ObjectProperty .
|
|
4279
|
+
|
|
4280
|
+
owl:Axiom a rdfs:Class ;
|
|
4281
|
+
rdfs:label "Axiom" ;
|
|
4282
|
+
rdfs:comment "The class of annotated axioms for which the RDF serialization consists of an annotated subject, predicate and object." ;
|
|
4283
|
+
rdfs:isDefinedBy <http://www.w3.org/2002/07/owl#> ;
|
|
4284
|
+
rdfs:subClassOf rdfs:Resource .
|
|
4285
|
+
|
|
4286
|
+
owl:Class a rdfs:Class ;
|
|
4287
|
+
rdfs:label "Class" ;
|
|
4288
|
+
rdfs:comment "The class of OWL classes." ;
|
|
4289
|
+
rdfs:isDefinedBy <http://www.w3.org/2002/07/owl#> ;
|
|
4290
|
+
rdfs:subClassOf rdfs:Class .
|
|
4291
|
+
|
|
4292
|
+
owl:DataRange a rdfs:Class ;
|
|
4293
|
+
rdfs:label "DataRange" ;
|
|
4294
|
+
rdfs:comment "The class of OWL data ranges, which are special kinds of datatypes. Note: The use of the IRI owl:DataRange has been deprecated as of OWL 2. The IRI rdfs:Datatype SHOULD be used instead." ;
|
|
4295
|
+
rdfs:isDefinedBy <http://www.w3.org/2002/07/owl#> ;
|
|
4296
|
+
rdfs:subClassOf rdfs:Datatype .
|
|
4297
|
+
|
|
4298
|
+
owl:DatatypeProperty a rdfs:Class ;
|
|
4299
|
+
rdfs:label "DatatypeProperty" ;
|
|
4300
|
+
rdfs:comment "The class of data properties." ;
|
|
4301
|
+
rdfs:isDefinedBy <http://www.w3.org/2002/07/owl#> ;
|
|
4302
|
+
rdfs:subClassOf rdf:Property .
|
|
4303
|
+
|
|
4304
|
+
owl:DeprecatedClass a rdfs:Class ;
|
|
4305
|
+
rdfs:label "DeprecatedClass" ;
|
|
4306
|
+
rdfs:comment "The class of deprecated classes." ;
|
|
4307
|
+
rdfs:isDefinedBy <http://www.w3.org/2002/07/owl#> ;
|
|
4308
|
+
rdfs:subClassOf rdfs:Class .
|
|
4309
|
+
|
|
4310
|
+
owl:DeprecatedProperty a rdfs:Class ;
|
|
4311
|
+
rdfs:label "DeprecatedProperty" ;
|
|
4312
|
+
rdfs:comment "The class of deprecated properties." ;
|
|
4313
|
+
rdfs:isDefinedBy <http://www.w3.org/2002/07/owl#> ;
|
|
4314
|
+
rdfs:subClassOf rdf:Property .
|
|
4315
|
+
|
|
4316
|
+
owl:FunctionalProperty a rdfs:Class ;
|
|
4317
|
+
rdfs:label "FunctionalProperty" ;
|
|
4318
|
+
rdfs:comment "The class of functional properties." ;
|
|
4319
|
+
rdfs:isDefinedBy <http://www.w3.org/2002/07/owl#> ;
|
|
4320
|
+
rdfs:subClassOf rdf:Property .
|
|
4321
|
+
|
|
4322
|
+
owl:InverseFunctionalProperty a rdfs:Class ;
|
|
4323
|
+
rdfs:label "InverseFunctionalProperty" ;
|
|
4324
|
+
rdfs:comment "The class of inverse-functional properties." ;
|
|
4325
|
+
rdfs:isDefinedBy <http://www.w3.org/2002/07/owl#> ;
|
|
4326
|
+
rdfs:subClassOf owl:ObjectProperty .
|
|
4327
|
+
|
|
4328
|
+
owl:IrreflexiveProperty a rdfs:Class ;
|
|
4329
|
+
rdfs:label "IrreflexiveProperty" ;
|
|
4330
|
+
rdfs:comment "The class of irreflexive properties." ;
|
|
4331
|
+
rdfs:isDefinedBy <http://www.w3.org/2002/07/owl#> ;
|
|
4332
|
+
rdfs:subClassOf owl:ObjectProperty .
|
|
4333
|
+
|
|
4334
|
+
owl:NamedIndividual a rdfs:Class ;
|
|
4335
|
+
rdfs:label "NamedIndividual" ;
|
|
4336
|
+
rdfs:comment "The class of named individuals." ;
|
|
4337
|
+
rdfs:isDefinedBy <http://www.w3.org/2002/07/owl#> ;
|
|
4338
|
+
rdfs:subClassOf owl:Thing .
|
|
4339
|
+
|
|
4340
|
+
owl:NegativePropertyAssertion a rdfs:Class ;
|
|
4341
|
+
rdfs:label "NegativePropertyAssertion" ;
|
|
4342
|
+
rdfs:comment "The class of negative property assertions." ;
|
|
4343
|
+
rdfs:isDefinedBy <http://www.w3.org/2002/07/owl#> ;
|
|
4344
|
+
rdfs:subClassOf rdfs:Resource .
|
|
4345
|
+
|
|
4346
|
+
owl:Nothing a owl:Class ;
|
|
4347
|
+
rdfs:label "Nothing" ;
|
|
4348
|
+
rdfs:comment "This is the empty class." ;
|
|
4349
|
+
rdfs:isDefinedBy <http://www.w3.org/2002/07/owl#> ;
|
|
4350
|
+
rdfs:subClassOf owl:Thing .
|
|
4351
|
+
|
|
4352
|
+
owl:ObjectProperty a rdfs:Class ;
|
|
4353
|
+
rdfs:label "ObjectProperty" ;
|
|
4354
|
+
rdfs:comment "The class of object properties." ;
|
|
4355
|
+
rdfs:isDefinedBy <http://www.w3.org/2002/07/owl#> ;
|
|
4356
|
+
rdfs:subClassOf rdf:Property .
|
|
4357
|
+
|
|
4358
|
+
owl:Ontology a rdfs:Class ;
|
|
4359
|
+
rdfs:label "Ontology" ;
|
|
4360
|
+
rdfs:comment "The class of ontologies." ;
|
|
4361
|
+
rdfs:isDefinedBy <http://www.w3.org/2002/07/owl#> ;
|
|
4362
|
+
rdfs:subClassOf rdfs:Resource .
|
|
4363
|
+
|
|
4364
|
+
owl:OntologyProperty a rdfs:Class ;
|
|
4365
|
+
rdfs:label "OntologyProperty" ;
|
|
4366
|
+
rdfs:comment "The class of ontology properties." ;
|
|
4367
|
+
rdfs:isDefinedBy <http://www.w3.org/2002/07/owl#> ;
|
|
4368
|
+
rdfs:subClassOf rdf:Property .
|
|
4369
|
+
|
|
4370
|
+
owl:ReflexiveProperty a rdfs:Class ;
|
|
4371
|
+
rdfs:label "ReflexiveProperty" ;
|
|
4372
|
+
rdfs:comment "The class of reflexive properties." ;
|
|
4373
|
+
rdfs:isDefinedBy <http://www.w3.org/2002/07/owl#> ;
|
|
4374
|
+
rdfs:subClassOf owl:ObjectProperty .
|
|
4375
|
+
|
|
4376
|
+
owl:Restriction a rdfs:Class ;
|
|
4377
|
+
rdfs:label "Restriction" ;
|
|
4378
|
+
rdfs:comment "The class of property restrictions." ;
|
|
4379
|
+
rdfs:isDefinedBy <http://www.w3.org/2002/07/owl#> ;
|
|
4380
|
+
rdfs:subClassOf owl:Class .
|
|
4381
|
+
|
|
4382
|
+
owl:SymmetricProperty a rdfs:Class ;
|
|
4383
|
+
rdfs:label "SymmetricProperty" ;
|
|
4384
|
+
rdfs:comment "The class of symmetric properties." ;
|
|
4385
|
+
rdfs:isDefinedBy <http://www.w3.org/2002/07/owl#> ;
|
|
4386
|
+
rdfs:subClassOf owl:ObjectProperty .
|
|
4387
|
+
|
|
4388
|
+
owl:TransitiveProperty a rdfs:Class ;
|
|
4389
|
+
rdfs:label "TransitiveProperty" ;
|
|
4390
|
+
rdfs:comment "The class of transitive properties." ;
|
|
4391
|
+
rdfs:isDefinedBy <http://www.w3.org/2002/07/owl#> ;
|
|
4392
|
+
rdfs:subClassOf owl:ObjectProperty .
|
|
4393
|
+
|
|
4394
|
+
owl:Thing a owl:Class ;
|
|
4395
|
+
rdfs:label "Thing" ;
|
|
4396
|
+
rdfs:comment "The class of OWL individuals." ;
|
|
4397
|
+
rdfs:isDefinedBy <http://www.w3.org/2002/07/owl#> .
|
|
4398
|
+
|
|
4399
|
+
owl:allValuesFrom a rdf:Property ;
|
|
4400
|
+
rdfs:label "allValuesFrom" ;
|
|
4401
|
+
rdfs:comment "The property that determines the class that a universal property restriction refers to." ;
|
|
4402
|
+
rdfs:domain owl:Restriction ;
|
|
4403
|
+
rdfs:isDefinedBy <http://www.w3.org/2002/07/owl#> ;
|
|
4404
|
+
rdfs:range rdfs:Class .
|
|
4405
|
+
|
|
4406
|
+
owl:annotatedProperty a rdf:Property ;
|
|
4407
|
+
rdfs:label "annotatedProperty" ;
|
|
4408
|
+
rdfs:comment "The property that determines the predicate of an annotated axiom or annotated annotation." ;
|
|
4409
|
+
rdfs:domain rdfs:Resource ;
|
|
4410
|
+
rdfs:isDefinedBy <http://www.w3.org/2002/07/owl#> ;
|
|
4411
|
+
rdfs:range rdfs:Resource .
|
|
4412
|
+
|
|
4413
|
+
owl:annotatedSource a rdf:Property ;
|
|
4414
|
+
rdfs:label "annotatedSource" ;
|
|
4415
|
+
rdfs:comment "The property that determines the subject of an annotated axiom or annotated annotation." ;
|
|
4416
|
+
rdfs:domain rdfs:Resource ;
|
|
4417
|
+
rdfs:isDefinedBy <http://www.w3.org/2002/07/owl#> ;
|
|
4418
|
+
rdfs:range rdfs:Resource .
|
|
4419
|
+
|
|
4420
|
+
owl:annotatedTarget a rdf:Property ;
|
|
4421
|
+
rdfs:label "annotatedTarget" ;
|
|
4422
|
+
rdfs:comment "The property that determines the object of an annotated axiom or annotated annotation." ;
|
|
4423
|
+
rdfs:domain rdfs:Resource ;
|
|
4424
|
+
rdfs:isDefinedBy <http://www.w3.org/2002/07/owl#> ;
|
|
4425
|
+
rdfs:range rdfs:Resource .
|
|
4426
|
+
|
|
4427
|
+
owl:assertionProperty a rdf:Property ;
|
|
4428
|
+
rdfs:label "assertionProperty" ;
|
|
4429
|
+
rdfs:comment "The property that determines the predicate of a negative property assertion." ;
|
|
4430
|
+
rdfs:domain owl:NegativePropertyAssertion ;
|
|
4431
|
+
rdfs:isDefinedBy <http://www.w3.org/2002/07/owl#> ;
|
|
4432
|
+
rdfs:range rdf:Property .
|
|
4433
|
+
|
|
4434
|
+
owl:backwardCompatibleWith a owl:AnnotationProperty, owl:OntologyProperty ;
|
|
4435
|
+
rdfs:label "backwardCompatibleWith" ;
|
|
4436
|
+
rdfs:comment "The annotation property that indicates that a given ontology is backward compatible with another ontology." ;
|
|
4437
|
+
rdfs:domain owl:Ontology ;
|
|
4438
|
+
rdfs:isDefinedBy <http://www.w3.org/2002/07/owl#> ;
|
|
4439
|
+
rdfs:range owl:Ontology .
|
|
4440
|
+
|
|
4441
|
+
owl:bottomDataProperty a owl:DatatypeProperty ;
|
|
4442
|
+
rdfs:label "bottomDataProperty" ;
|
|
4443
|
+
rdfs:comment "The data property that does not relate any individual to any data value." ;
|
|
4444
|
+
rdfs:domain owl:Thing ;
|
|
4445
|
+
rdfs:isDefinedBy <http://www.w3.org/2002/07/owl#> ;
|
|
4446
|
+
rdfs:range rdfs:Literal .
|
|
4447
|
+
|
|
4448
|
+
owl:bottomObjectProperty a owl:ObjectProperty ;
|
|
4449
|
+
rdfs:label "bottomObjectProperty" ;
|
|
4450
|
+
rdfs:comment "The object property that does not relate any two individuals." ;
|
|
4451
|
+
rdfs:domain owl:Thing ;
|
|
4452
|
+
rdfs:isDefinedBy <http://www.w3.org/2002/07/owl#> ;
|
|
4453
|
+
rdfs:range owl:Thing .
|
|
4149
4454
|
|
|
4150
4455
|
owl:cardinality a rdf:Property ;
|
|
4151
4456
|
rdfs:label "cardinality" ;
|
|
@@ -7074,444 +7379,155 @@ var Store = class {
|
|
|
7074
7379
|
});
|
|
7075
7380
|
}
|
|
7076
7381
|
/**
|
|
7077
|
-
* Indicates if the store contains triples in a given graph.
|
|
7078
|
-
* @param graphUri A graph URI.
|
|
7079
|
-
* @returns `true` if the store contains triples in the graph URI, `false` otherwise.
|
|
7080
|
-
*/
|
|
7081
|
-
hasGraph(graphUri) {
|
|
7082
|
-
const uri = typeof graphUri === "string" ? this.dataFactory.namedNode(graphUri) : graphUri;
|
|
7083
|
-
for (const _ of this._ds.match(null, null, null, uri)) {
|
|
7084
|
-
return true;
|
|
7085
|
-
}
|
|
7086
|
-
return false;
|
|
7087
|
-
}
|
|
7088
|
-
/**
|
|
7089
|
-
* Apply inference to the given graph and store the triples in the associated inference graph.
|
|
7090
|
-
* @param graphUri A graph URI.
|
|
7091
|
-
*/
|
|
7092
|
-
executeInference(graphUri) {
|
|
7093
|
-
if (this.reasoner) {
|
|
7094
|
-
this.reasoner.expand(this._ds, graphUri);
|
|
7095
|
-
}
|
|
7096
|
-
}
|
|
7097
|
-
/**
|
|
7098
|
-
* Delete named graphs from the store.
|
|
7099
|
-
* @param graphUris URIs of the graphs to be deleted.
|
|
7100
|
-
*/
|
|
7101
|
-
deleteGraphs(graphUris) {
|
|
7102
|
-
for (const graphUri of graphUris) {
|
|
7103
|
-
const graph2 = this.dataFactory.namedNode(graphUri);
|
|
7104
|
-
for (const quad5 of this._ds.match(null, null, null, graph2)) {
|
|
7105
|
-
this._ds.delete(quad5);
|
|
7106
|
-
}
|
|
7107
|
-
}
|
|
7108
|
-
}
|
|
7109
|
-
/**
|
|
7110
|
-
* Get the URIs of ordered list members in the store.
|
|
7111
|
-
* @param graphUris Optional graph URI or array of graph URIs to query.
|
|
7112
|
-
* @param listUri URI of the list to get the items from.
|
|
7113
|
-
* @returns An array of URIs of the items in the list.
|
|
7114
|
-
*/
|
|
7115
|
-
getListItems(graphUris, listUri) {
|
|
7116
|
-
const list = listUri.includes(":") ? this.dataFactory.namedNode(listUri) : this.dataFactory.blankNode(listUri);
|
|
7117
|
-
return this._getListItems(graphUris, list).map((t) => t.value);
|
|
7118
|
-
}
|
|
7119
|
-
_getListItems(graphUris, subject) {
|
|
7120
|
-
const first = Array.from(this.matchAll(graphUris, subject, rdf.first, null));
|
|
7121
|
-
if (!first.length) {
|
|
7122
|
-
return [];
|
|
7123
|
-
}
|
|
7124
|
-
const rest = Array.from(this.matchAll(graphUris, subject, rdf.rest, null));
|
|
7125
|
-
const firstItem = first[0].object;
|
|
7126
|
-
const restList = rest[0]?.object;
|
|
7127
|
-
if (restList.value === RDF.nil) {
|
|
7128
|
-
return [firstItem];
|
|
7129
|
-
} else {
|
|
7130
|
-
const restItems = this._getListItems(graphUris, restList);
|
|
7131
|
-
return [firstItem, ...restItems];
|
|
7132
|
-
}
|
|
7133
|
-
}
|
|
7134
|
-
/**
|
|
7135
|
-
* Returns the exact cardinality of the quads matching the pattern.
|
|
7136
|
-
* @param subject The optional subject.
|
|
7137
|
-
* @param predicate The optional predicate.
|
|
7138
|
-
* @param object The optional object.
|
|
7139
|
-
* @param graph The optional graph.
|
|
7140
|
-
*/
|
|
7141
|
-
countQuads(subject, predicate, object, graph2) {
|
|
7142
|
-
return this._store.countQuads(subject, predicate, object, graph2);
|
|
7143
|
-
}
|
|
7144
|
-
/**
|
|
7145
|
-
* Returns a stream of quads matching the given pattern.
|
|
7146
|
-
* @param subject The optional subject.
|
|
7147
|
-
* @param predicate The optional predicate.
|
|
7148
|
-
* @param object The optional object.
|
|
7149
|
-
* @param graph The optional graph.
|
|
7150
|
-
* @returns A stream of matching quads.
|
|
7151
|
-
*/
|
|
7152
|
-
match(subject, predicate, object, graph2) {
|
|
7153
|
-
return this._store.match(subject, predicate, object, graph2);
|
|
7154
|
-
}
|
|
7155
|
-
/**
|
|
7156
|
-
* Query the store for triples matching the given pattern supporting multiple graphs.
|
|
7157
|
-
* @param graphUris Optional graph URI or array of graph URIs to query.
|
|
7158
|
-
* @param subject A subject URI or null to match any subject.
|
|
7159
|
-
* @param predicate A predicate URI or null to match any predicate.
|
|
7160
|
-
* @param object An object URI or null to match any object.
|
|
7161
|
-
*/
|
|
7162
|
-
*matchAll(graphUris, subject, predicate, object, includeInferred) {
|
|
7163
|
-
if (includeInferred && !this.reasoner) {
|
|
7164
|
-
throw new Error("Reasoner is not available to include inferred triples.");
|
|
7165
|
-
}
|
|
7166
|
-
const s = subject;
|
|
7167
|
-
const p = predicate;
|
|
7168
|
-
const o = object;
|
|
7169
|
-
if (graphUris !== void 0) {
|
|
7170
|
-
const graphs = Array.isArray(graphUris) ? graphUris : [graphUris];
|
|
7171
|
-
for (const graph2 of graphs.map((g) => this.dataFactory.namedNode(g))) {
|
|
7172
|
-
for (const q of this._ds.match(s, p, o, graph2)) {
|
|
7173
|
-
yield q;
|
|
7174
|
-
}
|
|
7175
|
-
if (includeInferred !== false && this.reasoner) {
|
|
7176
|
-
const inferenceGraphUri = this.reasoner.targetUriGenerator.getGraphUri(graph2.value);
|
|
7177
|
-
const inferenceGraph = this.dataFactory.namedNode(inferenceGraphUri);
|
|
7178
|
-
for (let q of this._ds.match(s, p, o, inferenceGraph)) {
|
|
7179
|
-
yield q;
|
|
7180
|
-
}
|
|
7181
|
-
}
|
|
7182
|
-
}
|
|
7183
|
-
} else {
|
|
7184
|
-
yield* this._ds.match(s, p, o);
|
|
7185
|
-
}
|
|
7186
|
-
}
|
|
7187
|
-
/**
|
|
7188
|
-
* Indicate if there are triples matching the given pattern in the store.
|
|
7189
|
-
* @param graphUris Optional graph URI or array of graph URIs to query.
|
|
7190
|
-
* @param subject A subject URI or null to match any subject.
|
|
7191
|
-
* @param predicate A predicate URI or null to match any predicate.
|
|
7192
|
-
* @param object An object URI or null to match any object.
|
|
7193
|
-
* @returns `true` if there are triples matching the pattern, `false` otherwise.
|
|
7194
|
-
*/
|
|
7195
|
-
any(graphUris, subject, predicate, object, includeInferred) {
|
|
7196
|
-
return this.matchAll(graphUris, subject, predicate, object, includeInferred).next().done === false;
|
|
7197
|
-
}
|
|
7198
|
-
/**
|
|
7199
|
-
* Get the first triple matching the given pattern in the store.
|
|
7200
|
-
* @param graphUris Optional graph URI or array of graph URIs to query.
|
|
7201
|
-
* @param subject A subject URI or null to match any subject.
|
|
7202
|
-
* @param predicate A predicate URI or null to match any predicate.
|
|
7203
|
-
* @param object An object URI or null to match any object.
|
|
7204
|
-
* @returns The first triple that matches the pattern.
|
|
7205
|
-
* @throws {TripleNotFoundError} If no triple is found matching the pattern.
|
|
7206
|
-
*/
|
|
7207
|
-
first(graphUris, subject, predicate, object, includeInferred) {
|
|
7208
|
-
const result = this.matchAll(graphUris, subject, predicate, object, includeInferred).next().value;
|
|
7209
|
-
if (!result) {
|
|
7210
|
-
throw new TripleNotFoundError(subject, predicate, object);
|
|
7211
|
-
}
|
|
7212
|
-
return result;
|
|
7213
|
-
}
|
|
7214
|
-
};
|
|
7215
|
-
|
|
7216
|
-
// src/rdf/shape-repository.ts
|
|
7217
|
-
var { namedNode: namedNode7 } = dataFactory;
|
|
7218
|
-
var ShapeRepository = class extends IndividualRepository {
|
|
7219
|
-
constructor(store) {
|
|
7220
|
-
super(store);
|
|
7221
|
-
}
|
|
7222
|
-
/**
|
|
7223
|
-
* Get all shapes in the repository.
|
|
7224
|
-
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
7225
|
-
* @param options Optional query parameters.
|
|
7226
|
-
* @returns An iterable of all shapes in the repository.
|
|
7227
|
-
*/
|
|
7228
|
-
*getShapes(graphUris, subjectUri, options) {
|
|
7229
|
-
const yielded = /* @__PURE__ */ new Set();
|
|
7230
|
-
if (!subjectUri) {
|
|
7231
|
-
for (let q of this.store.matchAll(graphUris, null, rdf.type, sh.Shape, options?.includeInferred)) {
|
|
7232
|
-
if (!yielded.has(q.subject.value) && !this.skip(graphUris, q.subject, options)) {
|
|
7233
|
-
yielded.add(q.subject.value);
|
|
7234
|
-
yield q.subject.value;
|
|
7235
|
-
}
|
|
7236
|
-
}
|
|
7237
|
-
} else {
|
|
7238
|
-
const s = namedNode7(subjectUri);
|
|
7239
|
-
for (let q of this.store.matchAll(graphUris, s, rdf.type, sh.Shape, options?.includeInferred)) {
|
|
7240
|
-
if (!yielded.has(q.subject.value) && !this.skip(graphUris, q.subject, options)) {
|
|
7241
|
-
yielded.add(q.subject.value);
|
|
7242
|
-
yield q.subject.value;
|
|
7243
|
-
}
|
|
7244
|
-
}
|
|
7245
|
-
for (let q of this.store.matchAll(graphUris, null, sh.targetClass, s, options?.includeInferred)) {
|
|
7246
|
-
if (!yielded.has(q.subject.value) && !this.skip(graphUris, q.subject, options)) {
|
|
7247
|
-
yielded.add(q.subject.value);
|
|
7248
|
-
yield q.subject.value;
|
|
7249
|
-
}
|
|
7250
|
-
}
|
|
7251
|
-
for (let q of this.store.matchAll(graphUris, null, sh.path, s, options?.includeInferred)) {
|
|
7252
|
-
if (!yielded.has(q.subject.value) && !this.skip(graphUris, q.subject, options)) {
|
|
7253
|
-
yielded.add(q.subject.value);
|
|
7254
|
-
yield q.subject.value;
|
|
7255
|
-
}
|
|
7256
|
-
}
|
|
7257
|
-
}
|
|
7258
|
-
}
|
|
7259
|
-
/**
|
|
7260
|
-
* Get all shape types in the repository.
|
|
7261
|
-
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
7262
|
-
* @param options Optional query parameters.
|
|
7263
|
-
* @returns A list of all shape types in the repository.
|
|
7264
|
-
*/
|
|
7265
|
-
*getShapeTypes(graphUris, options) {
|
|
7266
|
-
for (let q of this.store.matchAll(graphUris, null, rdf.type, sh.NodeShape)) {
|
|
7267
|
-
if (!this.skip(graphUris, q.subject, options, { includeBlankNodes: true })) {
|
|
7268
|
-
yield SH.NodeShape;
|
|
7269
|
-
break;
|
|
7270
|
-
}
|
|
7271
|
-
}
|
|
7272
|
-
for (let q of this.store.matchAll(graphUris, null, rdf.type, sh.PropertyShape)) {
|
|
7273
|
-
if (!this.skip(graphUris, q.subject, options, { includeBlankNodes: true })) {
|
|
7274
|
-
yield SH.PropertyShape;
|
|
7275
|
-
break;
|
|
7276
|
-
}
|
|
7277
|
-
}
|
|
7278
|
-
}
|
|
7279
|
-
/**
|
|
7280
|
-
* Get all validator types in the repository.
|
|
7281
|
-
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
7282
|
-
* @param options Optional query parameters.
|
|
7283
|
-
* @returns An iterable of all shape types in the repository.
|
|
7284
|
-
*/
|
|
7285
|
-
*getValidatorTypes(graphUris, options) {
|
|
7286
|
-
if (this.store.any(graphUris, null, rdf.type, sh.Validator, options?.includeInferred)) {
|
|
7287
|
-
yield SH.Validator;
|
|
7288
|
-
}
|
|
7289
|
-
if (this.store.any(graphUris, null, rdf.type, sh.JSValidator, false)) {
|
|
7290
|
-
yield SH.JSValidator;
|
|
7291
|
-
}
|
|
7292
|
-
if (this.store.any(graphUris, null, rdf.type, sh.SPARQLAskValidator, false)) {
|
|
7293
|
-
yield SH.SPARQLAskValidator;
|
|
7294
|
-
}
|
|
7295
|
-
if (this.store.any(graphUris, null, rdf.type, sh.SPARQLSelectValidator, false)) {
|
|
7296
|
-
yield SH.SPARQLSelectValidator;
|
|
7297
|
-
}
|
|
7298
|
-
}
|
|
7299
|
-
/**
|
|
7300
|
-
* Get all target classes, nodes or properties of a given shape in the repository.
|
|
7301
|
-
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
7302
|
-
* @param shape The URI or blank id of the shape.
|
|
7303
|
-
* @param options Optional query parameters.
|
|
7304
|
-
* @returns An iterable of all targeted resources in the repository.
|
|
7305
|
-
*/
|
|
7306
|
-
*getShapeTargets(graphUris, shape, options) {
|
|
7307
|
-
const yielded = /* @__PURE__ */ new Set();
|
|
7308
|
-
for (let q of this.store.matchAll(graphUris, shape, rdf.type, rdfs.Class, true)) {
|
|
7309
|
-
if (!yielded.has(q.subject.value)) {
|
|
7310
|
-
yielded.add(q.subject.value);
|
|
7311
|
-
yield q.subject.value;
|
|
7312
|
-
}
|
|
7313
|
-
}
|
|
7314
|
-
for (let q of this.store.matchAll(graphUris, shape, sh.targetClass, null, options?.includeInferred)) {
|
|
7315
|
-
if (!yielded.has(q.object.value)) {
|
|
7316
|
-
yielded.add(q.object.value);
|
|
7317
|
-
yield q.object.value;
|
|
7318
|
-
}
|
|
7319
|
-
}
|
|
7320
|
-
for (let q of this.store.matchAll(graphUris, shape, sh.targetNode, null, options?.includeInferred)) {
|
|
7321
|
-
if (!yielded.has(q.object.value)) {
|
|
7322
|
-
yielded.add(q.object.value);
|
|
7323
|
-
yield q.object.value;
|
|
7324
|
-
}
|
|
7325
|
-
}
|
|
7326
|
-
for (let q of this.store.matchAll(graphUris, shape, sh.path, null, options?.includeInferred)) {
|
|
7327
|
-
if (!yielded.has(q.object.value)) {
|
|
7328
|
-
yielded.add(q.object.value);
|
|
7329
|
-
yield q.object.value;
|
|
7330
|
-
}
|
|
7331
|
-
}
|
|
7332
|
-
}
|
|
7333
|
-
/**
|
|
7334
|
-
* Indicate if there are shapes for a subject in the repository.
|
|
7335
|
-
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
7336
|
-
* @param subjectUri The URI of the subject.
|
|
7337
|
-
* @param options Optional query parameters.
|
|
7338
|
-
* @returns `true` if there are shapes for the subject, `false` otherwise.
|
|
7382
|
+
* Indicates if the store contains triples in a given graph.
|
|
7383
|
+
* @param graphUri A graph URI.
|
|
7384
|
+
* @returns `true` if the store contains triples in the graph URI, `false` otherwise.
|
|
7339
7385
|
*/
|
|
7340
|
-
|
|
7341
|
-
const
|
|
7342
|
-
for (
|
|
7343
|
-
|
|
7344
|
-
return true;
|
|
7345
|
-
}
|
|
7346
|
-
}
|
|
7347
|
-
for (let q of this.store.matchAll(graphUris, null, sh.targetClass, s)) {
|
|
7348
|
-
if (!this.skip(graphUris, q.subject, options, { includeBlankNodes: true })) {
|
|
7349
|
-
return true;
|
|
7350
|
-
}
|
|
7351
|
-
}
|
|
7352
|
-
for (let q of this.store.matchAll(graphUris, null, sh.path, s)) {
|
|
7353
|
-
if (!this.skip(graphUris, q.subject, options, { includeBlankNodes: true })) {
|
|
7354
|
-
return true;
|
|
7355
|
-
}
|
|
7386
|
+
hasGraph(graphUri) {
|
|
7387
|
+
const uri = typeof graphUri === "string" ? this.dataFactory.namedNode(graphUri) : graphUri;
|
|
7388
|
+
for (const _ of this._ds.match(null, null, null, uri)) {
|
|
7389
|
+
return true;
|
|
7356
7390
|
}
|
|
7357
7391
|
return false;
|
|
7358
7392
|
}
|
|
7359
7393
|
/**
|
|
7360
|
-
*
|
|
7361
|
-
* @param
|
|
7362
|
-
* @param options Optional query parameters.
|
|
7363
|
-
* @returns A list of all validators in the repository.
|
|
7394
|
+
* Apply inference to the given graph and store the triples in the associated inference graph.
|
|
7395
|
+
* @param graphUri A graph URI.
|
|
7364
7396
|
*/
|
|
7365
|
-
|
|
7366
|
-
|
|
7397
|
+
executeInference(graphUri) {
|
|
7398
|
+
if (this.reasoner) {
|
|
7399
|
+
this.reasoner.expand(this._ds, graphUri);
|
|
7400
|
+
}
|
|
7367
7401
|
}
|
|
7368
7402
|
/**
|
|
7369
|
-
*
|
|
7370
|
-
* @param graphUris URIs of the graphs to
|
|
7371
|
-
* @param options Optional query parameters.
|
|
7372
|
-
* @returns A list of all validators in the repository.
|
|
7403
|
+
* Delete named graphs from the store.
|
|
7404
|
+
* @param graphUris URIs of the graphs to be deleted.
|
|
7373
7405
|
*/
|
|
7374
|
-
|
|
7375
|
-
|
|
7406
|
+
deleteGraphs(graphUris) {
|
|
7407
|
+
for (const graphUri of graphUris) {
|
|
7408
|
+
const graph2 = this.dataFactory.namedNode(graphUri);
|
|
7409
|
+
for (const quad5 of this._ds.match(null, null, null, graph2)) {
|
|
7410
|
+
this._ds.delete(quad5);
|
|
7411
|
+
}
|
|
7412
|
+
}
|
|
7376
7413
|
}
|
|
7377
7414
|
/**
|
|
7378
|
-
*
|
|
7379
|
-
* @param graphUris
|
|
7380
|
-
* @param
|
|
7381
|
-
* @
|
|
7382
|
-
* @returns `true` if there are rules for the subject, `false` otherwise.
|
|
7415
|
+
* Get the URIs of ordered list members in the store.
|
|
7416
|
+
* @param graphUris Optional graph URI or array of graph URIs to query.
|
|
7417
|
+
* @param listUri URI of the list to get the items from.
|
|
7418
|
+
* @returns An array of URIs of the items in the list.
|
|
7383
7419
|
*/
|
|
7384
|
-
|
|
7385
|
-
|
|
7420
|
+
getListItems(graphUris, listUri) {
|
|
7421
|
+
const list = listUri.includes(":") ? this.dataFactory.namedNode(listUri) : this.dataFactory.blankNode(listUri);
|
|
7422
|
+
return this._getListItems(graphUris, list).map((t) => t.value);
|
|
7423
|
+
}
|
|
7424
|
+
_getListItems(graphUris, subject) {
|
|
7425
|
+
const first = Array.from(this.matchAll(graphUris, subject, rdf.first, null));
|
|
7426
|
+
if (!first.length) {
|
|
7427
|
+
return [];
|
|
7428
|
+
}
|
|
7429
|
+
const rest = Array.from(this.matchAll(graphUris, subject, rdf.rest, null));
|
|
7430
|
+
const firstItem = first[0].object;
|
|
7431
|
+
const restList = rest[0]?.object;
|
|
7432
|
+
if (restList.value === RDF.nil) {
|
|
7433
|
+
return [firstItem];
|
|
7434
|
+
} else {
|
|
7435
|
+
const restItems = this._getListItems(graphUris, restList);
|
|
7436
|
+
return [firstItem, ...restItems];
|
|
7437
|
+
}
|
|
7386
7438
|
}
|
|
7387
7439
|
/**
|
|
7388
|
-
*
|
|
7389
|
-
* @param
|
|
7390
|
-
* @param
|
|
7391
|
-
* @
|
|
7440
|
+
* Returns the exact cardinality of the quads matching the pattern.
|
|
7441
|
+
* @param subject The optional subject.
|
|
7442
|
+
* @param predicate The optional predicate.
|
|
7443
|
+
* @param object The optional object.
|
|
7444
|
+
* @param graph The optional graph.
|
|
7392
7445
|
*/
|
|
7393
|
-
|
|
7394
|
-
|
|
7446
|
+
countQuads(subject, predicate, object, graph2) {
|
|
7447
|
+
return this._store.countQuads(subject, predicate, object, graph2);
|
|
7395
7448
|
}
|
|
7396
7449
|
/**
|
|
7397
|
-
*
|
|
7398
|
-
* @param
|
|
7399
|
-
* @param
|
|
7400
|
-
* @param
|
|
7401
|
-
* @
|
|
7450
|
+
* Returns a stream of quads matching the given pattern.
|
|
7451
|
+
* @param subject The optional subject.
|
|
7452
|
+
* @param predicate The optional predicate.
|
|
7453
|
+
* @param object The optional object.
|
|
7454
|
+
* @param graph The optional graph.
|
|
7455
|
+
* @returns A stream of matching quads.
|
|
7402
7456
|
*/
|
|
7403
|
-
|
|
7404
|
-
|
|
7405
|
-
for (let x of this.store.matchAll(graphUris, q.subject, sh.datatype, null, options?.includeInferred)) {
|
|
7406
|
-
return x.object.value;
|
|
7407
|
-
}
|
|
7408
|
-
}
|
|
7457
|
+
match(subject, predicate, object, graph2) {
|
|
7458
|
+
return this._store.match(subject, predicate, object, graph2);
|
|
7409
7459
|
}
|
|
7410
7460
|
/**
|
|
7411
|
-
*
|
|
7412
|
-
* @param graphUris
|
|
7413
|
-
* @param
|
|
7414
|
-
* @param
|
|
7415
|
-
* @
|
|
7461
|
+
* Query the store for triples matching the given pattern supporting multiple graphs.
|
|
7462
|
+
* @param graphUris Optional graph URI or array of graph URIs to query.
|
|
7463
|
+
* @param subject A subject URI or null to match any subject.
|
|
7464
|
+
* @param predicate A predicate URI or null to match any predicate.
|
|
7465
|
+
* @param object An object URI or null to match any object.
|
|
7416
7466
|
*/
|
|
7417
|
-
|
|
7418
|
-
|
|
7419
|
-
|
|
7420
|
-
|
|
7421
|
-
|
|
7422
|
-
|
|
7423
|
-
|
|
7424
|
-
|
|
7425
|
-
|
|
7426
|
-
|
|
7427
|
-
|
|
7467
|
+
*matchAll(graphUris, subject, predicate, object, includeInferred) {
|
|
7468
|
+
if (includeInferred && !this.reasoner) {
|
|
7469
|
+
throw new Error("Reasoner is not available to include inferred triples.");
|
|
7470
|
+
}
|
|
7471
|
+
const s = subject;
|
|
7472
|
+
const p = predicate;
|
|
7473
|
+
const o = object;
|
|
7474
|
+
if (graphUris !== void 0) {
|
|
7475
|
+
const graphs = Array.isArray(graphUris) ? graphUris : [graphUris];
|
|
7476
|
+
for (const graph2 of graphs.map((g) => this.dataFactory.namedNode(g))) {
|
|
7477
|
+
for (const q of this._ds.match(s, p, o, graph2)) {
|
|
7478
|
+
yield q;
|
|
7479
|
+
}
|
|
7480
|
+
if (includeInferred !== false && this.reasoner) {
|
|
7481
|
+
const inferenceGraphUri = this.reasoner.targetUriGenerator.getGraphUri(graph2.value);
|
|
7482
|
+
const inferenceGraph = this.dataFactory.namedNode(inferenceGraphUri);
|
|
7483
|
+
for (let q of this._ds.match(s, p, o, inferenceGraph)) {
|
|
7484
|
+
yield q;
|
|
7485
|
+
}
|
|
7486
|
+
}
|
|
7428
7487
|
}
|
|
7488
|
+
} else {
|
|
7489
|
+
yield* this._ds.match(s, p, o);
|
|
7429
7490
|
}
|
|
7430
|
-
return { minCount, maxCount };
|
|
7431
7491
|
}
|
|
7432
7492
|
/**
|
|
7433
|
-
*
|
|
7434
|
-
*
|
|
7435
|
-
* @param
|
|
7436
|
-
* @param
|
|
7437
|
-
* @param
|
|
7438
|
-
* @returns
|
|
7493
|
+
* Indicate if there are triples matching the given pattern in the store.
|
|
7494
|
+
* @param graphUris Optional graph URI or array of graph URIs to query.
|
|
7495
|
+
* @param subject A subject URI or null to match any subject.
|
|
7496
|
+
* @param predicate A predicate URI or null to match any predicate.
|
|
7497
|
+
* @param object An object URI or null to match any object.
|
|
7498
|
+
* @returns `true` if there are triples matching the pattern, `false` otherwise.
|
|
7439
7499
|
*/
|
|
7440
|
-
|
|
7441
|
-
|
|
7442
|
-
const parse = (subject2, level, separator = "/", i = 0) => {
|
|
7443
|
-
if (visitedNodes.has(subject2.value)) {
|
|
7444
|
-
return [];
|
|
7445
|
-
}
|
|
7446
|
-
visitedNodes.add(subject2.value);
|
|
7447
|
-
if (subject2.termType === "NamedNode") {
|
|
7448
|
-
return [subject2];
|
|
7449
|
-
} else {
|
|
7450
|
-
const first = this.store.matchAll(graphUris, subject2, rdf.first, null, false).next().value;
|
|
7451
|
-
if (first) {
|
|
7452
|
-
const path = parse(first.object, level + 1);
|
|
7453
|
-
const rest = this.store.matchAll(graphUris, subject2, rdf.rest, null, false).next().value;
|
|
7454
|
-
if (rest && rest.object.value !== rdf.nil.value) {
|
|
7455
|
-
const tail = parse(rest.object, level, separator, i + 1);
|
|
7456
|
-
if (tail.length === 0) {
|
|
7457
|
-
return path;
|
|
7458
|
-
}
|
|
7459
|
-
if (i === 0 && level > 0) {
|
|
7460
|
-
return ["(", ...path, separator, ...tail, ")"];
|
|
7461
|
-
} else {
|
|
7462
|
-
return [...path, separator, ...tail];
|
|
7463
|
-
}
|
|
7464
|
-
}
|
|
7465
|
-
return path;
|
|
7466
|
-
} else {
|
|
7467
|
-
for (let q of this.store.matchAll(graphUris, subject2, null, null, false)) {
|
|
7468
|
-
switch (q.predicate.value) {
|
|
7469
|
-
case sh.inversePath.value: {
|
|
7470
|
-
return ["^", ...parse(q.object, level)];
|
|
7471
|
-
}
|
|
7472
|
-
case sh.zeroOrOnePath.value: {
|
|
7473
|
-
return [...parse(q.object, level), "?"];
|
|
7474
|
-
}
|
|
7475
|
-
case sh.zeroOrMorePath.value: {
|
|
7476
|
-
return [...parse(q.object, level), "*"];
|
|
7477
|
-
}
|
|
7478
|
-
case sh.oneOrMorePath.value: {
|
|
7479
|
-
return [...parse(q.object, level), "+"];
|
|
7480
|
-
}
|
|
7481
|
-
case sh.alternativePath.value: {
|
|
7482
|
-
return parse(q.object, level, "|");
|
|
7483
|
-
}
|
|
7484
|
-
default:
|
|
7485
|
-
throw new Error(`Unsupported path predicate: ${q.predicate.value}`);
|
|
7486
|
-
}
|
|
7487
|
-
}
|
|
7488
|
-
throw new Error(`Unsupported path subject: ${subject2}`);
|
|
7489
|
-
}
|
|
7490
|
-
}
|
|
7491
|
-
};
|
|
7492
|
-
return parse(subject, 0);
|
|
7500
|
+
any(graphUris, subject, predicate, object, includeInferred) {
|
|
7501
|
+
return this.matchAll(graphUris, subject, predicate, object, includeInferred).next().done === false;
|
|
7493
7502
|
}
|
|
7494
7503
|
/**
|
|
7495
|
-
* Get
|
|
7496
|
-
* @param graphUris
|
|
7497
|
-
* @param
|
|
7498
|
-
* @
|
|
7499
|
-
* @returns An iterator containing the path from the given class up to sh:Shape.
|
|
7504
|
+
* Get a new DatasetCore containing all quads from the specified graphs.
|
|
7505
|
+
* @param graphUris Optional graph URI or array of graph URIs. If undefined, all quads are included.
|
|
7506
|
+
* @param includeInferred Whether to include inferred triples. Defaults to false.
|
|
7507
|
+
* @returns A new DatasetCore instance with the matching quads.
|
|
7500
7508
|
*/
|
|
7501
|
-
|
|
7502
|
-
|
|
7509
|
+
getDataset(graphUris, includeInferred) {
|
|
7510
|
+
const dataset = RdfStore2.createDefault().asDataset();
|
|
7511
|
+
for (const q of this.matchAll(graphUris, null, null, null, includeInferred)) {
|
|
7512
|
+
dataset.add(q);
|
|
7513
|
+
}
|
|
7514
|
+
return dataset;
|
|
7503
7515
|
}
|
|
7504
|
-
|
|
7505
|
-
|
|
7506
|
-
|
|
7507
|
-
|
|
7508
|
-
|
|
7509
|
-
|
|
7510
|
-
|
|
7511
|
-
|
|
7512
|
-
|
|
7516
|
+
/**
|
|
7517
|
+
* Get the first triple matching the given pattern in the store.
|
|
7518
|
+
* @param graphUris Optional graph URI or array of graph URIs to query.
|
|
7519
|
+
* @param subject A subject URI or null to match any subject.
|
|
7520
|
+
* @param predicate A predicate URI or null to match any predicate.
|
|
7521
|
+
* @param object An object URI or null to match any object.
|
|
7522
|
+
* @returns The first triple that matches the pattern.
|
|
7523
|
+
* @throws {TripleNotFoundError} If no triple is found matching the pattern.
|
|
7524
|
+
*/
|
|
7525
|
+
first(graphUris, subject, predicate, object, includeInferred) {
|
|
7526
|
+
const result = this.matchAll(graphUris, subject, predicate, object, includeInferred).next().value;
|
|
7527
|
+
if (!result) {
|
|
7528
|
+
throw new TripleNotFoundError(subject, predicate, object);
|
|
7513
7529
|
}
|
|
7514
|
-
return
|
|
7530
|
+
return result;
|
|
7515
7531
|
}
|
|
7516
7532
|
};
|
|
7517
7533
|
|
|
@@ -7653,6 +7669,7 @@ export {
|
|
|
7653
7669
|
SH,
|
|
7654
7670
|
SKOS,
|
|
7655
7671
|
SKOS_XL,
|
|
7672
|
+
ShapeRepository,
|
|
7656
7673
|
Store,
|
|
7657
7674
|
TripleNotFoundError,
|
|
7658
7675
|
Uri,
|