@shaclmate/shacl-ast 4.0.30 → 4.0.32

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
@@ -241,9 +241,55 @@ var $RdfVocabularies;
241
241
  xsd.unsignedShort = dataFactory.namedNode("http://www.w3.org/2001/XMLSchema#unsignedShort");
242
242
  })(xsd = $RdfVocabularies.xsd || ($RdfVocabularies.xsd = {}));
243
243
  })($RdfVocabularies || ($RdfVocabularies = {}));
244
+ function $sequenceRecord(record) {
245
+ const result = {};
246
+ for (const key of globalThis.Object.keys(record)) {
247
+ const either = record[key];
248
+ if (either.isLeft()) {
249
+ return either;
250
+ }
251
+ result[key] = either.extract();
252
+ }
253
+ return Right(result);
254
+ }
244
255
  function $shaclPropertyFromRdf({ graph, propertySchema, resource, typeFromRdf, }) {
245
256
  return typeFromRdf(Right(resource.values(propertySchema.path, { graph, unique: true }))).chain((values) => values.head());
246
257
  }
258
+ function $wrap_FromRdfResourceFunction(_fromRdfResourceFunction) {
259
+ return (resource, options) => {
260
+ let { context, graph, ignoreRdfType = false, objectSet, preferredLanguages, } = options ?? {};
261
+ if (!objectSet) {
262
+ objectSet = new $RdfjsDatasetObjectSet(resource.dataset);
263
+ }
264
+ return _fromRdfResourceFunction(resource, {
265
+ context,
266
+ graph,
267
+ ignoreRdfType,
268
+ objectSet,
269
+ preferredLanguages,
270
+ });
271
+ };
272
+ }
273
+ function $wrap_ToRdfResourceFunction(_toRdfResourceFunction) {
274
+ return (object, options) => {
275
+ let { graph, ignoreRdfType = false, resourceSet } = options ?? {};
276
+ if (!resourceSet) {
277
+ resourceSet = new ResourceSet({
278
+ dataFactory: dataFactory,
279
+ dataset: datasetFactory.dataset(),
280
+ });
281
+ }
282
+ const resource = resourceSet.resource(object.$identifier());
283
+ _toRdfResourceFunction({
284
+ graph,
285
+ ignoreRdfType,
286
+ object,
287
+ resource,
288
+ resourceSet,
289
+ });
290
+ return resource;
291
+ };
292
+ }
247
293
  export var PropertyShape;
248
294
  (function (PropertyShape) {
249
295
  function create(parameters) {
@@ -977,33 +1023,7 @@ export var PropertyShape;
977
1023
  return true;
978
1024
  }
979
1025
  PropertyShape.filter = filter;
980
- PropertyShape.fromRdfResource = (resource, options) => {
981
- let { context, graph, ignoreRdfType = false, objectSet, preferredLanguages, } = options ?? {};
982
- if (!objectSet) {
983
- objectSet = new $RdfjsDatasetObjectSet(resource.dataset);
984
- }
985
- return PropertyShape.propertiesFromRdfResource(resource, {
986
- context,
987
- graph,
988
- ignoreRdfType,
989
- objectSet,
990
- preferredLanguages,
991
- }).map(create);
992
- };
993
- PropertyShape.fromRdfResourceValues = (values, options) => values.chain((values) => values.chainMap((value) => value
994
- .toResource()
995
- .chain((resource) => PropertyShape.fromRdfResource(resource, options))));
996
- PropertyShape.fromRdfType = dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyShape");
997
- function isPropertyShape(object) {
998
- switch (object.$type) {
999
- case "PropertyShape":
1000
- return true;
1001
- default:
1002
- return false;
1003
- }
1004
- }
1005
- PropertyShape.isPropertyShape = isPropertyShape;
1006
- PropertyShape.propertiesFromRdfResource = ($resource, _$options) => {
1026
+ PropertyShape._fromRdfResource = ($resource, _$options) => {
1007
1027
  return (!_$options.ignoreRdfType
1008
1028
  ? $resource
1009
1029
  .value($RdfVocabularies.rdf.type, { graph: _$options.graph })
@@ -1022,680 +1042,561 @@ export var PropertyShape;
1022
1042
  }
1023
1043
  return Left(new Error(`${$resource.identifier} has unexpected RDF type (actual: ${actualRdfType.value}, expected: http://www.w3.org/ns/shacl#PropertyShape)`));
1024
1044
  })
1025
- : Right(true)).chain((_rdfTypeCheck) => Right(new Resource.Value({
1026
- dataFactory: dataFactory,
1027
- focusResource: $resource,
1028
- propertyPath: $RdfVocabularies.rdf.subject,
1029
- term: $resource.identifier,
1030
- }).toValues())
1031
- .chain((values) => values.chainMap((value) => value.toIdentifier()))
1032
- .chain((values) => values.head())
1033
- .chain(($identifier) => Right("PropertyShape").chain(($type) => $shaclPropertyFromRdf({
1034
- graph: _$options.graph,
1035
- resource: $resource,
1036
- propertySchema: PropertyShape.schema.properties.and,
1037
- typeFromRdf: (resourceValues) => resourceValues
1038
- .chain((values) => values.chainMap((value) => value.toList({ graph: _$options.graph })))
1039
- .chain((valueLists) => valueLists.chainMap((valueList) => Right(Resource.Values.fromArray({
1040
- focusResource: $resource,
1041
- propertyPath: PropertyShape.schema.properties.and.path,
1042
- values: valueList.toArray(),
1043
- })).chain((values) => values.chainMap((value) => value.toIdentifier()))))
1044
- .map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
1045
- .map((values) => values.length > 0
1046
- ? values.map((value) => Maybe.of(value))
1047
- : Resource.Values.fromValue({
1048
- focusResource: $resource,
1049
- propertyPath: PropertyShape.schema.properties.and.path,
1050
- value: Maybe.empty(),
1051
- })),
1052
- }).chain((and) => $shaclPropertyFromRdf({
1053
- graph: _$options.graph,
1054
- resource: $resource,
1055
- propertySchema: PropertyShape.schema.properties.classes,
1056
- typeFromRdf: (resourceValues) => resourceValues
1057
- .chain((values) => values.chainMap((value) => value.toIri()))
1058
- .map((values) => values.toArray())
1059
- .map((valuesArray) => Resource.Values.fromValue({
1060
- focusResource: $resource,
1061
- propertyPath: PropertyShape.schema.properties.classes.path,
1062
- value: valuesArray,
1063
- })),
1064
- }).chain((classes) => $shaclPropertyFromRdf({
1065
- graph: _$options.graph,
1066
- resource: $resource,
1067
- propertySchema: PropertyShape.schema.properties.comment,
1068
- typeFromRdf: (resourceValues) => resourceValues
1069
- .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
1070
- .chain((values) => values.chainMap((value) => value.toString()))
1071
- .map((values) => values.length > 0
1072
- ? values.map((value) => Maybe.of(value))
1073
- : Resource.Values.fromValue({
1074
- focusResource: $resource,
1075
- propertyPath: PropertyShape.schema.properties.comment.path,
1076
- value: Maybe.empty(),
1077
- })),
1078
- }).chain((comment) => $shaclPropertyFromRdf({
1079
- graph: _$options.graph,
1080
- resource: $resource,
1081
- propertySchema: PropertyShape.schema.properties.datatype,
1082
- typeFromRdf: (resourceValues) => resourceValues
1083
- .chain((values) => values.chainMap((value) => value.toIri()))
1084
- .map((values) => values.length > 0
1085
- ? values.map((value) => Maybe.of(value))
1086
- : Resource.Values.fromValue({
1087
- focusResource: $resource,
1088
- propertyPath: PropertyShape.schema.properties.datatype.path,
1089
- value: Maybe.empty(),
1090
- })),
1091
- }).chain((datatype) => $shaclPropertyFromRdf({
1092
- graph: _$options.graph,
1093
- resource: $resource,
1094
- propertySchema: PropertyShape.schema.properties.deactivated,
1095
- typeFromRdf: (resourceValues) => resourceValues
1096
- .chain((values) => values.chainMap((value) => value.toBoolean()))
1097
- .map((values) => values.length > 0
1098
- ? values.map((value) => Maybe.of(value))
1099
- : Resource.Values.fromValue({
1100
- focusResource: $resource,
1101
- propertyPath: PropertyShape.schema.properties.deactivated
1102
- .path,
1103
- value: Maybe.empty(),
1104
- })),
1105
- }).chain((deactivated) => $shaclPropertyFromRdf({
1106
- graph: _$options.graph,
1107
- resource: $resource,
1108
- propertySchema: PropertyShape.schema.properties.defaultValue,
1109
- typeFromRdf: (resourceValues) => resourceValues
1110
- .chain((values) => values.chainMap((value) => value.toTerm().chain((term) => {
1111
- switch (term.termType) {
1112
- case "NamedNode":
1113
- case "Literal":
1114
- return Either.of(term);
1115
- default:
1116
- return Left(new Resource.MistypedTermValueError({
1117
- actualValue: term,
1118
- expectedValueType: "(NamedNode | Literal)",
1119
- focusResource: $resource,
1120
- propertyPath: PropertyShape.schema.properties
1121
- .defaultValue.path,
1122
- }));
1123
- }
1124
- })))
1125
- .map((values) => values.length > 0
1126
- ? values.map((value) => Maybe.of(value))
1127
- : Resource.Values.fromValue({
1128
- focusResource: $resource,
1129
- propertyPath: PropertyShape.schema.properties
1130
- .defaultValue.path,
1131
- value: Maybe.empty(),
1132
- })),
1133
- }).chain((defaultValue) => $shaclPropertyFromRdf({
1134
- graph: _$options.graph,
1135
- resource: $resource,
1136
- propertySchema: PropertyShape.schema.properties.description,
1137
- typeFromRdf: (resourceValues) => resourceValues
1138
- .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
1139
- .chain((values) => values.chainMap((value) => value.toString()))
1140
- .map((values) => values.length > 0
1141
- ? values.map((value) => Maybe.of(value))
1142
- : Resource.Values.fromValue({
1143
- focusResource: $resource,
1144
- propertyPath: PropertyShape.schema.properties
1145
- .description.path,
1146
- value: Maybe.empty(),
1147
- })),
1148
- }).chain((description) => $shaclPropertyFromRdf({
1149
- graph: _$options.graph,
1150
- resource: $resource,
1151
- propertySchema: PropertyShape.schema.properties.flags,
1152
- typeFromRdf: (resourceValues) => resourceValues
1153
- .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
1154
- .chain((values) => values.chainMap((value) => value.toString()))
1155
- .map((values) => values.toArray())
1156
- .map((valuesArray) => Resource.Values.fromValue({
1045
+ : Right(true)).chain((_rdfTypeCheck) => $sequenceRecord({
1046
+ $identifier: Right(new Resource.Value({
1047
+ dataFactory: dataFactory,
1157
1048
  focusResource: $resource,
1158
- propertyPath: PropertyShape.schema.properties.flags
1159
- .path,
1160
- value: valuesArray,
1161
- })),
1162
- }).chain((flags) => $shaclPropertyFromRdf({
1163
- graph: _$options.graph,
1164
- resource: $resource,
1165
- propertySchema: PropertyShape.schema.properties.groups,
1166
- typeFromRdf: (resourceValues) => resourceValues
1049
+ propertyPath: $RdfVocabularies.rdf.subject,
1050
+ term: $resource.identifier,
1051
+ }).toValues())
1167
1052
  .chain((values) => values.chainMap((value) => value.toIdentifier()))
1168
- .map((values) => values.toArray())
1169
- .map((valuesArray) => Resource.Values.fromValue({
1170
- focusResource: $resource,
1171
- propertyPath: PropertyShape.schema.properties.groups
1172
- .path,
1173
- value: valuesArray,
1174
- })),
1175
- }).chain((groups) => $shaclPropertyFromRdf({
1176
- graph: _$options.graph,
1177
- resource: $resource,
1178
- propertySchema: PropertyShape.schema.properties.hasValues,
1179
- typeFromRdf: (resourceValues) => resourceValues
1180
- .chain((values) => values.chainMap((value) => value.toTerm().chain((term) => {
1181
- switch (term.termType) {
1182
- case "NamedNode":
1183
- case "Literal":
1184
- return Either.of(term);
1185
- default:
1186
- return Left(new Resource.MistypedTermValueError({
1187
- actualValue: term,
1188
- expectedValueType: "(NamedNode | Literal)",
1189
- focusResource: $resource,
1190
- propertyPath: PropertyShape.schema
1191
- .properties.hasValues
1192
- .path,
1193
- }));
1194
- }
1195
- })))
1196
- .map((values) => values.toArray())
1197
- .map((valuesArray) => Resource.Values.fromValue({
1198
- focusResource: $resource,
1199
- propertyPath: PropertyShape.schema.properties
1200
- .hasValues.path,
1201
- value: valuesArray,
1202
- })),
1203
- }).chain((hasValues) => $shaclPropertyFromRdf({
1204
- graph: _$options.graph,
1205
- resource: $resource,
1206
- propertySchema: PropertyShape.schema.properties.in_,
1207
- typeFromRdf: (resourceValues) => resourceValues
1208
- .chain((values) => values.chainMap((value) => value.toList({
1053
+ .chain((values) => values.head()),
1054
+ and: $shaclPropertyFromRdf({
1209
1055
  graph: _$options.graph,
1210
- })))
1211
- .chain((valueLists) => valueLists.chainMap((valueList) => Right(Resource.Values.fromArray({
1212
- focusResource: $resource,
1213
- propertyPath: PropertyShape.schema.properties
1214
- .in_.path,
1215
- values: valueList.toArray(),
1216
- })).chain((values) => values.chainMap((value) => value.toTerm().chain((term) => {
1217
- switch (term.termType) {
1218
- case "NamedNode":
1219
- case "Literal":
1220
- return Either.of(term);
1221
- default:
1222
- return Left(new Resource.MistypedTermValueError({
1223
- actualValue: term,
1224
- expectedValueType: "(NamedNode | Literal)",
1225
- focusResource: $resource,
1226
- propertyPath: PropertyShape.schema
1227
- .properties.in_
1228
- .path,
1229
- }));
1230
- }
1231
- })))))
1232
- .map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
1233
- .map((values) => values.length > 0
1234
- ? values.map((value) => Maybe.of(value))
1235
- : Resource.Values.fromValue({
1236
- focusResource: $resource,
1237
- propertyPath: PropertyShape.schema.properties
1238
- .in_.path,
1239
- value: Maybe.empty(),
1240
- })),
1241
- }).chain((in_) => $shaclPropertyFromRdf({
1242
- graph: _$options.graph,
1243
- resource: $resource,
1244
- propertySchema: PropertyShape.schema.properties.isDefinedBy,
1245
- typeFromRdf: (resourceValues) => resourceValues
1246
- .chain((values) => values.chainMap((value) => value.toIdentifier()))
1247
- .map((values) => values.length > 0
1248
- ? values.map((value) => Maybe.of(value))
1249
- : Resource.Values.fromValue({
1250
- focusResource: $resource,
1251
- propertyPath: PropertyShape.schema
1252
- .properties.isDefinedBy
1253
- .path,
1254
- value: Maybe.empty(),
1255
- })),
1256
- }).chain((isDefinedBy) => $shaclPropertyFromRdf({
1257
- graph: _$options.graph,
1258
- resource: $resource,
1259
- propertySchema: PropertyShape.schema.properties.label,
1260
- typeFromRdf: (resourceValues) => resourceValues
1261
- .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
1262
- .chain((values) => values.chainMap((value) => value.toString()))
1263
- .map((values) => values.length > 0
1264
- ? values.map((value) => Maybe.of(value))
1265
- : Resource.Values.fromValue({
1056
+ resource: $resource,
1057
+ propertySchema: PropertyShape.schema.properties.and,
1058
+ typeFromRdf: (resourceValues) => resourceValues
1059
+ .chain((values) => values.chainMap((value) => value.toList({ graph: _$options.graph })))
1060
+ .chain((valueLists) => valueLists.chainMap((valueList) => Right(Resource.Values.fromArray({
1266
1061
  focusResource: $resource,
1267
- propertyPath: PropertyShape.schema
1268
- .properties.label.path,
1269
- value: Maybe.empty(),
1270
- })),
1271
- }).chain((label) => $shaclPropertyFromRdf({
1272
- graph: _$options.graph,
1273
- resource: $resource,
1274
- propertySchema: PropertyShape.schema.properties.languageIn,
1275
- typeFromRdf: (resourceValues) => resourceValues
1276
- .chain((values) => values.chainMap((value) => value.toList({
1062
+ propertyPath: PropertyShape.schema.properties.and.path,
1063
+ values: valueList.toArray(),
1064
+ })).chain((values) => values.chainMap((value) => value.toIdentifier()))))
1065
+ .map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
1066
+ .map((values) => values.length > 0
1067
+ ? values.map((value) => Maybe.of(value))
1068
+ : Resource.Values.fromValue({
1069
+ focusResource: $resource,
1070
+ propertyPath: PropertyShape.schema.properties.and.path,
1071
+ value: Maybe.empty(),
1072
+ })),
1073
+ }),
1074
+ classes: $shaclPropertyFromRdf({
1277
1075
  graph: _$options.graph,
1278
- })))
1279
- .chain((valueLists) => valueLists.chainMap((valueList) => Right(Resource.Values.fromArray({
1280
- focusResource: $resource,
1281
- propertyPath: PropertyShape.schema
1282
- .properties.languageIn
1283
- .path,
1284
- values: valueList.toArray(),
1285
- }))
1286
- .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
1287
- .chain((values) => values.chainMap((value) => value.toString()))))
1288
- .map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
1289
- .map((values) => values.length > 0
1290
- ? values.map((value) => Maybe.of(value))
1291
- : Resource.Values.fromValue({
1292
- focusResource: $resource,
1293
- propertyPath: PropertyShape.schema
1294
- .properties.languageIn
1295
- .path,
1296
- value: Maybe.empty(),
1297
- })),
1298
- }).chain((languageIn) => $shaclPropertyFromRdf({
1299
- graph: _$options.graph,
1300
- resource: $resource,
1301
- propertySchema: PropertyShape.schema.properties.maxCount,
1302
- typeFromRdf: (resourceValues) => resourceValues
1303
- .chain((values) => values.chainMap((value) => value.toBigInt()))
1304
- .map((values) => values.length > 0
1305
- ? values.map((value) => Maybe.of(value))
1306
- : Resource.Values.fromValue({
1307
- focusResource: $resource,
1308
- propertyPath: PropertyShape.schema
1309
- .properties.maxCount
1310
- .path,
1311
- value: Maybe.empty(),
1312
- })),
1313
- }).chain((maxCount) => $shaclPropertyFromRdf({
1314
- graph: _$options.graph,
1315
- resource: $resource,
1316
- propertySchema: PropertyShape.schema.properties.maxExclusive,
1317
- typeFromRdf: (resourceValues) => resourceValues
1318
- .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
1319
- .chain((values) => values.chainMap((value) => value.toLiteral()))
1320
- .map((values) => values.length > 0
1321
- ? values.map((value) => Maybe.of(value))
1322
- : Resource.Values.fromValue({
1323
- focusResource: $resource,
1324
- propertyPath: PropertyShape.schema
1325
- .properties
1326
- .maxExclusive.path,
1327
- value: Maybe.empty(),
1328
- })),
1329
- }).chain((maxExclusive) => $shaclPropertyFromRdf({
1330
- graph: _$options.graph,
1331
- resource: $resource,
1332
- propertySchema: PropertyShape.schema.properties.maxInclusive,
1333
- typeFromRdf: (resourceValues) => resourceValues
1334
- .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
1335
- .chain((values) => values.chainMap((value) => value.toLiteral()))
1336
- .map((values) => values.length > 0
1337
- ? values.map((value) => Maybe.of(value))
1338
- : Resource.Values.fromValue({
1339
- focusResource: $resource,
1340
- propertyPath: PropertyShape.schema
1341
- .properties
1342
- .maxInclusive
1343
- .path,
1344
- value: Maybe.empty(),
1345
- })),
1346
- }).chain((maxInclusive) => $shaclPropertyFromRdf({
1347
- graph: _$options.graph,
1348
- resource: $resource,
1349
- propertySchema: PropertyShape.schema.properties.maxLength,
1350
- typeFromRdf: (resourceValues) => resourceValues
1351
- .chain((values) => values.chainMap((value) => value.toBigInt()))
1352
- .map((values) => values.length > 0
1353
- ? values.map((value) => Maybe.of(value))
1354
- : Resource.Values.fromValue({
1355
- focusResource: $resource,
1356
- propertyPath: PropertyShape
1357
- .schema
1358
- .properties
1359
- .maxLength.path,
1360
- value: Maybe.empty(),
1361
- })),
1362
- }).chain((maxLength) => $shaclPropertyFromRdf({
1363
- graph: _$options.graph,
1364
- resource: $resource,
1365
- propertySchema: PropertyShape.schema.properties.minCount,
1366
- typeFromRdf: (resourceValues) => resourceValues
1367
- .chain((values) => values.chainMap((value) => value.toBigInt()))
1368
- .map((values) => values.length > 0
1369
- ? values.map((value) => Maybe.of(value))
1370
- : Resource.Values.fromValue({
1371
- focusResource: $resource,
1372
- propertyPath: PropertyShape
1373
- .schema
1374
- .properties
1375
- .minCount
1376
- .path,
1377
- value: Maybe.empty(),
1378
- })),
1379
- }).chain((minCount) => $shaclPropertyFromRdf({
1380
- graph: _$options.graph,
1381
- resource: $resource,
1382
- propertySchema: PropertyShape.schema.properties
1383
- .minExclusive,
1384
- typeFromRdf: (resourceValues) => resourceValues
1385
- .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
1386
- .chain((values) => values.chainMap((value) => value.toLiteral()))
1387
- .map((values) => values.length > 0
1388
- ? values.map((value) => Maybe.of(value))
1389
- : Resource.Values.fromValue({
1076
+ resource: $resource,
1077
+ propertySchema: PropertyShape.schema.properties.classes,
1078
+ typeFromRdf: (resourceValues) => resourceValues
1079
+ .chain((values) => values.chainMap((value) => value.toIri()))
1080
+ .map((values) => values.toArray())
1081
+ .map((valuesArray) => Resource.Values.fromValue({
1390
1082
  focusResource: $resource,
1391
- propertyPath: PropertyShape
1392
- .schema
1393
- .properties
1394
- .minExclusive
1395
- .path,
1396
- value: Maybe.empty(),
1083
+ propertyPath: PropertyShape.schema.properties.classes.path,
1084
+ value: valuesArray,
1397
1085
  })),
1398
- }).chain((minExclusive) => $shaclPropertyFromRdf({
1399
- graph: _$options.graph,
1400
- resource: $resource,
1401
- propertySchema: PropertyShape.schema.properties
1402
- .minInclusive,
1403
- typeFromRdf: (resourceValues) => resourceValues
1404
- .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
1405
- .chain((values) => values.chainMap((value) => value.toLiteral()))
1406
- .map((values) => values.length > 0
1407
- ? values.map((value) => Maybe.of(value))
1408
- : Resource.Values.fromValue({
1086
+ }),
1087
+ comment: $shaclPropertyFromRdf({
1088
+ graph: _$options.graph,
1089
+ resource: $resource,
1090
+ propertySchema: PropertyShape.schema.properties.comment,
1091
+ typeFromRdf: (resourceValues) => resourceValues
1092
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
1093
+ .chain((values) => values.chainMap((value) => value.toString()))
1094
+ .map((values) => values.length > 0
1095
+ ? values.map((value) => Maybe.of(value))
1096
+ : Resource.Values.fromValue({
1097
+ focusResource: $resource,
1098
+ propertyPath: PropertyShape.schema.properties.comment.path,
1099
+ value: Maybe.empty(),
1100
+ })),
1101
+ }),
1102
+ datatype: $shaclPropertyFromRdf({
1103
+ graph: _$options.graph,
1104
+ resource: $resource,
1105
+ propertySchema: PropertyShape.schema.properties.datatype,
1106
+ typeFromRdf: (resourceValues) => resourceValues
1107
+ .chain((values) => values.chainMap((value) => value.toIri()))
1108
+ .map((values) => values.length > 0
1109
+ ? values.map((value) => Maybe.of(value))
1110
+ : Resource.Values.fromValue({
1111
+ focusResource: $resource,
1112
+ propertyPath: PropertyShape.schema.properties.datatype.path,
1113
+ value: Maybe.empty(),
1114
+ })),
1115
+ }),
1116
+ deactivated: $shaclPropertyFromRdf({
1117
+ graph: _$options.graph,
1118
+ resource: $resource,
1119
+ propertySchema: PropertyShape.schema.properties.deactivated,
1120
+ typeFromRdf: (resourceValues) => resourceValues
1121
+ .chain((values) => values.chainMap((value) => value.toBoolean()))
1122
+ .map((values) => values.length > 0
1123
+ ? values.map((value) => Maybe.of(value))
1124
+ : Resource.Values.fromValue({
1125
+ focusResource: $resource,
1126
+ propertyPath: PropertyShape.schema.properties.deactivated.path,
1127
+ value: Maybe.empty(),
1128
+ })),
1129
+ }),
1130
+ defaultValue: $shaclPropertyFromRdf({
1131
+ graph: _$options.graph,
1132
+ resource: $resource,
1133
+ propertySchema: PropertyShape.schema.properties.defaultValue,
1134
+ typeFromRdf: (resourceValues) => resourceValues
1135
+ .chain((values) => values.chainMap((value) => value.toTerm().chain((term) => {
1136
+ switch (term.termType) {
1137
+ case "NamedNode":
1138
+ case "Literal":
1139
+ return Either.of(term);
1140
+ default:
1141
+ return Left(new Resource.MistypedTermValueError({
1142
+ actualValue: term,
1143
+ expectedValueType: "(NamedNode | Literal)",
1144
+ focusResource: $resource,
1145
+ propertyPath: PropertyShape.schema.properties.defaultValue.path,
1146
+ }));
1147
+ }
1148
+ })))
1149
+ .map((values) => values.length > 0
1150
+ ? values.map((value) => Maybe.of(value))
1151
+ : Resource.Values.fromValue({
1152
+ focusResource: $resource,
1153
+ propertyPath: PropertyShape.schema.properties.defaultValue.path,
1154
+ value: Maybe.empty(),
1155
+ })),
1156
+ }),
1157
+ description: $shaclPropertyFromRdf({
1158
+ graph: _$options.graph,
1159
+ resource: $resource,
1160
+ propertySchema: PropertyShape.schema.properties.description,
1161
+ typeFromRdf: (resourceValues) => resourceValues
1162
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
1163
+ .chain((values) => values.chainMap((value) => value.toString()))
1164
+ .map((values) => values.length > 0
1165
+ ? values.map((value) => Maybe.of(value))
1166
+ : Resource.Values.fromValue({
1167
+ focusResource: $resource,
1168
+ propertyPath: PropertyShape.schema.properties.description.path,
1169
+ value: Maybe.empty(),
1170
+ })),
1171
+ }),
1172
+ flags: $shaclPropertyFromRdf({
1173
+ graph: _$options.graph,
1174
+ resource: $resource,
1175
+ propertySchema: PropertyShape.schema.properties.flags,
1176
+ typeFromRdf: (resourceValues) => resourceValues
1177
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
1178
+ .chain((values) => values.chainMap((value) => value.toString()))
1179
+ .map((values) => values.toArray())
1180
+ .map((valuesArray) => Resource.Values.fromValue({
1409
1181
  focusResource: $resource,
1410
- propertyPath: PropertyShape
1411
- .schema
1412
- .properties
1413
- .minInclusive
1414
- .path,
1415
- value: Maybe.empty(),
1182
+ propertyPath: PropertyShape.schema.properties.flags.path,
1183
+ value: valuesArray,
1416
1184
  })),
1417
- }).chain((minInclusive) => $shaclPropertyFromRdf({
1418
- graph: _$options.graph,
1419
- resource: $resource,
1420
- propertySchema: PropertyShape.schema.properties
1421
- .minLength,
1422
- typeFromRdf: (resourceValues) => resourceValues
1423
- .chain((values) => values.chainMap((value) => value.toBigInt()))
1424
- .map((values) => values.length > 0
1425
- ? values.map((value) => Maybe.of(value))
1426
- : Resource.Values.fromValue({
1185
+ }),
1186
+ groups: $shaclPropertyFromRdf({
1187
+ graph: _$options.graph,
1188
+ resource: $resource,
1189
+ propertySchema: PropertyShape.schema.properties.groups,
1190
+ typeFromRdf: (resourceValues) => resourceValues
1191
+ .chain((values) => values.chainMap((value) => value.toIdentifier()))
1192
+ .map((values) => values.toArray())
1193
+ .map((valuesArray) => Resource.Values.fromValue({
1427
1194
  focusResource: $resource,
1428
- propertyPath: PropertyShape
1429
- .schema
1430
- .properties
1431
- .minLength
1432
- .path,
1433
- value: Maybe.empty(),
1195
+ propertyPath: PropertyShape.schema.properties.groups.path,
1196
+ value: valuesArray,
1434
1197
  })),
1435
- }).chain((minLength) => $shaclPropertyFromRdf({
1436
- graph: _$options.graph,
1437
- resource: $resource,
1438
- propertySchema: PropertyShape.schema.properties
1439
- .name,
1440
- typeFromRdf: (resourceValues) => resourceValues
1441
- .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
1442
- .chain((values) => values.chainMap((value) => value.toString()))
1443
- .map((values) => values.length >
1444
- 0
1445
- ? values.map((value) => Maybe.of(value))
1446
- : Resource.Values.fromValue({
1198
+ }),
1199
+ hasValues: $shaclPropertyFromRdf({
1200
+ graph: _$options.graph,
1201
+ resource: $resource,
1202
+ propertySchema: PropertyShape.schema.properties.hasValues,
1203
+ typeFromRdf: (resourceValues) => resourceValues
1204
+ .chain((values) => values.chainMap((value) => value.toTerm().chain((term) => {
1205
+ switch (term.termType) {
1206
+ case "NamedNode":
1207
+ case "Literal":
1208
+ return Either.of(term);
1209
+ default:
1210
+ return Left(new Resource.MistypedTermValueError({
1211
+ actualValue: term,
1212
+ expectedValueType: "(NamedNode | Literal)",
1213
+ focusResource: $resource,
1214
+ propertyPath: PropertyShape.schema.properties.hasValues.path,
1215
+ }));
1216
+ }
1217
+ })))
1218
+ .map((values) => values.toArray())
1219
+ .map((valuesArray) => Resource.Values.fromValue({
1447
1220
  focusResource: $resource,
1448
- propertyPath: PropertyShape
1449
- .schema
1450
- .properties
1451
- .name
1452
- .path,
1453
- value: Maybe.empty(),
1221
+ propertyPath: PropertyShape.schema.properties.hasValues.path,
1222
+ value: valuesArray,
1454
1223
  })),
1455
- }).chain((name) => $shaclPropertyFromRdf({
1456
- graph: _$options.graph,
1457
- resource: $resource,
1458
- propertySchema: PropertyShape.schema
1459
- .properties
1460
- .node,
1461
- typeFromRdf: (resourceValues) => resourceValues
1462
- .chain((values) => values.chainMap((value) => value.toIdentifier()))
1463
- .map((values) => values.length >
1464
- 0
1465
- ? values.map((value) => Maybe.of(value))
1466
- : Resource.Values.fromValue({
1224
+ }),
1225
+ in_: $shaclPropertyFromRdf({
1226
+ graph: _$options.graph,
1227
+ resource: $resource,
1228
+ propertySchema: PropertyShape.schema.properties.in_,
1229
+ typeFromRdf: (resourceValues) => resourceValues
1230
+ .chain((values) => values.chainMap((value) => value.toList({ graph: _$options.graph })))
1231
+ .chain((valueLists) => valueLists.chainMap((valueList) => Right(Resource.Values.fromArray({
1467
1232
  focusResource: $resource,
1468
- propertyPath: PropertyShape
1469
- .schema
1470
- .properties
1471
- .node
1472
- .path,
1473
- value: Maybe.empty(),
1474
- })),
1475
- }).chain((node) => $shaclPropertyFromRdf({
1476
- graph: _$options.graph,
1477
- resource: $resource,
1478
- propertySchema: PropertyShape.schema
1479
- .properties
1480
- .nodeKind,
1481
- typeFromRdf: (resourceValues) => resourceValues
1482
- .chain((values) => values.chainMap((value) => value.toIri([
1483
- dataFactory.namedNode("http://www.w3.org/ns/shacl#BlankNode"),
1484
- dataFactory.namedNode("http://www.w3.org/ns/shacl#BlankNodeOrIRI"),
1485
- dataFactory.namedNode("http://www.w3.org/ns/shacl#BlankNodeOrLiteral"),
1486
- dataFactory.namedNode("http://www.w3.org/ns/shacl#IRI"),
1487
- dataFactory.namedNode("http://www.w3.org/ns/shacl#IRIOrLiteral"),
1488
- dataFactory.namedNode("http://www.w3.org/ns/shacl#Literal"),
1489
- ])))
1490
- .map((values) => values.length >
1491
- 0
1492
- ? values.map((value) => Maybe.of(value))
1493
- : Resource.Values.fromValue({
1233
+ propertyPath: PropertyShape.schema.properties.in_.path,
1234
+ values: valueList.toArray(),
1235
+ })).chain((values) => values.chainMap((value) => value.toTerm().chain((term) => {
1236
+ switch (term.termType) {
1237
+ case "NamedNode":
1238
+ case "Literal":
1239
+ return Either.of(term);
1240
+ default:
1241
+ return Left(new Resource.MistypedTermValueError({
1242
+ actualValue: term,
1243
+ expectedValueType: "(NamedNode | Literal)",
1244
+ focusResource: $resource,
1245
+ propertyPath: PropertyShape.schema.properties.in_.path,
1246
+ }));
1247
+ }
1248
+ })))))
1249
+ .map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
1250
+ .map((values) => values.length > 0
1251
+ ? values.map((value) => Maybe.of(value))
1252
+ : Resource.Values.fromValue({
1253
+ focusResource: $resource,
1254
+ propertyPath: PropertyShape.schema.properties.in_.path,
1255
+ value: Maybe.empty(),
1256
+ })),
1257
+ }),
1258
+ isDefinedBy: $shaclPropertyFromRdf({
1259
+ graph: _$options.graph,
1260
+ resource: $resource,
1261
+ propertySchema: PropertyShape.schema.properties.isDefinedBy,
1262
+ typeFromRdf: (resourceValues) => resourceValues
1263
+ .chain((values) => values.chainMap((value) => value.toIdentifier()))
1264
+ .map((values) => values.length > 0
1265
+ ? values.map((value) => Maybe.of(value))
1266
+ : Resource.Values.fromValue({
1267
+ focusResource: $resource,
1268
+ propertyPath: PropertyShape.schema.properties.isDefinedBy.path,
1269
+ value: Maybe.empty(),
1270
+ })),
1271
+ }),
1272
+ label: $shaclPropertyFromRdf({
1273
+ graph: _$options.graph,
1274
+ resource: $resource,
1275
+ propertySchema: PropertyShape.schema.properties.label,
1276
+ typeFromRdf: (resourceValues) => resourceValues
1277
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
1278
+ .chain((values) => values.chainMap((value) => value.toString()))
1279
+ .map((values) => values.length > 0
1280
+ ? values.map((value) => Maybe.of(value))
1281
+ : Resource.Values.fromValue({
1282
+ focusResource: $resource,
1283
+ propertyPath: PropertyShape.schema.properties.label.path,
1284
+ value: Maybe.empty(),
1285
+ })),
1286
+ }),
1287
+ languageIn: $shaclPropertyFromRdf({
1288
+ graph: _$options.graph,
1289
+ resource: $resource,
1290
+ propertySchema: PropertyShape.schema.properties.languageIn,
1291
+ typeFromRdf: (resourceValues) => resourceValues
1292
+ .chain((values) => values.chainMap((value) => value.toList({ graph: _$options.graph })))
1293
+ .chain((valueLists) => valueLists.chainMap((valueList) => Right(Resource.Values.fromArray({
1494
1294
  focusResource: $resource,
1495
- propertyPath: PropertyShape
1496
- .schema
1497
- .properties
1498
- .nodeKind
1499
- .path,
1500
- value: Maybe.empty(),
1501
- })),
1502
- }).chain((nodeKind) => $shaclPropertyFromRdf({
1503
- graph: _$options.graph,
1504
- resource: $resource,
1505
- propertySchema: PropertyShape.schema
1506
- .properties
1507
- .not,
1508
- typeFromRdf: (resourceValues) => resourceValues
1509
- .chain((values) => values.chainMap((value) => value.toIdentifier()))
1510
- .map((values) => values.toArray())
1511
- .map((valuesArray) => Resource.Values.fromValue({
1512
- focusResource: $resource,
1513
- propertyPath: PropertyShape
1514
- .schema
1515
- .properties
1516
- .not
1517
- .path,
1518
- value: valuesArray,
1519
- })),
1520
- }).chain((not) => $shaclPropertyFromRdf({
1521
- graph: _$options.graph,
1522
- resource: $resource,
1523
- propertySchema: PropertyShape.schema
1524
- .properties
1525
- .or,
1526
- typeFromRdf: (resourceValues) => resourceValues
1527
- .chain((values) => values.chainMap((value) => value.toList({
1295
+ propertyPath: PropertyShape.schema.properties.languageIn.path,
1296
+ values: valueList.toArray(),
1297
+ }))
1298
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
1299
+ .chain((values) => values.chainMap((value) => value.toString()))))
1300
+ .map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
1301
+ .map((values) => values.length > 0
1302
+ ? values.map((value) => Maybe.of(value))
1303
+ : Resource.Values.fromValue({
1304
+ focusResource: $resource,
1305
+ propertyPath: PropertyShape.schema.properties.languageIn.path,
1306
+ value: Maybe.empty(),
1307
+ })),
1308
+ }),
1309
+ maxCount: $shaclPropertyFromRdf({
1528
1310
  graph: _$options.graph,
1529
- })))
1530
- .chain((valueLists) => valueLists.chainMap((valueList) => Right(Resource.Values.fromArray({
1531
- focusResource: $resource,
1532
- propertyPath: PropertyShape
1533
- .schema
1534
- .properties
1535
- .or
1536
- .path,
1537
- values: valueList.toArray(),
1538
- })).chain((values) => values.chainMap((value) => value.toIdentifier()))))
1539
- .map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
1540
- .map((values) => values.length >
1541
- 0
1542
- ? values.map((value) => Maybe.of(value))
1543
- : Resource.Values.fromValue({
1311
+ resource: $resource,
1312
+ propertySchema: PropertyShape.schema.properties.maxCount,
1313
+ typeFromRdf: (resourceValues) => resourceValues
1314
+ .chain((values) => values.chainMap((value) => value.toBigInt()))
1315
+ .map((values) => values.length > 0
1316
+ ? values.map((value) => Maybe.of(value))
1317
+ : Resource.Values.fromValue({
1318
+ focusResource: $resource,
1319
+ propertyPath: PropertyShape.schema.properties.maxCount.path,
1320
+ value: Maybe.empty(),
1321
+ })),
1322
+ }),
1323
+ maxExclusive: $shaclPropertyFromRdf({
1324
+ graph: _$options.graph,
1325
+ resource: $resource,
1326
+ propertySchema: PropertyShape.schema.properties.maxExclusive,
1327
+ typeFromRdf: (resourceValues) => resourceValues
1328
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
1329
+ .chain((values) => values.chainMap((value) => value.toLiteral()))
1330
+ .map((values) => values.length > 0
1331
+ ? values.map((value) => Maybe.of(value))
1332
+ : Resource.Values.fromValue({
1333
+ focusResource: $resource,
1334
+ propertyPath: PropertyShape.schema.properties.maxExclusive.path,
1335
+ value: Maybe.empty(),
1336
+ })),
1337
+ }),
1338
+ maxInclusive: $shaclPropertyFromRdf({
1339
+ graph: _$options.graph,
1340
+ resource: $resource,
1341
+ propertySchema: PropertyShape.schema.properties.maxInclusive,
1342
+ typeFromRdf: (resourceValues) => resourceValues
1343
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
1344
+ .chain((values) => values.chainMap((value) => value.toLiteral()))
1345
+ .map((values) => values.length > 0
1346
+ ? values.map((value) => Maybe.of(value))
1347
+ : Resource.Values.fromValue({
1348
+ focusResource: $resource,
1349
+ propertyPath: PropertyShape.schema.properties.maxInclusive.path,
1350
+ value: Maybe.empty(),
1351
+ })),
1352
+ }),
1353
+ maxLength: $shaclPropertyFromRdf({
1354
+ graph: _$options.graph,
1355
+ resource: $resource,
1356
+ propertySchema: PropertyShape.schema.properties.maxLength,
1357
+ typeFromRdf: (resourceValues) => resourceValues
1358
+ .chain((values) => values.chainMap((value) => value.toBigInt()))
1359
+ .map((values) => values.length > 0
1360
+ ? values.map((value) => Maybe.of(value))
1361
+ : Resource.Values.fromValue({
1362
+ focusResource: $resource,
1363
+ propertyPath: PropertyShape.schema.properties.maxLength.path,
1364
+ value: Maybe.empty(),
1365
+ })),
1366
+ }),
1367
+ minCount: $shaclPropertyFromRdf({
1368
+ graph: _$options.graph,
1369
+ resource: $resource,
1370
+ propertySchema: PropertyShape.schema.properties.minCount,
1371
+ typeFromRdf: (resourceValues) => resourceValues
1372
+ .chain((values) => values.chainMap((value) => value.toBigInt()))
1373
+ .map((values) => values.length > 0
1374
+ ? values.map((value) => Maybe.of(value))
1375
+ : Resource.Values.fromValue({
1376
+ focusResource: $resource,
1377
+ propertyPath: PropertyShape.schema.properties.minCount.path,
1378
+ value: Maybe.empty(),
1379
+ })),
1380
+ }),
1381
+ minExclusive: $shaclPropertyFromRdf({
1382
+ graph: _$options.graph,
1383
+ resource: $resource,
1384
+ propertySchema: PropertyShape.schema.properties.minExclusive,
1385
+ typeFromRdf: (resourceValues) => resourceValues
1386
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
1387
+ .chain((values) => values.chainMap((value) => value.toLiteral()))
1388
+ .map((values) => values.length > 0
1389
+ ? values.map((value) => Maybe.of(value))
1390
+ : Resource.Values.fromValue({
1391
+ focusResource: $resource,
1392
+ propertyPath: PropertyShape.schema.properties.minExclusive.path,
1393
+ value: Maybe.empty(),
1394
+ })),
1395
+ }),
1396
+ minInclusive: $shaclPropertyFromRdf({
1397
+ graph: _$options.graph,
1398
+ resource: $resource,
1399
+ propertySchema: PropertyShape.schema.properties.minInclusive,
1400
+ typeFromRdf: (resourceValues) => resourceValues
1401
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
1402
+ .chain((values) => values.chainMap((value) => value.toLiteral()))
1403
+ .map((values) => values.length > 0
1404
+ ? values.map((value) => Maybe.of(value))
1405
+ : Resource.Values.fromValue({
1406
+ focusResource: $resource,
1407
+ propertyPath: PropertyShape.schema.properties.minInclusive.path,
1408
+ value: Maybe.empty(),
1409
+ })),
1410
+ }),
1411
+ minLength: $shaclPropertyFromRdf({
1412
+ graph: _$options.graph,
1413
+ resource: $resource,
1414
+ propertySchema: PropertyShape.schema.properties.minLength,
1415
+ typeFromRdf: (resourceValues) => resourceValues
1416
+ .chain((values) => values.chainMap((value) => value.toBigInt()))
1417
+ .map((values) => values.length > 0
1418
+ ? values.map((value) => Maybe.of(value))
1419
+ : Resource.Values.fromValue({
1420
+ focusResource: $resource,
1421
+ propertyPath: PropertyShape.schema.properties.minLength.path,
1422
+ value: Maybe.empty(),
1423
+ })),
1424
+ }),
1425
+ name: $shaclPropertyFromRdf({
1426
+ graph: _$options.graph,
1427
+ resource: $resource,
1428
+ propertySchema: PropertyShape.schema.properties.name,
1429
+ typeFromRdf: (resourceValues) => resourceValues
1430
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
1431
+ .chain((values) => values.chainMap((value) => value.toString()))
1432
+ .map((values) => values.length > 0
1433
+ ? values.map((value) => Maybe.of(value))
1434
+ : Resource.Values.fromValue({
1435
+ focusResource: $resource,
1436
+ propertyPath: PropertyShape.schema.properties.name.path,
1437
+ value: Maybe.empty(),
1438
+ })),
1439
+ }),
1440
+ node: $shaclPropertyFromRdf({
1441
+ graph: _$options.graph,
1442
+ resource: $resource,
1443
+ propertySchema: PropertyShape.schema.properties.node,
1444
+ typeFromRdf: (resourceValues) => resourceValues
1445
+ .chain((values) => values.chainMap((value) => value.toIdentifier()))
1446
+ .map((values) => values.length > 0
1447
+ ? values.map((value) => Maybe.of(value))
1448
+ : Resource.Values.fromValue({
1449
+ focusResource: $resource,
1450
+ propertyPath: PropertyShape.schema.properties.node.path,
1451
+ value: Maybe.empty(),
1452
+ })),
1453
+ }),
1454
+ nodeKind: $shaclPropertyFromRdf({
1455
+ graph: _$options.graph,
1456
+ resource: $resource,
1457
+ propertySchema: PropertyShape.schema.properties.nodeKind,
1458
+ typeFromRdf: (resourceValues) => resourceValues
1459
+ .chain((values) => values.chainMap((value) => value.toIri([
1460
+ dataFactory.namedNode("http://www.w3.org/ns/shacl#BlankNode"),
1461
+ dataFactory.namedNode("http://www.w3.org/ns/shacl#BlankNodeOrIRI"),
1462
+ dataFactory.namedNode("http://www.w3.org/ns/shacl#BlankNodeOrLiteral"),
1463
+ dataFactory.namedNode("http://www.w3.org/ns/shacl#IRI"),
1464
+ dataFactory.namedNode("http://www.w3.org/ns/shacl#IRIOrLiteral"),
1465
+ dataFactory.namedNode("http://www.w3.org/ns/shacl#Literal"),
1466
+ ])))
1467
+ .map((values) => values.length > 0
1468
+ ? values.map((value) => Maybe.of(value))
1469
+ : Resource.Values.fromValue({
1470
+ focusResource: $resource,
1471
+ propertyPath: PropertyShape.schema.properties.nodeKind.path,
1472
+ value: Maybe.empty(),
1473
+ })),
1474
+ }),
1475
+ not: $shaclPropertyFromRdf({
1476
+ graph: _$options.graph,
1477
+ resource: $resource,
1478
+ propertySchema: PropertyShape.schema.properties.not,
1479
+ typeFromRdf: (resourceValues) => resourceValues
1480
+ .chain((values) => values.chainMap((value) => value.toIdentifier()))
1481
+ .map((values) => values.toArray())
1482
+ .map((valuesArray) => Resource.Values.fromValue({
1544
1483
  focusResource: $resource,
1545
- propertyPath: PropertyShape
1546
- .schema
1547
- .properties
1548
- .or
1549
- .path,
1550
- value: Maybe.empty(),
1484
+ propertyPath: PropertyShape.schema.properties.not.path,
1485
+ value: valuesArray,
1551
1486
  })),
1552
- }).chain((or) => $shaclPropertyFromRdf({
1553
- graph: _$options.graph,
1554
- resource: $resource,
1555
- propertySchema: PropertyShape.schema
1556
- .properties
1557
- .order,
1558
- typeFromRdf: (resourceValues) => resourceValues
1559
- .chain((values) => values.chainMap((value) => value.toFloat()))
1560
- .map((values) => values.length >
1561
- 0
1562
- ? values.map((value) => Maybe.of(value))
1563
- : Resource.Values.fromValue({
1487
+ }),
1488
+ or: $shaclPropertyFromRdf({
1489
+ graph: _$options.graph,
1490
+ resource: $resource,
1491
+ propertySchema: PropertyShape.schema.properties.or,
1492
+ typeFromRdf: (resourceValues) => resourceValues
1493
+ .chain((values) => values.chainMap((value) => value.toList({ graph: _$options.graph })))
1494
+ .chain((valueLists) => valueLists.chainMap((valueList) => Right(Resource.Values.fromArray({
1564
1495
  focusResource: $resource,
1565
- propertyPath: PropertyShape
1566
- .schema
1567
- .properties
1568
- .order
1569
- .path,
1570
- value: Maybe.empty(),
1571
- })),
1572
- }).chain((order) => $shaclPropertyFromRdf({
1573
- graph: _$options.graph,
1574
- resource: $resource,
1575
- propertySchema: PropertyShape.schema
1576
- .properties
1577
- .path,
1578
- typeFromRdf: (resourceValues) => $PropertyPath.fromRdfResourceValues(resourceValues, {
1579
- context: _$options.context,
1496
+ propertyPath: PropertyShape.schema.properties.or.path,
1497
+ values: valueList.toArray(),
1498
+ })).chain((values) => values.chainMap((value) => value.toIdentifier()))))
1499
+ .map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
1500
+ .map((values) => values.length > 0
1501
+ ? values.map((value) => Maybe.of(value))
1502
+ : Resource.Values.fromValue({
1503
+ focusResource: $resource,
1504
+ propertyPath: PropertyShape.schema.properties.or.path,
1505
+ value: Maybe.empty(),
1506
+ })),
1507
+ }),
1508
+ order: $shaclPropertyFromRdf({
1580
1509
  graph: _$options.graph,
1581
- preferredLanguages: _$options.preferredLanguages,
1582
- objectSet: _$options.objectSet,
1583
1510
  resource: $resource,
1584
- ignoreRdfType: true,
1585
- propertyPath: PropertyShape
1586
- .schema
1587
- .properties
1588
- .path
1589
- .path,
1511
+ propertySchema: PropertyShape.schema.properties.order,
1512
+ typeFromRdf: (resourceValues) => resourceValues
1513
+ .chain((values) => values.chainMap((value) => value.toFloat()))
1514
+ .map((values) => values.length > 0
1515
+ ? values.map((value) => Maybe.of(value))
1516
+ : Resource.Values.fromValue({
1517
+ focusResource: $resource,
1518
+ propertyPath: PropertyShape.schema.properties.order.path,
1519
+ value: Maybe.empty(),
1520
+ })),
1590
1521
  }),
1591
- }).chain((path) => $shaclPropertyFromRdf({
1592
- graph: _$options.graph,
1593
- resource: $resource,
1594
- propertySchema: PropertyShape.schema
1595
- .properties
1596
- .patterns,
1597
- typeFromRdf: (resourceValues) => resourceValues
1598
- .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
1599
- .chain((values) => values.chainMap((value) => value.toString()))
1600
- .map((values) => values.toArray())
1601
- .map((valuesArray) => Resource.Values.fromValue({
1602
- focusResource: $resource,
1603
- propertyPath: PropertyShape
1604
- .schema
1605
- .properties
1606
- .patterns
1607
- .path,
1608
- value: valuesArray,
1609
- })),
1610
- }).chain((patterns) => $shaclPropertyFromRdf({
1611
- graph: _$options.graph,
1612
- resource: $resource,
1613
- propertySchema: PropertyShape.schema
1614
- .properties
1615
- .uniqueLang,
1616
- typeFromRdf: (resourceValues) => resourceValues
1617
- .chain((values) => values.chainMap((value) => value.toBoolean()))
1618
- .map((values) => values.length >
1619
- 0
1620
- ? values.map((value) => Maybe.of(value))
1621
- : Resource.Values.fromValue({
1522
+ path: $shaclPropertyFromRdf({
1523
+ graph: _$options.graph,
1524
+ resource: $resource,
1525
+ propertySchema: PropertyShape.schema.properties.path,
1526
+ typeFromRdf: (resourceValues) => $PropertyPath.fromRdfResourceValues(resourceValues, {
1527
+ context: _$options.context,
1528
+ graph: _$options.graph,
1529
+ objectSet: _$options.objectSet,
1530
+ preferredLanguages: _$options.preferredLanguages,
1531
+ resource: $resource,
1532
+ ignoreRdfType: true,
1533
+ propertyPath: PropertyShape.schema.properties.path.path,
1534
+ }),
1535
+ }),
1536
+ patterns: $shaclPropertyFromRdf({
1537
+ graph: _$options.graph,
1538
+ resource: $resource,
1539
+ propertySchema: PropertyShape.schema.properties.patterns,
1540
+ typeFromRdf: (resourceValues) => resourceValues
1541
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
1542
+ .chain((values) => values.chainMap((value) => value.toString()))
1543
+ .map((values) => values.toArray())
1544
+ .map((valuesArray) => Resource.Values.fromValue({
1622
1545
  focusResource: $resource,
1623
- propertyPath: PropertyShape
1624
- .schema
1625
- .properties
1626
- .uniqueLang
1627
- .path,
1628
- value: Maybe.empty(),
1546
+ propertyPath: PropertyShape.schema.properties.patterns.path,
1547
+ value: valuesArray,
1629
1548
  })),
1630
- }).chain((uniqueLang) => $shaclPropertyFromRdf({
1631
- graph: _$options.graph,
1632
- resource: $resource,
1633
- propertySchema: PropertyShape.schema
1634
- .properties
1635
- .xone,
1636
- typeFromRdf: (resourceValues) => resourceValues
1637
- .chain((values) => values.chainMap((value) => value.toList({
1549
+ }),
1550
+ uniqueLang: $shaclPropertyFromRdf({
1638
1551
  graph: _$options.graph,
1639
- })))
1640
- .chain((valueLists) => valueLists.chainMap((valueList) => Right(Resource.Values.fromArray({
1641
- focusResource: $resource,
1642
- propertyPath: PropertyShape
1643
- .schema
1644
- .properties
1645
- .xone
1646
- .path,
1647
- values: valueList.toArray(),
1648
- })).chain((values) => values.chainMap((value) => value.toIdentifier()))))
1649
- .map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
1650
- .map((values) => values.length >
1651
- 0
1652
- ? values.map((value) => Maybe.of(value))
1653
- : Resource.Values.fromValue({
1552
+ resource: $resource,
1553
+ propertySchema: PropertyShape.schema.properties.uniqueLang,
1554
+ typeFromRdf: (resourceValues) => resourceValues
1555
+ .chain((values) => values.chainMap((value) => value.toBoolean()))
1556
+ .map((values) => values.length > 0
1557
+ ? values.map((value) => Maybe.of(value))
1558
+ : Resource.Values.fromValue({
1559
+ focusResource: $resource,
1560
+ propertyPath: PropertyShape.schema.properties.uniqueLang.path,
1561
+ value: Maybe.empty(),
1562
+ })),
1563
+ }),
1564
+ xone: $shaclPropertyFromRdf({
1565
+ graph: _$options.graph,
1566
+ resource: $resource,
1567
+ propertySchema: PropertyShape.schema.properties.xone,
1568
+ typeFromRdf: (resourceValues) => resourceValues
1569
+ .chain((values) => values.chainMap((value) => value.toList({ graph: _$options.graph })))
1570
+ .chain((valueLists) => valueLists.chainMap((valueList) => Right(Resource.Values.fromArray({
1654
1571
  focusResource: $resource,
1655
- propertyPath: PropertyShape
1656
- .schema
1657
- .properties
1658
- .xone
1659
- .path,
1660
- value: Maybe.empty(),
1661
- })),
1662
- }).map((xone) => ({
1663
- $identifier,
1664
- $type,
1665
- and,
1666
- classes,
1667
- comment,
1668
- datatype,
1669
- deactivated,
1670
- defaultValue,
1671
- description,
1672
- flags,
1673
- groups,
1674
- hasValues,
1675
- in_,
1676
- isDefinedBy,
1677
- label,
1678
- languageIn,
1679
- maxCount,
1680
- maxExclusive,
1681
- maxInclusive,
1682
- maxLength,
1683
- minCount,
1684
- minExclusive,
1685
- minInclusive,
1686
- minLength,
1687
- name,
1688
- node,
1689
- nodeKind,
1690
- not,
1691
- or,
1692
- order,
1693
- path,
1694
- patterns,
1695
- uniqueLang,
1696
- xone,
1697
- }))))))))))))))))))))))))))))))))))));
1572
+ propertyPath: PropertyShape.schema.properties.xone.path,
1573
+ values: valueList.toArray(),
1574
+ })).chain((values) => values.chainMap((value) => value.toIdentifier()))))
1575
+ .map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
1576
+ .map((values) => values.length > 0
1577
+ ? values.map((value) => Maybe.of(value))
1578
+ : Resource.Values.fromValue({
1579
+ focusResource: $resource,
1580
+ propertyPath: PropertyShape.schema.properties.xone.path,
1581
+ value: Maybe.empty(),
1582
+ })),
1583
+ }),
1584
+ }).map((properties) => create(properties)));
1698
1585
  };
1586
+ PropertyShape.fromRdfResource = $wrap_FromRdfResourceFunction(PropertyShape._fromRdfResource);
1587
+ PropertyShape.fromRdfResourceValues = (values, options) => values.chain((values) => values.chainMap((value) => value
1588
+ .toResource()
1589
+ .chain((resource) => PropertyShape.fromRdfResource(resource, options))));
1590
+ PropertyShape.fromRdfType = dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyShape");
1591
+ function isPropertyShape(object) {
1592
+ switch (object.$type) {
1593
+ case "PropertyShape":
1594
+ return true;
1595
+ default:
1596
+ return false;
1597
+ }
1598
+ }
1599
+ PropertyShape.isPropertyShape = isPropertyShape;
1699
1600
  PropertyShape.schema = {
1700
1601
  properties: {
1701
1602
  $identifier: {
@@ -1989,198 +1890,194 @@ export var PropertyShape;
1989
1890
  },
1990
1891
  },
1991
1892
  };
1992
- function toRdfResource(_propertyShape, options) {
1993
- const resourceSet = options?.resourceSet ??
1994
- new ResourceSet({
1995
- dataFactory: dataFactory,
1996
- dataset: datasetFactory.dataset(),
1997
- });
1998
- const resource = resourceSet.resource(_propertyShape.$identifier());
1999
- if (!options?.ignoreRdfType) {
2000
- resource.add($RdfVocabularies.rdf.type, dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyShape"), options?.graph);
1893
+ PropertyShape._toRdfResource = (parameters) => {
1894
+ if (!parameters.ignoreRdfType) {
1895
+ parameters.resource.add($RdfVocabularies.rdf.type, dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyShape"), parameters.graph);
2001
1896
  }
2002
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#and"), _propertyShape.and.toList().flatMap((value) => [
1897
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#and"), parameters.object.and.toList().flatMap((value) => [
2003
1898
  value.length > 0
2004
1899
  ? value.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
2005
1900
  if (itemIndex === 0) {
2006
1901
  currentSubListResource = listResource;
2007
1902
  }
2008
1903
  else {
2009
- const newSubListResource = resourceSet.resource((() => dataFactory.blankNode())());
2010
- currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier, options?.graph);
1904
+ const newSubListResource = parameters.resourceSet.resource((() => dataFactory.blankNode())());
1905
+ currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier, parameters.graph);
2011
1906
  currentSubListResource = newSubListResource;
2012
1907
  }
2013
- currentSubListResource.add($RdfVocabularies.rdf.first, [item], options?.graph);
1908
+ currentSubListResource.add($RdfVocabularies.rdf.first, [item], parameters.graph);
2014
1909
  if (itemIndex + 1 === list.length) {
2015
- currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil, options?.graph);
1910
+ currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil, parameters.graph);
2016
1911
  }
2017
1912
  return { currentSubListResource, listResource };
2018
1913
  }, {
2019
1914
  currentSubListResource: null,
2020
- listResource: resourceSet.resource((() => dataFactory.blankNode())()),
1915
+ listResource: parameters.resourceSet.resource((() => dataFactory.blankNode())()),
2021
1916
  }).listResource.identifier
2022
1917
  : $RdfVocabularies.rdf.nil,
2023
- ]), options?.graph);
2024
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#class"), _propertyShape.classes.flatMap((item) => [item]), options?.graph);
2025
- resource.add(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#comment"), _propertyShape.comment
1918
+ ]), parameters.graph);
1919
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#class"), parameters.object.classes.flatMap((item) => [item]), parameters.graph);
1920
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#comment"), parameters.object.comment
2026
1921
  .toList()
2027
- .flatMap((value) => [$literalFactory.string(value)]), options?.graph);
2028
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#datatype"), _propertyShape.datatype.toList(), options?.graph);
2029
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#deactivated"), _propertyShape.deactivated
1922
+ .flatMap((value) => [$literalFactory.string(value)]), parameters.graph);
1923
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#datatype"), parameters.object.datatype.toList(), parameters.graph);
1924
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#deactivated"), parameters.object.deactivated
2030
1925
  .toList()
2031
1926
  .flatMap((value) => [
2032
1927
  $literalFactory.boolean(value, $RdfVocabularies.xsd.boolean),
2033
- ]), options?.graph);
2034
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#defaultValue"), _propertyShape.defaultValue.toList(), options?.graph);
2035
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#description"), _propertyShape.description
1928
+ ]), parameters.graph);
1929
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#defaultValue"), parameters.object.defaultValue.toList(), parameters.graph);
1930
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#description"), parameters.object.description
2036
1931
  .toList()
2037
- .flatMap((value) => [$literalFactory.string(value)]), options?.graph);
2038
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#flags"), _propertyShape.flags.flatMap((item) => [$literalFactory.string(item)]), options?.graph);
2039
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#group"), _propertyShape.groups.flatMap((item) => [item]), options?.graph);
2040
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#hasValue"), _propertyShape.hasValues.flatMap((item) => [item]), options?.graph);
2041
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#in"), _propertyShape.in_.toList().flatMap((value) => [
1932
+ .flatMap((value) => [$literalFactory.string(value)]), parameters.graph);
1933
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#flags"), parameters.object.flags.flatMap((item) => [$literalFactory.string(item)]), parameters.graph);
1934
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#group"), parameters.object.groups.flatMap((item) => [item]), parameters.graph);
1935
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#hasValue"), parameters.object.hasValues.flatMap((item) => [item]), parameters.graph);
1936
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#in"), parameters.object.in_.toList().flatMap((value) => [
2042
1937
  value.length > 0
2043
1938
  ? value.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
2044
1939
  if (itemIndex === 0) {
2045
1940
  currentSubListResource = listResource;
2046
1941
  }
2047
1942
  else {
2048
- const newSubListResource = resourceSet.resource((() => dataFactory.blankNode())());
2049
- currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier, options?.graph);
1943
+ const newSubListResource = parameters.resourceSet.resource((() => dataFactory.blankNode())());
1944
+ currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier, parameters.graph);
2050
1945
  currentSubListResource = newSubListResource;
2051
1946
  }
2052
- currentSubListResource.add($RdfVocabularies.rdf.first, [item], options?.graph);
1947
+ currentSubListResource.add($RdfVocabularies.rdf.first, [item], parameters.graph);
2053
1948
  if (itemIndex + 1 === list.length) {
2054
- currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil, options?.graph);
1949
+ currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil, parameters.graph);
2055
1950
  }
2056
1951
  return { currentSubListResource, listResource };
2057
1952
  }, {
2058
1953
  currentSubListResource: null,
2059
- listResource: resourceSet.resource((() => dataFactory.blankNode())()),
1954
+ listResource: parameters.resourceSet.resource((() => dataFactory.blankNode())()),
2060
1955
  }).listResource.identifier
2061
1956
  : $RdfVocabularies.rdf.nil,
2062
- ]), options?.graph);
2063
- resource.add(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#isDefinedBy"), _propertyShape.isDefinedBy.toList(), options?.graph);
2064
- resource.add(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#label"), _propertyShape.label
1957
+ ]), parameters.graph);
1958
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#isDefinedBy"), parameters.object.isDefinedBy.toList(), parameters.graph);
1959
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#label"), parameters.object.label
2065
1960
  .toList()
2066
- .flatMap((value) => [$literalFactory.string(value)]), options?.graph);
2067
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#languageIn"), _propertyShape.languageIn.toList().flatMap((value) => [
1961
+ .flatMap((value) => [$literalFactory.string(value)]), parameters.graph);
1962
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#languageIn"), parameters.object.languageIn.toList().flatMap((value) => [
2068
1963
  value.length > 0
2069
1964
  ? value.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
2070
1965
  if (itemIndex === 0) {
2071
1966
  currentSubListResource = listResource;
2072
1967
  }
2073
1968
  else {
2074
- const newSubListResource = resourceSet.resource((() => dataFactory.blankNode())());
2075
- currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier, options?.graph);
1969
+ const newSubListResource = parameters.resourceSet.resource((() => dataFactory.blankNode())());
1970
+ currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier, parameters.graph);
2076
1971
  currentSubListResource = newSubListResource;
2077
1972
  }
2078
- currentSubListResource.add($RdfVocabularies.rdf.first, [$literalFactory.string(item)], options?.graph);
1973
+ currentSubListResource.add($RdfVocabularies.rdf.first, [$literalFactory.string(item)], parameters.graph);
2079
1974
  if (itemIndex + 1 === list.length) {
2080
- currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil, options?.graph);
1975
+ currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil, parameters.graph);
2081
1976
  }
2082
1977
  return { currentSubListResource, listResource };
2083
1978
  }, {
2084
1979
  currentSubListResource: null,
2085
- listResource: resourceSet.resource((() => dataFactory.blankNode())()),
1980
+ listResource: parameters.resourceSet.resource((() => dataFactory.blankNode())()),
2086
1981
  }).listResource.identifier
2087
1982
  : $RdfVocabularies.rdf.nil,
2088
- ]), options?.graph);
2089
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#maxCount"), _propertyShape.maxCount
1983
+ ]), parameters.graph);
1984
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#maxCount"), parameters.object.maxCount
2090
1985
  .toList()
2091
1986
  .flatMap((value) => [
2092
1987
  $literalFactory.bigint(value, $RdfVocabularies.xsd.integer),
2093
- ]), options?.graph);
2094
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#maxExclusive"), _propertyShape.maxExclusive.toList(), options?.graph);
2095
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#maxInclusive"), _propertyShape.maxInclusive.toList(), options?.graph);
2096
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#maxLength"), _propertyShape.maxLength
1988
+ ]), parameters.graph);
1989
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#maxExclusive"), parameters.object.maxExclusive.toList(), parameters.graph);
1990
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#maxInclusive"), parameters.object.maxInclusive.toList(), parameters.graph);
1991
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#maxLength"), parameters.object.maxLength
2097
1992
  .toList()
2098
1993
  .flatMap((value) => [
2099
1994
  $literalFactory.bigint(value, $RdfVocabularies.xsd.integer),
2100
- ]), options?.graph);
2101
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#minCount"), _propertyShape.minCount
1995
+ ]), parameters.graph);
1996
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#minCount"), parameters.object.minCount
2102
1997
  .toList()
2103
1998
  .flatMap((value) => [
2104
1999
  $literalFactory.bigint(value, $RdfVocabularies.xsd.integer),
2105
- ]), options?.graph);
2106
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#minExclusive"), _propertyShape.minExclusive.toList(), options?.graph);
2107
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#minInclusive"), _propertyShape.minInclusive.toList(), options?.graph);
2108
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#minLength"), _propertyShape.minLength
2000
+ ]), parameters.graph);
2001
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#minExclusive"), parameters.object.minExclusive.toList(), parameters.graph);
2002
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#minInclusive"), parameters.object.minInclusive.toList(), parameters.graph);
2003
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#minLength"), parameters.object.minLength
2109
2004
  .toList()
2110
2005
  .flatMap((value) => [
2111
2006
  $literalFactory.bigint(value, $RdfVocabularies.xsd.integer),
2112
- ]), options?.graph);
2113
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#name"), _propertyShape.name
2007
+ ]), parameters.graph);
2008
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#name"), parameters.object.name
2114
2009
  .toList()
2115
- .flatMap((value) => [$literalFactory.string(value)]), options?.graph);
2116
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#node"), _propertyShape.node.toList(), options?.graph);
2117
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#nodeKind"), _propertyShape.nodeKind.toList(), options?.graph);
2118
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#not"), _propertyShape.not.flatMap((item) => [item]), options?.graph);
2119
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#or"), _propertyShape.or.toList().flatMap((value) => [
2010
+ .flatMap((value) => [$literalFactory.string(value)]), parameters.graph);
2011
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#node"), parameters.object.node.toList(), parameters.graph);
2012
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#nodeKind"), parameters.object.nodeKind.toList(), parameters.graph);
2013
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#not"), parameters.object.not.flatMap((item) => [item]), parameters.graph);
2014
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#or"), parameters.object.or.toList().flatMap((value) => [
2120
2015
  value.length > 0
2121
2016
  ? value.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
2122
2017
  if (itemIndex === 0) {
2123
2018
  currentSubListResource = listResource;
2124
2019
  }
2125
2020
  else {
2126
- const newSubListResource = resourceSet.resource((() => dataFactory.blankNode())());
2127
- currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier, options?.graph);
2021
+ const newSubListResource = parameters.resourceSet.resource((() => dataFactory.blankNode())());
2022
+ currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier, parameters.graph);
2128
2023
  currentSubListResource = newSubListResource;
2129
2024
  }
2130
- currentSubListResource.add($RdfVocabularies.rdf.first, [item], options?.graph);
2025
+ currentSubListResource.add($RdfVocabularies.rdf.first, [item], parameters.graph);
2131
2026
  if (itemIndex + 1 === list.length) {
2132
- currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil, options?.graph);
2027
+ currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil, parameters.graph);
2133
2028
  }
2134
2029
  return { currentSubListResource, listResource };
2135
2030
  }, {
2136
2031
  currentSubListResource: null,
2137
- listResource: resourceSet.resource((() => dataFactory.blankNode())()),
2032
+ listResource: parameters.resourceSet.resource((() => dataFactory.blankNode())()),
2138
2033
  }).listResource.identifier
2139
2034
  : $RdfVocabularies.rdf.nil,
2140
- ]), options?.graph);
2141
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#order"), _propertyShape.order
2035
+ ]), parameters.graph);
2036
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#order"), parameters.object.order
2142
2037
  .toList()
2143
2038
  .flatMap((value) => [
2144
2039
  $literalFactory.number(value, $RdfVocabularies.xsd.double),
2145
- ]), options?.graph);
2146
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#path"), [
2147
- $PropertyPath.toRdfResource(_propertyShape.path, {
2148
- graph: options?.graph,
2149
- resourceSet: resourceSet,
2040
+ ]), parameters.graph);
2041
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#path"), [
2042
+ $PropertyPath.toRdfResource(parameters.object.path, {
2043
+ graph: parameters.graph,
2044
+ resourceSet: parameters.resourceSet,
2150
2045
  }).identifier,
2151
- ], options?.graph);
2152
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#pattern"), _propertyShape.patterns.flatMap((item) => [$literalFactory.string(item)]), options?.graph);
2153
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#uniqueLang"), _propertyShape.uniqueLang
2046
+ ], parameters.graph);
2047
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#pattern"), parameters.object.patterns.flatMap((item) => [
2048
+ $literalFactory.string(item),
2049
+ ]), parameters.graph);
2050
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#uniqueLang"), parameters.object.uniqueLang
2154
2051
  .toList()
2155
2052
  .flatMap((value) => [
2156
2053
  $literalFactory.boolean(value, $RdfVocabularies.xsd.boolean),
2157
- ]), options?.graph);
2158
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#xone"), _propertyShape.xone.toList().flatMap((value) => [
2054
+ ]), parameters.graph);
2055
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#xone"), parameters.object.xone.toList().flatMap((value) => [
2159
2056
  value.length > 0
2160
2057
  ? value.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
2161
2058
  if (itemIndex === 0) {
2162
2059
  currentSubListResource = listResource;
2163
2060
  }
2164
2061
  else {
2165
- const newSubListResource = resourceSet.resource((() => dataFactory.blankNode())());
2166
- currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier, options?.graph);
2062
+ const newSubListResource = parameters.resourceSet.resource((() => dataFactory.blankNode())());
2063
+ currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier, parameters.graph);
2167
2064
  currentSubListResource = newSubListResource;
2168
2065
  }
2169
- currentSubListResource.add($RdfVocabularies.rdf.first, [item], options?.graph);
2066
+ currentSubListResource.add($RdfVocabularies.rdf.first, [item], parameters.graph);
2170
2067
  if (itemIndex + 1 === list.length) {
2171
- currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil, options?.graph);
2068
+ currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil, parameters.graph);
2172
2069
  }
2173
2070
  return { currentSubListResource, listResource };
2174
2071
  }, {
2175
2072
  currentSubListResource: null,
2176
- listResource: resourceSet.resource((() => dataFactory.blankNode())()),
2073
+ listResource: parameters.resourceSet.resource((() => dataFactory.blankNode())()),
2177
2074
  }).listResource.identifier
2178
2075
  : $RdfVocabularies.rdf.nil,
2179
- ]), options?.graph);
2180
- return resource;
2181
- }
2182
- PropertyShape.toRdfResource = toRdfResource;
2183
- function propertiesToStrings(_propertyShape) {
2076
+ ]), parameters.graph);
2077
+ return parameters.resource;
2078
+ };
2079
+ PropertyShape.toRdfResource = $wrap_ToRdfResourceFunction(PropertyShape._toRdfResource);
2080
+ function _propertiesToStrings(_propertyShape) {
2184
2081
  return $compactRecord({
2185
2082
  $identifier: _propertyShape.$identifier().toString(),
2186
2083
  label: _propertyShape.label.map((item) => item.toString()).extract(),
@@ -2188,9 +2085,9 @@ export var PropertyShape;
2188
2085
  path: $PropertyPath.$toString(_propertyShape.path),
2189
2086
  });
2190
2087
  }
2191
- PropertyShape.propertiesToStrings = propertiesToStrings;
2088
+ PropertyShape._propertiesToStrings = _propertiesToStrings;
2192
2089
  function $toString(_propertyShape) {
2193
- return `PropertyShape(${JSON.stringify(propertiesToStrings((_propertyShape ?? this)))})`;
2090
+ return `PropertyShape(${JSON.stringify(_propertiesToStrings((_propertyShape ?? this)))})`;
2194
2091
  }
2195
2092
  PropertyShape.$toString = $toString;
2196
2093
  })(PropertyShape || (PropertyShape = {}));
@@ -2266,33 +2163,7 @@ export var PropertyGroup;
2266
2163
  return true;
2267
2164
  }
2268
2165
  PropertyGroup.filter = filter;
2269
- PropertyGroup.fromRdfResource = (resource, options) => {
2270
- let { context, graph, ignoreRdfType = false, objectSet, preferredLanguages, } = options ?? {};
2271
- if (!objectSet) {
2272
- objectSet = new $RdfjsDatasetObjectSet(resource.dataset);
2273
- }
2274
- return PropertyGroup.propertiesFromRdfResource(resource, {
2275
- context,
2276
- graph,
2277
- ignoreRdfType,
2278
- objectSet,
2279
- preferredLanguages,
2280
- }).map(create);
2281
- };
2282
- PropertyGroup.fromRdfResourceValues = (values, options) => values.chain((values) => values.chainMap((value) => value
2283
- .toResource()
2284
- .chain((resource) => PropertyGroup.fromRdfResource(resource, options))));
2285
- PropertyGroup.fromRdfType = dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyGroup");
2286
- function isPropertyGroup(object) {
2287
- switch (object.$type) {
2288
- case "PropertyGroup":
2289
- return true;
2290
- default:
2291
- return false;
2292
- }
2293
- }
2294
- PropertyGroup.isPropertyGroup = isPropertyGroup;
2295
- PropertyGroup.propertiesFromRdfResource = ($resource, _$options) => {
2166
+ PropertyGroup._fromRdfResource = ($resource, _$options) => {
2296
2167
  return (!_$options.ignoreRdfType
2297
2168
  ? $resource
2298
2169
  .value($RdfVocabularies.rdf.type, { graph: _$options.graph })
@@ -2311,44 +2182,61 @@ export var PropertyGroup;
2311
2182
  }
2312
2183
  return Left(new Error(`${$resource.identifier} has unexpected RDF type (actual: ${actualRdfType.value}, expected: http://www.w3.org/ns/shacl#PropertyGroup)`));
2313
2184
  })
2314
- : Right(true)).chain((_rdfTypeCheck) => Right(new Resource.Value({
2315
- dataFactory: dataFactory,
2316
- focusResource: $resource,
2317
- propertyPath: $RdfVocabularies.rdf.subject,
2318
- term: $resource.identifier,
2319
- }).toValues())
2320
- .chain((values) => values.chainMap((value) => value.toIdentifier()))
2321
- .chain((values) => values.head())
2322
- .chain(($identifier) => Right("PropertyGroup").chain(($type) => $shaclPropertyFromRdf({
2323
- graph: _$options.graph,
2324
- resource: $resource,
2325
- propertySchema: PropertyGroup.schema.properties.comment,
2326
- typeFromRdf: (resourceValues) => resourceValues
2327
- .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
2328
- .chain((values) => values.chainMap((value) => value.toString()))
2329
- .map((values) => values.length > 0
2330
- ? values.map((value) => Maybe.of(value))
2331
- : Resource.Values.fromValue({
2332
- focusResource: $resource,
2333
- propertyPath: PropertyShape.schema.properties.comment.path,
2334
- value: Maybe.empty(),
2335
- })),
2336
- }).chain((comment) => $shaclPropertyFromRdf({
2337
- graph: _$options.graph,
2338
- resource: $resource,
2339
- propertySchema: PropertyGroup.schema.properties.label,
2340
- typeFromRdf: (resourceValues) => resourceValues
2341
- .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
2342
- .chain((values) => values.chainMap((value) => value.toString()))
2343
- .map((values) => values.length > 0
2344
- ? values.map((value) => Maybe.of(value))
2345
- : Resource.Values.fromValue({
2346
- focusResource: $resource,
2347
- propertyPath: PropertyShape.schema.properties.label.path,
2348
- value: Maybe.empty(),
2349
- })),
2350
- }).map((label) => ({ $identifier, $type, comment, label }))))));
2185
+ : Right(true)).chain((_rdfTypeCheck) => $sequenceRecord({
2186
+ $identifier: Right(new Resource.Value({
2187
+ dataFactory: dataFactory,
2188
+ focusResource: $resource,
2189
+ propertyPath: $RdfVocabularies.rdf.subject,
2190
+ term: $resource.identifier,
2191
+ }).toValues())
2192
+ .chain((values) => values.chainMap((value) => value.toIdentifier()))
2193
+ .chain((values) => values.head()),
2194
+ comment: $shaclPropertyFromRdf({
2195
+ graph: _$options.graph,
2196
+ resource: $resource,
2197
+ propertySchema: PropertyGroup.schema.properties.comment,
2198
+ typeFromRdf: (resourceValues) => resourceValues
2199
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
2200
+ .chain((values) => values.chainMap((value) => value.toString()))
2201
+ .map((values) => values.length > 0
2202
+ ? values.map((value) => Maybe.of(value))
2203
+ : Resource.Values.fromValue({
2204
+ focusResource: $resource,
2205
+ propertyPath: PropertyShape.schema.properties.comment.path,
2206
+ value: Maybe.empty(),
2207
+ })),
2208
+ }),
2209
+ label: $shaclPropertyFromRdf({
2210
+ graph: _$options.graph,
2211
+ resource: $resource,
2212
+ propertySchema: PropertyGroup.schema.properties.label,
2213
+ typeFromRdf: (resourceValues) => resourceValues
2214
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
2215
+ .chain((values) => values.chainMap((value) => value.toString()))
2216
+ .map((values) => values.length > 0
2217
+ ? values.map((value) => Maybe.of(value))
2218
+ : Resource.Values.fromValue({
2219
+ focusResource: $resource,
2220
+ propertyPath: PropertyShape.schema.properties.label.path,
2221
+ value: Maybe.empty(),
2222
+ })),
2223
+ }),
2224
+ }).map((properties) => create(properties)));
2351
2225
  };
2226
+ PropertyGroup.fromRdfResource = $wrap_FromRdfResourceFunction(PropertyGroup._fromRdfResource);
2227
+ PropertyGroup.fromRdfResourceValues = (values, options) => values.chain((values) => values.chainMap((value) => value
2228
+ .toResource()
2229
+ .chain((resource) => PropertyGroup.fromRdfResource(resource, options))));
2230
+ PropertyGroup.fromRdfType = dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyGroup");
2231
+ function isPropertyGroup(object) {
2232
+ switch (object.$type) {
2233
+ case "PropertyGroup":
2234
+ return true;
2235
+ default:
2236
+ return false;
2237
+ }
2238
+ }
2239
+ PropertyGroup.isPropertyGroup = isPropertyGroup;
2352
2240
  PropertyGroup.schema = {
2353
2241
  properties: {
2354
2242
  $identifier: {
@@ -2380,34 +2268,28 @@ export var PropertyGroup;
2380
2268
  },
2381
2269
  },
2382
2270
  };
2383
- function toRdfResource(_propertyGroup, options) {
2384
- const resourceSet = options?.resourceSet ??
2385
- new ResourceSet({
2386
- dataFactory: dataFactory,
2387
- dataset: datasetFactory.dataset(),
2388
- });
2389
- const resource = resourceSet.resource(_propertyGroup.$identifier());
2390
- if (!options?.ignoreRdfType) {
2391
- resource.add($RdfVocabularies.rdf.type, dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyGroup"), options?.graph);
2271
+ PropertyGroup._toRdfResource = (parameters) => {
2272
+ if (!parameters.ignoreRdfType) {
2273
+ parameters.resource.add($RdfVocabularies.rdf.type, dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyGroup"), parameters.graph);
2392
2274
  }
2393
- resource.add(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#comment"), _propertyGroup.comment
2275
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#comment"), parameters.object.comment
2394
2276
  .toList()
2395
- .flatMap((value) => [$literalFactory.string(value)]), options?.graph);
2396
- resource.add(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#label"), _propertyGroup.label
2277
+ .flatMap((value) => [$literalFactory.string(value)]), parameters.graph);
2278
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#label"), parameters.object.label
2397
2279
  .toList()
2398
- .flatMap((value) => [$literalFactory.string(value)]), options?.graph);
2399
- return resource;
2400
- }
2401
- PropertyGroup.toRdfResource = toRdfResource;
2402
- function propertiesToStrings(_propertyGroup) {
2280
+ .flatMap((value) => [$literalFactory.string(value)]), parameters.graph);
2281
+ return parameters.resource;
2282
+ };
2283
+ PropertyGroup.toRdfResource = $wrap_ToRdfResourceFunction(PropertyGroup._toRdfResource);
2284
+ function _propertiesToStrings(_propertyGroup) {
2403
2285
  return $compactRecord({
2404
2286
  $identifier: _propertyGroup.$identifier().toString(),
2405
2287
  label: _propertyGroup.label.map((item) => item.toString()).extract(),
2406
2288
  });
2407
2289
  }
2408
- PropertyGroup.propertiesToStrings = propertiesToStrings;
2290
+ PropertyGroup._propertiesToStrings = _propertiesToStrings;
2409
2291
  function $toString(_propertyGroup) {
2410
- return `PropertyGroup(${JSON.stringify(propertiesToStrings((_propertyGroup ?? this)))})`;
2292
+ return `PropertyGroup(${JSON.stringify(_propertiesToStrings((_propertyGroup ?? this)))})`;
2411
2293
  }
2412
2294
  PropertyGroup.$toString = $toString;
2413
2295
  })(PropertyGroup || (PropertyGroup = {}));
@@ -2476,40 +2358,14 @@ export var Ontology;
2476
2358
  !$filterMaybe($filterString)(filter.comment, value.comment)) {
2477
2359
  return false;
2478
2360
  }
2479
- if (filter.label !== undefined &&
2480
- !$filterMaybe($filterString)(filter.label, value.label)) {
2481
- return false;
2482
- }
2483
- return true;
2484
- }
2485
- Ontology.filter = filter;
2486
- Ontology.fromRdfResource = (resource, options) => {
2487
- let { context, graph, ignoreRdfType = false, objectSet, preferredLanguages, } = options ?? {};
2488
- if (!objectSet) {
2489
- objectSet = new $RdfjsDatasetObjectSet(resource.dataset);
2490
- }
2491
- return Ontology.propertiesFromRdfResource(resource, {
2492
- context,
2493
- graph,
2494
- ignoreRdfType,
2495
- objectSet,
2496
- preferredLanguages,
2497
- }).map(create);
2498
- };
2499
- Ontology.fromRdfResourceValues = (values, options) => values.chain((values) => values.chainMap((value) => value
2500
- .toResource()
2501
- .chain((resource) => Ontology.fromRdfResource(resource, options))));
2502
- Ontology.fromRdfType = dataFactory.namedNode("http://www.w3.org/2002/07/owl#Ontology");
2503
- function isOntology(object) {
2504
- switch (object.$type) {
2505
- case "Ontology":
2506
- return true;
2507
- default:
2508
- return false;
2509
- }
2361
+ if (filter.label !== undefined &&
2362
+ !$filterMaybe($filterString)(filter.label, value.label)) {
2363
+ return false;
2364
+ }
2365
+ return true;
2510
2366
  }
2511
- Ontology.isOntology = isOntology;
2512
- Ontology.propertiesFromRdfResource = ($resource, _$options) => {
2367
+ Ontology.filter = filter;
2368
+ Ontology._fromRdfResource = ($resource, _$options) => {
2513
2369
  return (!_$options.ignoreRdfType
2514
2370
  ? $resource
2515
2371
  .value($RdfVocabularies.rdf.type, { graph: _$options.graph })
@@ -2528,44 +2384,61 @@ export var Ontology;
2528
2384
  }
2529
2385
  return Left(new Error(`${$resource.identifier} has unexpected RDF type (actual: ${actualRdfType.value}, expected: http://www.w3.org/2002/07/owl#Ontology)`));
2530
2386
  })
2531
- : Right(true)).chain((_rdfTypeCheck) => Right(new Resource.Value({
2532
- dataFactory: dataFactory,
2533
- focusResource: $resource,
2534
- propertyPath: $RdfVocabularies.rdf.subject,
2535
- term: $resource.identifier,
2536
- }).toValues())
2537
- .chain((values) => values.chainMap((value) => value.toIdentifier()))
2538
- .chain((values) => values.head())
2539
- .chain(($identifier) => Right("Ontology").chain(($type) => $shaclPropertyFromRdf({
2540
- graph: _$options.graph,
2541
- resource: $resource,
2542
- propertySchema: Ontology.schema.properties.comment,
2543
- typeFromRdf: (resourceValues) => resourceValues
2544
- .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
2545
- .chain((values) => values.chainMap((value) => value.toString()))
2546
- .map((values) => values.length > 0
2547
- ? values.map((value) => Maybe.of(value))
2548
- : Resource.Values.fromValue({
2549
- focusResource: $resource,
2550
- propertyPath: PropertyShape.schema.properties.comment.path,
2551
- value: Maybe.empty(),
2552
- })),
2553
- }).chain((comment) => $shaclPropertyFromRdf({
2554
- graph: _$options.graph,
2555
- resource: $resource,
2556
- propertySchema: Ontology.schema.properties.label,
2557
- typeFromRdf: (resourceValues) => resourceValues
2558
- .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
2559
- .chain((values) => values.chainMap((value) => value.toString()))
2560
- .map((values) => values.length > 0
2561
- ? values.map((value) => Maybe.of(value))
2562
- : Resource.Values.fromValue({
2563
- focusResource: $resource,
2564
- propertyPath: PropertyShape.schema.properties.label.path,
2565
- value: Maybe.empty(),
2566
- })),
2567
- }).map((label) => ({ $identifier, $type, comment, label }))))));
2387
+ : Right(true)).chain((_rdfTypeCheck) => $sequenceRecord({
2388
+ $identifier: Right(new Resource.Value({
2389
+ dataFactory: dataFactory,
2390
+ focusResource: $resource,
2391
+ propertyPath: $RdfVocabularies.rdf.subject,
2392
+ term: $resource.identifier,
2393
+ }).toValues())
2394
+ .chain((values) => values.chainMap((value) => value.toIdentifier()))
2395
+ .chain((values) => values.head()),
2396
+ comment: $shaclPropertyFromRdf({
2397
+ graph: _$options.graph,
2398
+ resource: $resource,
2399
+ propertySchema: Ontology.schema.properties.comment,
2400
+ typeFromRdf: (resourceValues) => resourceValues
2401
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
2402
+ .chain((values) => values.chainMap((value) => value.toString()))
2403
+ .map((values) => values.length > 0
2404
+ ? values.map((value) => Maybe.of(value))
2405
+ : Resource.Values.fromValue({
2406
+ focusResource: $resource,
2407
+ propertyPath: PropertyShape.schema.properties.comment.path,
2408
+ value: Maybe.empty(),
2409
+ })),
2410
+ }),
2411
+ label: $shaclPropertyFromRdf({
2412
+ graph: _$options.graph,
2413
+ resource: $resource,
2414
+ propertySchema: Ontology.schema.properties.label,
2415
+ typeFromRdf: (resourceValues) => resourceValues
2416
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
2417
+ .chain((values) => values.chainMap((value) => value.toString()))
2418
+ .map((values) => values.length > 0
2419
+ ? values.map((value) => Maybe.of(value))
2420
+ : Resource.Values.fromValue({
2421
+ focusResource: $resource,
2422
+ propertyPath: PropertyShape.schema.properties.label.path,
2423
+ value: Maybe.empty(),
2424
+ })),
2425
+ }),
2426
+ }).map((properties) => create(properties)));
2568
2427
  };
2428
+ Ontology.fromRdfResource = $wrap_FromRdfResourceFunction(Ontology._fromRdfResource);
2429
+ Ontology.fromRdfResourceValues = (values, options) => values.chain((values) => values.chainMap((value) => value
2430
+ .toResource()
2431
+ .chain((resource) => Ontology.fromRdfResource(resource, options))));
2432
+ Ontology.fromRdfType = dataFactory.namedNode("http://www.w3.org/2002/07/owl#Ontology");
2433
+ function isOntology(object) {
2434
+ switch (object.$type) {
2435
+ case "Ontology":
2436
+ return true;
2437
+ default:
2438
+ return false;
2439
+ }
2440
+ }
2441
+ Ontology.isOntology = isOntology;
2569
2442
  Ontology.schema = {
2570
2443
  properties: {
2571
2444
  $identifier: {
@@ -2597,34 +2470,28 @@ export var Ontology;
2597
2470
  },
2598
2471
  },
2599
2472
  };
2600
- function toRdfResource(_ontology, options) {
2601
- const resourceSet = options?.resourceSet ??
2602
- new ResourceSet({
2603
- dataFactory: dataFactory,
2604
- dataset: datasetFactory.dataset(),
2605
- });
2606
- const resource = resourceSet.resource(_ontology.$identifier());
2607
- if (!options?.ignoreRdfType) {
2608
- resource.add($RdfVocabularies.rdf.type, dataFactory.namedNode("http://www.w3.org/2002/07/owl#Ontology"), options?.graph);
2473
+ Ontology._toRdfResource = (parameters) => {
2474
+ if (!parameters.ignoreRdfType) {
2475
+ parameters.resource.add($RdfVocabularies.rdf.type, dataFactory.namedNode("http://www.w3.org/2002/07/owl#Ontology"), parameters.graph);
2609
2476
  }
2610
- resource.add(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#comment"), _ontology.comment
2477
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#comment"), parameters.object.comment
2611
2478
  .toList()
2612
- .flatMap((value) => [$literalFactory.string(value)]), options?.graph);
2613
- resource.add(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#label"), _ontology.label
2479
+ .flatMap((value) => [$literalFactory.string(value)]), parameters.graph);
2480
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#label"), parameters.object.label
2614
2481
  .toList()
2615
- .flatMap((value) => [$literalFactory.string(value)]), options?.graph);
2616
- return resource;
2617
- }
2618
- Ontology.toRdfResource = toRdfResource;
2619
- function propertiesToStrings(_ontology) {
2482
+ .flatMap((value) => [$literalFactory.string(value)]), parameters.graph);
2483
+ return parameters.resource;
2484
+ };
2485
+ Ontology.toRdfResource = $wrap_ToRdfResourceFunction(Ontology._toRdfResource);
2486
+ function _propertiesToStrings(_ontology) {
2620
2487
  return $compactRecord({
2621
2488
  $identifier: _ontology.$identifier().toString(),
2622
2489
  label: _ontology.label.map((item) => item.toString()).extract(),
2623
2490
  });
2624
2491
  }
2625
- Ontology.propertiesToStrings = propertiesToStrings;
2492
+ Ontology._propertiesToStrings = _propertiesToStrings;
2626
2493
  function $toString(_ontology) {
2627
- return `Ontology(${JSON.stringify(propertiesToStrings((_ontology ?? this)))})`;
2494
+ return `Ontology(${JSON.stringify(_propertiesToStrings((_ontology ?? this)))})`;
2628
2495
  }
2629
2496
  Ontology.$toString = $toString;
2630
2497
  })(Ontology || (Ontology = {}));
@@ -3324,33 +3191,7 @@ export var NodeShape;
3324
3191
  return true;
3325
3192
  }
3326
3193
  NodeShape.filter = filter;
3327
- NodeShape.fromRdfResource = (resource, options) => {
3328
- let { context, graph, ignoreRdfType = false, objectSet, preferredLanguages, } = options ?? {};
3329
- if (!objectSet) {
3330
- objectSet = new $RdfjsDatasetObjectSet(resource.dataset);
3331
- }
3332
- return NodeShape.propertiesFromRdfResource(resource, {
3333
- context,
3334
- graph,
3335
- ignoreRdfType,
3336
- objectSet,
3337
- preferredLanguages,
3338
- }).map(create);
3339
- };
3340
- NodeShape.fromRdfResourceValues = (values, options) => values.chain((values) => values.chainMap((value) => value
3341
- .toResource()
3342
- .chain((resource) => NodeShape.fromRdfResource(resource, options))));
3343
- NodeShape.fromRdfType = dataFactory.namedNode("http://www.w3.org/ns/shacl#NodeShape");
3344
- function isNodeShape(object) {
3345
- switch (object.$type) {
3346
- case "NodeShape":
3347
- return true;
3348
- default:
3349
- return false;
3350
- }
3351
- }
3352
- NodeShape.isNodeShape = isNodeShape;
3353
- NodeShape.propertiesFromRdfResource = ($resource, _$options) => {
3194
+ NodeShape._fromRdfResource = ($resource, _$options) => {
3354
3195
  return (!_$options.ignoreRdfType
3355
3196
  ? $resource
3356
3197
  .value($RdfVocabularies.rdf.type, { graph: _$options.graph })
@@ -3369,623 +3210,522 @@ export var NodeShape;
3369
3210
  }
3370
3211
  return Left(new Error(`${$resource.identifier} has unexpected RDF type (actual: ${actualRdfType.value}, expected: http://www.w3.org/ns/shacl#NodeShape)`));
3371
3212
  })
3372
- : Right(true)).chain((_rdfTypeCheck) => Right(new Resource.Value({
3373
- dataFactory: dataFactory,
3374
- focusResource: $resource,
3375
- propertyPath: $RdfVocabularies.rdf.subject,
3376
- term: $resource.identifier,
3377
- }).toValues())
3378
- .chain((values) => values.chainMap((value) => value.toIdentifier()))
3379
- .chain((values) => values.head())
3380
- .chain(($identifier) => Right("NodeShape").chain(($type) => $shaclPropertyFromRdf({
3381
- graph: _$options.graph,
3382
- resource: $resource,
3383
- propertySchema: NodeShape.schema.properties.and,
3384
- typeFromRdf: (resourceValues) => resourceValues
3385
- .chain((values) => values.chainMap((value) => value.toList({ graph: _$options.graph })))
3386
- .chain((valueLists) => valueLists.chainMap((valueList) => Right(Resource.Values.fromArray({
3213
+ : Right(true)).chain((_rdfTypeCheck) => $sequenceRecord({
3214
+ $identifier: Right(new Resource.Value({
3215
+ dataFactory: dataFactory,
3387
3216
  focusResource: $resource,
3388
- propertyPath: PropertyShape.schema.properties.and.path,
3389
- values: valueList.toArray(),
3390
- })).chain((values) => values.chainMap((value) => value.toIdentifier()))))
3391
- .map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
3392
- .map((values) => values.length > 0
3393
- ? values.map((value) => Maybe.of(value))
3394
- : Resource.Values.fromValue({
3217
+ propertyPath: $RdfVocabularies.rdf.subject,
3218
+ term: $resource.identifier,
3219
+ }).toValues())
3220
+ .chain((values) => values.chainMap((value) => value.toIdentifier()))
3221
+ .chain((values) => values.head()),
3222
+ and: $shaclPropertyFromRdf({
3223
+ graph: _$options.graph,
3224
+ resource: $resource,
3225
+ propertySchema: NodeShape.schema.properties.and,
3226
+ typeFromRdf: (resourceValues) => resourceValues
3227
+ .chain((values) => values.chainMap((value) => value.toList({ graph: _$options.graph })))
3228
+ .chain((valueLists) => valueLists.chainMap((valueList) => Right(Resource.Values.fromArray({
3395
3229
  focusResource: $resource,
3396
3230
  propertyPath: PropertyShape.schema.properties.and.path,
3397
- value: Maybe.empty(),
3398
- })),
3399
- }).chain((and) => $shaclPropertyFromRdf({
3400
- graph: _$options.graph,
3401
- resource: $resource,
3402
- propertySchema: NodeShape.schema.properties.classes,
3403
- typeFromRdf: (resourceValues) => resourceValues
3404
- .chain((values) => values.chainMap((value) => value.toIri()))
3405
- .map((values) => values.toArray())
3406
- .map((valuesArray) => Resource.Values.fromValue({
3407
- focusResource: $resource,
3408
- propertyPath: PropertyShape.schema.properties.classes.path,
3409
- value: valuesArray,
3410
- })),
3411
- }).chain((classes) => $shaclPropertyFromRdf({
3412
- graph: _$options.graph,
3413
- resource: $resource,
3414
- propertySchema: NodeShape.schema.properties.closed,
3415
- typeFromRdf: (resourceValues) => resourceValues
3416
- .chain((values) => values.chainMap((value) => value.toBoolean()))
3417
- .map((values) => values.length > 0
3418
- ? values.map((value) => Maybe.of(value))
3419
- : Resource.Values.fromValue({
3420
- focusResource: $resource,
3421
- propertyPath: NodeShape.schema.properties.closed.path,
3422
- value: Maybe.empty(),
3423
- })),
3424
- }).chain((closed) => $shaclPropertyFromRdf({
3425
- graph: _$options.graph,
3426
- resource: $resource,
3427
- propertySchema: NodeShape.schema.properties.comment,
3428
- typeFromRdf: (resourceValues) => resourceValues
3429
- .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
3430
- .chain((values) => values.chainMap((value) => value.toString()))
3431
- .map((values) => values.length > 0
3432
- ? values.map((value) => Maybe.of(value))
3433
- : Resource.Values.fromValue({
3434
- focusResource: $resource,
3435
- propertyPath: PropertyShape.schema.properties.comment.path,
3436
- value: Maybe.empty(),
3437
- })),
3438
- }).chain((comment) => $shaclPropertyFromRdf({
3439
- graph: _$options.graph,
3440
- resource: $resource,
3441
- propertySchema: NodeShape.schema.properties.datatype,
3442
- typeFromRdf: (resourceValues) => resourceValues
3443
- .chain((values) => values.chainMap((value) => value.toIri()))
3444
- .map((values) => values.length > 0
3445
- ? values.map((value) => Maybe.of(value))
3446
- : Resource.Values.fromValue({
3447
- focusResource: $resource,
3448
- propertyPath: PropertyShape.schema.properties.datatype
3449
- .path,
3450
- value: Maybe.empty(),
3451
- })),
3452
- }).chain((datatype) => $shaclPropertyFromRdf({
3453
- graph: _$options.graph,
3454
- resource: $resource,
3455
- propertySchema: NodeShape.schema.properties.deactivated,
3456
- typeFromRdf: (resourceValues) => resourceValues
3457
- .chain((values) => values.chainMap((value) => value.toBoolean()))
3458
- .map((values) => values.length > 0
3459
- ? values.map((value) => Maybe.of(value))
3460
- : Resource.Values.fromValue({
3461
- focusResource: $resource,
3462
- propertyPath: PropertyShape.schema.properties
3463
- .deactivated.path,
3464
- value: Maybe.empty(),
3465
- })),
3466
- }).chain((deactivated) => $shaclPropertyFromRdf({
3467
- graph: _$options.graph,
3468
- resource: $resource,
3469
- propertySchema: NodeShape.schema.properties.flags,
3470
- typeFromRdf: (resourceValues) => resourceValues
3471
- .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
3472
- .chain((values) => values.chainMap((value) => value.toString()))
3473
- .map((values) => values.toArray())
3474
- .map((valuesArray) => Resource.Values.fromValue({
3475
- focusResource: $resource,
3476
- propertyPath: PropertyShape.schema.properties.flags.path,
3477
- value: valuesArray,
3478
- })),
3479
- }).chain((flags) => $shaclPropertyFromRdf({
3480
- graph: _$options.graph,
3481
- resource: $resource,
3482
- propertySchema: NodeShape.schema.properties.hasValues,
3483
- typeFromRdf: (resourceValues) => resourceValues
3484
- .chain((values) => values.chainMap((value) => value.toTerm().chain((term) => {
3485
- switch (term.termType) {
3486
- case "NamedNode":
3487
- case "Literal":
3488
- return Either.of(term);
3489
- default:
3490
- return Left(new Resource.MistypedTermValueError({
3491
- actualValue: term,
3492
- expectedValueType: "(NamedNode | Literal)",
3493
- focusResource: $resource,
3494
- propertyPath: PropertyShape.schema
3495
- .properties.hasValues.path,
3496
- }));
3497
- }
3498
- })))
3499
- .map((values) => values.toArray())
3500
- .map((valuesArray) => Resource.Values.fromValue({
3501
- focusResource: $resource,
3502
- propertyPath: PropertyShape.schema.properties.hasValues
3503
- .path,
3504
- value: valuesArray,
3505
- })),
3506
- }).chain((hasValues) => $shaclPropertyFromRdf({
3507
- graph: _$options.graph,
3508
- resource: $resource,
3509
- propertySchema: NodeShape.schema.properties.ignoredProperties,
3510
- typeFromRdf: (resourceValues) => resourceValues
3511
- .chain((values) => values.chainMap((value) => value.toList({ graph: _$options.graph })))
3512
- .chain((valueLists) => valueLists.chainMap((valueList) => Right(Resource.Values.fromArray({
3513
- focusResource: $resource,
3514
- propertyPath: NodeShape.schema.properties
3515
- .ignoredProperties.path,
3516
- values: valueList.toArray(),
3517
- })).chain((values) => values.chainMap((value) => value.toIri()))))
3518
- .map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
3519
- .map((values) => values.length > 0
3520
- ? values.map((value) => Maybe.of(value))
3521
- : Resource.Values.fromValue({
3522
- focusResource: $resource,
3523
- propertyPath: NodeShape.schema.properties
3524
- .ignoredProperties.path,
3525
- value: Maybe.empty(),
3526
- })),
3527
- }).chain((ignoredProperties) => $shaclPropertyFromRdf({
3528
- graph: _$options.graph,
3529
- resource: $resource,
3530
- propertySchema: NodeShape.schema.properties.in_,
3531
- typeFromRdf: (resourceValues) => resourceValues
3532
- .chain((values) => values.chainMap((value) => value.toList({
3231
+ values: valueList.toArray(),
3232
+ })).chain((values) => values.chainMap((value) => value.toIdentifier()))))
3233
+ .map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
3234
+ .map((values) => values.length > 0
3235
+ ? values.map((value) => Maybe.of(value))
3236
+ : Resource.Values.fromValue({
3237
+ focusResource: $resource,
3238
+ propertyPath: PropertyShape.schema.properties.and.path,
3239
+ value: Maybe.empty(),
3240
+ })),
3241
+ }),
3242
+ classes: $shaclPropertyFromRdf({
3533
3243
  graph: _$options.graph,
3534
- })))
3535
- .chain((valueLists) => valueLists.chainMap((valueList) => Right(Resource.Values.fromArray({
3536
- focusResource: $resource,
3537
- propertyPath: PropertyShape.schema.properties
3538
- .in_.path,
3539
- values: valueList.toArray(),
3540
- })).chain((values) => values.chainMap((value) => value.toTerm().chain((term) => {
3541
- switch (term.termType) {
3542
- case "NamedNode":
3543
- case "Literal":
3544
- return Either.of(term);
3545
- default:
3546
- return Left(new Resource.MistypedTermValueError({
3547
- actualValue: term,
3548
- expectedValueType: "(NamedNode | Literal)",
3549
- focusResource: $resource,
3550
- propertyPath: PropertyShape.schema
3551
- .properties.in_
3552
- .path,
3553
- }));
3554
- }
3555
- })))))
3556
- .map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
3557
- .map((values) => values.length > 0
3558
- ? values.map((value) => Maybe.of(value))
3559
- : Resource.Values.fromValue({
3560
- focusResource: $resource,
3561
- propertyPath: PropertyShape.schema.properties
3562
- .in_.path,
3563
- value: Maybe.empty(),
3564
- })),
3565
- }).chain((in_) => $shaclPropertyFromRdf({
3566
- graph: _$options.graph,
3567
- resource: $resource,
3568
- propertySchema: NodeShape.schema.properties.isDefinedBy,
3569
- typeFromRdf: (resourceValues) => resourceValues
3570
- .chain((values) => values.chainMap((value) => value.toIdentifier()))
3571
- .map((values) => values.length > 0
3572
- ? values.map((value) => Maybe.of(value))
3573
- : Resource.Values.fromValue({
3574
- focusResource: $resource,
3575
- propertyPath: PropertyShape.schema.properties
3576
- .isDefinedBy.path,
3577
- value: Maybe.empty(),
3578
- })),
3579
- }).chain((isDefinedBy) => $shaclPropertyFromRdf({
3580
- graph: _$options.graph,
3581
- resource: $resource,
3582
- propertySchema: NodeShape.schema.properties.label,
3583
- typeFromRdf: (resourceValues) => resourceValues
3584
- .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
3585
- .chain((values) => values.chainMap((value) => value.toString()))
3586
- .map((values) => values.length > 0
3587
- ? values.map((value) => Maybe.of(value))
3588
- : Resource.Values.fromValue({
3244
+ resource: $resource,
3245
+ propertySchema: NodeShape.schema.properties.classes,
3246
+ typeFromRdf: (resourceValues) => resourceValues
3247
+ .chain((values) => values.chainMap((value) => value.toIri()))
3248
+ .map((values) => values.toArray())
3249
+ .map((valuesArray) => Resource.Values.fromValue({
3589
3250
  focusResource: $resource,
3590
- propertyPath: PropertyShape.schema
3591
- .properties.label.path,
3592
- value: Maybe.empty(),
3251
+ propertyPath: PropertyShape.schema.properties.classes.path,
3252
+ value: valuesArray,
3593
3253
  })),
3594
- }).chain((label) => $shaclPropertyFromRdf({
3595
- graph: _$options.graph,
3596
- resource: $resource,
3597
- propertySchema: NodeShape.schema.properties.languageIn,
3598
- typeFromRdf: (resourceValues) => resourceValues
3599
- .chain((values) => values.chainMap((value) => value.toList({
3254
+ }),
3255
+ closed: $shaclPropertyFromRdf({
3600
3256
  graph: _$options.graph,
3601
- })))
3602
- .chain((valueLists) => valueLists.chainMap((valueList) => Right(Resource.Values.fromArray({
3603
- focusResource: $resource,
3604
- propertyPath: PropertyShape.schema
3605
- .properties.languageIn
3606
- .path,
3607
- values: valueList.toArray(),
3608
- }))
3609
- .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
3610
- .chain((values) => values.chainMap((value) => value.toString()))))
3611
- .map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
3612
- .map((values) => values.length > 0
3613
- ? values.map((value) => Maybe.of(value))
3614
- : Resource.Values.fromValue({
3615
- focusResource: $resource,
3616
- propertyPath: PropertyShape.schema
3617
- .properties.languageIn
3618
- .path,
3619
- value: Maybe.empty(),
3620
- })),
3621
- }).chain((languageIn) => $shaclPropertyFromRdf({
3622
- graph: _$options.graph,
3623
- resource: $resource,
3624
- propertySchema: NodeShape.schema.properties.maxCount,
3625
- typeFromRdf: (resourceValues) => resourceValues
3626
- .chain((values) => values.chainMap((value) => value.toBigInt()))
3627
- .map((values) => values.length > 0
3628
- ? values.map((value) => Maybe.of(value))
3629
- : Resource.Values.fromValue({
3257
+ resource: $resource,
3258
+ propertySchema: NodeShape.schema.properties.closed,
3259
+ typeFromRdf: (resourceValues) => resourceValues
3260
+ .chain((values) => values.chainMap((value) => value.toBoolean()))
3261
+ .map((values) => values.length > 0
3262
+ ? values.map((value) => Maybe.of(value))
3263
+ : Resource.Values.fromValue({
3264
+ focusResource: $resource,
3265
+ propertyPath: NodeShape.schema.properties.closed.path,
3266
+ value: Maybe.empty(),
3267
+ })),
3268
+ }),
3269
+ comment: $shaclPropertyFromRdf({
3270
+ graph: _$options.graph,
3271
+ resource: $resource,
3272
+ propertySchema: NodeShape.schema.properties.comment,
3273
+ typeFromRdf: (resourceValues) => resourceValues
3274
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
3275
+ .chain((values) => values.chainMap((value) => value.toString()))
3276
+ .map((values) => values.length > 0
3277
+ ? values.map((value) => Maybe.of(value))
3278
+ : Resource.Values.fromValue({
3279
+ focusResource: $resource,
3280
+ propertyPath: PropertyShape.schema.properties.comment.path,
3281
+ value: Maybe.empty(),
3282
+ })),
3283
+ }),
3284
+ datatype: $shaclPropertyFromRdf({
3285
+ graph: _$options.graph,
3286
+ resource: $resource,
3287
+ propertySchema: NodeShape.schema.properties.datatype,
3288
+ typeFromRdf: (resourceValues) => resourceValues
3289
+ .chain((values) => values.chainMap((value) => value.toIri()))
3290
+ .map((values) => values.length > 0
3291
+ ? values.map((value) => Maybe.of(value))
3292
+ : Resource.Values.fromValue({
3293
+ focusResource: $resource,
3294
+ propertyPath: PropertyShape.schema.properties.datatype.path,
3295
+ value: Maybe.empty(),
3296
+ })),
3297
+ }),
3298
+ deactivated: $shaclPropertyFromRdf({
3299
+ graph: _$options.graph,
3300
+ resource: $resource,
3301
+ propertySchema: NodeShape.schema.properties.deactivated,
3302
+ typeFromRdf: (resourceValues) => resourceValues
3303
+ .chain((values) => values.chainMap((value) => value.toBoolean()))
3304
+ .map((values) => values.length > 0
3305
+ ? values.map((value) => Maybe.of(value))
3306
+ : Resource.Values.fromValue({
3307
+ focusResource: $resource,
3308
+ propertyPath: PropertyShape.schema.properties.deactivated.path,
3309
+ value: Maybe.empty(),
3310
+ })),
3311
+ }),
3312
+ flags: $shaclPropertyFromRdf({
3313
+ graph: _$options.graph,
3314
+ resource: $resource,
3315
+ propertySchema: NodeShape.schema.properties.flags,
3316
+ typeFromRdf: (resourceValues) => resourceValues
3317
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
3318
+ .chain((values) => values.chainMap((value) => value.toString()))
3319
+ .map((values) => values.toArray())
3320
+ .map((valuesArray) => Resource.Values.fromValue({
3630
3321
  focusResource: $resource,
3631
- propertyPath: PropertyShape.schema
3632
- .properties.maxCount
3633
- .path,
3634
- value: Maybe.empty(),
3322
+ propertyPath: PropertyShape.schema.properties.flags.path,
3323
+ value: valuesArray,
3635
3324
  })),
3636
- }).chain((maxCount) => $shaclPropertyFromRdf({
3637
- graph: _$options.graph,
3638
- resource: $resource,
3639
- propertySchema: NodeShape.schema.properties.maxExclusive,
3640
- typeFromRdf: (resourceValues) => resourceValues
3641
- .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
3642
- .chain((values) => values.chainMap((value) => value.toLiteral()))
3643
- .map((values) => values.length > 0
3644
- ? values.map((value) => Maybe.of(value))
3645
- : Resource.Values.fromValue({
3325
+ }),
3326
+ hasValues: $shaclPropertyFromRdf({
3327
+ graph: _$options.graph,
3328
+ resource: $resource,
3329
+ propertySchema: NodeShape.schema.properties.hasValues,
3330
+ typeFromRdf: (resourceValues) => resourceValues
3331
+ .chain((values) => values.chainMap((value) => value.toTerm().chain((term) => {
3332
+ switch (term.termType) {
3333
+ case "NamedNode":
3334
+ case "Literal":
3335
+ return Either.of(term);
3336
+ default:
3337
+ return Left(new Resource.MistypedTermValueError({
3338
+ actualValue: term,
3339
+ expectedValueType: "(NamedNode | Literal)",
3340
+ focusResource: $resource,
3341
+ propertyPath: PropertyShape.schema.properties.hasValues.path,
3342
+ }));
3343
+ }
3344
+ })))
3345
+ .map((values) => values.toArray())
3346
+ .map((valuesArray) => Resource.Values.fromValue({
3646
3347
  focusResource: $resource,
3647
- propertyPath: PropertyShape.schema
3648
- .properties
3649
- .maxExclusive.path,
3650
- value: Maybe.empty(),
3348
+ propertyPath: PropertyShape.schema.properties.hasValues.path,
3349
+ value: valuesArray,
3651
3350
  })),
3652
- }).chain((maxExclusive) => $shaclPropertyFromRdf({
3653
- graph: _$options.graph,
3654
- resource: $resource,
3655
- propertySchema: NodeShape.schema.properties.maxInclusive,
3656
- typeFromRdf: (resourceValues) => resourceValues
3657
- .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
3658
- .chain((values) => values.chainMap((value) => value.toLiteral()))
3659
- .map((values) => values.length > 0
3660
- ? values.map((value) => Maybe.of(value))
3661
- : Resource.Values.fromValue({
3351
+ }),
3352
+ ignoredProperties: $shaclPropertyFromRdf({
3353
+ graph: _$options.graph,
3354
+ resource: $resource,
3355
+ propertySchema: NodeShape.schema.properties.ignoredProperties,
3356
+ typeFromRdf: (resourceValues) => resourceValues
3357
+ .chain((values) => values.chainMap((value) => value.toList({ graph: _$options.graph })))
3358
+ .chain((valueLists) => valueLists.chainMap((valueList) => Right(Resource.Values.fromArray({
3662
3359
  focusResource: $resource,
3663
- propertyPath: PropertyShape.schema
3664
- .properties
3665
- .maxInclusive.path,
3666
- value: Maybe.empty(),
3667
- })),
3668
- }).chain((maxInclusive) => $shaclPropertyFromRdf({
3669
- graph: _$options.graph,
3670
- resource: $resource,
3671
- propertySchema: NodeShape.schema.properties.maxLength,
3672
- typeFromRdf: (resourceValues) => resourceValues
3673
- .chain((values) => values.chainMap((value) => value.toBigInt()))
3674
- .map((values) => values.length > 0
3675
- ? values.map((value) => Maybe.of(value))
3676
- : Resource.Values.fromValue({
3360
+ propertyPath: NodeShape.schema.properties.ignoredProperties.path,
3361
+ values: valueList.toArray(),
3362
+ })).chain((values) => values.chainMap((value) => value.toIri()))))
3363
+ .map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
3364
+ .map((values) => values.length > 0
3365
+ ? values.map((value) => Maybe.of(value))
3366
+ : Resource.Values.fromValue({
3367
+ focusResource: $resource,
3368
+ propertyPath: NodeShape.schema.properties.ignoredProperties.path,
3369
+ value: Maybe.empty(),
3370
+ })),
3371
+ }),
3372
+ in_: $shaclPropertyFromRdf({
3373
+ graph: _$options.graph,
3374
+ resource: $resource,
3375
+ propertySchema: NodeShape.schema.properties.in_,
3376
+ typeFromRdf: (resourceValues) => resourceValues
3377
+ .chain((values) => values.chainMap((value) => value.toList({ graph: _$options.graph })))
3378
+ .chain((valueLists) => valueLists.chainMap((valueList) => Right(Resource.Values.fromArray({
3677
3379
  focusResource: $resource,
3678
- propertyPath: PropertyShape.schema
3679
- .properties
3680
- .maxLength.path,
3681
- value: Maybe.empty(),
3682
- })),
3683
- }).chain((maxLength) => $shaclPropertyFromRdf({
3684
- graph: _$options.graph,
3685
- resource: $resource,
3686
- propertySchema: NodeShape.schema.properties.minCount,
3687
- typeFromRdf: (resourceValues) => resourceValues
3688
- .chain((values) => values.chainMap((value) => value.toBigInt()))
3689
- .map((values) => values.length > 0
3690
- ? values.map((value) => Maybe.of(value))
3691
- : Resource.Values.fromValue({
3380
+ propertyPath: PropertyShape.schema.properties.in_.path,
3381
+ values: valueList.toArray(),
3382
+ })).chain((values) => values.chainMap((value) => value.toTerm().chain((term) => {
3383
+ switch (term.termType) {
3384
+ case "NamedNode":
3385
+ case "Literal":
3386
+ return Either.of(term);
3387
+ default:
3388
+ return Left(new Resource.MistypedTermValueError({
3389
+ actualValue: term,
3390
+ expectedValueType: "(NamedNode | Literal)",
3391
+ focusResource: $resource,
3392
+ propertyPath: PropertyShape.schema.properties.in_.path,
3393
+ }));
3394
+ }
3395
+ })))))
3396
+ .map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
3397
+ .map((values) => values.length > 0
3398
+ ? values.map((value) => Maybe.of(value))
3399
+ : Resource.Values.fromValue({
3400
+ focusResource: $resource,
3401
+ propertyPath: PropertyShape.schema.properties.in_.path,
3402
+ value: Maybe.empty(),
3403
+ })),
3404
+ }),
3405
+ isDefinedBy: $shaclPropertyFromRdf({
3406
+ graph: _$options.graph,
3407
+ resource: $resource,
3408
+ propertySchema: NodeShape.schema.properties.isDefinedBy,
3409
+ typeFromRdf: (resourceValues) => resourceValues
3410
+ .chain((values) => values.chainMap((value) => value.toIdentifier()))
3411
+ .map((values) => values.length > 0
3412
+ ? values.map((value) => Maybe.of(value))
3413
+ : Resource.Values.fromValue({
3414
+ focusResource: $resource,
3415
+ propertyPath: PropertyShape.schema.properties.isDefinedBy.path,
3416
+ value: Maybe.empty(),
3417
+ })),
3418
+ }),
3419
+ label: $shaclPropertyFromRdf({
3420
+ graph: _$options.graph,
3421
+ resource: $resource,
3422
+ propertySchema: NodeShape.schema.properties.label,
3423
+ typeFromRdf: (resourceValues) => resourceValues
3424
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
3425
+ .chain((values) => values.chainMap((value) => value.toString()))
3426
+ .map((values) => values.length > 0
3427
+ ? values.map((value) => Maybe.of(value))
3428
+ : Resource.Values.fromValue({
3429
+ focusResource: $resource,
3430
+ propertyPath: PropertyShape.schema.properties.label.path,
3431
+ value: Maybe.empty(),
3432
+ })),
3433
+ }),
3434
+ languageIn: $shaclPropertyFromRdf({
3435
+ graph: _$options.graph,
3436
+ resource: $resource,
3437
+ propertySchema: NodeShape.schema.properties.languageIn,
3438
+ typeFromRdf: (resourceValues) => resourceValues
3439
+ .chain((values) => values.chainMap((value) => value.toList({ graph: _$options.graph })))
3440
+ .chain((valueLists) => valueLists.chainMap((valueList) => Right(Resource.Values.fromArray({
3692
3441
  focusResource: $resource,
3693
- propertyPath: PropertyShape
3694
- .schema
3695
- .properties
3696
- .minCount.path,
3697
- value: Maybe.empty(),
3698
- })),
3699
- }).chain((minCount) => $shaclPropertyFromRdf({
3700
- graph: _$options.graph,
3701
- resource: $resource,
3702
- propertySchema: NodeShape.schema.properties
3703
- .minExclusive,
3704
- typeFromRdf: (resourceValues) => resourceValues
3705
- .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
3706
- .chain((values) => values.chainMap((value) => value.toLiteral()))
3707
- .map((values) => values.length > 0
3708
- ? values.map((value) => Maybe.of(value))
3709
- : Resource.Values.fromValue({
3442
+ propertyPath: PropertyShape.schema.properties.languageIn.path,
3443
+ values: valueList.toArray(),
3444
+ }))
3445
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
3446
+ .chain((values) => values.chainMap((value) => value.toString()))))
3447
+ .map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
3448
+ .map((values) => values.length > 0
3449
+ ? values.map((value) => Maybe.of(value))
3450
+ : Resource.Values.fromValue({
3451
+ focusResource: $resource,
3452
+ propertyPath: PropertyShape.schema.properties.languageIn.path,
3453
+ value: Maybe.empty(),
3454
+ })),
3455
+ }),
3456
+ maxCount: $shaclPropertyFromRdf({
3457
+ graph: _$options.graph,
3458
+ resource: $resource,
3459
+ propertySchema: NodeShape.schema.properties.maxCount,
3460
+ typeFromRdf: (resourceValues) => resourceValues
3461
+ .chain((values) => values.chainMap((value) => value.toBigInt()))
3462
+ .map((values) => values.length > 0
3463
+ ? values.map((value) => Maybe.of(value))
3464
+ : Resource.Values.fromValue({
3465
+ focusResource: $resource,
3466
+ propertyPath: PropertyShape.schema.properties.maxCount.path,
3467
+ value: Maybe.empty(),
3468
+ })),
3469
+ }),
3470
+ maxExclusive: $shaclPropertyFromRdf({
3471
+ graph: _$options.graph,
3472
+ resource: $resource,
3473
+ propertySchema: NodeShape.schema.properties.maxExclusive,
3474
+ typeFromRdf: (resourceValues) => resourceValues
3475
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
3476
+ .chain((values) => values.chainMap((value) => value.toLiteral()))
3477
+ .map((values) => values.length > 0
3478
+ ? values.map((value) => Maybe.of(value))
3479
+ : Resource.Values.fromValue({
3480
+ focusResource: $resource,
3481
+ propertyPath: PropertyShape.schema.properties.maxExclusive.path,
3482
+ value: Maybe.empty(),
3483
+ })),
3484
+ }),
3485
+ maxInclusive: $shaclPropertyFromRdf({
3486
+ graph: _$options.graph,
3487
+ resource: $resource,
3488
+ propertySchema: NodeShape.schema.properties.maxInclusive,
3489
+ typeFromRdf: (resourceValues) => resourceValues
3490
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
3491
+ .chain((values) => values.chainMap((value) => value.toLiteral()))
3492
+ .map((values) => values.length > 0
3493
+ ? values.map((value) => Maybe.of(value))
3494
+ : Resource.Values.fromValue({
3495
+ focusResource: $resource,
3496
+ propertyPath: PropertyShape.schema.properties.maxInclusive.path,
3497
+ value: Maybe.empty(),
3498
+ })),
3499
+ }),
3500
+ maxLength: $shaclPropertyFromRdf({
3501
+ graph: _$options.graph,
3502
+ resource: $resource,
3503
+ propertySchema: NodeShape.schema.properties.maxLength,
3504
+ typeFromRdf: (resourceValues) => resourceValues
3505
+ .chain((values) => values.chainMap((value) => value.toBigInt()))
3506
+ .map((values) => values.length > 0
3507
+ ? values.map((value) => Maybe.of(value))
3508
+ : Resource.Values.fromValue({
3509
+ focusResource: $resource,
3510
+ propertyPath: PropertyShape.schema.properties.maxLength.path,
3511
+ value: Maybe.empty(),
3512
+ })),
3513
+ }),
3514
+ minCount: $shaclPropertyFromRdf({
3515
+ graph: _$options.graph,
3516
+ resource: $resource,
3517
+ propertySchema: NodeShape.schema.properties.minCount,
3518
+ typeFromRdf: (resourceValues) => resourceValues
3519
+ .chain((values) => values.chainMap((value) => value.toBigInt()))
3520
+ .map((values) => values.length > 0
3521
+ ? values.map((value) => Maybe.of(value))
3522
+ : Resource.Values.fromValue({
3523
+ focusResource: $resource,
3524
+ propertyPath: PropertyShape.schema.properties.minCount.path,
3525
+ value: Maybe.empty(),
3526
+ })),
3527
+ }),
3528
+ minExclusive: $shaclPropertyFromRdf({
3529
+ graph: _$options.graph,
3530
+ resource: $resource,
3531
+ propertySchema: NodeShape.schema.properties.minExclusive,
3532
+ typeFromRdf: (resourceValues) => resourceValues
3533
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
3534
+ .chain((values) => values.chainMap((value) => value.toLiteral()))
3535
+ .map((values) => values.length > 0
3536
+ ? values.map((value) => Maybe.of(value))
3537
+ : Resource.Values.fromValue({
3538
+ focusResource: $resource,
3539
+ propertyPath: PropertyShape.schema.properties.minExclusive.path,
3540
+ value: Maybe.empty(),
3541
+ })),
3542
+ }),
3543
+ minInclusive: $shaclPropertyFromRdf({
3544
+ graph: _$options.graph,
3545
+ resource: $resource,
3546
+ propertySchema: NodeShape.schema.properties.minInclusive,
3547
+ typeFromRdf: (resourceValues) => resourceValues
3548
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
3549
+ .chain((values) => values.chainMap((value) => value.toLiteral()))
3550
+ .map((values) => values.length > 0
3551
+ ? values.map((value) => Maybe.of(value))
3552
+ : Resource.Values.fromValue({
3553
+ focusResource: $resource,
3554
+ propertyPath: PropertyShape.schema.properties.minInclusive.path,
3555
+ value: Maybe.empty(),
3556
+ })),
3557
+ }),
3558
+ minLength: $shaclPropertyFromRdf({
3559
+ graph: _$options.graph,
3560
+ resource: $resource,
3561
+ propertySchema: NodeShape.schema.properties.minLength,
3562
+ typeFromRdf: (resourceValues) => resourceValues
3563
+ .chain((values) => values.chainMap((value) => value.toBigInt()))
3564
+ .map((values) => values.length > 0
3565
+ ? values.map((value) => Maybe.of(value))
3566
+ : Resource.Values.fromValue({
3567
+ focusResource: $resource,
3568
+ propertyPath: PropertyShape.schema.properties.minLength.path,
3569
+ value: Maybe.empty(),
3570
+ })),
3571
+ }),
3572
+ node: $shaclPropertyFromRdf({
3573
+ graph: _$options.graph,
3574
+ resource: $resource,
3575
+ propertySchema: NodeShape.schema.properties.node,
3576
+ typeFromRdf: (resourceValues) => resourceValues
3577
+ .chain((values) => values.chainMap((value) => value.toIdentifier()))
3578
+ .map((values) => values.length > 0
3579
+ ? values.map((value) => Maybe.of(value))
3580
+ : Resource.Values.fromValue({
3581
+ focusResource: $resource,
3582
+ propertyPath: PropertyShape.schema.properties.node.path,
3583
+ value: Maybe.empty(),
3584
+ })),
3585
+ }),
3586
+ nodeKind: $shaclPropertyFromRdf({
3587
+ graph: _$options.graph,
3588
+ resource: $resource,
3589
+ propertySchema: NodeShape.schema.properties.nodeKind,
3590
+ typeFromRdf: (resourceValues) => resourceValues
3591
+ .chain((values) => values.chainMap((value) => value.toIri([
3592
+ dataFactory.namedNode("http://www.w3.org/ns/shacl#BlankNode"),
3593
+ dataFactory.namedNode("http://www.w3.org/ns/shacl#BlankNodeOrIRI"),
3594
+ dataFactory.namedNode("http://www.w3.org/ns/shacl#BlankNodeOrLiteral"),
3595
+ dataFactory.namedNode("http://www.w3.org/ns/shacl#IRI"),
3596
+ dataFactory.namedNode("http://www.w3.org/ns/shacl#IRIOrLiteral"),
3597
+ dataFactory.namedNode("http://www.w3.org/ns/shacl#Literal"),
3598
+ ])))
3599
+ .map((values) => values.length > 0
3600
+ ? values.map((value) => Maybe.of(value))
3601
+ : Resource.Values.fromValue({
3602
+ focusResource: $resource,
3603
+ propertyPath: PropertyShape.schema.properties.nodeKind.path,
3604
+ value: Maybe.empty(),
3605
+ })),
3606
+ }),
3607
+ not: $shaclPropertyFromRdf({
3608
+ graph: _$options.graph,
3609
+ resource: $resource,
3610
+ propertySchema: NodeShape.schema.properties.not,
3611
+ typeFromRdf: (resourceValues) => resourceValues
3612
+ .chain((values) => values.chainMap((value) => value.toIdentifier()))
3613
+ .map((values) => values.toArray())
3614
+ .map((valuesArray) => Resource.Values.fromValue({
3710
3615
  focusResource: $resource,
3711
- propertyPath: PropertyShape
3712
- .schema
3713
- .properties
3714
- .minExclusive
3715
- .path,
3716
- value: Maybe.empty(),
3616
+ propertyPath: PropertyShape.schema.properties.not.path,
3617
+ value: valuesArray,
3717
3618
  })),
3718
- }).chain((minExclusive) => $shaclPropertyFromRdf({
3719
- graph: _$options.graph,
3720
- resource: $resource,
3721
- propertySchema: NodeShape.schema.properties
3722
- .minInclusive,
3723
- typeFromRdf: (resourceValues) => resourceValues
3724
- .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
3725
- .chain((values) => values.chainMap((value) => value.toLiteral()))
3726
- .map((values) => values.length > 0
3727
- ? values.map((value) => Maybe.of(value))
3728
- : Resource.Values.fromValue({
3619
+ }),
3620
+ or: $shaclPropertyFromRdf({
3621
+ graph: _$options.graph,
3622
+ resource: $resource,
3623
+ propertySchema: NodeShape.schema.properties.or,
3624
+ typeFromRdf: (resourceValues) => resourceValues
3625
+ .chain((values) => values.chainMap((value) => value.toList({ graph: _$options.graph })))
3626
+ .chain((valueLists) => valueLists.chainMap((valueList) => Right(Resource.Values.fromArray({
3729
3627
  focusResource: $resource,
3730
- propertyPath: PropertyShape
3731
- .schema
3732
- .properties
3733
- .minInclusive
3734
- .path,
3735
- value: Maybe.empty(),
3736
- })),
3737
- }).chain((minInclusive) => $shaclPropertyFromRdf({
3738
- graph: _$options.graph,
3739
- resource: $resource,
3740
- propertySchema: NodeShape.schema.properties
3741
- .minLength,
3742
- typeFromRdf: (resourceValues) => resourceValues
3743
- .chain((values) => values.chainMap((value) => value.toBigInt()))
3744
- .map((values) => values.length > 0
3745
- ? values.map((value) => Maybe.of(value))
3746
- : Resource.Values.fromValue({
3628
+ propertyPath: PropertyShape.schema.properties.or.path,
3629
+ values: valueList.toArray(),
3630
+ })).chain((values) => values.chainMap((value) => value.toIdentifier()))))
3631
+ .map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
3632
+ .map((values) => values.length > 0
3633
+ ? values.map((value) => Maybe.of(value))
3634
+ : Resource.Values.fromValue({
3635
+ focusResource: $resource,
3636
+ propertyPath: PropertyShape.schema.properties.or.path,
3637
+ value: Maybe.empty(),
3638
+ })),
3639
+ }),
3640
+ patterns: $shaclPropertyFromRdf({
3641
+ graph: _$options.graph,
3642
+ resource: $resource,
3643
+ propertySchema: NodeShape.schema.properties.patterns,
3644
+ typeFromRdf: (resourceValues) => resourceValues
3645
+ .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
3646
+ .chain((values) => values.chainMap((value) => value.toString()))
3647
+ .map((values) => values.toArray())
3648
+ .map((valuesArray) => Resource.Values.fromValue({
3747
3649
  focusResource: $resource,
3748
- propertyPath: PropertyShape
3749
- .schema
3750
- .properties
3751
- .minLength
3752
- .path,
3753
- value: Maybe.empty(),
3650
+ propertyPath: PropertyShape.schema.properties.patterns.path,
3651
+ value: valuesArray,
3754
3652
  })),
3755
- }).chain((minLength) => $shaclPropertyFromRdf({
3756
- graph: _$options.graph,
3757
- resource: $resource,
3758
- propertySchema: NodeShape.schema.properties
3759
- .node,
3760
- typeFromRdf: (resourceValues) => resourceValues
3761
- .chain((values) => values.chainMap((value) => value.toIdentifier()))
3762
- .map((values) => values.length > 0
3763
- ? values.map((value) => Maybe.of(value))
3764
- : Resource.Values.fromValue({
3653
+ }),
3654
+ properties: $shaclPropertyFromRdf({
3655
+ graph: _$options.graph,
3656
+ resource: $resource,
3657
+ propertySchema: NodeShape.schema.properties.properties,
3658
+ typeFromRdf: (resourceValues) => resourceValues
3659
+ .chain((values) => values.chainMap((value) => value.toIdentifier()))
3660
+ .map((values) => values.toArray())
3661
+ .map((valuesArray) => Resource.Values.fromValue({
3765
3662
  focusResource: $resource,
3766
- propertyPath: PropertyShape
3767
- .schema
3768
- .properties
3769
- .node
3770
- .path,
3771
- value: Maybe.empty(),
3663
+ propertyPath: NodeShape.schema.properties.properties.path,
3664
+ value: valuesArray,
3772
3665
  })),
3773
- }).chain((node) => $shaclPropertyFromRdf({
3774
- graph: _$options.graph,
3775
- resource: $resource,
3776
- propertySchema: NodeShape.schema.properties
3777
- .nodeKind,
3778
- typeFromRdf: (resourceValues) => resourceValues
3779
- .chain((values) => values.chainMap((value) => value.toIri([
3780
- dataFactory.namedNode("http://www.w3.org/ns/shacl#BlankNode"),
3781
- dataFactory.namedNode("http://www.w3.org/ns/shacl#BlankNodeOrIRI"),
3782
- dataFactory.namedNode("http://www.w3.org/ns/shacl#BlankNodeOrLiteral"),
3783
- dataFactory.namedNode("http://www.w3.org/ns/shacl#IRI"),
3784
- dataFactory.namedNode("http://www.w3.org/ns/shacl#IRIOrLiteral"),
3785
- dataFactory.namedNode("http://www.w3.org/ns/shacl#Literal"),
3786
- ])))
3787
- .map((values) => values.length >
3788
- 0
3789
- ? values.map((value) => Maybe.of(value))
3790
- : Resource.Values.fromValue({
3666
+ }),
3667
+ subClassOf: $shaclPropertyFromRdf({
3668
+ graph: _$options.graph,
3669
+ resource: $resource,
3670
+ propertySchema: NodeShape.schema.properties.subClassOf,
3671
+ typeFromRdf: (resourceValues) => resourceValues
3672
+ .chain((values) => values.chainMap((value) => value.toIri()))
3673
+ .map((values) => values.toArray())
3674
+ .map((valuesArray) => Resource.Values.fromValue({
3791
3675
  focusResource: $resource,
3792
- propertyPath: PropertyShape
3793
- .schema
3794
- .properties
3795
- .nodeKind
3796
- .path,
3797
- value: Maybe.empty(),
3676
+ propertyPath: NodeShape.schema.properties.subClassOf.path,
3677
+ value: valuesArray,
3798
3678
  })),
3799
- }).chain((nodeKind) => $shaclPropertyFromRdf({
3800
- graph: _$options.graph,
3801
- resource: $resource,
3802
- propertySchema: NodeShape.schema
3803
- .properties
3804
- .not,
3805
- typeFromRdf: (resourceValues) => resourceValues
3806
- .chain((values) => values.chainMap((value) => value.toIdentifier()))
3807
- .map((values) => values.toArray())
3808
- .map((valuesArray) => Resource.Values.fromValue({
3809
- focusResource: $resource,
3810
- propertyPath: PropertyShape
3811
- .schema
3812
- .properties
3813
- .not
3814
- .path,
3815
- value: valuesArray,
3816
- })),
3817
- }).chain((not) => $shaclPropertyFromRdf({
3818
- graph: _$options.graph,
3819
- resource: $resource,
3820
- propertySchema: NodeShape.schema
3821
- .properties
3822
- .or,
3823
- typeFromRdf: (resourceValues) => resourceValues
3824
- .chain((values) => values.chainMap((value) => value.toList({
3679
+ }),
3680
+ types: $shaclPropertyFromRdf({
3825
3681
  graph: _$options.graph,
3826
- })))
3827
- .chain((valueLists) => valueLists.chainMap((valueList) => Right(Resource.Values.fromArray({
3828
- focusResource: $resource,
3829
- propertyPath: PropertyShape
3830
- .schema
3831
- .properties
3832
- .or
3833
- .path,
3834
- values: valueList.toArray(),
3835
- })).chain((values) => values.chainMap((value) => value.toIdentifier()))))
3836
- .map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
3837
- .map((values) => values.length >
3838
- 0
3839
- ? values.map((value) => Maybe.of(value))
3840
- : Resource.Values.fromValue({
3682
+ resource: $resource,
3683
+ propertySchema: NodeShape.schema.properties.types,
3684
+ typeFromRdf: (resourceValues) => resourceValues
3685
+ .chain((values) => values.chainMap((value) => value.toIri()))
3686
+ .map((values) => values.toArray())
3687
+ .map((valuesArray) => Resource.Values.fromValue({
3841
3688
  focusResource: $resource,
3842
- propertyPath: PropertyShape
3843
- .schema
3844
- .properties
3845
- .or
3846
- .path,
3847
- value: Maybe.empty(),
3689
+ propertyPath: NodeShape.schema.properties.types.path,
3690
+ value: valuesArray,
3848
3691
  })),
3849
- }).chain((or) => $shaclPropertyFromRdf({
3850
- graph: _$options.graph,
3851
- resource: $resource,
3852
- propertySchema: NodeShape.schema
3853
- .properties
3854
- .patterns,
3855
- typeFromRdf: (resourceValues) => resourceValues
3856
- .chain((values) => $fromRdfPreferredLanguages(values, _$options.preferredLanguages))
3857
- .chain((values) => values.chainMap((value) => value.toString()))
3858
- .map((values) => values.toArray())
3859
- .map((valuesArray) => Resource.Values.fromValue({
3860
- focusResource: $resource,
3861
- propertyPath: PropertyShape
3862
- .schema
3863
- .properties
3864
- .patterns
3865
- .path,
3866
- value: valuesArray,
3867
- })),
3868
- }).chain((patterns) => $shaclPropertyFromRdf({
3869
- graph: _$options.graph,
3870
- resource: $resource,
3871
- propertySchema: NodeShape.schema
3872
- .properties
3873
- .properties,
3874
- typeFromRdf: (resourceValues) => resourceValues
3875
- .chain((values) => values.chainMap((value) => value.toIdentifier()))
3876
- .map((values) => values.toArray())
3877
- .map((valuesArray) => Resource.Values.fromValue({
3878
- focusResource: $resource,
3879
- propertyPath: NodeShape
3880
- .schema
3881
- .properties
3882
- .properties
3883
- .path,
3884
- value: valuesArray,
3885
- })),
3886
- }).chain((properties) => $shaclPropertyFromRdf({
3887
- graph: _$options.graph,
3888
- resource: $resource,
3889
- propertySchema: NodeShape.schema
3890
- .properties
3891
- .subClassOf,
3892
- typeFromRdf: (resourceValues) => resourceValues
3893
- .chain((values) => values.chainMap((value) => value.toIri()))
3894
- .map((values) => values.toArray())
3895
- .map((valuesArray) => Resource.Values.fromValue({
3896
- focusResource: $resource,
3897
- propertyPath: NodeShape
3898
- .schema
3899
- .properties
3900
- .subClassOf
3901
- .path,
3902
- value: valuesArray,
3903
- })),
3904
- }).chain((subClassOf) => $shaclPropertyFromRdf({
3905
- graph: _$options.graph,
3906
- resource: $resource,
3907
- propertySchema: NodeShape.schema
3908
- .properties
3909
- .types,
3910
- typeFromRdf: (resourceValues) => resourceValues
3911
- .chain((values) => values.chainMap((value) => value.toIri()))
3912
- .map((values) => values.toArray())
3913
- .map((valuesArray) => Resource.Values.fromValue({
3914
- focusResource: $resource,
3915
- propertyPath: NodeShape
3916
- .schema
3917
- .properties
3918
- .types
3919
- .path,
3920
- value: valuesArray,
3921
- })),
3922
- }).chain((types) => $shaclPropertyFromRdf({
3923
- graph: _$options.graph,
3924
- resource: $resource,
3925
- propertySchema: NodeShape.schema
3926
- .properties
3927
- .xone,
3928
- typeFromRdf: (resourceValues) => resourceValues
3929
- .chain((values) => values.chainMap((value) => value.toList({
3692
+ }),
3693
+ xone: $shaclPropertyFromRdf({
3930
3694
  graph: _$options.graph,
3931
- })))
3932
- .chain((valueLists) => valueLists.chainMap((valueList) => Right(Resource.Values.fromArray({
3933
- focusResource: $resource,
3934
- propertyPath: PropertyShape
3935
- .schema
3936
- .properties
3937
- .xone
3938
- .path,
3939
- values: valueList.toArray(),
3940
- })).chain((values) => values.chainMap((value) => value.toIdentifier()))))
3941
- .map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
3942
- .map((values) => values.length >
3943
- 0
3944
- ? values.map((value) => Maybe.of(value))
3945
- : Resource.Values.fromValue({
3695
+ resource: $resource,
3696
+ propertySchema: NodeShape.schema.properties.xone,
3697
+ typeFromRdf: (resourceValues) => resourceValues
3698
+ .chain((values) => values.chainMap((value) => value.toList({ graph: _$options.graph })))
3699
+ .chain((valueLists) => valueLists.chainMap((valueList) => Right(Resource.Values.fromArray({
3946
3700
  focusResource: $resource,
3947
- propertyPath: PropertyShape
3948
- .schema
3949
- .properties
3950
- .xone
3951
- .path,
3952
- value: Maybe.empty(),
3953
- })),
3954
- }).map((xone) => ({
3955
- $identifier,
3956
- $type,
3957
- and,
3958
- classes,
3959
- closed,
3960
- comment,
3961
- datatype,
3962
- deactivated,
3963
- flags,
3964
- hasValues,
3965
- ignoredProperties,
3966
- in_,
3967
- isDefinedBy,
3968
- label,
3969
- languageIn,
3970
- maxCount,
3971
- maxExclusive,
3972
- maxInclusive,
3973
- maxLength,
3974
- minCount,
3975
- minExclusive,
3976
- minInclusive,
3977
- minLength,
3978
- node,
3979
- nodeKind,
3980
- not,
3981
- or,
3982
- patterns,
3983
- properties,
3984
- subClassOf,
3985
- types,
3986
- xone,
3987
- }))))))))))))))))))))))))))))))))));
3701
+ propertyPath: PropertyShape.schema.properties.xone.path,
3702
+ values: valueList.toArray(),
3703
+ })).chain((values) => values.chainMap((value) => value.toIdentifier()))))
3704
+ .map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
3705
+ .map((values) => values.length > 0
3706
+ ? values.map((value) => Maybe.of(value))
3707
+ : Resource.Values.fromValue({
3708
+ focusResource: $resource,
3709
+ propertyPath: PropertyShape.schema.properties.xone.path,
3710
+ value: Maybe.empty(),
3711
+ })),
3712
+ }),
3713
+ }).map((properties) => create(properties)));
3988
3714
  };
3715
+ NodeShape.fromRdfResource = $wrap_FromRdfResourceFunction(NodeShape._fromRdfResource);
3716
+ NodeShape.fromRdfResourceValues = (values, options) => values.chain((values) => values.chainMap((value) => value
3717
+ .toResource()
3718
+ .chain((resource) => NodeShape.fromRdfResource(resource, options))));
3719
+ NodeShape.fromRdfType = dataFactory.namedNode("http://www.w3.org/ns/shacl#NodeShape");
3720
+ function isNodeShape(object) {
3721
+ switch (object.$type) {
3722
+ case "NodeShape":
3723
+ return true;
3724
+ default:
3725
+ return false;
3726
+ }
3727
+ }
3728
+ NodeShape.isNodeShape = isNodeShape;
3989
3729
  NodeShape.schema = {
3990
3730
  properties: {
3991
3731
  $identifier: {
@@ -4269,212 +4009,208 @@ export var NodeShape;
4269
4009
  },
4270
4010
  },
4271
4011
  };
4272
- function toRdfResource(_nodeShape, options) {
4273
- const resourceSet = options?.resourceSet ??
4274
- new ResourceSet({
4275
- dataFactory: dataFactory,
4276
- dataset: datasetFactory.dataset(),
4277
- });
4278
- const resource = resourceSet.resource(_nodeShape.$identifier());
4279
- if (!options?.ignoreRdfType) {
4280
- resource.add($RdfVocabularies.rdf.type, dataFactory.namedNode("http://www.w3.org/ns/shacl#NodeShape"), options?.graph);
4012
+ NodeShape._toRdfResource = (parameters) => {
4013
+ if (!parameters.ignoreRdfType) {
4014
+ parameters.resource.add($RdfVocabularies.rdf.type, dataFactory.namedNode("http://www.w3.org/ns/shacl#NodeShape"), parameters.graph);
4281
4015
  }
4282
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#and"), _nodeShape.and.toList().flatMap((value) => [
4016
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#and"), parameters.object.and.toList().flatMap((value) => [
4283
4017
  value.length > 0
4284
4018
  ? value.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
4285
4019
  if (itemIndex === 0) {
4286
4020
  currentSubListResource = listResource;
4287
4021
  }
4288
4022
  else {
4289
- const newSubListResource = resourceSet.resource((() => dataFactory.blankNode())());
4290
- currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier, options?.graph);
4023
+ const newSubListResource = parameters.resourceSet.resource((() => dataFactory.blankNode())());
4024
+ currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier, parameters.graph);
4291
4025
  currentSubListResource = newSubListResource;
4292
4026
  }
4293
- currentSubListResource.add($RdfVocabularies.rdf.first, [item], options?.graph);
4027
+ currentSubListResource.add($RdfVocabularies.rdf.first, [item], parameters.graph);
4294
4028
  if (itemIndex + 1 === list.length) {
4295
- currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil, options?.graph);
4029
+ currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil, parameters.graph);
4296
4030
  }
4297
4031
  return { currentSubListResource, listResource };
4298
4032
  }, {
4299
4033
  currentSubListResource: null,
4300
- listResource: resourceSet.resource((() => dataFactory.blankNode())()),
4034
+ listResource: parameters.resourceSet.resource((() => dataFactory.blankNode())()),
4301
4035
  }).listResource.identifier
4302
4036
  : $RdfVocabularies.rdf.nil,
4303
- ]), options?.graph);
4304
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#class"), _nodeShape.classes.flatMap((item) => [item]), options?.graph);
4305
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#closed"), _nodeShape.closed
4037
+ ]), parameters.graph);
4038
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#class"), parameters.object.classes.flatMap((item) => [item]), parameters.graph);
4039
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#closed"), parameters.object.closed
4306
4040
  .toList()
4307
4041
  .flatMap((value) => [
4308
4042
  $literalFactory.boolean(value, $RdfVocabularies.xsd.boolean),
4309
- ]), options?.graph);
4310
- resource.add(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#comment"), _nodeShape.comment
4043
+ ]), parameters.graph);
4044
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#comment"), parameters.object.comment
4311
4045
  .toList()
4312
- .flatMap((value) => [$literalFactory.string(value)]), options?.graph);
4313
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#datatype"), _nodeShape.datatype.toList(), options?.graph);
4314
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#deactivated"), _nodeShape.deactivated
4046
+ .flatMap((value) => [$literalFactory.string(value)]), parameters.graph);
4047
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#datatype"), parameters.object.datatype.toList(), parameters.graph);
4048
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#deactivated"), parameters.object.deactivated
4315
4049
  .toList()
4316
4050
  .flatMap((value) => [
4317
4051
  $literalFactory.boolean(value, $RdfVocabularies.xsd.boolean),
4318
- ]), options?.graph);
4319
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#flags"), _nodeShape.flags.flatMap((item) => [$literalFactory.string(item)]), options?.graph);
4320
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#hasValue"), _nodeShape.hasValues.flatMap((item) => [item]), options?.graph);
4321
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#ignoredProperties"), _nodeShape.ignoredProperties.toList().flatMap((value) => [
4052
+ ]), parameters.graph);
4053
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#flags"), parameters.object.flags.flatMap((item) => [$literalFactory.string(item)]), parameters.graph);
4054
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#hasValue"), parameters.object.hasValues.flatMap((item) => [item]), parameters.graph);
4055
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#ignoredProperties"), parameters.object.ignoredProperties.toList().flatMap((value) => [
4322
4056
  value.length > 0
4323
4057
  ? value.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
4324
4058
  if (itemIndex === 0) {
4325
4059
  currentSubListResource = listResource;
4326
4060
  }
4327
4061
  else {
4328
- const newSubListResource = resourceSet.resource((() => dataFactory.blankNode())());
4329
- currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier, options?.graph);
4062
+ const newSubListResource = parameters.resourceSet.resource((() => dataFactory.blankNode())());
4063
+ currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier, parameters.graph);
4330
4064
  currentSubListResource = newSubListResource;
4331
4065
  }
4332
- currentSubListResource.add($RdfVocabularies.rdf.first, [item], options?.graph);
4066
+ currentSubListResource.add($RdfVocabularies.rdf.first, [item], parameters.graph);
4333
4067
  if (itemIndex + 1 === list.length) {
4334
- currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil, options?.graph);
4068
+ currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil, parameters.graph);
4335
4069
  }
4336
4070
  return { currentSubListResource, listResource };
4337
4071
  }, {
4338
4072
  currentSubListResource: null,
4339
- listResource: resourceSet.resource((() => dataFactory.blankNode())()),
4073
+ listResource: parameters.resourceSet.resource((() => dataFactory.blankNode())()),
4340
4074
  }).listResource.identifier
4341
4075
  : $RdfVocabularies.rdf.nil,
4342
- ]), options?.graph);
4343
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#in"), _nodeShape.in_.toList().flatMap((value) => [
4076
+ ]), parameters.graph);
4077
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#in"), parameters.object.in_.toList().flatMap((value) => [
4344
4078
  value.length > 0
4345
4079
  ? value.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
4346
4080
  if (itemIndex === 0) {
4347
4081
  currentSubListResource = listResource;
4348
4082
  }
4349
4083
  else {
4350
- const newSubListResource = resourceSet.resource((() => dataFactory.blankNode())());
4351
- currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier, options?.graph);
4084
+ const newSubListResource = parameters.resourceSet.resource((() => dataFactory.blankNode())());
4085
+ currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier, parameters.graph);
4352
4086
  currentSubListResource = newSubListResource;
4353
4087
  }
4354
- currentSubListResource.add($RdfVocabularies.rdf.first, [item], options?.graph);
4088
+ currentSubListResource.add($RdfVocabularies.rdf.first, [item], parameters.graph);
4355
4089
  if (itemIndex + 1 === list.length) {
4356
- currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil, options?.graph);
4090
+ currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil, parameters.graph);
4357
4091
  }
4358
4092
  return { currentSubListResource, listResource };
4359
4093
  }, {
4360
4094
  currentSubListResource: null,
4361
- listResource: resourceSet.resource((() => dataFactory.blankNode())()),
4095
+ listResource: parameters.resourceSet.resource((() => dataFactory.blankNode())()),
4362
4096
  }).listResource.identifier
4363
4097
  : $RdfVocabularies.rdf.nil,
4364
- ]), options?.graph);
4365
- resource.add(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#isDefinedBy"), _nodeShape.isDefinedBy.toList(), options?.graph);
4366
- resource.add(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#label"), _nodeShape.label
4098
+ ]), parameters.graph);
4099
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#isDefinedBy"), parameters.object.isDefinedBy.toList(), parameters.graph);
4100
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#label"), parameters.object.label
4367
4101
  .toList()
4368
- .flatMap((value) => [$literalFactory.string(value)]), options?.graph);
4369
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#languageIn"), _nodeShape.languageIn.toList().flatMap((value) => [
4102
+ .flatMap((value) => [$literalFactory.string(value)]), parameters.graph);
4103
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#languageIn"), parameters.object.languageIn.toList().flatMap((value) => [
4370
4104
  value.length > 0
4371
4105
  ? value.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
4372
4106
  if (itemIndex === 0) {
4373
4107
  currentSubListResource = listResource;
4374
4108
  }
4375
4109
  else {
4376
- const newSubListResource = resourceSet.resource((() => dataFactory.blankNode())());
4377
- currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier, options?.graph);
4110
+ const newSubListResource = parameters.resourceSet.resource((() => dataFactory.blankNode())());
4111
+ currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier, parameters.graph);
4378
4112
  currentSubListResource = newSubListResource;
4379
4113
  }
4380
- currentSubListResource.add($RdfVocabularies.rdf.first, [$literalFactory.string(item)], options?.graph);
4114
+ currentSubListResource.add($RdfVocabularies.rdf.first, [$literalFactory.string(item)], parameters.graph);
4381
4115
  if (itemIndex + 1 === list.length) {
4382
- currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil, options?.graph);
4116
+ currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil, parameters.graph);
4383
4117
  }
4384
4118
  return { currentSubListResource, listResource };
4385
4119
  }, {
4386
4120
  currentSubListResource: null,
4387
- listResource: resourceSet.resource((() => dataFactory.blankNode())()),
4121
+ listResource: parameters.resourceSet.resource((() => dataFactory.blankNode())()),
4388
4122
  }).listResource.identifier
4389
4123
  : $RdfVocabularies.rdf.nil,
4390
- ]), options?.graph);
4391
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#maxCount"), _nodeShape.maxCount
4124
+ ]), parameters.graph);
4125
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#maxCount"), parameters.object.maxCount
4392
4126
  .toList()
4393
4127
  .flatMap((value) => [
4394
4128
  $literalFactory.bigint(value, $RdfVocabularies.xsd.integer),
4395
- ]), options?.graph);
4396
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#maxExclusive"), _nodeShape.maxExclusive.toList(), options?.graph);
4397
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#maxInclusive"), _nodeShape.maxInclusive.toList(), options?.graph);
4398
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#maxLength"), _nodeShape.maxLength
4129
+ ]), parameters.graph);
4130
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#maxExclusive"), parameters.object.maxExclusive.toList(), parameters.graph);
4131
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#maxInclusive"), parameters.object.maxInclusive.toList(), parameters.graph);
4132
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#maxLength"), parameters.object.maxLength
4399
4133
  .toList()
4400
4134
  .flatMap((value) => [
4401
4135
  $literalFactory.bigint(value, $RdfVocabularies.xsd.integer),
4402
- ]), options?.graph);
4403
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#minCount"), _nodeShape.minCount
4136
+ ]), parameters.graph);
4137
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#minCount"), parameters.object.minCount
4404
4138
  .toList()
4405
4139
  .flatMap((value) => [
4406
4140
  $literalFactory.bigint(value, $RdfVocabularies.xsd.integer),
4407
- ]), options?.graph);
4408
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#minExclusive"), _nodeShape.minExclusive.toList(), options?.graph);
4409
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#minInclusive"), _nodeShape.minInclusive.toList(), options?.graph);
4410
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#minLength"), _nodeShape.minLength
4141
+ ]), parameters.graph);
4142
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#minExclusive"), parameters.object.minExclusive.toList(), parameters.graph);
4143
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#minInclusive"), parameters.object.minInclusive.toList(), parameters.graph);
4144
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#minLength"), parameters.object.minLength
4411
4145
  .toList()
4412
4146
  .flatMap((value) => [
4413
4147
  $literalFactory.bigint(value, $RdfVocabularies.xsd.integer),
4414
- ]), options?.graph);
4415
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#node"), _nodeShape.node.toList(), options?.graph);
4416
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#nodeKind"), _nodeShape.nodeKind.toList(), options?.graph);
4417
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#not"), _nodeShape.not.flatMap((item) => [item]), options?.graph);
4418
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#or"), _nodeShape.or.toList().flatMap((value) => [
4148
+ ]), parameters.graph);
4149
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#node"), parameters.object.node.toList(), parameters.graph);
4150
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#nodeKind"), parameters.object.nodeKind.toList(), parameters.graph);
4151
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#not"), parameters.object.not.flatMap((item) => [item]), parameters.graph);
4152
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#or"), parameters.object.or.toList().flatMap((value) => [
4419
4153
  value.length > 0
4420
4154
  ? value.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
4421
4155
  if (itemIndex === 0) {
4422
4156
  currentSubListResource = listResource;
4423
4157
  }
4424
4158
  else {
4425
- const newSubListResource = resourceSet.resource((() => dataFactory.blankNode())());
4426
- currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier, options?.graph);
4159
+ const newSubListResource = parameters.resourceSet.resource((() => dataFactory.blankNode())());
4160
+ currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier, parameters.graph);
4427
4161
  currentSubListResource = newSubListResource;
4428
4162
  }
4429
- currentSubListResource.add($RdfVocabularies.rdf.first, [item], options?.graph);
4163
+ currentSubListResource.add($RdfVocabularies.rdf.first, [item], parameters.graph);
4430
4164
  if (itemIndex + 1 === list.length) {
4431
- currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil, options?.graph);
4165
+ currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil, parameters.graph);
4432
4166
  }
4433
4167
  return { currentSubListResource, listResource };
4434
4168
  }, {
4435
4169
  currentSubListResource: null,
4436
- listResource: resourceSet.resource((() => dataFactory.blankNode())()),
4170
+ listResource: parameters.resourceSet.resource((() => dataFactory.blankNode())()),
4437
4171
  }).listResource.identifier
4438
4172
  : $RdfVocabularies.rdf.nil,
4439
- ]), options?.graph);
4440
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#pattern"), _nodeShape.patterns.flatMap((item) => [$literalFactory.string(item)]), options?.graph);
4441
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#property"), _nodeShape.properties.flatMap((item) => [item]), options?.graph);
4442
- resource.add($RdfVocabularies.rdfs.subClassOf, _nodeShape.subClassOf.flatMap((item) => [item]), options?.graph);
4443
- resource.add($RdfVocabularies.rdf.type, _nodeShape.types.flatMap((item) => [item]), options?.graph);
4444
- resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#xone"), _nodeShape.xone.toList().flatMap((value) => [
4173
+ ]), parameters.graph);
4174
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#pattern"), parameters.object.patterns.flatMap((item) => [
4175
+ $literalFactory.string(item),
4176
+ ]), parameters.graph);
4177
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#property"), parameters.object.properties.flatMap((item) => [item]), parameters.graph);
4178
+ parameters.resource.add($RdfVocabularies.rdfs.subClassOf, parameters.object.subClassOf.flatMap((item) => [item]), parameters.graph);
4179
+ parameters.resource.add($RdfVocabularies.rdf.type, parameters.object.types.flatMap((item) => [item]), parameters.graph);
4180
+ parameters.resource.add(dataFactory.namedNode("http://www.w3.org/ns/shacl#xone"), parameters.object.xone.toList().flatMap((value) => [
4445
4181
  value.length > 0
4446
4182
  ? value.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
4447
4183
  if (itemIndex === 0) {
4448
4184
  currentSubListResource = listResource;
4449
4185
  }
4450
4186
  else {
4451
- const newSubListResource = resourceSet.resource((() => dataFactory.blankNode())());
4452
- currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier, options?.graph);
4187
+ const newSubListResource = parameters.resourceSet.resource((() => dataFactory.blankNode())());
4188
+ currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier, parameters.graph);
4453
4189
  currentSubListResource = newSubListResource;
4454
4190
  }
4455
- currentSubListResource.add($RdfVocabularies.rdf.first, [item], options?.graph);
4191
+ currentSubListResource.add($RdfVocabularies.rdf.first, [item], parameters.graph);
4456
4192
  if (itemIndex + 1 === list.length) {
4457
- currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil, options?.graph);
4193
+ currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil, parameters.graph);
4458
4194
  }
4459
4195
  return { currentSubListResource, listResource };
4460
4196
  }, {
4461
4197
  currentSubListResource: null,
4462
- listResource: resourceSet.resource((() => dataFactory.blankNode())()),
4198
+ listResource: parameters.resourceSet.resource((() => dataFactory.blankNode())()),
4463
4199
  }).listResource.identifier
4464
4200
  : $RdfVocabularies.rdf.nil,
4465
- ]), options?.graph);
4466
- return resource;
4467
- }
4468
- NodeShape.toRdfResource = toRdfResource;
4469
- function propertiesToStrings(_nodeShape) {
4201
+ ]), parameters.graph);
4202
+ return parameters.resource;
4203
+ };
4204
+ NodeShape.toRdfResource = $wrap_ToRdfResourceFunction(NodeShape._toRdfResource);
4205
+ function _propertiesToStrings(_nodeShape) {
4470
4206
  return $compactRecord({
4471
4207
  $identifier: _nodeShape.$identifier().toString(),
4472
4208
  label: _nodeShape.label.map((item) => item.toString()).extract(),
4473
4209
  });
4474
4210
  }
4475
- NodeShape.propertiesToStrings = propertiesToStrings;
4211
+ NodeShape._propertiesToStrings = _propertiesToStrings;
4476
4212
  function $toString(_nodeShape) {
4477
- return `NodeShape(${JSON.stringify(propertiesToStrings((_nodeShape ?? this)))})`;
4213
+ return `NodeShape(${JSON.stringify(_propertiesToStrings((_nodeShape ?? this)))})`;
4478
4214
  }
4479
4215
  NodeShape.$toString = $toString;
4480
4216
  })(NodeShape || (NodeShape = {}));
@@ -4783,12 +4519,12 @@ export var Shape;
4783
4519
  },
4784
4520
  },
4785
4521
  };
4786
- Shape.toRdfResource = (value, options) => {
4787
- if (NodeShape.isNodeShape(value)) {
4788
- return NodeShape.toRdfResource(value, options);
4522
+ Shape.toRdfResource = (object, options) => {
4523
+ if (NodeShape.isNodeShape(object)) {
4524
+ return NodeShape.toRdfResource(object, options);
4789
4525
  }
4790
- if (PropertyShape.isPropertyShape(value)) {
4791
- return PropertyShape.toRdfResource(value, options);
4526
+ if (PropertyShape.isPropertyShape(object)) {
4527
+ return PropertyShape.toRdfResource(object, options);
4792
4528
  }
4793
4529
  throw new Error("unrecognized type");
4794
4530
  };
@@ -4953,18 +4689,18 @@ export var $Object;
4953
4689
  },
4954
4690
  },
4955
4691
  };
4956
- $Object.toRdfResource = (value, options) => {
4957
- if (NodeShape.isNodeShape(value)) {
4958
- return NodeShape.toRdfResource(value, options);
4692
+ $Object.toRdfResource = (object, options) => {
4693
+ if (NodeShape.isNodeShape(object)) {
4694
+ return NodeShape.toRdfResource(object, options);
4959
4695
  }
4960
- if (Ontology.isOntology(value)) {
4961
- return Ontology.toRdfResource(value, options);
4696
+ if (Ontology.isOntology(object)) {
4697
+ return Ontology.toRdfResource(object, options);
4962
4698
  }
4963
- if (PropertyGroup.isPropertyGroup(value)) {
4964
- return PropertyGroup.toRdfResource(value, options);
4699
+ if (PropertyGroup.isPropertyGroup(object)) {
4700
+ return PropertyGroup.toRdfResource(object, options);
4965
4701
  }
4966
- if (PropertyShape.isPropertyShape(value)) {
4967
- return PropertyShape.toRdfResource(value, options);
4702
+ if (PropertyShape.isPropertyShape(object)) {
4703
+ return PropertyShape.toRdfResource(object, options);
4968
4704
  }
4969
4705
  throw new Error("unrecognized type");
4970
4706
  };