@shaclmate/shacl-ast 2.0.13 → 2.0.15

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/generated.js ADDED
@@ -0,0 +1,863 @@
1
+ import { PropertyPath } from "@shaclmate/shacl-ast/PropertyPath.js";
2
+ import { DataFactory as dataFactory } from "n3";
3
+ import * as purify from "purify-ts";
4
+ import * as rdfjsResource from "rdfjs-resource";
5
+ export var BaseShaclCoreShape;
6
+ (function (BaseShaclCoreShape) {
7
+ function fromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource,
8
+ // @ts-ignore
9
+ ..._context }) {
10
+ const _andEither = purify.Either.of([
11
+ ..._resource
12
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#and"), {
13
+ unique: true,
14
+ })
15
+ .flatMap((_item) => _item
16
+ .toValues()
17
+ .head()
18
+ .chain((value) => value.toList())
19
+ .map((values) => values.flatMap((_value) => _value
20
+ .toValues()
21
+ .head()
22
+ .chain((_value) => _value.toIdentifier())
23
+ .toMaybe()
24
+ .toList()))
25
+ .toMaybe()
26
+ .toList()),
27
+ ]);
28
+ if (_andEither.isLeft()) {
29
+ return _andEither;
30
+ }
31
+ const and = _andEither.unsafeCoerce();
32
+ const _classesEither = purify.Either.of([
33
+ ..._resource
34
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#class"), {
35
+ unique: true,
36
+ })
37
+ .flatMap((_item) => _item
38
+ .toValues()
39
+ .head()
40
+ .chain((_value) => _value.toIri())
41
+ .toMaybe()
42
+ .toList()),
43
+ ]);
44
+ if (_classesEither.isLeft()) {
45
+ return _classesEither;
46
+ }
47
+ const classes = _classesEither.unsafeCoerce();
48
+ const _commentsEither = purify.Either.of([
49
+ ..._resource
50
+ .values(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#comment"), { unique: true })
51
+ .flatMap((_item) => _item
52
+ .toValues()
53
+ .filter((_value) => {
54
+ const _languageInOrDefault = _languageIn ?? [];
55
+ if (_languageInOrDefault.length === 0) {
56
+ return true;
57
+ }
58
+ const _valueLiteral = _value.toLiteral().toMaybe().extract();
59
+ if (typeof _valueLiteral === "undefined") {
60
+ return false;
61
+ }
62
+ return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
63
+ })
64
+ .head()
65
+ .chain((_value) => _value.toLiteral())
66
+ .toMaybe()
67
+ .toList()),
68
+ ]);
69
+ if (_commentsEither.isLeft()) {
70
+ return _commentsEither;
71
+ }
72
+ const comments = _commentsEither.unsafeCoerce();
73
+ const _datatypeEither = purify.Either.of(_resource
74
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#datatype"), {
75
+ unique: true,
76
+ })
77
+ .head()
78
+ .chain((_value) => _value.toIri())
79
+ .toMaybe());
80
+ if (_datatypeEither.isLeft()) {
81
+ return _datatypeEither;
82
+ }
83
+ const datatype = _datatypeEither.unsafeCoerce();
84
+ const _deactivatedEither = purify.Either.of(_resource
85
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#deactivated"), { unique: true })
86
+ .head()
87
+ .chain((_value) => _value.toBoolean())
88
+ .toMaybe());
89
+ if (_deactivatedEither.isLeft()) {
90
+ return _deactivatedEither;
91
+ }
92
+ const deactivated = _deactivatedEither.unsafeCoerce();
93
+ const _flagsEither = purify.Either.of([
94
+ ..._resource
95
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#flags"), {
96
+ unique: true,
97
+ })
98
+ .flatMap((_item) => _item
99
+ .toValues()
100
+ .head()
101
+ .chain((_value) => _value.toString())
102
+ .toMaybe()
103
+ .toList()),
104
+ ]);
105
+ if (_flagsEither.isLeft()) {
106
+ return _flagsEither;
107
+ }
108
+ const flags = _flagsEither.unsafeCoerce();
109
+ const _hasValuesEither = purify.Either.of([
110
+ ..._resource
111
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#hasValue"), {
112
+ unique: true,
113
+ })
114
+ .flatMap((_item) => _item
115
+ .toValues()
116
+ .head()
117
+ .chain((_value) => purify.Either.of(_value.toTerm()))
118
+ .toMaybe()
119
+ .toList()),
120
+ ]);
121
+ if (_hasValuesEither.isLeft()) {
122
+ return _hasValuesEither;
123
+ }
124
+ const hasValues = _hasValuesEither.unsafeCoerce();
125
+ const identifier = _resource.identifier;
126
+ const _in_Either = purify.Either.of(_resource
127
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#in"), {
128
+ unique: true,
129
+ })
130
+ .head()
131
+ .chain((value) => value.toList())
132
+ .map((values) => values.flatMap((_value) => _value
133
+ .toValues()
134
+ .head()
135
+ .chain((_value) => purify.Either.of(_value.toTerm()))
136
+ .toMaybe()
137
+ .toList()))
138
+ .toMaybe());
139
+ if (_in_Either.isLeft()) {
140
+ return _in_Either;
141
+ }
142
+ const in_ = _in_Either.unsafeCoerce();
143
+ const _isDefinedByEither = purify.Either.of(_resource
144
+ .values(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#isDefinedBy"), { unique: true })
145
+ .head()
146
+ .chain((_value) => _value.toIdentifier())
147
+ .toMaybe());
148
+ if (_isDefinedByEither.isLeft()) {
149
+ return _isDefinedByEither;
150
+ }
151
+ const isDefinedBy = _isDefinedByEither.unsafeCoerce();
152
+ const _labelsEither = purify.Either.of([
153
+ ..._resource
154
+ .values(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#label"), { unique: true })
155
+ .flatMap((_item) => _item
156
+ .toValues()
157
+ .filter((_value) => {
158
+ const _languageInOrDefault = _languageIn ?? [];
159
+ if (_languageInOrDefault.length === 0) {
160
+ return true;
161
+ }
162
+ const _valueLiteral = _value.toLiteral().toMaybe().extract();
163
+ if (typeof _valueLiteral === "undefined") {
164
+ return false;
165
+ }
166
+ return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
167
+ })
168
+ .head()
169
+ .chain((_value) => _value.toLiteral())
170
+ .toMaybe()
171
+ .toList()),
172
+ ]);
173
+ if (_labelsEither.isLeft()) {
174
+ return _labelsEither;
175
+ }
176
+ const labels = _labelsEither.unsafeCoerce();
177
+ const _languageInEither = purify.Either.of(_resource
178
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#languageIn"), { unique: true })
179
+ .head()
180
+ .chain((value) => value.toList())
181
+ .map((values) => values.flatMap((_value) => _value
182
+ .toValues()
183
+ .head()
184
+ .chain((_value) => _value.toString())
185
+ .toMaybe()
186
+ .toList()))
187
+ .toMaybe());
188
+ if (_languageInEither.isLeft()) {
189
+ return _languageInEither;
190
+ }
191
+ const languageIn = _languageInEither.unsafeCoerce();
192
+ const _maxCountEither = purify.Either.of(_resource
193
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#maxCount"), {
194
+ unique: true,
195
+ })
196
+ .head()
197
+ .chain((_value) => _value.toNumber())
198
+ .toMaybe());
199
+ if (_maxCountEither.isLeft()) {
200
+ return _maxCountEither;
201
+ }
202
+ const maxCount = _maxCountEither.unsafeCoerce();
203
+ const _maxExclusiveEither = purify.Either.of(_resource
204
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#maxExclusive"), { unique: true })
205
+ .filter((_value) => {
206
+ const _languageInOrDefault = _languageIn ?? [];
207
+ if (_languageInOrDefault.length === 0) {
208
+ return true;
209
+ }
210
+ const _valueLiteral = _value.toLiteral().toMaybe().extract();
211
+ if (typeof _valueLiteral === "undefined") {
212
+ return false;
213
+ }
214
+ return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
215
+ })
216
+ .head()
217
+ .chain((_value) => _value.toLiteral())
218
+ .toMaybe());
219
+ if (_maxExclusiveEither.isLeft()) {
220
+ return _maxExclusiveEither;
221
+ }
222
+ const maxExclusive = _maxExclusiveEither.unsafeCoerce();
223
+ const _maxInclusiveEither = purify.Either.of(_resource
224
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#maxInclusive"), { unique: true })
225
+ .filter((_value) => {
226
+ const _languageInOrDefault = _languageIn ?? [];
227
+ if (_languageInOrDefault.length === 0) {
228
+ return true;
229
+ }
230
+ const _valueLiteral = _value.toLiteral().toMaybe().extract();
231
+ if (typeof _valueLiteral === "undefined") {
232
+ return false;
233
+ }
234
+ return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
235
+ })
236
+ .head()
237
+ .chain((_value) => _value.toLiteral())
238
+ .toMaybe());
239
+ if (_maxInclusiveEither.isLeft()) {
240
+ return _maxInclusiveEither;
241
+ }
242
+ const maxInclusive = _maxInclusiveEither.unsafeCoerce();
243
+ const _maxLengthEither = purify.Either.of(_resource
244
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#maxLength"), {
245
+ unique: true,
246
+ })
247
+ .head()
248
+ .chain((_value) => _value.toNumber())
249
+ .toMaybe());
250
+ if (_maxLengthEither.isLeft()) {
251
+ return _maxLengthEither;
252
+ }
253
+ const maxLength = _maxLengthEither.unsafeCoerce();
254
+ const _minCountEither = purify.Either.of(_resource
255
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#minCount"), {
256
+ unique: true,
257
+ })
258
+ .head()
259
+ .chain((_value) => _value.toNumber())
260
+ .toMaybe());
261
+ if (_minCountEither.isLeft()) {
262
+ return _minCountEither;
263
+ }
264
+ const minCount = _minCountEither.unsafeCoerce();
265
+ const _minExclusiveEither = purify.Either.of(_resource
266
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#minExclusive"), { unique: true })
267
+ .filter((_value) => {
268
+ const _languageInOrDefault = _languageIn ?? [];
269
+ if (_languageInOrDefault.length === 0) {
270
+ return true;
271
+ }
272
+ const _valueLiteral = _value.toLiteral().toMaybe().extract();
273
+ if (typeof _valueLiteral === "undefined") {
274
+ return false;
275
+ }
276
+ return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
277
+ })
278
+ .head()
279
+ .chain((_value) => _value.toLiteral())
280
+ .toMaybe());
281
+ if (_minExclusiveEither.isLeft()) {
282
+ return _minExclusiveEither;
283
+ }
284
+ const minExclusive = _minExclusiveEither.unsafeCoerce();
285
+ const _minInclusiveEither = purify.Either.of(_resource
286
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#minInclusive"), { unique: true })
287
+ .filter((_value) => {
288
+ const _languageInOrDefault = _languageIn ?? [];
289
+ if (_languageInOrDefault.length === 0) {
290
+ return true;
291
+ }
292
+ const _valueLiteral = _value.toLiteral().toMaybe().extract();
293
+ if (typeof _valueLiteral === "undefined") {
294
+ return false;
295
+ }
296
+ return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
297
+ })
298
+ .head()
299
+ .chain((_value) => _value.toLiteral())
300
+ .toMaybe());
301
+ if (_minInclusiveEither.isLeft()) {
302
+ return _minInclusiveEither;
303
+ }
304
+ const minInclusive = _minInclusiveEither.unsafeCoerce();
305
+ const _minLengthEither = purify.Either.of(_resource
306
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#minLength"), {
307
+ unique: true,
308
+ })
309
+ .head()
310
+ .chain((_value) => _value.toNumber())
311
+ .toMaybe());
312
+ if (_minLengthEither.isLeft()) {
313
+ return _minLengthEither;
314
+ }
315
+ const minLength = _minLengthEither.unsafeCoerce();
316
+ const _nodeKindEither = purify.Either.of(_resource
317
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#nodeKind"), {
318
+ unique: true,
319
+ })
320
+ .head()
321
+ .chain((_value) => _value.toIri().chain((iri) => {
322
+ switch (iri.value) {
323
+ case "http://www.w3.org/ns/shacl#BlankNode":
324
+ return purify.Either.of(iri);
325
+ case "http://www.w3.org/ns/shacl#BlankNodeOrIRI":
326
+ return purify.Either.of(iri);
327
+ case "http://www.w3.org/ns/shacl#BlankNodeOrLiteral":
328
+ return purify.Either.of(iri);
329
+ case "http://www.w3.org/ns/shacl#IRI":
330
+ return purify.Either.of(iri);
331
+ case "http://www.w3.org/ns/shacl#IRIOrLiteral":
332
+ return purify.Either.of(iri);
333
+ case "http://www.w3.org/ns/shacl#Literal":
334
+ return purify.Either.of(iri);
335
+ default:
336
+ return purify.Left(new rdfjsResource.Resource.MistypedValueError({
337
+ actualValue: iri,
338
+ expectedValueType: 'rdfjs.NamedNode<"http://www.w3.org/ns/shacl#BlankNode" | "http://www.w3.org/ns/shacl#BlankNodeOrIRI" | "http://www.w3.org/ns/shacl#BlankNodeOrLiteral" | "http://www.w3.org/ns/shacl#IRI" | "http://www.w3.org/ns/shacl#IRIOrLiteral" | "http://www.w3.org/ns/shacl#Literal">',
339
+ focusResource: _resource,
340
+ predicate: dataFactory.namedNode("http://www.w3.org/ns/shacl#nodeKind"),
341
+ }));
342
+ }
343
+ }))
344
+ .toMaybe());
345
+ if (_nodeKindEither.isLeft()) {
346
+ return _nodeKindEither;
347
+ }
348
+ const nodeKind = _nodeKindEither.unsafeCoerce();
349
+ const _nodesEither = purify.Either.of([
350
+ ..._resource
351
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#node"), {
352
+ unique: true,
353
+ })
354
+ .flatMap((_item) => _item
355
+ .toValues()
356
+ .head()
357
+ .chain((_value) => _value.toIdentifier())
358
+ .toMaybe()
359
+ .toList()),
360
+ ]);
361
+ if (_nodesEither.isLeft()) {
362
+ return _nodesEither;
363
+ }
364
+ const nodes = _nodesEither.unsafeCoerce();
365
+ const _notEither = purify.Either.of([
366
+ ..._resource
367
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#not"), {
368
+ unique: true,
369
+ })
370
+ .flatMap((_item) => _item
371
+ .toValues()
372
+ .head()
373
+ .chain((_value) => _value.toIdentifier())
374
+ .toMaybe()
375
+ .toList()),
376
+ ]);
377
+ if (_notEither.isLeft()) {
378
+ return _notEither;
379
+ }
380
+ const not = _notEither.unsafeCoerce();
381
+ const _orEither = purify.Either.of([
382
+ ..._resource
383
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#or"), {
384
+ unique: true,
385
+ })
386
+ .flatMap((_item) => _item
387
+ .toValues()
388
+ .head()
389
+ .chain((value) => value.toList())
390
+ .map((values) => values.flatMap((_value) => _value
391
+ .toValues()
392
+ .head()
393
+ .chain((_value) => _value.toIdentifier())
394
+ .toMaybe()
395
+ .toList()))
396
+ .toMaybe()
397
+ .toList()),
398
+ ]);
399
+ if (_orEither.isLeft()) {
400
+ return _orEither;
401
+ }
402
+ const or = _orEither.unsafeCoerce();
403
+ const _patternsEither = purify.Either.of([
404
+ ..._resource
405
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#pattern"), {
406
+ unique: true,
407
+ })
408
+ .flatMap((_item) => _item
409
+ .toValues()
410
+ .head()
411
+ .chain((_value) => _value.toString())
412
+ .toMaybe()
413
+ .toList()),
414
+ ]);
415
+ if (_patternsEither.isLeft()) {
416
+ return _patternsEither;
417
+ }
418
+ const patterns = _patternsEither.unsafeCoerce();
419
+ const _xoneEither = purify.Either.of([
420
+ ..._resource
421
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#xone"), {
422
+ unique: true,
423
+ })
424
+ .flatMap((_item) => _item
425
+ .toValues()
426
+ .head()
427
+ .chain((value) => value.toList())
428
+ .map((values) => values.flatMap((_value) => _value
429
+ .toValues()
430
+ .head()
431
+ .chain((_value) => _value.toIdentifier())
432
+ .toMaybe()
433
+ .toList()))
434
+ .toMaybe()
435
+ .toList()),
436
+ ]);
437
+ if (_xoneEither.isLeft()) {
438
+ return _xoneEither;
439
+ }
440
+ const xone = _xoneEither.unsafeCoerce();
441
+ return purify.Either.of({
442
+ and,
443
+ classes,
444
+ comments,
445
+ datatype,
446
+ deactivated,
447
+ flags,
448
+ hasValues,
449
+ identifier,
450
+ in_,
451
+ isDefinedBy,
452
+ labels,
453
+ languageIn,
454
+ maxCount,
455
+ maxExclusive,
456
+ maxInclusive,
457
+ maxLength,
458
+ minCount,
459
+ minExclusive,
460
+ minInclusive,
461
+ minLength,
462
+ nodeKind,
463
+ nodes,
464
+ not,
465
+ or,
466
+ patterns,
467
+ xone,
468
+ });
469
+ }
470
+ BaseShaclCoreShape.fromRdf = fromRdf;
471
+ })(BaseShaclCoreShape || (BaseShaclCoreShape = {}));
472
+ export var ShaclCorePropertyShape;
473
+ (function (ShaclCorePropertyShape) {
474
+ function fromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource,
475
+ // @ts-ignore
476
+ ..._context }) {
477
+ return BaseShaclCoreShape.fromRdf({
478
+ ..._context,
479
+ ignoreRdfType: true,
480
+ languageIn: _languageIn,
481
+ resource: _resource,
482
+ }).chain((_super) => {
483
+ if (!_ignoreRdfType &&
484
+ !_resource.isInstanceOf(dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyShape"))) {
485
+ return purify.Left(new rdfjsResource.Resource.ValueError({
486
+ focusResource: _resource,
487
+ message: `${rdfjsResource.Resource.Identifier.toString(_resource.identifier)} has unexpected RDF type`,
488
+ predicate: dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyShape"),
489
+ }));
490
+ }
491
+ const _defaultValueEither = purify.Either.of(_resource
492
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#defaultValue"), { unique: true })
493
+ .head()
494
+ .chain((_value) => purify.Either.of(_value.toTerm()))
495
+ .toMaybe());
496
+ if (_defaultValueEither.isLeft()) {
497
+ return _defaultValueEither;
498
+ }
499
+ const defaultValue = _defaultValueEither.unsafeCoerce();
500
+ const _descriptionsEither = purify.Either.of([
501
+ ..._resource
502
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#description"), { unique: true })
503
+ .flatMap((_item) => _item
504
+ .toValues()
505
+ .filter((_value) => {
506
+ const _languageInOrDefault = _languageIn ?? [];
507
+ if (_languageInOrDefault.length === 0) {
508
+ return true;
509
+ }
510
+ const _valueLiteral = _value.toLiteral().toMaybe().extract();
511
+ if (typeof _valueLiteral === "undefined") {
512
+ return false;
513
+ }
514
+ return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
515
+ })
516
+ .head()
517
+ .chain((_value) => _value.toLiteral())
518
+ .toMaybe()
519
+ .toList()),
520
+ ]);
521
+ if (_descriptionsEither.isLeft()) {
522
+ return _descriptionsEither;
523
+ }
524
+ const descriptions = _descriptionsEither.unsafeCoerce();
525
+ const _groupsEither = purify.Either.of([
526
+ ..._resource
527
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#group"), {
528
+ unique: true,
529
+ })
530
+ .flatMap((_item) => _item
531
+ .toValues()
532
+ .head()
533
+ .chain((_value) => _value.toIdentifier())
534
+ .toMaybe()
535
+ .toList()),
536
+ ]);
537
+ if (_groupsEither.isLeft()) {
538
+ return _groupsEither;
539
+ }
540
+ const groups = _groupsEither.unsafeCoerce();
541
+ const identifier = _resource.identifier;
542
+ const _namesEither = purify.Either.of([
543
+ ..._resource
544
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#name"), {
545
+ unique: true,
546
+ })
547
+ .flatMap((_item) => _item
548
+ .toValues()
549
+ .filter((_value) => {
550
+ const _languageInOrDefault = _languageIn ?? [];
551
+ if (_languageInOrDefault.length === 0) {
552
+ return true;
553
+ }
554
+ const _valueLiteral = _value.toLiteral().toMaybe().extract();
555
+ if (typeof _valueLiteral === "undefined") {
556
+ return false;
557
+ }
558
+ return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
559
+ })
560
+ .head()
561
+ .chain((_value) => _value.toLiteral())
562
+ .toMaybe()
563
+ .toList()),
564
+ ]);
565
+ if (_namesEither.isLeft()) {
566
+ return _namesEither;
567
+ }
568
+ const names = _namesEither.unsafeCoerce();
569
+ const _orderEither = purify.Either.of(_resource
570
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#order"), {
571
+ unique: true,
572
+ })
573
+ .head()
574
+ .chain((_value) => _value.toNumber())
575
+ .toMaybe());
576
+ if (_orderEither.isLeft()) {
577
+ return _orderEither;
578
+ }
579
+ const order = _orderEither.unsafeCoerce();
580
+ const _pathEither = _resource
581
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#path"), {
582
+ unique: true,
583
+ })
584
+ .head()
585
+ .chain((value) => value.toResource())
586
+ .chain((_resource) => PropertyPath.fromRdf({
587
+ ..._context,
588
+ ignoreRdfType: true,
589
+ languageIn: _languageIn,
590
+ resource: _resource,
591
+ }));
592
+ if (_pathEither.isLeft()) {
593
+ return _pathEither;
594
+ }
595
+ const path = _pathEither.unsafeCoerce();
596
+ const type = "ShaclCorePropertyShape";
597
+ const _uniqueLangEither = purify.Either.of(_resource
598
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#uniqueLang"), { unique: true })
599
+ .head()
600
+ .chain((_value) => _value.toBoolean())
601
+ .toMaybe());
602
+ if (_uniqueLangEither.isLeft()) {
603
+ return _uniqueLangEither;
604
+ }
605
+ const uniqueLang = _uniqueLangEither.unsafeCoerce();
606
+ return purify.Either.of({
607
+ and: _super.and,
608
+ classes: _super.classes,
609
+ comments: _super.comments,
610
+ datatype: _super.datatype,
611
+ deactivated: _super.deactivated,
612
+ flags: _super.flags,
613
+ hasValues: _super.hasValues,
614
+ identifier,
615
+ in_: _super.in_,
616
+ isDefinedBy: _super.isDefinedBy,
617
+ labels: _super.labels,
618
+ languageIn: _super.languageIn,
619
+ maxCount: _super.maxCount,
620
+ maxExclusive: _super.maxExclusive,
621
+ maxInclusive: _super.maxInclusive,
622
+ maxLength: _super.maxLength,
623
+ minCount: _super.minCount,
624
+ minExclusive: _super.minExclusive,
625
+ minInclusive: _super.minInclusive,
626
+ minLength: _super.minLength,
627
+ nodeKind: _super.nodeKind,
628
+ nodes: _super.nodes,
629
+ not: _super.not,
630
+ or: _super.or,
631
+ patterns: _super.patterns,
632
+ xone: _super.xone,
633
+ defaultValue,
634
+ descriptions,
635
+ groups,
636
+ names,
637
+ order,
638
+ path,
639
+ type,
640
+ uniqueLang,
641
+ });
642
+ });
643
+ }
644
+ ShaclCorePropertyShape.fromRdf = fromRdf;
645
+ })(ShaclCorePropertyShape || (ShaclCorePropertyShape = {}));
646
+ export var ShaclCorePropertyGroup;
647
+ (function (ShaclCorePropertyGroup) {
648
+ function fromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource,
649
+ // @ts-ignore
650
+ ..._context }) {
651
+ if (!_ignoreRdfType &&
652
+ !_resource.isInstanceOf(dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyGroup"))) {
653
+ return purify.Left(new rdfjsResource.Resource.ValueError({
654
+ focusResource: _resource,
655
+ message: `${rdfjsResource.Resource.Identifier.toString(_resource.identifier)} has unexpected RDF type`,
656
+ predicate: dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyGroup"),
657
+ }));
658
+ }
659
+ const _commentsEither = purify.Either.of([
660
+ ..._resource
661
+ .values(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#comment"), { unique: true })
662
+ .flatMap((_item) => _item
663
+ .toValues()
664
+ .filter((_value) => {
665
+ const _languageInOrDefault = _languageIn ?? [];
666
+ if (_languageInOrDefault.length === 0) {
667
+ return true;
668
+ }
669
+ const _valueLiteral = _value.toLiteral().toMaybe().extract();
670
+ if (typeof _valueLiteral === "undefined") {
671
+ return false;
672
+ }
673
+ return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
674
+ })
675
+ .head()
676
+ .chain((_value) => _value.toLiteral())
677
+ .toMaybe()
678
+ .toList()),
679
+ ]);
680
+ if (_commentsEither.isLeft()) {
681
+ return _commentsEither;
682
+ }
683
+ const comments = _commentsEither.unsafeCoerce();
684
+ const identifier = _resource.identifier;
685
+ const _labelsEither = purify.Either.of([
686
+ ..._resource
687
+ .values(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#label"), { unique: true })
688
+ .flatMap((_item) => _item
689
+ .toValues()
690
+ .filter((_value) => {
691
+ const _languageInOrDefault = _languageIn ?? [];
692
+ if (_languageInOrDefault.length === 0) {
693
+ return true;
694
+ }
695
+ const _valueLiteral = _value.toLiteral().toMaybe().extract();
696
+ if (typeof _valueLiteral === "undefined") {
697
+ return false;
698
+ }
699
+ return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
700
+ })
701
+ .head()
702
+ .chain((_value) => _value.toLiteral())
703
+ .toMaybe()
704
+ .toList()),
705
+ ]);
706
+ if (_labelsEither.isLeft()) {
707
+ return _labelsEither;
708
+ }
709
+ const labels = _labelsEither.unsafeCoerce();
710
+ const type = "ShaclCorePropertyGroup";
711
+ return purify.Either.of({ comments, identifier, labels, type });
712
+ }
713
+ ShaclCorePropertyGroup.fromRdf = fromRdf;
714
+ })(ShaclCorePropertyGroup || (ShaclCorePropertyGroup = {}));
715
+ export var ShaclCoreNodeShape;
716
+ (function (ShaclCoreNodeShape) {
717
+ function fromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource,
718
+ // @ts-ignore
719
+ ..._context }) {
720
+ return BaseShaclCoreShape.fromRdf({
721
+ ..._context,
722
+ ignoreRdfType: true,
723
+ languageIn: _languageIn,
724
+ resource: _resource,
725
+ }).chain((_super) => {
726
+ if (!_ignoreRdfType &&
727
+ !_resource.isInstanceOf(dataFactory.namedNode("http://www.w3.org/ns/shacl#NodeShape"))) {
728
+ return purify.Left(new rdfjsResource.Resource.ValueError({
729
+ focusResource: _resource,
730
+ message: `${rdfjsResource.Resource.Identifier.toString(_resource.identifier)} has unexpected RDF type`,
731
+ predicate: dataFactory.namedNode("http://www.w3.org/ns/shacl#NodeShape"),
732
+ }));
733
+ }
734
+ const _closedEither = purify.Either.of(_resource
735
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#closed"), {
736
+ unique: true,
737
+ })
738
+ .head()
739
+ .chain((_value) => _value.toBoolean())
740
+ .toMaybe());
741
+ if (_closedEither.isLeft()) {
742
+ return _closedEither;
743
+ }
744
+ const closed = _closedEither.unsafeCoerce();
745
+ const identifier = _resource.identifier;
746
+ const _ignoredPropertiesEither = purify.Either.of(_resource
747
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#ignoredProperties"), { unique: true })
748
+ .head()
749
+ .chain((value) => value.toList())
750
+ .map((values) => values.flatMap((_value) => _value
751
+ .toValues()
752
+ .head()
753
+ .chain((_value) => _value.toIri())
754
+ .toMaybe()
755
+ .toList()))
756
+ .toMaybe());
757
+ if (_ignoredPropertiesEither.isLeft()) {
758
+ return _ignoredPropertiesEither;
759
+ }
760
+ const ignoredProperties = _ignoredPropertiesEither.unsafeCoerce();
761
+ const _propertiesEither = purify.Either.of([
762
+ ..._resource
763
+ .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#property"), { unique: true })
764
+ .flatMap((_item) => _item
765
+ .toValues()
766
+ .head()
767
+ .chain((_value) => _value.toIdentifier())
768
+ .toMaybe()
769
+ .toList()),
770
+ ]);
771
+ if (_propertiesEither.isLeft()) {
772
+ return _propertiesEither;
773
+ }
774
+ const properties = _propertiesEither.unsafeCoerce();
775
+ const type = "ShaclCoreNodeShape";
776
+ return purify.Either.of({
777
+ and: _super.and,
778
+ classes: _super.classes,
779
+ comments: _super.comments,
780
+ datatype: _super.datatype,
781
+ deactivated: _super.deactivated,
782
+ flags: _super.flags,
783
+ hasValues: _super.hasValues,
784
+ identifier,
785
+ in_: _super.in_,
786
+ isDefinedBy: _super.isDefinedBy,
787
+ labels: _super.labels,
788
+ languageIn: _super.languageIn,
789
+ maxCount: _super.maxCount,
790
+ maxExclusive: _super.maxExclusive,
791
+ maxInclusive: _super.maxInclusive,
792
+ maxLength: _super.maxLength,
793
+ minCount: _super.minCount,
794
+ minExclusive: _super.minExclusive,
795
+ minInclusive: _super.minInclusive,
796
+ minLength: _super.minLength,
797
+ nodeKind: _super.nodeKind,
798
+ nodes: _super.nodes,
799
+ not: _super.not,
800
+ or: _super.or,
801
+ patterns: _super.patterns,
802
+ xone: _super.xone,
803
+ closed,
804
+ ignoredProperties,
805
+ properties,
806
+ type,
807
+ });
808
+ });
809
+ }
810
+ ShaclCoreNodeShape.fromRdf = fromRdf;
811
+ })(ShaclCoreNodeShape || (ShaclCoreNodeShape = {}));
812
+ export var OwlOntology;
813
+ (function (OwlOntology) {
814
+ function fromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource,
815
+ // @ts-ignore
816
+ ..._context }) {
817
+ if (!_ignoreRdfType &&
818
+ !_resource.isInstanceOf(dataFactory.namedNode("http://www.w3.org/2002/07/owl#Ontology"))) {
819
+ return purify.Left(new rdfjsResource.Resource.ValueError({
820
+ focusResource: _resource,
821
+ message: `${rdfjsResource.Resource.Identifier.toString(_resource.identifier)} has unexpected RDF type`,
822
+ predicate: dataFactory.namedNode("http://www.w3.org/2002/07/owl#Ontology"),
823
+ }));
824
+ }
825
+ const identifier = _resource.identifier;
826
+ const _labelsEither = purify.Either.of([
827
+ ..._resource
828
+ .values(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#label"), { unique: true })
829
+ .flatMap((_item) => _item
830
+ .toValues()
831
+ .filter((_value) => {
832
+ const _languageInOrDefault = _languageIn ?? [];
833
+ if (_languageInOrDefault.length === 0) {
834
+ return true;
835
+ }
836
+ const _valueLiteral = _value.toLiteral().toMaybe().extract();
837
+ if (typeof _valueLiteral === "undefined") {
838
+ return false;
839
+ }
840
+ return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
841
+ })
842
+ .head()
843
+ .chain((_value) => _value.toLiteral())
844
+ .toMaybe()
845
+ .toList()),
846
+ ]);
847
+ if (_labelsEither.isLeft()) {
848
+ return _labelsEither;
849
+ }
850
+ const labels = _labelsEither.unsafeCoerce();
851
+ const type = "OwlOntology";
852
+ return purify.Either.of({ identifier, labels, type });
853
+ }
854
+ OwlOntology.fromRdf = fromRdf;
855
+ })(OwlOntology || (OwlOntology = {}));
856
+ export var ShaclCoreShape;
857
+ (function (ShaclCoreShape) {
858
+ function fromRdf(parameters) {
859
+ return ShaclCoreNodeShape.fromRdf(parameters).altLazy(() => ShaclCorePropertyShape.fromRdf(parameters));
860
+ }
861
+ ShaclCoreShape.fromRdf = fromRdf;
862
+ })(ShaclCoreShape || (ShaclCoreShape = {}));
863
+ //# sourceMappingURL=generated.js.map