@shaclmate/shacl-ast 4.0.35 → 4.0.37

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
@@ -80,119 +80,6 @@ function $convertToMaybe(convertToItem) {
80
80
  return convertToItem(value).map(Maybe.of);
81
81
  };
82
82
  }
83
- function $filterArray(filterItem) {
84
- return (filter, values) => {
85
- for (const value of values) {
86
- if (!filterItem(filter, value)) {
87
- return false;
88
- }
89
- }
90
- if (filter.$maxCount !== undefined && values.length > filter.$maxCount) {
91
- return false;
92
- }
93
- if (filter.$minCount !== undefined && values.length < filter.$minCount) {
94
- return false;
95
- }
96
- return true;
97
- };
98
- }
99
- function $filterBoolean(filter, value) {
100
- if (filter.value !== undefined && value !== filter.value) {
101
- return false;
102
- }
103
- return true;
104
- }
105
- function $filterIdentifier(filter, value) {
106
- if (filter.in !== undefined &&
107
- !filter.in.some((inValue) => inValue.equals(value))) {
108
- return false;
109
- }
110
- if (filter.type !== undefined && value.termType !== filter.type) {
111
- return false;
112
- }
113
- return true;
114
- }
115
- function $filterIri(filter, value) {
116
- if (filter.in !== undefined &&
117
- !filter.in.some((inValue) => inValue.equals(value))) {
118
- return false;
119
- }
120
- return true;
121
- }
122
- function $filterLiteral(filter, value) {
123
- return $filterTerm(filter, value);
124
- }
125
- function $filterMaybe(filterItem) {
126
- return (filter, value) => {
127
- if (filter !== null) {
128
- if (value.isNothing()) {
129
- return false;
130
- }
131
- if (!filterItem(filter, value.extract())) {
132
- return false;
133
- }
134
- }
135
- else {
136
- if (value.isJust()) {
137
- return false;
138
- }
139
- }
140
- return true;
141
- };
142
- }
143
- function $filterNumeric(filter, value) {
144
- if (filter.in !== undefined &&
145
- !filter.in.some((inValue) => inValue === value)) {
146
- return false;
147
- }
148
- if (filter.maxExclusive !== undefined && value >= filter.maxExclusive) {
149
- return false;
150
- }
151
- if (filter.maxInclusive !== undefined && value > filter.maxInclusive) {
152
- return false;
153
- }
154
- if (filter.minExclusive !== undefined && value <= filter.minExclusive) {
155
- return false;
156
- }
157
- if (filter.minInclusive !== undefined && value < filter.minInclusive) {
158
- return false;
159
- }
160
- return true;
161
- }
162
- function $filterString(filter, value) {
163
- if (filter.in !== undefined &&
164
- !filter.in.some((inValue) => inValue === value)) {
165
- return false;
166
- }
167
- if (filter.maxLength !== undefined && value.length > filter.maxLength) {
168
- return false;
169
- }
170
- if (filter.minLength !== undefined && value.length < filter.minLength) {
171
- return false;
172
- }
173
- return true;
174
- }
175
- function $filterTerm(filter, value) {
176
- if (filter.datatypeIn !== undefined &&
177
- (value.termType !== "Literal" ||
178
- !filter.datatypeIn.some((inDatatype) => inDatatype.equals(value.datatype)))) {
179
- return false;
180
- }
181
- if (filter.in !== undefined &&
182
- !filter.in.some((inTerm) => inTerm.equals(value))) {
183
- return false;
184
- }
185
- if (filter.languageIn !== undefined &&
186
- (value.termType !== "Literal" ||
187
- !filter.languageIn.some((inLanguage) => inLanguage === value.language))) {
188
- return false;
189
- }
190
- if (filter.typeIn !== undefined &&
191
- !filter.typeIn.some((inType) => inType === value.termType)) {
192
- return false;
193
- }
194
- return true;
195
- }
196
83
  function $fromRdfPreferredLanguages(values, preferredLanguages) {
197
84
  if (!preferredLanguages || preferredLanguages.length === 0) {
198
85
  return Right(values);
@@ -215,28 +102,6 @@ function $fromRdfPreferredLanguages(values, preferredLanguages) {
215
102
  values: filteredValues,
216
103
  }));
217
104
  }
218
- class $IdentifierSet {
219
- blankNodeValues = new Set();
220
- namedNodeValues = new Set();
221
- add(identifier) {
222
- switch (identifier.termType) {
223
- case "BlankNode":
224
- this.blankNodeValues.add(identifier.value);
225
- return this;
226
- case "NamedNode":
227
- this.namedNodeValues.add(identifier.value);
228
- return this;
229
- }
230
- }
231
- has(identifier) {
232
- switch (identifier.termType) {
233
- case "BlankNode":
234
- return this.blankNodeValues.has(identifier.value);
235
- case "NamedNode":
236
- return this.namedNodeValues.has(identifier.value);
237
- }
238
- }
239
- }
240
105
  function $identityConversionFunction(value) {
241
106
  return Either.of(value);
242
107
  }
@@ -244,13 +109,26 @@ function $identityValidationFunction(_schema, value) {
244
109
  return Either.of(value);
245
110
  }
246
111
  const $literalFactory = new LiteralFactory({ dataFactory: dataFactory });
112
+ function $monkeyPatchObject(obj, methods) {
113
+ if (methods.toJson &&
114
+ !globalThis.Object.prototype.hasOwnProperty.call(obj, "toJSON")) {
115
+ const toJsonMethod = methods.toJson;
116
+ obj.toJSON = function (_key) {
117
+ return toJsonMethod(this);
118
+ };
119
+ }
120
+ if (methods.$toString &&
121
+ !globalThis.Object.prototype.hasOwnProperty.call(obj, "toString")) {
122
+ const toStringMethod = methods.$toString;
123
+ obj.toString = function () {
124
+ return toStringMethod(this);
125
+ };
126
+ }
127
+ return obj;
128
+ }
247
129
  const $parseIdentifier = NTriplesIdentifier.parser(dataFactory);
248
130
  export var $PropertyPath;
249
131
  (function ($PropertyPath) {
250
- function filter(_filter, _value) {
251
- return true;
252
- }
253
- $PropertyPath.filter = filter;
254
132
  $PropertyPath.fromRdfResource = RdfxResourcePropertyPath.fromResource;
255
133
  $PropertyPath.fromRdfResourceValues = (values, options) => values.chain((values) => values.chainMap((value) => value
256
134
  .toResource()
@@ -326,15 +204,11 @@ function $validateMaybe(validateItem) {
326
204
  }
327
205
  function $wrap_FromRdfResourceFunction(_fromRdfResourceFunction) {
328
206
  return (resource, options) => {
329
- let { context, graph, ignoreRdfType = false, objectSet, preferredLanguages, } = options ?? {};
330
- if (!objectSet) {
331
- objectSet = new $RdfjsDatasetObjectSet(resource.dataset);
332
- }
207
+ const { context, graph, ignoreRdfType = false, preferredLanguages, } = options ?? {};
333
208
  return _fromRdfResourceFunction(resource, {
334
209
  context,
335
210
  graph,
336
211
  ignoreRdfType,
337
- objectSet,
338
212
  preferredLanguages,
339
213
  });
340
214
  };
@@ -396,13 +270,7 @@ export var PropertyShape;
396
270
  patterns: $convertToArray($identityConversionFunction, true)(parameters.patterns).chain((value) => $validateArray($identityValidationFunction, true)(PropertyShape.schema.properties.patterns.type(), value)),
397
271
  uniqueLang: $convertToMaybe($identityConversionFunction)(parameters.uniqueLang).chain((value) => $validateMaybe($identityValidationFunction)(PropertyShape.schema.properties.uniqueLang.type(), value)),
398
272
  xone: $convertToMaybe($convertToArray($convertToIdentifier, true))(parameters.xone).chain((value) => $validateMaybe($validateArray($identityValidationFunction, true))(PropertyShape.schema.properties.xone.type(), value)),
399
- }).map((properties) => {
400
- const finalObject = { ...properties, $type: "PropertyShape" };
401
- if (!globalThis.Object.prototype.hasOwnProperty.call(finalObject, "toString")) {
402
- finalObject.toString = $toString;
403
- }
404
- return finalObject;
405
- });
273
+ }).map((properties) => $monkeyPatchObject({ ...properties, $type: "PropertyShape" }, { $toString }));
406
274
  }
407
275
  PropertyShape.create = create;
408
276
  function createUnsafe(parameters) {
@@ -414,142 +282,6 @@ export var PropertyShape;
414
282
  Identifier.parse = $parseIdentifier;
415
283
  Identifier.stringify = NTriplesTerm.stringify;
416
284
  })(Identifier = PropertyShape.Identifier || (PropertyShape.Identifier = {}));
417
- function filter(filter, value) {
418
- if (filter.$identifier !== undefined &&
419
- !$filterIdentifier(filter.$identifier, value.$identifier())) {
420
- return false;
421
- }
422
- if (filter.and !== undefined &&
423
- !$filterMaybe($filterArray($filterIdentifier))(filter.and, value.and)) {
424
- return false;
425
- }
426
- if (filter.classes !== undefined &&
427
- !$filterArray($filterIri)(filter.classes, value.classes)) {
428
- return false;
429
- }
430
- if (filter.comment !== undefined &&
431
- !$filterMaybe($filterString)(filter.comment, value.comment)) {
432
- return false;
433
- }
434
- if (filter.datatype !== undefined &&
435
- !$filterMaybe($filterIri)(filter.datatype, value.datatype)) {
436
- return false;
437
- }
438
- if (filter.deactivated !== undefined &&
439
- !$filterMaybe($filterBoolean)(filter.deactivated, value.deactivated)) {
440
- return false;
441
- }
442
- if (filter.defaultValue !== undefined &&
443
- !$filterMaybe($filterTerm)(filter.defaultValue, value.defaultValue)) {
444
- return false;
445
- }
446
- if (filter.description !== undefined &&
447
- !$filterMaybe($filterString)(filter.description, value.description)) {
448
- return false;
449
- }
450
- if (filter.flags !== undefined &&
451
- !$filterArray($filterString)(filter.flags, value.flags)) {
452
- return false;
453
- }
454
- if (filter.groups !== undefined &&
455
- !$filterArray($filterIdentifier)(filter.groups, value.groups)) {
456
- return false;
457
- }
458
- if (filter.hasValues !== undefined &&
459
- !$filterArray($filterTerm)(filter.hasValues, value.hasValues)) {
460
- return false;
461
- }
462
- if (filter.in_ !== undefined &&
463
- !$filterMaybe($filterArray($filterTerm))(filter.in_, value.in_)) {
464
- return false;
465
- }
466
- if (filter.isDefinedBy !== undefined &&
467
- !$filterMaybe($filterIdentifier)(filter.isDefinedBy, value.isDefinedBy)) {
468
- return false;
469
- }
470
- if (filter.label !== undefined &&
471
- !$filterMaybe($filterString)(filter.label, value.label)) {
472
- return false;
473
- }
474
- if (filter.languageIn !== undefined &&
475
- !$filterMaybe($filterArray($filterString))(filter.languageIn, value.languageIn)) {
476
- return false;
477
- }
478
- if (filter.maxCount !== undefined &&
479
- !$filterMaybe(($filterNumeric))(filter.maxCount, value.maxCount)) {
480
- return false;
481
- }
482
- if (filter.maxExclusive !== undefined &&
483
- !$filterMaybe($filterLiteral)(filter.maxExclusive, value.maxExclusive)) {
484
- return false;
485
- }
486
- if (filter.maxInclusive !== undefined &&
487
- !$filterMaybe($filterLiteral)(filter.maxInclusive, value.maxInclusive)) {
488
- return false;
489
- }
490
- if (filter.maxLength !== undefined &&
491
- !$filterMaybe(($filterNumeric))(filter.maxLength, value.maxLength)) {
492
- return false;
493
- }
494
- if (filter.minCount !== undefined &&
495
- !$filterMaybe(($filterNumeric))(filter.minCount, value.minCount)) {
496
- return false;
497
- }
498
- if (filter.minExclusive !== undefined &&
499
- !$filterMaybe($filterLiteral)(filter.minExclusive, value.minExclusive)) {
500
- return false;
501
- }
502
- if (filter.minInclusive !== undefined &&
503
- !$filterMaybe($filterLiteral)(filter.minInclusive, value.minInclusive)) {
504
- return false;
505
- }
506
- if (filter.minLength !== undefined &&
507
- !$filterMaybe(($filterNumeric))(filter.minLength, value.minLength)) {
508
- return false;
509
- }
510
- if (filter.name !== undefined &&
511
- !$filterMaybe($filterString)(filter.name, value.name)) {
512
- return false;
513
- }
514
- if (filter.node !== undefined &&
515
- !$filterMaybe($filterIdentifier)(filter.node, value.node)) {
516
- return false;
517
- }
518
- if (filter.nodeKind !== undefined &&
519
- !$filterMaybe($filterIri)(filter.nodeKind, value.nodeKind)) {
520
- return false;
521
- }
522
- if (filter.not !== undefined &&
523
- !$filterArray($filterIdentifier)(filter.not, value.not)) {
524
- return false;
525
- }
526
- if (filter.or !== undefined &&
527
- !$filterMaybe($filterArray($filterIdentifier))(filter.or, value.or)) {
528
- return false;
529
- }
530
- if (filter.order !== undefined &&
531
- !$filterMaybe(($filterNumeric))(filter.order, value.order)) {
532
- return false;
533
- }
534
- if (filter.path !== undefined &&
535
- !$PropertyPath.filter(filter.path, value.path)) {
536
- return false;
537
- }
538
- if (filter.patterns !== undefined &&
539
- !$filterArray($filterString)(filter.patterns, value.patterns)) {
540
- return false;
541
- }
542
- if (filter.uniqueLang !== undefined &&
543
- !$filterMaybe($filterBoolean)(filter.uniqueLang, value.uniqueLang)) {
544
- return false;
545
- }
546
- if (filter.xone !== undefined &&
547
- !$filterMaybe($filterArray($filterIdentifier))(filter.xone, value.xone)) {
548
- return false;
549
- }
550
- return true;
551
- }
552
- PropertyShape.filter = filter;
553
285
  PropertyShape._fromRdfResource = ($resource, _$options) => {
554
286
  return (!_$options.ignoreRdfType
555
287
  ? $resource
@@ -1053,7 +785,6 @@ export var PropertyShape;
1053
785
  typeFromRdf: (resourceValues) => $PropertyPath.fromRdfResourceValues(resourceValues, {
1054
786
  context: _$options.context,
1055
787
  graph: _$options.graph,
1056
- objectSet: _$options.objectSet,
1057
788
  preferredLanguages: _$options.preferredLanguages,
1058
789
  resource: $resource,
1059
790
  ignoreRdfType: true,
@@ -1421,7 +1152,7 @@ export var PropertyShape;
1421
1152
  if (!parameters.ignoreRdfType) {
1422
1153
  parameters.resource.add($RdfVocabularies.rdf.type, dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyShape"), parameters.graph);
1423
1154
  }
1424
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#and"), parameters.object.and.toList().flatMap((value) => [
1155
+ parameters.resource.add(PropertyShape.schema.properties.and.path, parameters.object.and.toList().flatMap((value) => [
1425
1156
  value.length > 0
1426
1157
  ? value.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
1427
1158
  if (itemIndex === 0) {
@@ -1443,24 +1174,24 @@ export var PropertyShape;
1443
1174
  }).listResource.identifier
1444
1175
  : $RdfVocabularies.rdf.nil,
1445
1176
  ]), parameters.graph);
1446
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#class"), parameters.object.classes.flatMap((item) => [item]), parameters.graph);
1447
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#comment"), parameters.object.comment
1177
+ parameters.resource.add(PropertyShape.schema.properties.classes.path, parameters.object.classes.flatMap((item) => [item]), parameters.graph);
1178
+ parameters.resource.add(PropertyShape.schema.properties.comment.path, parameters.object.comment
1448
1179
  .toList()
1449
1180
  .flatMap((value) => [$literalFactory.string(value)]), parameters.graph);
1450
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#datatype"), parameters.object.datatype.toList(), parameters.graph);
1451
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#deactivated"), parameters.object.deactivated
1181
+ parameters.resource.add(PropertyShape.schema.properties.datatype.path, parameters.object.datatype.toList(), parameters.graph);
1182
+ parameters.resource.add(PropertyShape.schema.properties.deactivated.path, parameters.object.deactivated
1452
1183
  .toList()
1453
1184
  .flatMap((value) => [
1454
1185
  $literalFactory.boolean(value, $RdfVocabularies.xsd.boolean),
1455
1186
  ]), parameters.graph);
1456
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#defaultValue"), parameters.object.defaultValue.toList(), parameters.graph);
1457
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#description"), parameters.object.description
1187
+ parameters.resource.add(PropertyShape.schema.properties.defaultValue.path, parameters.object.defaultValue.toList(), parameters.graph);
1188
+ parameters.resource.add(PropertyShape.schema.properties.description.path, parameters.object.description
1458
1189
  .toList()
1459
1190
  .flatMap((value) => [$literalFactory.string(value)]), parameters.graph);
1460
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#flags"), parameters.object.flags.flatMap((item) => [$literalFactory.string(item)]), parameters.graph);
1461
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#group"), parameters.object.groups.flatMap((item) => [item]), parameters.graph);
1462
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#hasValue"), parameters.object.hasValues.flatMap((item) => [item]), parameters.graph);
1463
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#in"), parameters.object.in_.toList().flatMap((value) => [
1191
+ parameters.resource.add(PropertyShape.schema.properties.flags.path, parameters.object.flags.flatMap((item) => [$literalFactory.string(item)]), parameters.graph);
1192
+ parameters.resource.add(PropertyShape.schema.properties.groups.path, parameters.object.groups.flatMap((item) => [item]), parameters.graph);
1193
+ parameters.resource.add(PropertyShape.schema.properties.hasValues.path, parameters.object.hasValues.flatMap((item) => [item]), parameters.graph);
1194
+ parameters.resource.add(PropertyShape.schema.properties.in_.path, parameters.object.in_.toList().flatMap((value) => [
1464
1195
  value.length > 0
1465
1196
  ? value.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
1466
1197
  if (itemIndex === 0) {
@@ -1482,11 +1213,11 @@ export var PropertyShape;
1482
1213
  }).listResource.identifier
1483
1214
  : $RdfVocabularies.rdf.nil,
1484
1215
  ]), parameters.graph);
1485
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#isDefinedBy"), parameters.object.isDefinedBy.toList(), parameters.graph);
1486
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#label"), parameters.object.label
1216
+ parameters.resource.add(PropertyShape.schema.properties.isDefinedBy.path, parameters.object.isDefinedBy.toList(), parameters.graph);
1217
+ parameters.resource.add(PropertyShape.schema.properties.label.path, parameters.object.label
1487
1218
  .toList()
1488
1219
  .flatMap((value) => [$literalFactory.string(value)]), parameters.graph);
1489
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#languageIn"), parameters.object.languageIn.toList().flatMap((value) => [
1220
+ parameters.resource.add(PropertyShape.schema.properties.languageIn.path, parameters.object.languageIn.toList().flatMap((value) => [
1490
1221
  value.length > 0
1491
1222
  ? value.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
1492
1223
  if (itemIndex === 0) {
@@ -1508,37 +1239,37 @@ export var PropertyShape;
1508
1239
  }).listResource.identifier
1509
1240
  : $RdfVocabularies.rdf.nil,
1510
1241
  ]), parameters.graph);
1511
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#maxCount"), parameters.object.maxCount
1242
+ parameters.resource.add(PropertyShape.schema.properties.maxCount.path, parameters.object.maxCount
1512
1243
  .toList()
1513
1244
  .flatMap((value) => [
1514
1245
  $literalFactory.bigint(value, $RdfVocabularies.xsd.integer),
1515
1246
  ]), parameters.graph);
1516
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#maxExclusive"), parameters.object.maxExclusive.toList(), parameters.graph);
1517
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#maxInclusive"), parameters.object.maxInclusive.toList(), parameters.graph);
1518
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#maxLength"), parameters.object.maxLength
1247
+ parameters.resource.add(PropertyShape.schema.properties.maxExclusive.path, parameters.object.maxExclusive.toList(), parameters.graph);
1248
+ parameters.resource.add(PropertyShape.schema.properties.maxInclusive.path, parameters.object.maxInclusive.toList(), parameters.graph);
1249
+ parameters.resource.add(PropertyShape.schema.properties.maxLength.path, parameters.object.maxLength
1519
1250
  .toList()
1520
1251
  .flatMap((value) => [
1521
1252
  $literalFactory.bigint(value, $RdfVocabularies.xsd.integer),
1522
1253
  ]), parameters.graph);
1523
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#minCount"), parameters.object.minCount
1254
+ parameters.resource.add(PropertyShape.schema.properties.minCount.path, parameters.object.minCount
1524
1255
  .toList()
1525
1256
  .flatMap((value) => [
1526
1257
  $literalFactory.bigint(value, $RdfVocabularies.xsd.integer),
1527
1258
  ]), parameters.graph);
1528
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#minExclusive"), parameters.object.minExclusive.toList(), parameters.graph);
1529
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#minInclusive"), parameters.object.minInclusive.toList(), parameters.graph);
1530
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#minLength"), parameters.object.minLength
1259
+ parameters.resource.add(PropertyShape.schema.properties.minExclusive.path, parameters.object.minExclusive.toList(), parameters.graph);
1260
+ parameters.resource.add(PropertyShape.schema.properties.minInclusive.path, parameters.object.minInclusive.toList(), parameters.graph);
1261
+ parameters.resource.add(PropertyShape.schema.properties.minLength.path, parameters.object.minLength
1531
1262
  .toList()
1532
1263
  .flatMap((value) => [
1533
1264
  $literalFactory.bigint(value, $RdfVocabularies.xsd.integer),
1534
1265
  ]), parameters.graph);
1535
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#name"), parameters.object.name
1266
+ parameters.resource.add(PropertyShape.schema.properties.name.path, parameters.object.name
1536
1267
  .toList()
1537
1268
  .flatMap((value) => [$literalFactory.string(value)]), parameters.graph);
1538
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#node"), parameters.object.node.toList(), parameters.graph);
1539
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#nodeKind"), parameters.object.nodeKind.toList(), parameters.graph);
1540
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#not"), parameters.object.not.flatMap((item) => [item]), parameters.graph);
1541
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#or"), parameters.object.or.toList().flatMap((value) => [
1269
+ parameters.resource.add(PropertyShape.schema.properties.node.path, parameters.object.node.toList(), parameters.graph);
1270
+ parameters.resource.add(PropertyShape.schema.properties.nodeKind.path, parameters.object.nodeKind.toList(), parameters.graph);
1271
+ parameters.resource.add(PropertyShape.schema.properties.not.path, parameters.object.not.flatMap((item) => [item]), parameters.graph);
1272
+ parameters.resource.add(PropertyShape.schema.properties.or.path, parameters.object.or.toList().flatMap((value) => [
1542
1273
  value.length > 0
1543
1274
  ? value.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
1544
1275
  if (itemIndex === 0) {
@@ -1560,26 +1291,26 @@ export var PropertyShape;
1560
1291
  }).listResource.identifier
1561
1292
  : $RdfVocabularies.rdf.nil,
1562
1293
  ]), parameters.graph);
1563
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#order"), parameters.object.order
1294
+ parameters.resource.add(PropertyShape.schema.properties.order.path, parameters.object.order
1564
1295
  .toList()
1565
1296
  .flatMap((value) => [
1566
1297
  $literalFactory.number(value, $RdfVocabularies.xsd.double),
1567
1298
  ]), parameters.graph);
1568
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#path"), [
1299
+ parameters.resource.add(PropertyShape.schema.properties.path.path, [
1569
1300
  $PropertyPath.toRdfResource(parameters.object.path, {
1570
1301
  graph: parameters.graph,
1571
1302
  resourceSet: parameters.resourceSet,
1572
1303
  }).identifier,
1573
1304
  ], parameters.graph);
1574
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#pattern"), parameters.object.patterns.flatMap((item) => [
1305
+ parameters.resource.add(PropertyShape.schema.properties.patterns.path, parameters.object.patterns.flatMap((item) => [
1575
1306
  $literalFactory.string(item),
1576
1307
  ]), parameters.graph);
1577
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#uniqueLang"), parameters.object.uniqueLang
1308
+ parameters.resource.add(PropertyShape.schema.properties.uniqueLang.path, parameters.object.uniqueLang
1578
1309
  .toList()
1579
1310
  .flatMap((value) => [
1580
1311
  $literalFactory.boolean(value, $RdfVocabularies.xsd.boolean),
1581
1312
  ]), parameters.graph);
1582
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#xone"), parameters.object.xone.toList().flatMap((value) => [
1313
+ parameters.resource.add(PropertyShape.schema.properties.xone.path, parameters.object.xone.toList().flatMap((value) => [
1583
1314
  value.length > 0
1584
1315
  ? value.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
1585
1316
  if (itemIndex === 0) {
@@ -1614,7 +1345,7 @@ export var PropertyShape;
1614
1345
  }
1615
1346
  PropertyShape._propertiesToStrings = _propertiesToStrings;
1616
1347
  function $toString(_propertyShape) {
1617
- return `PropertyShape(${JSON.stringify(_propertiesToStrings((_propertyShape ?? this)))})`;
1348
+ return `PropertyShape(${JSON.stringify(_propertiesToStrings(_propertyShape))})`;
1618
1349
  }
1619
1350
  PropertyShape.$toString = $toString;
1620
1351
  })(PropertyShape || (PropertyShape = {}));
@@ -1625,13 +1356,7 @@ export var PropertyGroup;
1625
1356
  $identifier: $convertToIdentifierProperty(parameters?.$identifier),
1626
1357
  comment: $convertToMaybe($identityConversionFunction)(parameters?.comment).chain((value) => $validateMaybe($identityValidationFunction)(PropertyShape.schema.properties.comment.type(), value)),
1627
1358
  label: $convertToMaybe($identityConversionFunction)(parameters?.label).chain((value) => $validateMaybe($identityValidationFunction)(PropertyShape.schema.properties.label.type(), value)),
1628
- }).map((properties) => {
1629
- const finalObject = { ...properties, $type: "PropertyGroup" };
1630
- if (!globalThis.Object.prototype.hasOwnProperty.call(finalObject, "toString")) {
1631
- finalObject.toString = $toString;
1632
- }
1633
- return finalObject;
1634
- });
1359
+ }).map((properties) => $monkeyPatchObject({ ...properties, $type: "PropertyGroup" }, { $toString }));
1635
1360
  }
1636
1361
  PropertyGroup.create = create;
1637
1362
  function createUnsafe(parameters) {
@@ -1643,22 +1368,6 @@ export var PropertyGroup;
1643
1368
  Identifier.parse = $parseIdentifier;
1644
1369
  Identifier.stringify = NTriplesTerm.stringify;
1645
1370
  })(Identifier = PropertyGroup.Identifier || (PropertyGroup.Identifier = {}));
1646
- function filter(filter, value) {
1647
- if (filter.$identifier !== undefined &&
1648
- !$filterIdentifier(filter.$identifier, value.$identifier())) {
1649
- return false;
1650
- }
1651
- if (filter.comment !== undefined &&
1652
- !$filterMaybe($filterString)(filter.comment, value.comment)) {
1653
- return false;
1654
- }
1655
- if (filter.label !== undefined &&
1656
- !$filterMaybe($filterString)(filter.label, value.label)) {
1657
- return false;
1658
- }
1659
- return true;
1660
- }
1661
- PropertyGroup.filter = filter;
1662
1371
  PropertyGroup._fromRdfResource = ($resource, _$options) => {
1663
1372
  return (!_$options.ignoreRdfType
1664
1373
  ? $resource
@@ -1768,10 +1477,10 @@ export var PropertyGroup;
1768
1477
  if (!parameters.ignoreRdfType) {
1769
1478
  parameters.resource.add($RdfVocabularies.rdf.type, dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyGroup"), parameters.graph);
1770
1479
  }
1771
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#comment"), parameters.object.comment
1480
+ parameters.resource.add(PropertyShape.schema.properties.comment.path, parameters.object.comment
1772
1481
  .toList()
1773
1482
  .flatMap((value) => [$literalFactory.string(value)]), parameters.graph);
1774
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#label"), parameters.object.label
1483
+ parameters.resource.add(PropertyShape.schema.properties.label.path, parameters.object.label
1775
1484
  .toList()
1776
1485
  .flatMap((value) => [$literalFactory.string(value)]), parameters.graph);
1777
1486
  return parameters.resource;
@@ -1785,7 +1494,7 @@ export var PropertyGroup;
1785
1494
  }
1786
1495
  PropertyGroup._propertiesToStrings = _propertiesToStrings;
1787
1496
  function $toString(_propertyGroup) {
1788
- return `PropertyGroup(${JSON.stringify(_propertiesToStrings((_propertyGroup ?? this)))})`;
1497
+ return `PropertyGroup(${JSON.stringify(_propertiesToStrings(_propertyGroup))})`;
1789
1498
  }
1790
1499
  PropertyGroup.$toString = $toString;
1791
1500
  })(PropertyGroup || (PropertyGroup = {}));
@@ -1796,13 +1505,7 @@ export var Ontology;
1796
1505
  $identifier: $convertToIdentifierProperty(parameters?.$identifier),
1797
1506
  comment: $convertToMaybe($identityConversionFunction)(parameters?.comment).chain((value) => $validateMaybe($identityValidationFunction)(PropertyShape.schema.properties.comment.type(), value)),
1798
1507
  label: $convertToMaybe($identityConversionFunction)(parameters?.label).chain((value) => $validateMaybe($identityValidationFunction)(PropertyShape.schema.properties.label.type(), value)),
1799
- }).map((properties) => {
1800
- const finalObject = { ...properties, $type: "Ontology" };
1801
- if (!globalThis.Object.prototype.hasOwnProperty.call(finalObject, "toString")) {
1802
- finalObject.toString = $toString;
1803
- }
1804
- return finalObject;
1805
- });
1508
+ }).map((properties) => $monkeyPatchObject({ ...properties, $type: "Ontology" }, { $toString }));
1806
1509
  }
1807
1510
  Ontology.create = create;
1808
1511
  function createUnsafe(parameters) {
@@ -1814,22 +1517,6 @@ export var Ontology;
1814
1517
  Identifier.parse = $parseIdentifier;
1815
1518
  Identifier.stringify = NTriplesTerm.stringify;
1816
1519
  })(Identifier = Ontology.Identifier || (Ontology.Identifier = {}));
1817
- function filter(filter, value) {
1818
- if (filter.$identifier !== undefined &&
1819
- !$filterIdentifier(filter.$identifier, value.$identifier())) {
1820
- return false;
1821
- }
1822
- if (filter.comment !== undefined &&
1823
- !$filterMaybe($filterString)(filter.comment, value.comment)) {
1824
- return false;
1825
- }
1826
- if (filter.label !== undefined &&
1827
- !$filterMaybe($filterString)(filter.label, value.label)) {
1828
- return false;
1829
- }
1830
- return true;
1831
- }
1832
- Ontology.filter = filter;
1833
1520
  Ontology._fromRdfResource = ($resource, _$options) => {
1834
1521
  return (!_$options.ignoreRdfType
1835
1522
  ? $resource
@@ -1939,10 +1626,10 @@ export var Ontology;
1939
1626
  if (!parameters.ignoreRdfType) {
1940
1627
  parameters.resource.add($RdfVocabularies.rdf.type, dataFactory.namedNode("http://www.w3.org/2002/07/owl#Ontology"), parameters.graph);
1941
1628
  }
1942
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#comment"), parameters.object.comment
1629
+ parameters.resource.add(PropertyShape.schema.properties.comment.path, parameters.object.comment
1943
1630
  .toList()
1944
1631
  .flatMap((value) => [$literalFactory.string(value)]), parameters.graph);
1945
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#label"), parameters.object.label
1632
+ parameters.resource.add(PropertyShape.schema.properties.label.path, parameters.object.label
1946
1633
  .toList()
1947
1634
  .flatMap((value) => [$literalFactory.string(value)]), parameters.graph);
1948
1635
  return parameters.resource;
@@ -1956,7 +1643,7 @@ export var Ontology;
1956
1643
  }
1957
1644
  Ontology._propertiesToStrings = _propertiesToStrings;
1958
1645
  function $toString(_ontology) {
1959
- return `Ontology(${JSON.stringify(_propertiesToStrings((_ontology ?? this)))})`;
1646
+ return `Ontology(${JSON.stringify(_propertiesToStrings(_ontology))})`;
1960
1647
  }
1961
1648
  Ontology.$toString = $toString;
1962
1649
  })(Ontology || (Ontology = {}));
@@ -1995,13 +1682,7 @@ export var NodeShape;
1995
1682
  subClassOf: $convertToArray(($convertToIri), true)(parameters?.subClassOf).chain((value) => $validateArray($identityValidationFunction, true)(NodeShape.schema.properties.subClassOf.type(), value)),
1996
1683
  types: $convertToArray(($convertToIri), true)(parameters?.types).chain((value) => $validateArray($identityValidationFunction, true)(NodeShape.schema.properties.types.type(), value)),
1997
1684
  xone: $convertToMaybe($convertToArray($convertToIdentifier, true))(parameters?.xone).chain((value) => $validateMaybe($validateArray($identityValidationFunction, true))(PropertyShape.schema.properties.xone.type(), value)),
1998
- }).map((properties) => {
1999
- const finalObject = { ...properties, $type: "NodeShape" };
2000
- if (!globalThis.Object.prototype.hasOwnProperty.call(finalObject, "toString")) {
2001
- finalObject.toString = $toString;
2002
- }
2003
- return finalObject;
2004
- });
1685
+ }).map((properties) => $monkeyPatchObject({ ...properties, $type: "NodeShape" }, { $toString }));
2005
1686
  }
2006
1687
  NodeShape.create = create;
2007
1688
  function createUnsafe(parameters) {
@@ -2013,134 +1694,6 @@ export var NodeShape;
2013
1694
  Identifier.parse = $parseIdentifier;
2014
1695
  Identifier.stringify = NTriplesTerm.stringify;
2015
1696
  })(Identifier = NodeShape.Identifier || (NodeShape.Identifier = {}));
2016
- function filter(filter, value) {
2017
- if (filter.$identifier !== undefined &&
2018
- !$filterIdentifier(filter.$identifier, value.$identifier())) {
2019
- return false;
2020
- }
2021
- if (filter.and !== undefined &&
2022
- !$filterMaybe($filterArray($filterIdentifier))(filter.and, value.and)) {
2023
- return false;
2024
- }
2025
- if (filter.classes !== undefined &&
2026
- !$filterArray($filterIri)(filter.classes, value.classes)) {
2027
- return false;
2028
- }
2029
- if (filter.closed !== undefined &&
2030
- !$filterMaybe($filterBoolean)(filter.closed, value.closed)) {
2031
- return false;
2032
- }
2033
- if (filter.comment !== undefined &&
2034
- !$filterMaybe($filterString)(filter.comment, value.comment)) {
2035
- return false;
2036
- }
2037
- if (filter.datatype !== undefined &&
2038
- !$filterMaybe($filterIri)(filter.datatype, value.datatype)) {
2039
- return false;
2040
- }
2041
- if (filter.deactivated !== undefined &&
2042
- !$filterMaybe($filterBoolean)(filter.deactivated, value.deactivated)) {
2043
- return false;
2044
- }
2045
- if (filter.flags !== undefined &&
2046
- !$filterArray($filterString)(filter.flags, value.flags)) {
2047
- return false;
2048
- }
2049
- if (filter.hasValues !== undefined &&
2050
- !$filterArray($filterTerm)(filter.hasValues, value.hasValues)) {
2051
- return false;
2052
- }
2053
- if (filter.ignoredProperties !== undefined &&
2054
- !$filterMaybe($filterArray($filterIri))(filter.ignoredProperties, value.ignoredProperties)) {
2055
- return false;
2056
- }
2057
- if (filter.in_ !== undefined &&
2058
- !$filterMaybe($filterArray($filterTerm))(filter.in_, value.in_)) {
2059
- return false;
2060
- }
2061
- if (filter.isDefinedBy !== undefined &&
2062
- !$filterMaybe($filterIdentifier)(filter.isDefinedBy, value.isDefinedBy)) {
2063
- return false;
2064
- }
2065
- if (filter.label !== undefined &&
2066
- !$filterMaybe($filterString)(filter.label, value.label)) {
2067
- return false;
2068
- }
2069
- if (filter.languageIn !== undefined &&
2070
- !$filterMaybe($filterArray($filterString))(filter.languageIn, value.languageIn)) {
2071
- return false;
2072
- }
2073
- if (filter.maxCount !== undefined &&
2074
- !$filterMaybe(($filterNumeric))(filter.maxCount, value.maxCount)) {
2075
- return false;
2076
- }
2077
- if (filter.maxExclusive !== undefined &&
2078
- !$filterMaybe($filterLiteral)(filter.maxExclusive, value.maxExclusive)) {
2079
- return false;
2080
- }
2081
- if (filter.maxInclusive !== undefined &&
2082
- !$filterMaybe($filterLiteral)(filter.maxInclusive, value.maxInclusive)) {
2083
- return false;
2084
- }
2085
- if (filter.maxLength !== undefined &&
2086
- !$filterMaybe(($filterNumeric))(filter.maxLength, value.maxLength)) {
2087
- return false;
2088
- }
2089
- if (filter.minCount !== undefined &&
2090
- !$filterMaybe(($filterNumeric))(filter.minCount, value.minCount)) {
2091
- return false;
2092
- }
2093
- if (filter.minExclusive !== undefined &&
2094
- !$filterMaybe($filterLiteral)(filter.minExclusive, value.minExclusive)) {
2095
- return false;
2096
- }
2097
- if (filter.minInclusive !== undefined &&
2098
- !$filterMaybe($filterLiteral)(filter.minInclusive, value.minInclusive)) {
2099
- return false;
2100
- }
2101
- if (filter.minLength !== undefined &&
2102
- !$filterMaybe(($filterNumeric))(filter.minLength, value.minLength)) {
2103
- return false;
2104
- }
2105
- if (filter.node !== undefined &&
2106
- !$filterMaybe($filterIdentifier)(filter.node, value.node)) {
2107
- return false;
2108
- }
2109
- if (filter.nodeKind !== undefined &&
2110
- !$filterMaybe($filterIri)(filter.nodeKind, value.nodeKind)) {
2111
- return false;
2112
- }
2113
- if (filter.not !== undefined &&
2114
- !$filterArray($filterIdentifier)(filter.not, value.not)) {
2115
- return false;
2116
- }
2117
- if (filter.or !== undefined &&
2118
- !$filterMaybe($filterArray($filterIdentifier))(filter.or, value.or)) {
2119
- return false;
2120
- }
2121
- if (filter.patterns !== undefined &&
2122
- !$filterArray($filterString)(filter.patterns, value.patterns)) {
2123
- return false;
2124
- }
2125
- if (filter.properties !== undefined &&
2126
- !$filterArray($filterIdentifier)(filter.properties, value.properties)) {
2127
- return false;
2128
- }
2129
- if (filter.subClassOf !== undefined &&
2130
- !$filterArray($filterIri)(filter.subClassOf, value.subClassOf)) {
2131
- return false;
2132
- }
2133
- if (filter.types !== undefined &&
2134
- !$filterArray($filterIri)(filter.types, value.types)) {
2135
- return false;
2136
- }
2137
- if (filter.xone !== undefined &&
2138
- !$filterMaybe($filterArray($filterIdentifier))(filter.xone, value.xone)) {
2139
- return false;
2140
- }
2141
- return true;
2142
- }
2143
- NodeShape.filter = filter;
2144
1697
  NodeShape._fromRdfResource = ($resource, _$options) => {
2145
1698
  return (!_$options.ignoreRdfType
2146
1699
  ? $resource
@@ -2963,7 +2516,7 @@ export var NodeShape;
2963
2516
  if (!parameters.ignoreRdfType) {
2964
2517
  parameters.resource.add($RdfVocabularies.rdf.type, dataFactory.namedNode("http://www.w3.org/ns/shacl#NodeShape"), parameters.graph);
2965
2518
  }
2966
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#and"), parameters.object.and.toList().flatMap((value) => [
2519
+ parameters.resource.add(PropertyShape.schema.properties.and.path, parameters.object.and.toList().flatMap((value) => [
2967
2520
  value.length > 0
2968
2521
  ? value.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
2969
2522
  if (itemIndex === 0) {
@@ -2985,24 +2538,24 @@ export var NodeShape;
2985
2538
  }).listResource.identifier
2986
2539
  : $RdfVocabularies.rdf.nil,
2987
2540
  ]), parameters.graph);
2988
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#class"), parameters.object.classes.flatMap((item) => [item]), parameters.graph);
2989
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#closed"), parameters.object.closed
2541
+ parameters.resource.add(PropertyShape.schema.properties.classes.path, parameters.object.classes.flatMap((item) => [item]), parameters.graph);
2542
+ parameters.resource.add(NodeShape.schema.properties.closed.path, parameters.object.closed
2990
2543
  .toList()
2991
2544
  .flatMap((value) => [
2992
2545
  $literalFactory.boolean(value, $RdfVocabularies.xsd.boolean),
2993
2546
  ]), parameters.graph);
2994
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#comment"), parameters.object.comment
2547
+ parameters.resource.add(PropertyShape.schema.properties.comment.path, parameters.object.comment
2995
2548
  .toList()
2996
2549
  .flatMap((value) => [$literalFactory.string(value)]), parameters.graph);
2997
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#datatype"), parameters.object.datatype.toList(), parameters.graph);
2998
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#deactivated"), parameters.object.deactivated
2550
+ parameters.resource.add(PropertyShape.schema.properties.datatype.path, parameters.object.datatype.toList(), parameters.graph);
2551
+ parameters.resource.add(PropertyShape.schema.properties.deactivated.path, parameters.object.deactivated
2999
2552
  .toList()
3000
2553
  .flatMap((value) => [
3001
2554
  $literalFactory.boolean(value, $RdfVocabularies.xsd.boolean),
3002
2555
  ]), parameters.graph);
3003
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#flags"), parameters.object.flags.flatMap((item) => [$literalFactory.string(item)]), parameters.graph);
3004
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#hasValue"), parameters.object.hasValues.flatMap((item) => [item]), parameters.graph);
3005
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#ignoredProperties"), parameters.object.ignoredProperties.toList().flatMap((value) => [
2556
+ parameters.resource.add(PropertyShape.schema.properties.flags.path, parameters.object.flags.flatMap((item) => [$literalFactory.string(item)]), parameters.graph);
2557
+ parameters.resource.add(PropertyShape.schema.properties.hasValues.path, parameters.object.hasValues.flatMap((item) => [item]), parameters.graph);
2558
+ parameters.resource.add(NodeShape.schema.properties.ignoredProperties.path, parameters.object.ignoredProperties.toList().flatMap((value) => [
3006
2559
  value.length > 0
3007
2560
  ? value.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
3008
2561
  if (itemIndex === 0) {
@@ -3024,7 +2577,7 @@ export var NodeShape;
3024
2577
  }).listResource.identifier
3025
2578
  : $RdfVocabularies.rdf.nil,
3026
2579
  ]), parameters.graph);
3027
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#in"), parameters.object.in_.toList().flatMap((value) => [
2580
+ parameters.resource.add(PropertyShape.schema.properties.in_.path, parameters.object.in_.toList().flatMap((value) => [
3028
2581
  value.length > 0
3029
2582
  ? value.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
3030
2583
  if (itemIndex === 0) {
@@ -3046,11 +2599,11 @@ export var NodeShape;
3046
2599
  }).listResource.identifier
3047
2600
  : $RdfVocabularies.rdf.nil,
3048
2601
  ]), parameters.graph);
3049
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#isDefinedBy"), parameters.object.isDefinedBy.toList(), parameters.graph);
3050
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#label"), parameters.object.label
2602
+ parameters.resource.add(PropertyShape.schema.properties.isDefinedBy.path, parameters.object.isDefinedBy.toList(), parameters.graph);
2603
+ parameters.resource.add(PropertyShape.schema.properties.label.path, parameters.object.label
3051
2604
  .toList()
3052
2605
  .flatMap((value) => [$literalFactory.string(value)]), parameters.graph);
3053
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#languageIn"), parameters.object.languageIn.toList().flatMap((value) => [
2606
+ parameters.resource.add(PropertyShape.schema.properties.languageIn.path, parameters.object.languageIn.toList().flatMap((value) => [
3054
2607
  value.length > 0
3055
2608
  ? value.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
3056
2609
  if (itemIndex === 0) {
@@ -3072,34 +2625,34 @@ export var NodeShape;
3072
2625
  }).listResource.identifier
3073
2626
  : $RdfVocabularies.rdf.nil,
3074
2627
  ]), parameters.graph);
3075
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#maxCount"), parameters.object.maxCount
2628
+ parameters.resource.add(PropertyShape.schema.properties.maxCount.path, parameters.object.maxCount
3076
2629
  .toList()
3077
2630
  .flatMap((value) => [
3078
2631
  $literalFactory.bigint(value, $RdfVocabularies.xsd.integer),
3079
2632
  ]), parameters.graph);
3080
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#maxExclusive"), parameters.object.maxExclusive.toList(), parameters.graph);
3081
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#maxInclusive"), parameters.object.maxInclusive.toList(), parameters.graph);
3082
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#maxLength"), parameters.object.maxLength
2633
+ parameters.resource.add(PropertyShape.schema.properties.maxExclusive.path, parameters.object.maxExclusive.toList(), parameters.graph);
2634
+ parameters.resource.add(PropertyShape.schema.properties.maxInclusive.path, parameters.object.maxInclusive.toList(), parameters.graph);
2635
+ parameters.resource.add(PropertyShape.schema.properties.maxLength.path, parameters.object.maxLength
3083
2636
  .toList()
3084
2637
  .flatMap((value) => [
3085
2638
  $literalFactory.bigint(value, $RdfVocabularies.xsd.integer),
3086
2639
  ]), parameters.graph);
3087
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#minCount"), parameters.object.minCount
2640
+ parameters.resource.add(PropertyShape.schema.properties.minCount.path, parameters.object.minCount
3088
2641
  .toList()
3089
2642
  .flatMap((value) => [
3090
2643
  $literalFactory.bigint(value, $RdfVocabularies.xsd.integer),
3091
2644
  ]), parameters.graph);
3092
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#minExclusive"), parameters.object.minExclusive.toList(), parameters.graph);
3093
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#minInclusive"), parameters.object.minInclusive.toList(), parameters.graph);
3094
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#minLength"), parameters.object.minLength
2645
+ parameters.resource.add(PropertyShape.schema.properties.minExclusive.path, parameters.object.minExclusive.toList(), parameters.graph);
2646
+ parameters.resource.add(PropertyShape.schema.properties.minInclusive.path, parameters.object.minInclusive.toList(), parameters.graph);
2647
+ parameters.resource.add(PropertyShape.schema.properties.minLength.path, parameters.object.minLength
3095
2648
  .toList()
3096
2649
  .flatMap((value) => [
3097
2650
  $literalFactory.bigint(value, $RdfVocabularies.xsd.integer),
3098
2651
  ]), parameters.graph);
3099
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#node"), parameters.object.node.toList(), parameters.graph);
3100
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#nodeKind"), parameters.object.nodeKind.toList(), parameters.graph);
3101
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#not"), parameters.object.not.flatMap((item) => [item]), parameters.graph);
3102
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#or"), parameters.object.or.toList().flatMap((value) => [
2652
+ parameters.resource.add(PropertyShape.schema.properties.node.path, parameters.object.node.toList(), parameters.graph);
2653
+ parameters.resource.add(PropertyShape.schema.properties.nodeKind.path, parameters.object.nodeKind.toList(), parameters.graph);
2654
+ parameters.resource.add(PropertyShape.schema.properties.not.path, parameters.object.not.flatMap((item) => [item]), parameters.graph);
2655
+ parameters.resource.add(PropertyShape.schema.properties.or.path, parameters.object.or.toList().flatMap((value) => [
3103
2656
  value.length > 0
3104
2657
  ? value.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
3105
2658
  if (itemIndex === 0) {
@@ -3121,13 +2674,13 @@ export var NodeShape;
3121
2674
  }).listResource.identifier
3122
2675
  : $RdfVocabularies.rdf.nil,
3123
2676
  ]), parameters.graph);
3124
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#pattern"), parameters.object.patterns.flatMap((item) => [
2677
+ parameters.resource.add(PropertyShape.schema.properties.patterns.path, parameters.object.patterns.flatMap((item) => [
3125
2678
  $literalFactory.string(item),
3126
2679
  ]), parameters.graph);
3127
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#property"), parameters.object.properties.flatMap((item) => [item]), parameters.graph);
3128
- parameters.resource.add($RdfVocabularies.rdfs.subClassOf, parameters.object.subClassOf.flatMap((item) => [item]), parameters.graph);
3129
- parameters.resource.add($RdfVocabularies.rdf.type, parameters.object.types.flatMap((item) => [item]), parameters.graph);
3130
- parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#xone"), parameters.object.xone.toList().flatMap((value) => [
2680
+ parameters.resource.add(NodeShape.schema.properties.properties.path, parameters.object.properties.flatMap((item) => [item]), parameters.graph);
2681
+ parameters.resource.add(NodeShape.schema.properties.subClassOf.path, parameters.object.subClassOf.flatMap((item) => [item]), parameters.graph);
2682
+ parameters.resource.add(NodeShape.schema.properties.types.path, parameters.object.types.flatMap((item) => [item]), parameters.graph);
2683
+ parameters.resource.add(PropertyShape.schema.properties.xone.path, parameters.object.xone.toList().flatMap((value) => [
3131
2684
  value.length > 0
3132
2685
  ? value.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
3133
2686
  if (itemIndex === 0) {
@@ -3160,7 +2713,7 @@ export var NodeShape;
3160
2713
  }
3161
2714
  NodeShape._propertiesToStrings = _propertiesToStrings;
3162
2715
  function $toString(_nodeShape) {
3163
- return `NodeShape(${JSON.stringify(_propertiesToStrings((_nodeShape ?? this)))})`;
2716
+ return `NodeShape(${JSON.stringify(_propertiesToStrings(_nodeShape))})`;
3164
2717
  }
3165
2718
  NodeShape.$toString = $toString;
3166
2719
  })(NodeShape || (NodeShape = {}));
@@ -3175,25 +2728,6 @@ export var Shape;
3175
2728
  }
3176
2729
  throw new Error("unable to serialize to string");
3177
2730
  };
3178
- Shape.filter = (filter, value) => {
3179
- if (filter.$identifier !== undefined &&
3180
- !$filterIdentifier(filter.$identifier, value.$identifier())) {
3181
- return false;
3182
- }
3183
- if (filter.on?.["NodeShape"] !== undefined &&
3184
- NodeShape.isNodeShape(value)) {
3185
- if (!NodeShape.filter(filter.on["NodeShape"], value)) {
3186
- return false;
3187
- }
3188
- }
3189
- if (filter.on?.["PropertyShape"] !== undefined &&
3190
- PropertyShape.isPropertyShape(value)) {
3191
- if (!PropertyShape.filter(filter.on["PropertyShape"], value)) {
3192
- return false;
3193
- }
3194
- }
3195
- return true;
3196
- };
3197
2731
  Shape.fromRdfResource = (resource, options) => NodeShape.fromRdfResource(resource, {
3198
2732
  ...options,
3199
2733
  ignoreRdfType: false,
@@ -3207,7 +2741,6 @@ export var Shape;
3207
2741
  context: _options.context,
3208
2742
  graph: _options.graph,
3209
2743
  ignoreRdfType: false,
3210
- objectSet: _options.objectSet,
3211
2744
  preferredLanguages: _options.preferredLanguages,
3212
2745
  propertyPath: _options.propertyPath,
3213
2746
  resource: _options.resource,
@@ -3216,7 +2749,6 @@ export var Shape;
3216
2749
  context: _options.context,
3217
2750
  graph: _options.graph,
3218
2751
  ignoreRdfType: false,
3219
- objectSet: _options.objectSet,
3220
2752
  preferredLanguages: _options.preferredLanguages,
3221
2753
  propertyPath: _options.propertyPath,
3222
2754
  resource: _options.resource,
@@ -3515,36 +3047,6 @@ export var $Object;
3515
3047
  }
3516
3048
  throw new Error("unable to serialize to string");
3517
3049
  };
3518
- $Object.filter = (filter, value) => {
3519
- if (filter.$identifier !== undefined &&
3520
- !$filterIdentifier(filter.$identifier, value.$identifier())) {
3521
- return false;
3522
- }
3523
- if (filter.on?.["NodeShape"] !== undefined &&
3524
- NodeShape.isNodeShape(value)) {
3525
- if (!NodeShape.filter(filter.on["NodeShape"], value)) {
3526
- return false;
3527
- }
3528
- }
3529
- if (filter.on?.["Ontology"] !== undefined && Ontology.isOntology(value)) {
3530
- if (!Ontology.filter(filter.on["Ontology"], value)) {
3531
- return false;
3532
- }
3533
- }
3534
- if (filter.on?.["PropertyGroup"] !== undefined &&
3535
- PropertyGroup.isPropertyGroup(value)) {
3536
- if (!PropertyGroup.filter(filter.on["PropertyGroup"], value)) {
3537
- return false;
3538
- }
3539
- }
3540
- if (filter.on?.["PropertyShape"] !== undefined &&
3541
- PropertyShape.isPropertyShape(value)) {
3542
- if (!PropertyShape.filter(filter.on["PropertyShape"], value)) {
3543
- return false;
3544
- }
3545
- }
3546
- return true;
3547
- };
3548
3050
  $Object.fromRdfResource = (resource, options) => NodeShape.fromRdfResource(resource, {
3549
3051
  ...options,
3550
3052
  ignoreRdfType: false,
@@ -3567,7 +3069,6 @@ export var $Object;
3567
3069
  context: _options.context,
3568
3070
  graph: _options.graph,
3569
3071
  ignoreRdfType: false,
3570
- objectSet: _options.objectSet,
3571
3072
  preferredLanguages: _options.preferredLanguages,
3572
3073
  propertyPath: _options.propertyPath,
3573
3074
  resource: _options.resource,
@@ -3576,7 +3077,6 @@ export var $Object;
3576
3077
  context: _options.context,
3577
3078
  graph: _options.graph,
3578
3079
  ignoreRdfType: false,
3579
- objectSet: _options.objectSet,
3580
3080
  preferredLanguages: _options.preferredLanguages,
3581
3081
  propertyPath: _options.propertyPath,
3582
3082
  resource: _options.resource,
@@ -3585,7 +3085,6 @@ export var $Object;
3585
3085
  context: _options.context,
3586
3086
  graph: _options.graph,
3587
3087
  ignoreRdfType: false,
3588
- objectSet: _options.objectSet,
3589
3088
  preferredLanguages: _options.preferredLanguages,
3590
3089
  propertyPath: _options.propertyPath,
3591
3090
  resource: _options.resource,
@@ -3594,7 +3093,6 @@ export var $Object;
3594
3093
  context: _options.context,
3595
3094
  graph: _options.graph,
3596
3095
  ignoreRdfType: false,
3597
- objectSet: _options.objectSet,
3598
3096
  preferredLanguages: _options.preferredLanguages,
3599
3097
  propertyPath: _options.propertyPath,
3600
3098
  resource: _options.resource,
@@ -3690,443 +3188,4 @@ export var $Object;
3690
3188
  throw new Error("unable to serialize to RDF");
3691
3189
  });
3692
3190
  })($Object || ($Object = {}));
3693
- export class $RdfjsDatasetObjectSet {
3694
- #dataset;
3695
- #graph;
3696
- constructor(dataset, options) {
3697
- this.#dataset = dataset;
3698
- this.#graph = options?.graph;
3699
- }
3700
- $dataset() {
3701
- if (typeof this.#dataset === "object") {
3702
- return this.#dataset;
3703
- }
3704
- return this.#dataset();
3705
- }
3706
- $resourceSet() {
3707
- return new ResourceSet({
3708
- dataFactory: dataFactory,
3709
- dataset: this.$dataset(),
3710
- });
3711
- }
3712
- async nodeShape(identifier, options) {
3713
- return this.nodeShapeSync(identifier, options);
3714
- }
3715
- nodeShapeSync(identifier, options) {
3716
- return this.nodeShapesSync({
3717
- identifiers: [identifier],
3718
- preferredLanguages: options?.preferredLanguages,
3719
- }).map((objects) => objects[0]);
3720
- }
3721
- async nodeShapeCount(query) {
3722
- return this.nodeShapeCountSync(query);
3723
- }
3724
- nodeShapeCountSync(query) {
3725
- return this.nodeShapesSync(query).map((objects) => objects.length);
3726
- }
3727
- async nodeShapeIdentifiers(query) {
3728
- return this.nodeShapeIdentifiersSync(query);
3729
- }
3730
- nodeShapeIdentifiersSync(query) {
3731
- return this.nodeShapesSync(query).map((objects) => objects.map((object) => object.$identifier()));
3732
- }
3733
- async nodeShapes(query) {
3734
- return this.nodeShapesSync(query);
3735
- }
3736
- nodeShapesSync(query) {
3737
- return this.#objectsSync({
3738
- filter: NodeShape.filter,
3739
- fromRdfResource: NodeShape.fromRdfResource,
3740
- fromRdfTypes: [NodeShape.fromRdfType],
3741
- }, query);
3742
- }
3743
- async ontology(identifier, options) {
3744
- return this.ontologySync(identifier, options);
3745
- }
3746
- ontologySync(identifier, options) {
3747
- return this.ontologiesSync({
3748
- identifiers: [identifier],
3749
- preferredLanguages: options?.preferredLanguages,
3750
- }).map((objects) => objects[0]);
3751
- }
3752
- async ontologyCount(query) {
3753
- return this.ontologyCountSync(query);
3754
- }
3755
- ontologyCountSync(query) {
3756
- return this.ontologiesSync(query).map((objects) => objects.length);
3757
- }
3758
- async ontologyIdentifiers(query) {
3759
- return this.ontologyIdentifiersSync(query);
3760
- }
3761
- ontologyIdentifiersSync(query) {
3762
- return this.ontologiesSync(query).map((objects) => objects.map((object) => object.$identifier()));
3763
- }
3764
- async ontologies(query) {
3765
- return this.ontologiesSync(query);
3766
- }
3767
- ontologiesSync(query) {
3768
- return this.#objectsSync({
3769
- filter: Ontology.filter,
3770
- fromRdfResource: Ontology.fromRdfResource,
3771
- fromRdfTypes: [Ontology.fromRdfType],
3772
- }, query);
3773
- }
3774
- async propertyGroup(identifier, options) {
3775
- return this.propertyGroupSync(identifier, options);
3776
- }
3777
- propertyGroupSync(identifier, options) {
3778
- return this.propertyGroupsSync({
3779
- identifiers: [identifier],
3780
- preferredLanguages: options?.preferredLanguages,
3781
- }).map((objects) => objects[0]);
3782
- }
3783
- async propertyGroupCount(query) {
3784
- return this.propertyGroupCountSync(query);
3785
- }
3786
- propertyGroupCountSync(query) {
3787
- return this.propertyGroupsSync(query).map((objects) => objects.length);
3788
- }
3789
- async propertyGroupIdentifiers(query) {
3790
- return this.propertyGroupIdentifiersSync(query);
3791
- }
3792
- propertyGroupIdentifiersSync(query) {
3793
- return this.propertyGroupsSync(query).map((objects) => objects.map((object) => object.$identifier()));
3794
- }
3795
- async propertyGroups(query) {
3796
- return this.propertyGroupsSync(query);
3797
- }
3798
- propertyGroupsSync(query) {
3799
- return this.#objectsSync({
3800
- filter: PropertyGroup.filter,
3801
- fromRdfResource: PropertyGroup.fromRdfResource,
3802
- fromRdfTypes: [PropertyGroup.fromRdfType],
3803
- }, query);
3804
- }
3805
- async propertyShape(identifier, options) {
3806
- return this.propertyShapeSync(identifier, options);
3807
- }
3808
- propertyShapeSync(identifier, options) {
3809
- return this.propertyShapesSync({
3810
- identifiers: [identifier],
3811
- preferredLanguages: options?.preferredLanguages,
3812
- }).map((objects) => objects[0]);
3813
- }
3814
- async propertyShapeCount(query) {
3815
- return this.propertyShapeCountSync(query);
3816
- }
3817
- propertyShapeCountSync(query) {
3818
- return this.propertyShapesSync(query).map((objects) => objects.length);
3819
- }
3820
- async propertyShapeIdentifiers(query) {
3821
- return this.propertyShapeIdentifiersSync(query);
3822
- }
3823
- propertyShapeIdentifiersSync(query) {
3824
- return this.propertyShapesSync(query).map((objects) => objects.map((object) => object.$identifier()));
3825
- }
3826
- async propertyShapes(query) {
3827
- return this.propertyShapesSync(query);
3828
- }
3829
- propertyShapesSync(query) {
3830
- return this.#objectsSync({
3831
- filter: PropertyShape.filter,
3832
- fromRdfResource: PropertyShape.fromRdfResource,
3833
- fromRdfTypes: [PropertyShape.fromRdfType],
3834
- }, query);
3835
- }
3836
- async shape(identifier, options) {
3837
- return this.shapeSync(identifier, options);
3838
- }
3839
- shapeSync(identifier, options) {
3840
- return this.shapesSync({
3841
- identifiers: [identifier],
3842
- preferredLanguages: options?.preferredLanguages,
3843
- }).map((objects) => objects[0]);
3844
- }
3845
- async shapeCount(query) {
3846
- return this.shapeCountSync(query);
3847
- }
3848
- shapeCountSync(query) {
3849
- return this.shapesSync(query).map((objects) => objects.length);
3850
- }
3851
- async shapeIdentifiers(query) {
3852
- return this.shapeIdentifiersSync(query);
3853
- }
3854
- shapeIdentifiersSync(query) {
3855
- return this.shapesSync(query).map((objects) => objects.map((object) => object.$identifier()));
3856
- }
3857
- async shapes(query) {
3858
- return this.shapesSync(query);
3859
- }
3860
- shapesSync(query) {
3861
- return this.#objectUnionsSync([
3862
- {
3863
- filter: Shape.filter,
3864
- fromRdfResource: NodeShape.fromRdfResource,
3865
- fromRdfTypes: [NodeShape.fromRdfType],
3866
- },
3867
- {
3868
- filter: Shape.filter,
3869
- fromRdfResource: PropertyShape.fromRdfResource,
3870
- fromRdfTypes: [PropertyShape.fromRdfType],
3871
- },
3872
- ], query);
3873
- }
3874
- async $object(identifier, options) {
3875
- return this.$objectSync(identifier, options);
3876
- }
3877
- $objectSync(identifier, options) {
3878
- return this.$objectsSync({
3879
- identifiers: [identifier],
3880
- preferredLanguages: options?.preferredLanguages,
3881
- }).map((objects) => objects[0]);
3882
- }
3883
- async $objectCount(query) {
3884
- return this.$objectCountSync(query);
3885
- }
3886
- $objectCountSync(query) {
3887
- return this.$objectsSync(query).map((objects) => objects.length);
3888
- }
3889
- async $objectIdentifiers(query) {
3890
- return this.$objectIdentifiersSync(query);
3891
- }
3892
- $objectIdentifiersSync(query) {
3893
- return this.$objectsSync(query).map((objects) => objects.map((object) => object.$identifier()));
3894
- }
3895
- async $objects(query) {
3896
- return this.$objectsSync(query);
3897
- }
3898
- $objectsSync(query) {
3899
- return this.#objectUnionsSync([
3900
- {
3901
- filter: $Object.filter,
3902
- fromRdfResource: NodeShape.fromRdfResource,
3903
- fromRdfTypes: [NodeShape.fromRdfType],
3904
- },
3905
- {
3906
- filter: $Object.filter,
3907
- fromRdfResource: Ontology.fromRdfResource,
3908
- fromRdfTypes: [Ontology.fromRdfType],
3909
- },
3910
- {
3911
- filter: $Object.filter,
3912
- fromRdfResource: PropertyGroup.fromRdfResource,
3913
- fromRdfTypes: [PropertyGroup.fromRdfType],
3914
- },
3915
- {
3916
- filter: $Object.filter,
3917
- fromRdfResource: PropertyShape.fromRdfResource,
3918
- fromRdfTypes: [PropertyShape.fromRdfType],
3919
- },
3920
- ], query);
3921
- }
3922
- #objectsSync(namedObjectType, query) {
3923
- const graph = query?.graph ?? this.#graph;
3924
- const limit = query?.limit ?? Number.MAX_SAFE_INTEGER;
3925
- if (limit <= 0) {
3926
- return Right([]);
3927
- }
3928
- let offset = query?.offset ?? 0;
3929
- if (offset < 0) {
3930
- offset = 0;
3931
- }
3932
- const fromRdfResourceOptions = {
3933
- graph,
3934
- objectSet: this,
3935
- preferredLanguages: query?.preferredLanguages,
3936
- };
3937
- let resources;
3938
- const resourceSet = this.$resourceSet(); // Access once, in case it's instantiated lazily
3939
- let sortResources;
3940
- if (query?.identifiers) {
3941
- resources = query.identifiers.map((identifier) => ({
3942
- resource: resourceSet.resource(identifier),
3943
- }));
3944
- sortResources = false;
3945
- }
3946
- else if (namedObjectType.fromRdfTypes.length > 0) {
3947
- const identifierSet = new $IdentifierSet();
3948
- resources = [];
3949
- sortResources = true;
3950
- for (const fromRdfType of namedObjectType.fromRdfTypes) {
3951
- for (const resource of resourceSet.instancesOf(fromRdfType, {
3952
- graph,
3953
- })) {
3954
- if (!identifierSet.has(resource.identifier)) {
3955
- identifierSet.add(resource.identifier);
3956
- resources.push({ resource });
3957
- }
3958
- }
3959
- }
3960
- }
3961
- else {
3962
- const identifierSet = new $IdentifierSet();
3963
- resources = [];
3964
- sortResources = true;
3965
- for (const quad of resourceSet.dataset) {
3966
- if (graph && !quad.graph.equals(graph)) {
3967
- continue;
3968
- }
3969
- switch (quad.subject.termType) {
3970
- case "BlankNode":
3971
- case "NamedNode":
3972
- break;
3973
- default:
3974
- continue;
3975
- }
3976
- if (identifierSet.has(quad.subject)) {
3977
- continue;
3978
- }
3979
- identifierSet.add(quad.subject);
3980
- const resource = resourceSet.resource(quad.subject);
3981
- // Eagerly eliminate the majority of resources that won't match the object type
3982
- namedObjectType
3983
- .fromRdfResource(resource, fromRdfResourceOptions)
3984
- .ifRight((object) => {
3985
- resources.push({ object, resource });
3986
- });
3987
- }
3988
- }
3989
- if (sortResources) {
3990
- // Sort resources by identifier so limit and offset are deterministic
3991
- resources.sort((left, right) => left.resource.identifier.value.localeCompare(right.resource.identifier.value));
3992
- }
3993
- let objectI = 0;
3994
- const objects = [];
3995
- for (let { object, resource } of resources) {
3996
- if (!object) {
3997
- const objectEither = namedObjectType.fromRdfResource(resource, fromRdfResourceOptions);
3998
- if (objectEither.isLeft()) {
3999
- return objectEither;
4000
- }
4001
- object = objectEither.unsafeCoerce();
4002
- }
4003
- if (query?.filter && !namedObjectType.filter(query.filter, object)) {
4004
- continue;
4005
- }
4006
- if (objectI++ >= offset) {
4007
- objects.push(object);
4008
- if (objects.length === limit) {
4009
- return Right(objects);
4010
- }
4011
- }
4012
- }
4013
- return Right(objects);
4014
- }
4015
- #objectUnionsSync(namedObjectTypes, query) {
4016
- const graph = query?.graph ?? this.#graph;
4017
- const limit = query?.limit ?? Number.MAX_SAFE_INTEGER;
4018
- if (limit <= 0) {
4019
- return Right([]);
4020
- }
4021
- let offset = query?.offset ?? 0;
4022
- if (offset < 0) {
4023
- offset = 0;
4024
- }
4025
- const fromRdfResourceOptions = {
4026
- graph,
4027
- objectSet: this,
4028
- preferredLanguages: query?.preferredLanguages,
4029
- };
4030
- let resources;
4031
- const resourceSet = this.$resourceSet(); // Access once, in case it's instantiated lazily
4032
- let sortResources;
4033
- if (query?.identifiers) {
4034
- resources = query.identifiers.map((identifier) => ({
4035
- resource: resourceSet.resource(identifier),
4036
- }));
4037
- sortResources = false;
4038
- }
4039
- else if (namedObjectTypes.every((namedObjectType) => namedObjectType.fromRdfTypes.length > 0)) {
4040
- const identifierSet = new $IdentifierSet();
4041
- resources = [];
4042
- sortResources = true;
4043
- for (const namedObjectType of namedObjectTypes) {
4044
- for (const fromRdfType of namedObjectType.fromRdfTypes) {
4045
- for (const resource of resourceSet.instancesOf(fromRdfType, {
4046
- graph,
4047
- })) {
4048
- if (!identifierSet.has(resource.identifier)) {
4049
- identifierSet.add(resource.identifier);
4050
- resources.push({ namedObjectType, resource });
4051
- }
4052
- }
4053
- }
4054
- }
4055
- }
4056
- else {
4057
- const identifierSet = new $IdentifierSet();
4058
- resources = [];
4059
- sortResources = true;
4060
- for (const quad of resourceSet.dataset) {
4061
- if (graph && !quad.graph.equals(graph)) {
4062
- continue;
4063
- }
4064
- switch (quad.subject.termType) {
4065
- case "BlankNode":
4066
- case "NamedNode":
4067
- break;
4068
- default:
4069
- continue;
4070
- }
4071
- if (identifierSet.has(quad.subject)) {
4072
- continue;
4073
- }
4074
- identifierSet.add(quad.subject);
4075
- // Eagerly eliminate the majority of resources that won't match the object types
4076
- const resource = resourceSet.resource(quad.subject);
4077
- for (const namedObjectType of namedObjectTypes) {
4078
- if (namedObjectType
4079
- .fromRdfResource(resource, fromRdfResourceOptions)
4080
- .ifRight((object) => {
4081
- resources.push({ object, namedObjectType, resource });
4082
- })
4083
- .isRight()) {
4084
- break;
4085
- }
4086
- }
4087
- }
4088
- }
4089
- if (sortResources) {
4090
- // Sort resources by identifier so limit and offset are deterministic
4091
- resources.sort((left, right) => left.resource.identifier.value.localeCompare(right.resource.identifier.value));
4092
- }
4093
- let objectI = 0;
4094
- const objects = [];
4095
- for (let { object, namedObjectType, resource } of resources) {
4096
- if (!object) {
4097
- let objectEither;
4098
- if (namedObjectType) {
4099
- objectEither = namedObjectType.fromRdfResource(resource, fromRdfResourceOptions);
4100
- }
4101
- else {
4102
- objectEither = Left(new Error("no object types"));
4103
- for (const tryObjectType of namedObjectTypes) {
4104
- objectEither = tryObjectType.fromRdfResource(resource, fromRdfResourceOptions);
4105
- if (objectEither.isRight()) {
4106
- namedObjectType = tryObjectType;
4107
- break;
4108
- }
4109
- }
4110
- }
4111
- if (objectEither.isLeft()) {
4112
- return objectEither;
4113
- }
4114
- object = objectEither.unsafeCoerce();
4115
- }
4116
- if (!namedObjectType) {
4117
- throw new Error("namedObjectType should be set here");
4118
- }
4119
- if (query?.filter && !namedObjectType.filter(query.filter, object)) {
4120
- continue;
4121
- }
4122
- if (objectI++ >= offset) {
4123
- objects.push(object);
4124
- if (objects.length === limit) {
4125
- return Right(objects);
4126
- }
4127
- }
4128
- }
4129
- return Right(objects);
4130
- }
4131
- }
4132
3191
  //# sourceMappingURL=generated.js.map