@shaclmate/compiler 2.0.22 → 2.0.24

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.
Files changed (194) hide show
  1. package/dist/ShapesGraphToAstTransformer.d.ts +6 -5
  2. package/dist/ShapesGraphToAstTransformer.js +61 -17
  3. package/dist/_ShapesGraphToAstTransformer/InheritableShapeConstraints.d.ts +2 -0
  4. package/dist/_ShapesGraphToAstTransformer/InheritableShapeConstraints.js +2 -0
  5. package/dist/_ShapesGraphToAstTransformer/ShapeStack.d.ts +15 -0
  6. package/dist/_ShapesGraphToAstTransformer/ShapeStack.js +51 -0
  7. package/dist/_ShapesGraphToAstTransformer/flattenAstObjectCompositeTypeMemberTypes.d.ts +13 -0
  8. package/dist/_ShapesGraphToAstTransformer/flattenAstObjectCompositeTypeMemberTypes.js +51 -0
  9. package/dist/_ShapesGraphToAstTransformer/index.d.ts +5 -5
  10. package/dist/_ShapesGraphToAstTransformer/index.js +5 -5
  11. package/dist/_ShapesGraphToAstTransformer/shapeAstName.js +53 -12
  12. package/dist/_ShapesGraphToAstTransformer/transformNodeShapeToAstType.d.ts +5 -0
  13. package/dist/_ShapesGraphToAstTransformer/transformNodeShapeToAstType.js +130 -54
  14. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +175 -5
  15. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompositeType.d.ts +10 -0
  16. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompositeType.js +185 -0
  17. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstIdentifierType.d.ts +10 -0
  18. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstIdentifierType.js +32 -0
  19. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstLiteralType.d.ts +10 -0
  20. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstLiteralType.js +46 -0
  21. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.d.ts +12 -0
  22. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.js +24 -0
  23. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.d.ts +13 -0
  24. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.js +14 -0
  25. package/dist/ast/Ast.d.ts +0 -1
  26. package/dist/ast/Curie.d.ts +14 -0
  27. package/dist/ast/Curie.js +21 -0
  28. package/dist/ast/IdentifierType.d.ts +3 -2
  29. package/dist/ast/ListType.d.ts +2 -1
  30. package/dist/ast/LiteralType.d.ts +1 -1
  31. package/dist/ast/Name.d.ts +40 -5
  32. package/dist/ast/ObjectCompositeType.d.ts +11 -0
  33. package/dist/ast/ObjectType.d.ts +18 -13
  34. package/dist/ast/ObjectUnionType.d.ts +0 -11
  35. package/dist/ast/OptionType.d.ts +2 -4
  36. package/dist/ast/SetType.d.ts +2 -7
  37. package/dist/ast/TermType.d.ts +12 -4
  38. package/dist/ast/Type.d.ts +1 -1
  39. package/dist/ast/index.d.ts +1 -0
  40. package/dist/ast/index.js +1 -0
  41. package/dist/enums/TsFeature.d.ts +1 -4
  42. package/dist/enums/TsFeature.js +1 -15
  43. package/dist/generators/json/AstJsonGenerator.js +26 -4
  44. package/dist/generators/ts/BooleanType.d.ts +4 -2
  45. package/dist/generators/ts/BooleanType.js +12 -3
  46. package/dist/generators/ts/DateTimeType.d.ts +9 -8
  47. package/dist/generators/ts/DateTimeType.js +32 -8
  48. package/dist/generators/ts/DateType.d.ts +5 -2
  49. package/dist/generators/ts/DateType.js +15 -1
  50. package/dist/generators/ts/DeclaredType.d.ts +2 -2
  51. package/dist/generators/ts/DeclaredType.js +2 -2
  52. package/dist/generators/ts/FloatType.d.ts +6 -0
  53. package/dist/generators/ts/FloatType.js +18 -0
  54. package/dist/generators/ts/IdentifierType.d.ts +17 -7
  55. package/dist/generators/ts/IdentifierType.js +112 -18
  56. package/dist/generators/ts/Import.d.ts +2 -0
  57. package/dist/generators/ts/Import.js +10 -0
  58. package/dist/generators/ts/IntType.d.ts +6 -0
  59. package/dist/generators/ts/IntType.js +18 -0
  60. package/dist/generators/ts/ListType.d.ts +15 -12
  61. package/dist/generators/ts/ListType.js +113 -61
  62. package/dist/generators/ts/LiteralType.d.ts +17 -9
  63. package/dist/generators/ts/LiteralType.js +92 -17
  64. package/dist/generators/ts/NumberType.d.ts +3 -2
  65. package/dist/generators/ts/NumberType.js +8 -3
  66. package/dist/generators/ts/ObjectType.d.ts +65 -43
  67. package/dist/generators/ts/ObjectType.js +143 -123
  68. package/dist/generators/ts/ObjectUnionType.d.ts +50 -8
  69. package/dist/generators/ts/ObjectUnionType.js +303 -101
  70. package/dist/generators/ts/OptionType.d.ts +14 -10
  71. package/dist/generators/ts/OptionType.js +62 -34
  72. package/dist/generators/ts/PrimitiveType.d.ts +23 -5
  73. package/dist/generators/ts/PrimitiveType.js +34 -6
  74. package/dist/generators/ts/SetType.d.ts +17 -13
  75. package/dist/generators/ts/SetType.js +76 -44
  76. package/dist/generators/ts/SnippetDeclarations.d.ts +13 -8
  77. package/dist/generators/ts/SnippetDeclarations.js +226 -101
  78. package/dist/generators/ts/StringType.d.ts +4 -2
  79. package/dist/generators/ts/StringType.js +20 -8
  80. package/dist/generators/ts/TermType.d.ts +29 -33
  81. package/dist/generators/ts/TermType.js +89 -68
  82. package/dist/generators/ts/TsGenerator.d.ts +2 -1
  83. package/dist/generators/ts/TsGenerator.js +26 -12
  84. package/dist/generators/ts/Type.d.ts +100 -32
  85. package/dist/generators/ts/Type.js +58 -54
  86. package/dist/generators/ts/TypeFactory.d.ts +12 -5
  87. package/dist/generators/ts/TypeFactory.js +380 -226
  88. package/dist/generators/ts/UnionType.d.ts +14 -10
  89. package/dist/generators/ts/UnionType.js +319 -142
  90. package/dist/generators/ts/_ObjectType/EagerShaclProperty.d.ts +12 -0
  91. package/dist/generators/ts/_ObjectType/EagerShaclProperty.js +31 -0
  92. package/dist/generators/ts/_ObjectType/IdentifierPrefixProperty.d.ts +13 -12
  93. package/dist/generators/ts/_ObjectType/IdentifierPrefixProperty.js +59 -46
  94. package/dist/generators/ts/_ObjectType/IdentifierProperty.d.ts +20 -13
  95. package/dist/generators/ts/_ObjectType/IdentifierProperty.js +198 -140
  96. package/dist/generators/ts/_ObjectType/LazyShaclProperty.d.ts +100 -0
  97. package/dist/generators/ts/_ObjectType/LazyShaclProperty.js +315 -0
  98. package/dist/generators/ts/_ObjectType/Property.d.ts +47 -46
  99. package/dist/generators/ts/_ObjectType/Property.js +1 -10
  100. package/dist/generators/ts/_ObjectType/ShaclProperty.d.ts +25 -30
  101. package/dist/generators/ts/_ObjectType/ShaclProperty.js +120 -85
  102. package/dist/generators/ts/_ObjectType/TypeDiscriminatorProperty.d.ts +21 -17
  103. package/dist/generators/ts/_ObjectType/TypeDiscriminatorProperty.js +61 -53
  104. package/dist/generators/ts/_ObjectType/classDeclaration.js +22 -17
  105. package/dist/generators/ts/_ObjectType/createFunctionDeclaration.js +26 -13
  106. package/dist/generators/ts/_ObjectType/equalsFunctionOrMethodDeclaration.js +8 -5
  107. package/dist/generators/ts/_ObjectType/fromRdfTypeVariableStatement.d.ts +1 -1
  108. package/dist/generators/ts/_ObjectType/fromRdfTypeVariableStatement.js +8 -5
  109. package/dist/generators/ts/_ObjectType/graphqlTypeVariableStatement.d.ts +5 -0
  110. package/dist/generators/ts/_ObjectType/graphqlTypeVariableStatement.js +49 -0
  111. package/dist/generators/ts/_ObjectType/hashFunctionOrMethodDeclarations.js +7 -8
  112. package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.d.ts +7 -0
  113. package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.js +54 -0
  114. package/dist/generators/ts/_ObjectType/index.d.ts +9 -7
  115. package/dist/generators/ts/_ObjectType/index.js +9 -7
  116. package/dist/generators/ts/_ObjectType/interfaceDeclaration.js +1 -1
  117. package/dist/generators/ts/_ObjectType/jsonFunctionDeclarations.d.ts +4 -0
  118. package/dist/generators/ts/_ObjectType/jsonFunctionDeclarations.js +189 -0
  119. package/dist/generators/ts/_ObjectType/jsonTypeAliasDeclaration.d.ts +5 -0
  120. package/dist/generators/ts/_ObjectType/jsonTypeAliasDeclaration.js +28 -0
  121. package/dist/generators/ts/_ObjectType/objectSetMethodNames.d.ts +9 -0
  122. package/dist/generators/ts/_ObjectType/objectSetMethodNames.js +18 -0
  123. package/dist/generators/ts/_ObjectType/propertiesVariableStatement.d.ts +5 -0
  124. package/dist/generators/ts/_ObjectType/propertiesVariableStatement.js +37 -0
  125. package/dist/generators/ts/_ObjectType/rdfFunctionDeclarations.d.ts +4 -0
  126. package/dist/generators/ts/_ObjectType/rdfFunctionDeclarations.js +144 -0
  127. package/dist/generators/ts/_ObjectType/sparqlConstructQueryFunctionDeclaration.d.ts +1 -1
  128. package/dist/generators/ts/_ObjectType/sparqlConstructQueryFunctionDeclaration.js +6 -5
  129. package/dist/generators/ts/_ObjectType/sparqlConstructQueryStringFunctionDeclaration.d.ts +1 -1
  130. package/dist/generators/ts/_ObjectType/sparqlConstructQueryStringFunctionDeclaration.js +4 -3
  131. package/dist/generators/ts/_ObjectType/sparqlFunctionDeclarations.js +109 -37
  132. package/dist/generators/ts/_ObjectType/toJsonFunctionOrMethodDeclaration.js +6 -6
  133. package/dist/generators/ts/_ObjectType/toRdfFunctionOrMethodDeclaration.js +33 -24
  134. package/dist/generators/ts/graphqlSchemaVariableStatement.d.ts +9 -0
  135. package/dist/generators/ts/graphqlSchemaVariableStatement.js +86 -0
  136. package/dist/generators/ts/objectSetDeclarations.d.ts +8 -0
  137. package/dist/generators/ts/objectSetDeclarations.js +59 -0
  138. package/dist/generators/ts/objectSetInterfaceDeclaration.d.ts +8 -0
  139. package/dist/generators/ts/objectSetInterfaceDeclaration.js +46 -0
  140. package/dist/generators/ts/objectSetMethodSignatures.d.ts +11 -0
  141. package/dist/generators/ts/objectSetMethodSignatures.js +52 -0
  142. package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.d.ts +8 -0
  143. package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.js +393 -0
  144. package/dist/generators/ts/rdfjsTermExpression.d.ts +3 -0
  145. package/dist/generators/ts/rdfjsTermExpression.js +57 -0
  146. package/dist/generators/ts/sparqlObjectSetClassDeclaration.d.ts +8 -0
  147. package/dist/generators/ts/sparqlObjectSetClassDeclaration.js +415 -0
  148. package/dist/generators/ts/syntheticNamePrefix.d.ts +2 -0
  149. package/dist/generators/ts/syntheticNamePrefix.js +2 -0
  150. package/dist/generators/ts/tsName.js +27 -13
  151. package/dist/generators/ts/unsupportedObjectSetMethodDeclarations.d.ts +10 -0
  152. package/dist/generators/ts/unsupportedObjectSetMethodDeclarations.js +19 -0
  153. package/dist/input/NodeShape.d.ts +6 -8
  154. package/dist/input/NodeShape.js +20 -44
  155. package/dist/input/Ontology.d.ts +0 -3
  156. package/dist/input/Ontology.js +0 -9
  157. package/dist/input/PropertyPath.d.ts +5 -5
  158. package/dist/input/PropertyPath.js +14 -24
  159. package/dist/input/PropertyShape.d.ts +3 -1
  160. package/dist/input/PropertyShape.js +8 -2
  161. package/dist/input/ShapesGraph.js +4 -8
  162. package/dist/input/generated.d.ts +967 -107
  163. package/dist/input/generated.js +2548 -1046
  164. package/dist/input/tsFeatures.d.ts +3 -2
  165. package/dist/input/tsFeatures.js +44 -27
  166. package/package.json +18 -16
  167. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstCompositeType.d.ts +0 -13
  168. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstCompositeType.js +0 -200
  169. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstIdentifierType.d.ts +0 -12
  170. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstIdentifierType.js +0 -29
  171. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstLiteralType.d.ts +0 -12
  172. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstLiteralType.js +0 -43
  173. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstTermType.d.ts +0 -14
  174. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstTermType.js +0 -21
  175. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstType.d.ts +0 -16
  176. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstType.js +0 -60
  177. package/dist/generators/ts/_ObjectType/fromJsonFunctionDeclarations.d.ts +0 -4
  178. package/dist/generators/ts/_ObjectType/fromJsonFunctionDeclarations.js +0 -78
  179. package/dist/generators/ts/_ObjectType/fromRdfFunctionDeclarations.d.ts +0 -4
  180. package/dist/generators/ts/_ObjectType/fromRdfFunctionDeclarations.js +0 -91
  181. package/dist/generators/ts/_ObjectType/jsonSchemaFunctionDeclaration.d.ts +0 -5
  182. package/dist/generators/ts/_ObjectType/jsonSchemaFunctionDeclaration.js +0 -19
  183. package/dist/generators/ts/_ObjectType/jsonUiSchemaFunctionDeclaration.d.ts +0 -5
  184. package/dist/generators/ts/_ObjectType/jsonUiSchemaFunctionDeclaration.js +0 -31
  185. package/dist/generators/ts/_ObjectType/jsonZodSchemaFunctionDeclaration.d.ts +0 -5
  186. package/dist/generators/ts/_ObjectType/jsonZodSchemaFunctionDeclaration.js +0 -37
  187. package/dist/generators/ts/_ObjectType/rdfjsTermExpression.d.ts +0 -6
  188. package/dist/generators/ts/_ObjectType/rdfjsTermExpression.js +0 -17
  189. package/dist/generators/ts/_ObjectType/toJsonFunctionDeclaration.d.ts +0 -5
  190. package/dist/generators/ts/_ObjectType/toJsonFunctionDeclaration.js +0 -19
  191. package/dist/generators/ts/_ObjectType/toJsonReturnType.d.ts +0 -3
  192. package/dist/generators/ts/_ObjectType/toJsonReturnType.js +0 -17
  193. package/dist/generators/ts/_ObjectType/toRdfFunctionDeclaration.d.ts +0 -5
  194. package/dist/generators/ts/_ObjectType/toRdfFunctionDeclaration.js +0 -19
@@ -1,324 +1,593 @@
1
- import { DataFactory as dataFactory } from "n3";
1
+ import { StoreFactory as _DatasetFactory, DataFactory as dataFactory, } from "n3";
2
+ const datasetFactory = new _DatasetFactory();
2
3
  import * as purify from "purify-ts";
3
4
  import * as rdfjsResource from "rdfjs-resource";
4
5
  import { PropertyPath } from "./PropertyPath.js";
5
- export var BaseShaclCoreShape;
6
- (function (BaseShaclCoreShape) {
7
- function _propertiesFromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource,
6
+ export var $RdfVocabularies;
7
+ (function ($RdfVocabularies) {
8
+ let rdf;
9
+ (function (rdf) {
10
+ rdf.first = dataFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#first");
11
+ rdf.nil = dataFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#nil");
12
+ rdf.rest = dataFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#rest");
13
+ rdf.subject = dataFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#subject");
14
+ rdf.type = dataFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
15
+ })(rdf = $RdfVocabularies.rdf || ($RdfVocabularies.rdf = {}));
16
+ let rdfs;
17
+ (function (rdfs) {
18
+ rdfs.subClassOf = dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#subClassOf");
19
+ })(rdfs = $RdfVocabularies.rdfs || ($RdfVocabularies.rdfs = {}));
20
+ let xsd;
21
+ (function (xsd) {
22
+ xsd.boolean = dataFactory.namedNode("http://www.w3.org/2001/XMLSchema#boolean");
23
+ xsd.date = dataFactory.namedNode("http://www.w3.org/2001/XMLSchema#date");
24
+ xsd.dateTime = dataFactory.namedNode("http://www.w3.org/2001/XMLSchema#dateTime");
25
+ xsd.integer = dataFactory.namedNode("http://www.w3.org/2001/XMLSchema#integer");
26
+ })(xsd = $RdfVocabularies.xsd || ($RdfVocabularies.xsd = {}));
27
+ })($RdfVocabularies || ($RdfVocabularies = {}));
28
+ export var BaseShaclCoreShapeStatic;
29
+ (function (BaseShaclCoreShapeStatic) {
30
+ let $Identifier;
31
+ (function ($Identifier) {
32
+ function fromString(identifier) {
33
+ return purify.Either.encase(() => rdfjsResource.Resource.Identifier.fromString({
34
+ dataFactory,
35
+ identifier,
36
+ }));
37
+ }
38
+ $Identifier.fromString = fromString;
39
+ $Identifier.toString = rdfjsResource.Resource.Identifier.toString;
40
+ })($Identifier = BaseShaclCoreShapeStatic.$Identifier || (BaseShaclCoreShapeStatic.$Identifier = {}));
41
+ function $fromRdf(resource, options) {
42
+ let { ignoreRdfType = false, languageIn, objectSet, ...context } = options ?? {};
43
+ if (!objectSet) {
44
+ objectSet = new $RdfjsDatasetObjectSet({ dataset: resource.dataset });
45
+ }
46
+ return ShaclCoreNodeShapeStatic.$fromRdf(resource, {
47
+ ...context,
48
+ ignoreRdfType: false,
49
+ objectSet,
50
+ }).altLazy(() => ShaclCorePropertyShapeStatic.$fromRdf(resource, {
51
+ ...context,
52
+ ignoreRdfType: false,
53
+ objectSet,
54
+ }));
55
+ }
56
+ BaseShaclCoreShapeStatic.$fromRdf = $fromRdf;
57
+ function $propertiesFromRdf({ ignoreRdfType: $ignoreRdfType, languageIn: $languageIn, objectSet: $objectSet, resource: $resource,
8
58
  // @ts-ignore
9
- ..._context }) {
10
- const identifier = _resource.identifier;
11
- const _andEither = purify.Either.of([
12
- ..._resource
13
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#and"), {
14
- unique: true,
15
- })
16
- .flatMap((_item) => _item
17
- .toValues()
18
- .head()
19
- .chain((value) => value.toList())
20
- .map((values) => values.flatMap((_value) => _value
21
- .toValues()
22
- .head()
23
- .chain((_value) => _value.toIdentifier())
24
- .toMaybe()
25
- .toList()))
26
- .toMaybe()
27
- .toList()),
28
- ]);
59
+ ...$context }) {
60
+ const $identifier = $resource.identifier;
61
+ const _andEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.and["identifier"], { unique: true }))
62
+ .chain((values) => values.chainMap((value) => value.toList()))
63
+ .chain((valueLists) => valueLists.chainMap((valueList) => purify.Either.of(rdfjsResource.Resource.Values.fromArray({
64
+ objects: valueList,
65
+ predicate: BaseShaclCoreShapeStatic.$properties.and["identifier"],
66
+ subject: $resource,
67
+ })).chain((values) => values.chainMap((value) => value.toIdentifier()))))
68
+ .map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
69
+ .map((values) => values.toArray())
70
+ .map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
71
+ object: valuesArray,
72
+ predicate: BaseShaclCoreShapeStatic.$properties.and["identifier"],
73
+ subject: $resource,
74
+ }))
75
+ .chain((values) => values.head());
29
76
  if (_andEither.isLeft()) {
30
77
  return _andEither;
31
78
  }
32
79
  const and = _andEither.unsafeCoerce();
33
- const _classesEither = purify.Either.of([
34
- ..._resource
35
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#class"), {
36
- unique: true,
37
- })
38
- .flatMap((_item) => _item
39
- .toValues()
40
- .head()
41
- .chain((_value) => _value.toIri())
42
- .toMaybe()
43
- .toList()),
44
- ]);
80
+ const _classesEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.classes["identifier"], { unique: true }))
81
+ .chain((values) => values.chainMap((value) => value.toIri()))
82
+ .map((values) => values.toArray())
83
+ .map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
84
+ object: valuesArray,
85
+ predicate: BaseShaclCoreShapeStatic.$properties.classes["identifier"],
86
+ subject: $resource,
87
+ }))
88
+ .chain((values) => values.head());
45
89
  if (_classesEither.isLeft()) {
46
90
  return _classesEither;
47
91
  }
48
92
  const classes = _classesEither.unsafeCoerce();
49
- const _commentsEither = purify.Either.of([
50
- ..._resource
51
- .values(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#comment"), { unique: true })
52
- .flatMap((_item) => _item
53
- .toValues()
54
- .filter((_value) => {
55
- const _languageInOrDefault = _languageIn ?? [];
56
- if (_languageInOrDefault.length === 0) {
57
- return true;
93
+ const _commentsEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.comments["identifier"], { unique: true }))
94
+ .chain((values) => {
95
+ const literalValuesEither = values.chainMap((value) => value.toLiteral());
96
+ if (literalValuesEither.isLeft()) {
97
+ return literalValuesEither;
98
+ }
99
+ const literalValues = literalValuesEither.unsafeCoerce();
100
+ const nonUniqueLanguageIn = $languageIn ?? [];
101
+ if (nonUniqueLanguageIn.length === 0) {
102
+ return purify.Either.of(literalValues);
103
+ }
104
+ let uniqueLanguageIn;
105
+ if (nonUniqueLanguageIn.length === 1) {
106
+ uniqueLanguageIn = [nonUniqueLanguageIn[0]];
107
+ }
108
+ else {
109
+ uniqueLanguageIn = [];
110
+ for (const languageIn of nonUniqueLanguageIn) {
111
+ if (uniqueLanguageIn.indexOf(languageIn) === -1) {
112
+ uniqueLanguageIn.push(languageIn);
113
+ }
58
114
  }
59
- const _valueLiteral = _value.toLiteral().toMaybe().extract();
60
- if (typeof _valueLiteral === "undefined") {
61
- return false;
115
+ }
116
+ // Return all literals for the first languageIn, then all literals for the second languageIn, etc.
117
+ // Within a languageIn the literals may be in any order.
118
+ let filteredLiteralValues;
119
+ for (const languageIn of uniqueLanguageIn) {
120
+ if (!filteredLiteralValues) {
121
+ filteredLiteralValues = literalValues.filter((value) => value.language === languageIn);
122
+ }
123
+ else {
124
+ filteredLiteralValues = filteredLiteralValues.concat(...literalValues
125
+ .filter((value) => value.language === languageIn)
126
+ .toArray());
62
127
  }
63
- return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
64
- })
65
- .head()
66
- .chain((_value) => _value.toLiteral())
67
- .toMaybe()
68
- .toList()),
69
- ]);
128
+ }
129
+ return purify.Either.of(filteredLiteralValues);
130
+ })
131
+ .map((values) => values.toArray())
132
+ .map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
133
+ object: valuesArray,
134
+ predicate: BaseShaclCoreShapeStatic.$properties.comments["identifier"],
135
+ subject: $resource,
136
+ }))
137
+ .chain((values) => values.head());
70
138
  if (_commentsEither.isLeft()) {
71
139
  return _commentsEither;
72
140
  }
73
141
  const comments = _commentsEither.unsafeCoerce();
74
- const _datatypeEither = purify.Either.of(_resource
75
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#datatype"), {
76
- unique: true,
77
- })
78
- .head()
79
- .chain((_value) => _value.toIri())
80
- .toMaybe());
142
+ const _datatypeEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.datatype["identifier"], { unique: true }))
143
+ .chain((values) => values.chainMap((value) => value.toIri()))
144
+ .map((values) => values.length > 0
145
+ ? values.map((value) => purify.Maybe.of(value))
146
+ : rdfjsResource.Resource.Values.fromValue({
147
+ object: purify.Maybe.empty(),
148
+ predicate: BaseShaclCoreShapeStatic.$properties.datatype["identifier"],
149
+ subject: $resource,
150
+ }))
151
+ .chain((values) => values.head());
81
152
  if (_datatypeEither.isLeft()) {
82
153
  return _datatypeEither;
83
154
  }
84
155
  const datatype = _datatypeEither.unsafeCoerce();
85
- const _deactivatedEither = purify.Either.of(_resource
86
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#deactivated"), { unique: true })
87
- .head()
88
- .chain((_value) => _value.toBoolean())
89
- .toMaybe());
156
+ const _deactivatedEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.deactivated["identifier"], { unique: true }))
157
+ .chain((values) => values.chainMap((value) => value.toBoolean()))
158
+ .map((values) => values.length > 0
159
+ ? values.map((value) => purify.Maybe.of(value))
160
+ : rdfjsResource.Resource.Values.fromValue({
161
+ object: purify.Maybe.empty(),
162
+ predicate: BaseShaclCoreShapeStatic.$properties.deactivated["identifier"],
163
+ subject: $resource,
164
+ }))
165
+ .chain((values) => values.head());
90
166
  if (_deactivatedEither.isLeft()) {
91
167
  return _deactivatedEither;
92
168
  }
93
169
  const deactivated = _deactivatedEither.unsafeCoerce();
94
- const _flagsEither = purify.Either.of([
95
- ..._resource
96
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#flags"), {
97
- unique: true,
98
- })
99
- .flatMap((_item) => _item
100
- .toValues()
101
- .head()
102
- .chain((_value) => _value.toString())
103
- .toMaybe()
104
- .toList()),
105
- ]);
170
+ const _flagsEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.flags["identifier"], { unique: true }))
171
+ .chain((values) => values.chainMap((value) => value.toString()))
172
+ .map((values) => values.toArray())
173
+ .map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
174
+ object: valuesArray,
175
+ predicate: BaseShaclCoreShapeStatic.$properties.flags["identifier"],
176
+ subject: $resource,
177
+ }))
178
+ .chain((values) => values.head());
106
179
  if (_flagsEither.isLeft()) {
107
180
  return _flagsEither;
108
181
  }
109
182
  const flags = _flagsEither.unsafeCoerce();
110
- const _hasValuesEither = purify.Either.of([
111
- ..._resource
112
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#hasValue"), {
113
- unique: true,
114
- })
115
- .flatMap((_item) => _item
116
- .toValues()
117
- .head()
118
- .chain((_value) => purify.Either.of(_value.toTerm()))
119
- .toMaybe()
120
- .toList()),
121
- ]);
183
+ const _hasValuesEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.hasValues["identifier"], { unique: true }))
184
+ .chain((values) => values.chainMap((value) => purify.Either.of(value.toTerm()).chain((term) => {
185
+ switch (term.termType) {
186
+ case "Literal":
187
+ case "NamedNode":
188
+ return purify.Either.of(term);
189
+ default:
190
+ return purify.Left(new rdfjsResource.Resource.MistypedValueError({
191
+ actualValue: term,
192
+ expectedValueType: "(rdfjs.Literal | rdfjs.NamedNode)",
193
+ focusResource: $resource,
194
+ predicate: BaseShaclCoreShapeStatic.$properties.hasValues["identifier"],
195
+ }));
196
+ }
197
+ })))
198
+ .map((values) => values.toArray())
199
+ .map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
200
+ object: valuesArray,
201
+ predicate: BaseShaclCoreShapeStatic.$properties.hasValues["identifier"],
202
+ subject: $resource,
203
+ }))
204
+ .chain((values) => values.head());
122
205
  if (_hasValuesEither.isLeft()) {
123
206
  return _hasValuesEither;
124
207
  }
125
208
  const hasValues = _hasValuesEither.unsafeCoerce();
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());
209
+ const _in_Either = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.in_["identifier"], { unique: true }))
210
+ .chain((values) => values.chainMap((value) => value.toList()))
211
+ .chain((valueLists) => valueLists.chainMap((valueList) => purify.Either.of(rdfjsResource.Resource.Values.fromArray({
212
+ objects: valueList,
213
+ predicate: BaseShaclCoreShapeStatic.$properties.in_["identifier"],
214
+ subject: $resource,
215
+ })).chain((values) => values.chainMap((value) => purify.Either.of(value.toTerm()).chain((term) => {
216
+ switch (term.termType) {
217
+ case "Literal":
218
+ case "NamedNode":
219
+ return purify.Either.of(term);
220
+ default:
221
+ return purify.Left(new rdfjsResource.Resource.MistypedValueError({
222
+ actualValue: term,
223
+ expectedValueType: "(rdfjs.Literal | rdfjs.NamedNode)",
224
+ focusResource: $resource,
225
+ predicate: BaseShaclCoreShapeStatic.$properties.in_["identifier"],
226
+ }));
227
+ }
228
+ })))))
229
+ .map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
230
+ .map((values) => values.length > 0
231
+ ? values.map((value) => purify.Maybe.of(value))
232
+ : rdfjsResource.Resource.Values.fromValue({
233
+ object: purify.Maybe.empty(),
234
+ predicate: BaseShaclCoreShapeStatic.$properties.in_["identifier"],
235
+ subject: $resource,
236
+ }))
237
+ .chain((values) => values.head());
139
238
  if (_in_Either.isLeft()) {
140
239
  return _in_Either;
141
240
  }
142
241
  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());
242
+ const _isDefinedByEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.isDefinedBy["identifier"], { unique: true }))
243
+ .chain((values) => values.chainMap((value) => value.toIdentifier()))
244
+ .map((values) => values.length > 0
245
+ ? values.map((value) => purify.Maybe.of(value))
246
+ : rdfjsResource.Resource.Values.fromValue({
247
+ object: purify.Maybe.empty(),
248
+ predicate: BaseShaclCoreShapeStatic.$properties.isDefinedBy["identifier"],
249
+ subject: $resource,
250
+ }))
251
+ .chain((values) => values.head());
148
252
  if (_isDefinedByEither.isLeft()) {
149
253
  return _isDefinedByEither;
150
254
  }
151
255
  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;
256
+ const _labelsEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.labels["identifier"], { unique: true }))
257
+ .chain((values) => {
258
+ const literalValuesEither = values.chainMap((value) => value.toLiteral());
259
+ if (literalValuesEither.isLeft()) {
260
+ return literalValuesEither;
261
+ }
262
+ const literalValues = literalValuesEither.unsafeCoerce();
263
+ const nonUniqueLanguageIn = $languageIn ?? [];
264
+ if (nonUniqueLanguageIn.length === 0) {
265
+ return purify.Either.of(literalValues);
266
+ }
267
+ let uniqueLanguageIn;
268
+ if (nonUniqueLanguageIn.length === 1) {
269
+ uniqueLanguageIn = [nonUniqueLanguageIn[0]];
270
+ }
271
+ else {
272
+ uniqueLanguageIn = [];
273
+ for (const languageIn of nonUniqueLanguageIn) {
274
+ if (uniqueLanguageIn.indexOf(languageIn) === -1) {
275
+ uniqueLanguageIn.push(languageIn);
276
+ }
277
+ }
278
+ }
279
+ // Return all literals for the first languageIn, then all literals for the second languageIn, etc.
280
+ // Within a languageIn the literals may be in any order.
281
+ let filteredLiteralValues;
282
+ for (const languageIn of uniqueLanguageIn) {
283
+ if (!filteredLiteralValues) {
284
+ filteredLiteralValues = literalValues.filter((value) => value.language === languageIn);
161
285
  }
162
- const _valueLiteral = _value.toLiteral().toMaybe().extract();
163
- if (typeof _valueLiteral === "undefined") {
164
- return false;
286
+ else {
287
+ filteredLiteralValues = filteredLiteralValues.concat(...literalValues
288
+ .filter((value) => value.language === languageIn)
289
+ .toArray());
165
290
  }
166
- return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
167
- })
168
- .head()
169
- .chain((_value) => _value.toLiteral())
170
- .toMaybe()
171
- .toList()),
172
- ]);
291
+ }
292
+ return purify.Either.of(filteredLiteralValues);
293
+ })
294
+ .map((values) => values.toArray())
295
+ .map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
296
+ object: valuesArray,
297
+ predicate: BaseShaclCoreShapeStatic.$properties.labels["identifier"],
298
+ subject: $resource,
299
+ }))
300
+ .chain((values) => values.head());
173
301
  if (_labelsEither.isLeft()) {
174
302
  return _labelsEither;
175
303
  }
176
304
  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());
305
+ const _languageInEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.languageIn["identifier"], { unique: true }))
306
+ .chain((values) => values.chainMap((value) => value.toList()))
307
+ .chain((valueLists) => valueLists.chainMap((valueList) => purify.Either.of(rdfjsResource.Resource.Values.fromArray({
308
+ objects: valueList,
309
+ predicate: BaseShaclCoreShapeStatic.$properties.languageIn["identifier"],
310
+ subject: $resource,
311
+ })).chain((values) => values.chainMap((value) => value.toString()))))
312
+ .map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
313
+ .map((values) => values.length > 0
314
+ ? values.map((value) => purify.Maybe.of(value))
315
+ : rdfjsResource.Resource.Values.fromValue({
316
+ object: purify.Maybe.empty(),
317
+ predicate: BaseShaclCoreShapeStatic.$properties.languageIn["identifier"],
318
+ subject: $resource,
319
+ }))
320
+ .chain((values) => values.head());
188
321
  if (_languageInEither.isLeft()) {
189
322
  return _languageInEither;
190
323
  }
191
324
  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());
325
+ const _maxCountEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.maxCount["identifier"], { unique: true }))
326
+ .chain((values) => values.chainMap((value) => value.toNumber()))
327
+ .map((values) => values.length > 0
328
+ ? values.map((value) => purify.Maybe.of(value))
329
+ : rdfjsResource.Resource.Values.fromValue({
330
+ object: purify.Maybe.empty(),
331
+ predicate: BaseShaclCoreShapeStatic.$properties.maxCount["identifier"],
332
+ subject: $resource,
333
+ }))
334
+ .chain((values) => values.head());
199
335
  if (_maxCountEither.isLeft()) {
200
336
  return _maxCountEither;
201
337
  }
202
338
  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);
339
+ const _maxExclusiveEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.maxExclusive["identifier"], {
340
+ unique: true,
341
+ }))
342
+ .chain((values) => {
343
+ const literalValuesEither = values.chainMap((value) => value.toLiteral());
344
+ if (literalValuesEither.isLeft()) {
345
+ return literalValuesEither;
346
+ }
347
+ const literalValues = literalValuesEither.unsafeCoerce();
348
+ const nonUniqueLanguageIn = $languageIn ?? [];
349
+ if (nonUniqueLanguageIn.length === 0) {
350
+ return purify.Either.of(literalValues);
351
+ }
352
+ let uniqueLanguageIn;
353
+ if (nonUniqueLanguageIn.length === 1) {
354
+ uniqueLanguageIn = [nonUniqueLanguageIn[0]];
355
+ }
356
+ else {
357
+ uniqueLanguageIn = [];
358
+ for (const languageIn of nonUniqueLanguageIn) {
359
+ if (uniqueLanguageIn.indexOf(languageIn) === -1) {
360
+ uniqueLanguageIn.push(languageIn);
361
+ }
362
+ }
363
+ }
364
+ // Return all literals for the first languageIn, then all literals for the second languageIn, etc.
365
+ // Within a languageIn the literals may be in any order.
366
+ let filteredLiteralValues;
367
+ for (const languageIn of uniqueLanguageIn) {
368
+ if (!filteredLiteralValues) {
369
+ filteredLiteralValues = literalValues.filter((value) => value.language === languageIn);
370
+ }
371
+ else {
372
+ filteredLiteralValues = filteredLiteralValues.concat(...literalValues
373
+ .filter((value) => value.language === languageIn)
374
+ .toArray());
375
+ }
376
+ }
377
+ return purify.Either.of(filteredLiteralValues);
215
378
  })
216
- .head()
217
- .chain((_value) => _value.toLiteral())
218
- .toMaybe());
379
+ .map((values) => values.length > 0
380
+ ? values.map((value) => purify.Maybe.of(value))
381
+ : rdfjsResource.Resource.Values.fromValue({
382
+ object: purify.Maybe.empty(),
383
+ predicate: BaseShaclCoreShapeStatic.$properties.maxExclusive["identifier"],
384
+ subject: $resource,
385
+ }))
386
+ .chain((values) => values.head());
219
387
  if (_maxExclusiveEither.isLeft()) {
220
388
  return _maxExclusiveEither;
221
389
  }
222
390
  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);
391
+ const _maxInclusiveEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.maxInclusive["identifier"], {
392
+ unique: true,
393
+ }))
394
+ .chain((values) => {
395
+ const literalValuesEither = values.chainMap((value) => value.toLiteral());
396
+ if (literalValuesEither.isLeft()) {
397
+ return literalValuesEither;
398
+ }
399
+ const literalValues = literalValuesEither.unsafeCoerce();
400
+ const nonUniqueLanguageIn = $languageIn ?? [];
401
+ if (nonUniqueLanguageIn.length === 0) {
402
+ return purify.Either.of(literalValues);
403
+ }
404
+ let uniqueLanguageIn;
405
+ if (nonUniqueLanguageIn.length === 1) {
406
+ uniqueLanguageIn = [nonUniqueLanguageIn[0]];
407
+ }
408
+ else {
409
+ uniqueLanguageIn = [];
410
+ for (const languageIn of nonUniqueLanguageIn) {
411
+ if (uniqueLanguageIn.indexOf(languageIn) === -1) {
412
+ uniqueLanguageIn.push(languageIn);
413
+ }
414
+ }
415
+ }
416
+ // Return all literals for the first languageIn, then all literals for the second languageIn, etc.
417
+ // Within a languageIn the literals may be in any order.
418
+ let filteredLiteralValues;
419
+ for (const languageIn of uniqueLanguageIn) {
420
+ if (!filteredLiteralValues) {
421
+ filteredLiteralValues = literalValues.filter((value) => value.language === languageIn);
422
+ }
423
+ else {
424
+ filteredLiteralValues = filteredLiteralValues.concat(...literalValues
425
+ .filter((value) => value.language === languageIn)
426
+ .toArray());
427
+ }
428
+ }
429
+ return purify.Either.of(filteredLiteralValues);
235
430
  })
236
- .head()
237
- .chain((_value) => _value.toLiteral())
238
- .toMaybe());
431
+ .map((values) => values.length > 0
432
+ ? values.map((value) => purify.Maybe.of(value))
433
+ : rdfjsResource.Resource.Values.fromValue({
434
+ object: purify.Maybe.empty(),
435
+ predicate: BaseShaclCoreShapeStatic.$properties.maxInclusive["identifier"],
436
+ subject: $resource,
437
+ }))
438
+ .chain((values) => values.head());
239
439
  if (_maxInclusiveEither.isLeft()) {
240
440
  return _maxInclusiveEither;
241
441
  }
242
442
  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());
443
+ const _maxLengthEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.maxLength["identifier"], { unique: true }))
444
+ .chain((values) => values.chainMap((value) => value.toNumber()))
445
+ .map((values) => values.length > 0
446
+ ? values.map((value) => purify.Maybe.of(value))
447
+ : rdfjsResource.Resource.Values.fromValue({
448
+ object: purify.Maybe.empty(),
449
+ predicate: BaseShaclCoreShapeStatic.$properties.maxLength["identifier"],
450
+ subject: $resource,
451
+ }))
452
+ .chain((values) => values.head());
250
453
  if (_maxLengthEither.isLeft()) {
251
454
  return _maxLengthEither;
252
455
  }
253
456
  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());
457
+ const _minCountEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.minCount["identifier"], { unique: true }))
458
+ .chain((values) => values.chainMap((value) => value.toNumber()))
459
+ .map((values) => values.length > 0
460
+ ? values.map((value) => purify.Maybe.of(value))
461
+ : rdfjsResource.Resource.Values.fromValue({
462
+ object: purify.Maybe.empty(),
463
+ predicate: BaseShaclCoreShapeStatic.$properties.minCount["identifier"],
464
+ subject: $resource,
465
+ }))
466
+ .chain((values) => values.head());
261
467
  if (_minCountEither.isLeft()) {
262
468
  return _minCountEither;
263
469
  }
264
470
  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);
471
+ const _minExclusiveEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.minExclusive["identifier"], {
472
+ unique: true,
473
+ }))
474
+ .chain((values) => {
475
+ const literalValuesEither = values.chainMap((value) => value.toLiteral());
476
+ if (literalValuesEither.isLeft()) {
477
+ return literalValuesEither;
478
+ }
479
+ const literalValues = literalValuesEither.unsafeCoerce();
480
+ const nonUniqueLanguageIn = $languageIn ?? [];
481
+ if (nonUniqueLanguageIn.length === 0) {
482
+ return purify.Either.of(literalValues);
483
+ }
484
+ let uniqueLanguageIn;
485
+ if (nonUniqueLanguageIn.length === 1) {
486
+ uniqueLanguageIn = [nonUniqueLanguageIn[0]];
487
+ }
488
+ else {
489
+ uniqueLanguageIn = [];
490
+ for (const languageIn of nonUniqueLanguageIn) {
491
+ if (uniqueLanguageIn.indexOf(languageIn) === -1) {
492
+ uniqueLanguageIn.push(languageIn);
493
+ }
494
+ }
495
+ }
496
+ // Return all literals for the first languageIn, then all literals for the second languageIn, etc.
497
+ // Within a languageIn the literals may be in any order.
498
+ let filteredLiteralValues;
499
+ for (const languageIn of uniqueLanguageIn) {
500
+ if (!filteredLiteralValues) {
501
+ filteredLiteralValues = literalValues.filter((value) => value.language === languageIn);
502
+ }
503
+ else {
504
+ filteredLiteralValues = filteredLiteralValues.concat(...literalValues
505
+ .filter((value) => value.language === languageIn)
506
+ .toArray());
507
+ }
508
+ }
509
+ return purify.Either.of(filteredLiteralValues);
277
510
  })
278
- .head()
279
- .chain((_value) => _value.toLiteral())
280
- .toMaybe());
511
+ .map((values) => values.length > 0
512
+ ? values.map((value) => purify.Maybe.of(value))
513
+ : rdfjsResource.Resource.Values.fromValue({
514
+ object: purify.Maybe.empty(),
515
+ predicate: BaseShaclCoreShapeStatic.$properties.minExclusive["identifier"],
516
+ subject: $resource,
517
+ }))
518
+ .chain((values) => values.head());
281
519
  if (_minExclusiveEither.isLeft()) {
282
520
  return _minExclusiveEither;
283
521
  }
284
522
  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);
523
+ const _minInclusiveEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.minInclusive["identifier"], {
524
+ unique: true,
525
+ }))
526
+ .chain((values) => {
527
+ const literalValuesEither = values.chainMap((value) => value.toLiteral());
528
+ if (literalValuesEither.isLeft()) {
529
+ return literalValuesEither;
530
+ }
531
+ const literalValues = literalValuesEither.unsafeCoerce();
532
+ const nonUniqueLanguageIn = $languageIn ?? [];
533
+ if (nonUniqueLanguageIn.length === 0) {
534
+ return purify.Either.of(literalValues);
535
+ }
536
+ let uniqueLanguageIn;
537
+ if (nonUniqueLanguageIn.length === 1) {
538
+ uniqueLanguageIn = [nonUniqueLanguageIn[0]];
539
+ }
540
+ else {
541
+ uniqueLanguageIn = [];
542
+ for (const languageIn of nonUniqueLanguageIn) {
543
+ if (uniqueLanguageIn.indexOf(languageIn) === -1) {
544
+ uniqueLanguageIn.push(languageIn);
545
+ }
546
+ }
547
+ }
548
+ // Return all literals for the first languageIn, then all literals for the second languageIn, etc.
549
+ // Within a languageIn the literals may be in any order.
550
+ let filteredLiteralValues;
551
+ for (const languageIn of uniqueLanguageIn) {
552
+ if (!filteredLiteralValues) {
553
+ filteredLiteralValues = literalValues.filter((value) => value.language === languageIn);
554
+ }
555
+ else {
556
+ filteredLiteralValues = filteredLiteralValues.concat(...literalValues
557
+ .filter((value) => value.language === languageIn)
558
+ .toArray());
559
+ }
560
+ }
561
+ return purify.Either.of(filteredLiteralValues);
297
562
  })
298
- .head()
299
- .chain((_value) => _value.toLiteral())
300
- .toMaybe());
563
+ .map((values) => values.length > 0
564
+ ? values.map((value) => purify.Maybe.of(value))
565
+ : rdfjsResource.Resource.Values.fromValue({
566
+ object: purify.Maybe.empty(),
567
+ predicate: BaseShaclCoreShapeStatic.$properties.minInclusive["identifier"],
568
+ subject: $resource,
569
+ }))
570
+ .chain((values) => values.head());
301
571
  if (_minInclusiveEither.isLeft()) {
302
572
  return _minInclusiveEither;
303
573
  }
304
574
  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());
575
+ const _minLengthEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.minLength["identifier"], { unique: true }))
576
+ .chain((values) => values.chainMap((value) => value.toNumber()))
577
+ .map((values) => values.length > 0
578
+ ? values.map((value) => purify.Maybe.of(value))
579
+ : rdfjsResource.Resource.Values.fromValue({
580
+ object: purify.Maybe.empty(),
581
+ predicate: BaseShaclCoreShapeStatic.$properties.minLength["identifier"],
582
+ subject: $resource,
583
+ }))
584
+ .chain((values) => values.head());
312
585
  if (_minLengthEither.isLeft()) {
313
586
  return _minLengthEither;
314
587
  }
315
588
  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) => {
589
+ const _nodeKindEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.nodeKind["identifier"], { unique: true }))
590
+ .chain((values) => values.chainMap((value) => value.toIri().chain((iri) => {
322
591
  switch (iri.value) {
323
592
  case "http://www.w3.org/ns/shacl#BlankNode":
324
593
  return purify.Either.of(iri);
@@ -336,110 +605,102 @@ export var BaseShaclCoreShape;
336
605
  return purify.Left(new rdfjsResource.Resource.MistypedValueError({
337
606
  actualValue: iri,
338
607
  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"),
608
+ focusResource: $resource,
609
+ predicate: BaseShaclCoreShapeStatic.$properties.nodeKind["identifier"],
341
610
  }));
342
611
  }
343
- }))
344
- .toMaybe());
612
+ })))
613
+ .map((values) => values.length > 0
614
+ ? values.map((value) => purify.Maybe.of(value))
615
+ : rdfjsResource.Resource.Values.fromValue({
616
+ object: purify.Maybe.empty(),
617
+ predicate: BaseShaclCoreShapeStatic.$properties.nodeKind["identifier"],
618
+ subject: $resource,
619
+ }))
620
+ .chain((values) => values.head());
345
621
  if (_nodeKindEither.isLeft()) {
346
622
  return _nodeKindEither;
347
623
  }
348
624
  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
- ]);
625
+ const _nodesEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.nodes["identifier"], { unique: true }))
626
+ .chain((values) => values.chainMap((value) => value.toIdentifier()))
627
+ .map((values) => values.toArray())
628
+ .map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
629
+ object: valuesArray,
630
+ predicate: BaseShaclCoreShapeStatic.$properties.nodes["identifier"],
631
+ subject: $resource,
632
+ }))
633
+ .chain((values) => values.head());
361
634
  if (_nodesEither.isLeft()) {
362
635
  return _nodesEither;
363
636
  }
364
637
  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
- ]);
638
+ const _notEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.not["identifier"], { unique: true }))
639
+ .chain((values) => values.chainMap((value) => value.toIdentifier()))
640
+ .map((values) => values.toArray())
641
+ .map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
642
+ object: valuesArray,
643
+ predicate: BaseShaclCoreShapeStatic.$properties.not["identifier"],
644
+ subject: $resource,
645
+ }))
646
+ .chain((values) => values.head());
377
647
  if (_notEither.isLeft()) {
378
648
  return _notEither;
379
649
  }
380
650
  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
- ]);
651
+ const _orEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.or["identifier"], { unique: true }))
652
+ .chain((values) => values.chainMap((value) => value.toList()))
653
+ .chain((valueLists) => valueLists.chainMap((valueList) => purify.Either.of(rdfjsResource.Resource.Values.fromArray({
654
+ objects: valueList,
655
+ predicate: BaseShaclCoreShapeStatic.$properties.or["identifier"],
656
+ subject: $resource,
657
+ })).chain((values) => values.chainMap((value) => value.toIdentifier()))))
658
+ .map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
659
+ .map((values) => values.toArray())
660
+ .map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
661
+ object: valuesArray,
662
+ predicate: BaseShaclCoreShapeStatic.$properties.or["identifier"],
663
+ subject: $resource,
664
+ }))
665
+ .chain((values) => values.head());
399
666
  if (_orEither.isLeft()) {
400
667
  return _orEither;
401
668
  }
402
669
  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
- ]);
670
+ const _patternsEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.patterns["identifier"], { unique: true }))
671
+ .chain((values) => values.chainMap((value) => value.toString()))
672
+ .map((values) => values.toArray())
673
+ .map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
674
+ object: valuesArray,
675
+ predicate: BaseShaclCoreShapeStatic.$properties.patterns["identifier"],
676
+ subject: $resource,
677
+ }))
678
+ .chain((values) => values.head());
415
679
  if (_patternsEither.isLeft()) {
416
680
  return _patternsEither;
417
681
  }
418
682
  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
- ]);
683
+ const _xoneEither = purify.Either.of($resource.values(BaseShaclCoreShapeStatic.$properties.xone["identifier"], { unique: true }))
684
+ .chain((values) => values.chainMap((value) => value.toList()))
685
+ .chain((valueLists) => valueLists.chainMap((valueList) => purify.Either.of(rdfjsResource.Resource.Values.fromArray({
686
+ objects: valueList,
687
+ predicate: BaseShaclCoreShapeStatic.$properties.xone["identifier"],
688
+ subject: $resource,
689
+ })).chain((values) => values.chainMap((value) => value.toIdentifier()))))
690
+ .map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
691
+ .map((values) => values.toArray())
692
+ .map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
693
+ object: valuesArray,
694
+ predicate: BaseShaclCoreShapeStatic.$properties.xone["identifier"],
695
+ subject: $resource,
696
+ }))
697
+ .chain((values) => values.head());
437
698
  if (_xoneEither.isLeft()) {
438
699
  return _xoneEither;
439
700
  }
440
701
  const xone = _xoneEither.unsafeCoerce();
441
702
  return purify.Either.of({
442
- identifier,
703
+ $identifier,
443
704
  and,
444
705
  classes,
445
706
  comments,
@@ -467,150 +728,442 @@ export var BaseShaclCoreShape;
467
728
  xone,
468
729
  });
469
730
  }
470
- BaseShaclCoreShape._propertiesFromRdf = _propertiesFromRdf;
471
- })(BaseShaclCoreShape || (BaseShaclCoreShape = {}));
472
- export var ShaclCorePropertyShape;
473
- (function (ShaclCorePropertyShape) {
474
- function _propertiesFromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource,
731
+ BaseShaclCoreShapeStatic.$propertiesFromRdf = $propertiesFromRdf;
732
+ function $toRdf(_baseShaclCoreShape, options) {
733
+ const mutateGraph = options?.mutateGraph;
734
+ const resourceSet = options?.resourceSet ??
735
+ new rdfjsResource.MutableResourceSet({
736
+ dataFactory,
737
+ dataset: datasetFactory.dataset(),
738
+ });
739
+ const resource = resourceSet.mutableResource(_baseShaclCoreShape.$identifier, { mutateGraph });
740
+ resource.add(BaseShaclCoreShapeStatic.$properties.and["identifier"], _baseShaclCoreShape.and.map((item) => item.length > 0
741
+ ? item.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
742
+ if (itemIndex === 0) {
743
+ currentSubListResource = listResource;
744
+ }
745
+ else {
746
+ const newSubListResource = resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph });
747
+ currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier);
748
+ currentSubListResource = newSubListResource;
749
+ }
750
+ currentSubListResource.add($RdfVocabularies.rdf.first, item);
751
+ if (itemIndex + 1 === list.length) {
752
+ currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil);
753
+ }
754
+ return { currentSubListResource, listResource };
755
+ }, {
756
+ currentSubListResource: null,
757
+ listResource: resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph }),
758
+ }).listResource.identifier
759
+ : $RdfVocabularies.rdf.nil));
760
+ resource.add(BaseShaclCoreShapeStatic.$properties.classes["identifier"], _baseShaclCoreShape.classes.map((item) => item));
761
+ resource.add(BaseShaclCoreShapeStatic.$properties.comments["identifier"], _baseShaclCoreShape.comments.map((item) => item));
762
+ resource.add(BaseShaclCoreShapeStatic.$properties.datatype["identifier"], _baseShaclCoreShape.datatype);
763
+ resource.add(BaseShaclCoreShapeStatic.$properties.deactivated["identifier"], _baseShaclCoreShape.deactivated);
764
+ resource.add(BaseShaclCoreShapeStatic.$properties.flags["identifier"], _baseShaclCoreShape.flags.map((item) => item));
765
+ resource.add(BaseShaclCoreShapeStatic.$properties.hasValues["identifier"], _baseShaclCoreShape.hasValues.map((item) => item));
766
+ resource.add(BaseShaclCoreShapeStatic.$properties.in_["identifier"], _baseShaclCoreShape.in_.map((value) => value.length > 0
767
+ ? value.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
768
+ if (itemIndex === 0) {
769
+ currentSubListResource = listResource;
770
+ }
771
+ else {
772
+ const newSubListResource = resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph });
773
+ currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier);
774
+ currentSubListResource = newSubListResource;
775
+ }
776
+ currentSubListResource.add($RdfVocabularies.rdf.first, item);
777
+ if (itemIndex + 1 === list.length) {
778
+ currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil);
779
+ }
780
+ return { currentSubListResource, listResource };
781
+ }, {
782
+ currentSubListResource: null,
783
+ listResource: resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph }),
784
+ }).listResource.identifier
785
+ : $RdfVocabularies.rdf.nil));
786
+ resource.add(BaseShaclCoreShapeStatic.$properties.isDefinedBy["identifier"], _baseShaclCoreShape.isDefinedBy);
787
+ resource.add(BaseShaclCoreShapeStatic.$properties.labels["identifier"], _baseShaclCoreShape.labels.map((item) => item));
788
+ resource.add(BaseShaclCoreShapeStatic.$properties.languageIn["identifier"], _baseShaclCoreShape.languageIn.map((value) => value.length > 0
789
+ ? value.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
790
+ if (itemIndex === 0) {
791
+ currentSubListResource = listResource;
792
+ }
793
+ else {
794
+ const newSubListResource = resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph });
795
+ currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier);
796
+ currentSubListResource = newSubListResource;
797
+ }
798
+ currentSubListResource.add($RdfVocabularies.rdf.first, item);
799
+ if (itemIndex + 1 === list.length) {
800
+ currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil);
801
+ }
802
+ return { currentSubListResource, listResource };
803
+ }, {
804
+ currentSubListResource: null,
805
+ listResource: resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph }),
806
+ }).listResource.identifier
807
+ : $RdfVocabularies.rdf.nil));
808
+ resource.add(BaseShaclCoreShapeStatic.$properties.maxCount["identifier"], _baseShaclCoreShape.maxCount);
809
+ resource.add(BaseShaclCoreShapeStatic.$properties.maxExclusive["identifier"], _baseShaclCoreShape.maxExclusive);
810
+ resource.add(BaseShaclCoreShapeStatic.$properties.maxInclusive["identifier"], _baseShaclCoreShape.maxInclusive);
811
+ resource.add(BaseShaclCoreShapeStatic.$properties.maxLength["identifier"], _baseShaclCoreShape.maxLength);
812
+ resource.add(BaseShaclCoreShapeStatic.$properties.minCount["identifier"], _baseShaclCoreShape.minCount);
813
+ resource.add(BaseShaclCoreShapeStatic.$properties.minExclusive["identifier"], _baseShaclCoreShape.minExclusive);
814
+ resource.add(BaseShaclCoreShapeStatic.$properties.minInclusive["identifier"], _baseShaclCoreShape.minInclusive);
815
+ resource.add(BaseShaclCoreShapeStatic.$properties.minLength["identifier"], _baseShaclCoreShape.minLength);
816
+ resource.add(BaseShaclCoreShapeStatic.$properties.nodeKind["identifier"], _baseShaclCoreShape.nodeKind);
817
+ resource.add(BaseShaclCoreShapeStatic.$properties.nodes["identifier"], _baseShaclCoreShape.nodes.map((item) => item));
818
+ resource.add(BaseShaclCoreShapeStatic.$properties.not["identifier"], _baseShaclCoreShape.not.map((item) => item));
819
+ resource.add(BaseShaclCoreShapeStatic.$properties.or["identifier"], _baseShaclCoreShape.or.map((item) => item.length > 0
820
+ ? item.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
821
+ if (itemIndex === 0) {
822
+ currentSubListResource = listResource;
823
+ }
824
+ else {
825
+ const newSubListResource = resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph });
826
+ currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier);
827
+ currentSubListResource = newSubListResource;
828
+ }
829
+ currentSubListResource.add($RdfVocabularies.rdf.first, item);
830
+ if (itemIndex + 1 === list.length) {
831
+ currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil);
832
+ }
833
+ return { currentSubListResource, listResource };
834
+ }, {
835
+ currentSubListResource: null,
836
+ listResource: resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph }),
837
+ }).listResource.identifier
838
+ : $RdfVocabularies.rdf.nil));
839
+ resource.add(BaseShaclCoreShapeStatic.$properties.patterns["identifier"], _baseShaclCoreShape.patterns.map((item) => item));
840
+ resource.add(BaseShaclCoreShapeStatic.$properties.xone["identifier"], _baseShaclCoreShape.xone.map((item) => item.length > 0
841
+ ? item.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
842
+ if (itemIndex === 0) {
843
+ currentSubListResource = listResource;
844
+ }
845
+ else {
846
+ const newSubListResource = resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph });
847
+ currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier);
848
+ currentSubListResource = newSubListResource;
849
+ }
850
+ currentSubListResource.add($RdfVocabularies.rdf.first, item);
851
+ if (itemIndex + 1 === list.length) {
852
+ currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil);
853
+ }
854
+ return { currentSubListResource, listResource };
855
+ }, {
856
+ currentSubListResource: null,
857
+ listResource: resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph }),
858
+ }).listResource.identifier
859
+ : $RdfVocabularies.rdf.nil));
860
+ return resource;
861
+ }
862
+ BaseShaclCoreShapeStatic.$toRdf = $toRdf;
863
+ BaseShaclCoreShapeStatic.$properties = {
864
+ and: {
865
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#and"),
866
+ },
867
+ classes: {
868
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#class"),
869
+ },
870
+ comments: {
871
+ identifier: dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#comment"),
872
+ },
873
+ datatype: {
874
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#datatype"),
875
+ },
876
+ deactivated: {
877
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#deactivated"),
878
+ },
879
+ flags: {
880
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#flags"),
881
+ },
882
+ hasValues: {
883
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#hasValue"),
884
+ },
885
+ in_: { identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#in") },
886
+ isDefinedBy: {
887
+ identifier: dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#isDefinedBy"),
888
+ },
889
+ labels: {
890
+ identifier: dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#label"),
891
+ },
892
+ languageIn: {
893
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#languageIn"),
894
+ },
895
+ maxCount: {
896
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#maxCount"),
897
+ },
898
+ maxExclusive: {
899
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#maxExclusive"),
900
+ },
901
+ maxInclusive: {
902
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#maxInclusive"),
903
+ },
904
+ maxLength: {
905
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#maxLength"),
906
+ },
907
+ minCount: {
908
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#minCount"),
909
+ },
910
+ minExclusive: {
911
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#minExclusive"),
912
+ },
913
+ minInclusive: {
914
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#minInclusive"),
915
+ },
916
+ minLength: {
917
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#minLength"),
918
+ },
919
+ nodeKind: {
920
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#nodeKind"),
921
+ },
922
+ nodes: {
923
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#node"),
924
+ },
925
+ not: {
926
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#not"),
927
+ },
928
+ or: { identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#or") },
929
+ patterns: {
930
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#pattern"),
931
+ },
932
+ xone: {
933
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#xone"),
934
+ },
935
+ };
936
+ })(BaseShaclCoreShapeStatic || (BaseShaclCoreShapeStatic = {}));
937
+ export var ShaclCorePropertyShapeStatic;
938
+ (function (ShaclCorePropertyShapeStatic) {
939
+ ShaclCorePropertyShapeStatic.$fromRdfType = dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyShape");
940
+ ShaclCorePropertyShapeStatic.$Identifier = BaseShaclCoreShapeStatic.$Identifier;
941
+ function $fromRdf(resource, options) {
942
+ let { ignoreRdfType = false, languageIn, objectSet, ...context } = options ?? {};
943
+ if (!objectSet) {
944
+ objectSet = new $RdfjsDatasetObjectSet({ dataset: resource.dataset });
945
+ }
946
+ return ShaclmatePropertyShape.$fromRdf(resource, {
947
+ ...context,
948
+ ignoreRdfType: false,
949
+ objectSet,
950
+ }).altLazy(() => ShaclCorePropertyShapeStatic.$propertiesFromRdf({
951
+ ...context,
952
+ ignoreRdfType,
953
+ languageIn,
954
+ objectSet,
955
+ resource,
956
+ }));
957
+ }
958
+ ShaclCorePropertyShapeStatic.$fromRdf = $fromRdf;
959
+ function $propertiesFromRdf({ ignoreRdfType: $ignoreRdfType, languageIn: $languageIn, objectSet: $objectSet, resource: $resource,
475
960
  // @ts-ignore
476
- ..._context }) {
477
- const _super0Either = BaseShaclCoreShape._propertiesFromRdf({
478
- ..._context,
961
+ ...$context }) {
962
+ const $super0Either = BaseShaclCoreShapeStatic.$propertiesFromRdf({
963
+ ...$context,
479
964
  ignoreRdfType: true,
480
- languageIn: _languageIn,
481
- resource: _resource,
965
+ languageIn: $languageIn,
966
+ objectSet: $objectSet,
967
+ resource: $resource,
482
968
  });
483
- if (_super0Either.isLeft()) {
484
- return _super0Either;
485
- }
486
- const _super0 = _super0Either.unsafeCoerce();
487
- if (!_ignoreRdfType &&
488
- !_resource.isInstanceOf(dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyShape"))) {
489
- return purify.Left(new rdfjsResource.Resource.ValueError({
490
- focusResource: _resource,
491
- message: `${rdfjsResource.Resource.Identifier.toString(_resource.identifier)} has unexpected RDF type`,
492
- predicate: dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyShape"),
493
- }));
494
- }
495
- const identifier = _resource.identifier;
496
- const type = "ShaclCorePropertyShape";
497
- const _defaultValueEither = purify.Either.of(_resource
498
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#defaultValue"), { unique: true })
499
- .head()
500
- .chain((_value) => purify.Either.of(_value.toTerm()))
501
- .toMaybe());
969
+ if ($super0Either.isLeft()) {
970
+ return $super0Either;
971
+ }
972
+ const $super0 = $super0Either.unsafeCoerce();
973
+ if (!$ignoreRdfType && !$resource.isInstanceOf(ShaclCorePropertyShapeStatic.$fromRdfType)) {
974
+ return $resource
975
+ .value($RdfVocabularies.rdf.type)
976
+ .chain((actualRdfType) => actualRdfType.toIri())
977
+ .chain((actualRdfType) => purify.Left(new Error(`${rdfjsResource.Resource.Identifier.toString($resource.identifier)} has unexpected RDF type (actual: ${actualRdfType.value}, expected: http://www.w3.org/ns/shacl#PropertyShape)`)));
978
+ }
979
+ const $identifier = $resource.identifier;
980
+ const $type = "ShaclCorePropertyShape";
981
+ const _defaultValueEither = purify.Either.of($resource.values(ShaclCorePropertyShapeStatic.$properties.defaultValue["identifier"], {
982
+ unique: true,
983
+ }))
984
+ .chain((values) => values.chainMap((value) => purify.Either.of(value.toTerm()).chain((term) => {
985
+ switch (term.termType) {
986
+ case "Literal":
987
+ case "NamedNode":
988
+ return purify.Either.of(term);
989
+ default:
990
+ return purify.Left(new rdfjsResource.Resource.MistypedValueError({
991
+ actualValue: term,
992
+ expectedValueType: "(rdfjs.Literal | rdfjs.NamedNode)",
993
+ focusResource: $resource,
994
+ predicate: ShaclCorePropertyShapeStatic.$properties.defaultValue["identifier"],
995
+ }));
996
+ }
997
+ })))
998
+ .map((values) => values.length > 0
999
+ ? values.map((value) => purify.Maybe.of(value))
1000
+ : rdfjsResource.Resource.Values.fromValue({
1001
+ object: purify.Maybe.empty(),
1002
+ predicate: ShaclCorePropertyShapeStatic.$properties.defaultValue["identifier"],
1003
+ subject: $resource,
1004
+ }))
1005
+ .chain((values) => values.head());
502
1006
  if (_defaultValueEither.isLeft()) {
503
1007
  return _defaultValueEither;
504
1008
  }
505
1009
  const defaultValue = _defaultValueEither.unsafeCoerce();
506
- const _descriptionsEither = purify.Either.of([
507
- ..._resource
508
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#description"), { unique: true })
509
- .flatMap((_item) => _item
510
- .toValues()
511
- .filter((_value) => {
512
- const _languageInOrDefault = _languageIn ?? [];
513
- if (_languageInOrDefault.length === 0) {
514
- return true;
1010
+ const _descriptionsEither = purify.Either.of($resource.values(ShaclCorePropertyShapeStatic.$properties.descriptions["identifier"], {
1011
+ unique: true,
1012
+ }))
1013
+ .chain((values) => {
1014
+ const literalValuesEither = values.chainMap((value) => value.toLiteral());
1015
+ if (literalValuesEither.isLeft()) {
1016
+ return literalValuesEither;
1017
+ }
1018
+ const literalValues = literalValuesEither.unsafeCoerce();
1019
+ const nonUniqueLanguageIn = $languageIn ?? [];
1020
+ if (nonUniqueLanguageIn.length === 0) {
1021
+ return purify.Either.of(literalValues);
1022
+ }
1023
+ let uniqueLanguageIn;
1024
+ if (nonUniqueLanguageIn.length === 1) {
1025
+ uniqueLanguageIn = [nonUniqueLanguageIn[0]];
1026
+ }
1027
+ else {
1028
+ uniqueLanguageIn = [];
1029
+ for (const languageIn of nonUniqueLanguageIn) {
1030
+ if (uniqueLanguageIn.indexOf(languageIn) === -1) {
1031
+ uniqueLanguageIn.push(languageIn);
1032
+ }
1033
+ }
1034
+ }
1035
+ // Return all literals for the first languageIn, then all literals for the second languageIn, etc.
1036
+ // Within a languageIn the literals may be in any order.
1037
+ let filteredLiteralValues;
1038
+ for (const languageIn of uniqueLanguageIn) {
1039
+ if (!filteredLiteralValues) {
1040
+ filteredLiteralValues = literalValues.filter((value) => value.language === languageIn);
515
1041
  }
516
- const _valueLiteral = _value.toLiteral().toMaybe().extract();
517
- if (typeof _valueLiteral === "undefined") {
518
- return false;
1042
+ else {
1043
+ filteredLiteralValues = filteredLiteralValues.concat(...literalValues
1044
+ .filter((value) => value.language === languageIn)
1045
+ .toArray());
519
1046
  }
520
- return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
521
- })
522
- .head()
523
- .chain((_value) => _value.toLiteral())
524
- .toMaybe()
525
- .toList()),
526
- ]);
1047
+ }
1048
+ return purify.Either.of(filteredLiteralValues);
1049
+ })
1050
+ .map((values) => values.toArray())
1051
+ .map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
1052
+ object: valuesArray,
1053
+ predicate: ShaclCorePropertyShapeStatic.$properties.descriptions["identifier"],
1054
+ subject: $resource,
1055
+ }))
1056
+ .chain((values) => values.head());
527
1057
  if (_descriptionsEither.isLeft()) {
528
1058
  return _descriptionsEither;
529
1059
  }
530
1060
  const descriptions = _descriptionsEither.unsafeCoerce();
531
- const _groupsEither = purify.Either.of([
532
- ..._resource
533
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#group"), {
534
- unique: true,
535
- })
536
- .flatMap((_item) => _item
537
- .toValues()
538
- .head()
539
- .chain((_value) => _value.toIdentifier())
540
- .toMaybe()
541
- .toList()),
542
- ]);
1061
+ const _groupsEither = purify.Either.of($resource.values(ShaclCorePropertyShapeStatic.$properties.groups["identifier"], { unique: true }))
1062
+ .chain((values) => values.chainMap((value) => value.toIdentifier()))
1063
+ .map((values) => values.toArray())
1064
+ .map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
1065
+ object: valuesArray,
1066
+ predicate: ShaclCorePropertyShapeStatic.$properties.groups["identifier"],
1067
+ subject: $resource,
1068
+ }))
1069
+ .chain((values) => values.head());
543
1070
  if (_groupsEither.isLeft()) {
544
1071
  return _groupsEither;
545
1072
  }
546
1073
  const groups = _groupsEither.unsafeCoerce();
547
- const _namesEither = purify.Either.of([
548
- ..._resource
549
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#name"), {
550
- unique: true,
551
- })
552
- .flatMap((_item) => _item
553
- .toValues()
554
- .filter((_value) => {
555
- const _languageInOrDefault = _languageIn ?? [];
556
- if (_languageInOrDefault.length === 0) {
557
- return true;
1074
+ const _namesEither = purify.Either.of($resource.values(ShaclCorePropertyShapeStatic.$properties.names["identifier"], { unique: true }))
1075
+ .chain((values) => {
1076
+ const literalValuesEither = values.chainMap((value) => value.toLiteral());
1077
+ if (literalValuesEither.isLeft()) {
1078
+ return literalValuesEither;
1079
+ }
1080
+ const literalValues = literalValuesEither.unsafeCoerce();
1081
+ const nonUniqueLanguageIn = $languageIn ?? [];
1082
+ if (nonUniqueLanguageIn.length === 0) {
1083
+ return purify.Either.of(literalValues);
1084
+ }
1085
+ let uniqueLanguageIn;
1086
+ if (nonUniqueLanguageIn.length === 1) {
1087
+ uniqueLanguageIn = [nonUniqueLanguageIn[0]];
1088
+ }
1089
+ else {
1090
+ uniqueLanguageIn = [];
1091
+ for (const languageIn of nonUniqueLanguageIn) {
1092
+ if (uniqueLanguageIn.indexOf(languageIn) === -1) {
1093
+ uniqueLanguageIn.push(languageIn);
1094
+ }
1095
+ }
1096
+ }
1097
+ // Return all literals for the first languageIn, then all literals for the second languageIn, etc.
1098
+ // Within a languageIn the literals may be in any order.
1099
+ let filteredLiteralValues;
1100
+ for (const languageIn of uniqueLanguageIn) {
1101
+ if (!filteredLiteralValues) {
1102
+ filteredLiteralValues = literalValues.filter((value) => value.language === languageIn);
558
1103
  }
559
- const _valueLiteral = _value.toLiteral().toMaybe().extract();
560
- if (typeof _valueLiteral === "undefined") {
561
- return false;
1104
+ else {
1105
+ filteredLiteralValues = filteredLiteralValues.concat(...literalValues
1106
+ .filter((value) => value.language === languageIn)
1107
+ .toArray());
562
1108
  }
563
- return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
564
- })
565
- .head()
566
- .chain((_value) => _value.toLiteral())
567
- .toMaybe()
568
- .toList()),
569
- ]);
1109
+ }
1110
+ return purify.Either.of(filteredLiteralValues);
1111
+ })
1112
+ .map((values) => values.toArray())
1113
+ .map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
1114
+ object: valuesArray,
1115
+ predicate: ShaclCorePropertyShapeStatic.$properties.names["identifier"],
1116
+ subject: $resource,
1117
+ }))
1118
+ .chain((values) => values.head());
570
1119
  if (_namesEither.isLeft()) {
571
1120
  return _namesEither;
572
1121
  }
573
1122
  const names = _namesEither.unsafeCoerce();
574
- const _orderEither = purify.Either.of(_resource
575
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#order"), {
576
- unique: true,
577
- })
578
- .head()
579
- .chain((_value) => _value.toNumber())
580
- .toMaybe());
1123
+ const _orderEither = purify.Either.of($resource.values(ShaclCorePropertyShapeStatic.$properties.order["identifier"], { unique: true }))
1124
+ .chain((values) => values.chainMap((value) => value.toNumber()))
1125
+ .map((values) => values.length > 0
1126
+ ? values.map((value) => purify.Maybe.of(value))
1127
+ : rdfjsResource.Resource.Values.fromValue({
1128
+ object: purify.Maybe.empty(),
1129
+ predicate: ShaclCorePropertyShapeStatic.$properties.order["identifier"],
1130
+ subject: $resource,
1131
+ }))
1132
+ .chain((values) => values.head());
581
1133
  if (_orderEither.isLeft()) {
582
1134
  return _orderEither;
583
1135
  }
584
1136
  const order = _orderEither.unsafeCoerce();
585
- const _pathEither = _resource
586
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#path"), {
587
- unique: true,
588
- })
589
- .head()
590
- .chain((value) => value.toResource())
591
- .chain((_resource) => PropertyPath.fromRdf({
592
- ..._context,
1137
+ const _pathEither = purify.Either.of($resource.values(ShaclCorePropertyShapeStatic.$properties.path["identifier"], { unique: true }))
1138
+ .chain((values) => values.chainMap((value) => value.toResource().chain((resource) => PropertyPath.$fromRdf(resource, {
1139
+ ...$context,
593
1140
  ignoreRdfType: true,
594
- languageIn: _languageIn,
595
- resource: _resource,
596
- }));
1141
+ languageIn: $languageIn,
1142
+ objectSet: $objectSet,
1143
+ }))))
1144
+ .chain((values) => values.head());
597
1145
  if (_pathEither.isLeft()) {
598
1146
  return _pathEither;
599
1147
  }
600
1148
  const path = _pathEither.unsafeCoerce();
601
- const _uniqueLangEither = purify.Either.of(_resource
602
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#uniqueLang"), { unique: true })
603
- .head()
604
- .chain((_value) => _value.toBoolean())
605
- .toMaybe());
1149
+ const _uniqueLangEither = purify.Either.of($resource.values(ShaclCorePropertyShapeStatic.$properties.uniqueLang["identifier"], { unique: true }))
1150
+ .chain((values) => values.chainMap((value) => value.toBoolean()))
1151
+ .map((values) => values.length > 0
1152
+ ? values.map((value) => purify.Maybe.of(value))
1153
+ : rdfjsResource.Resource.Values.fromValue({
1154
+ object: purify.Maybe.empty(),
1155
+ predicate: ShaclCorePropertyShapeStatic.$properties.uniqueLang["identifier"],
1156
+ subject: $resource,
1157
+ }))
1158
+ .chain((values) => values.head());
606
1159
  if (_uniqueLangEither.isLeft()) {
607
1160
  return _uniqueLangEither;
608
1161
  }
609
1162
  const uniqueLang = _uniqueLangEither.unsafeCoerce();
610
1163
  return purify.Either.of({
611
- ..._super0,
612
- identifier,
613
- type,
1164
+ ...$super0,
1165
+ $identifier,
1166
+ $type,
614
1167
  defaultValue,
615
1168
  descriptions,
616
1169
  groups,
@@ -620,69 +1173,160 @@ export var ShaclCorePropertyShape;
620
1173
  uniqueLang,
621
1174
  });
622
1175
  }
623
- ShaclCorePropertyShape._propertiesFromRdf = _propertiesFromRdf;
624
- function fromRdf(parameters) {
625
- return ShaclCorePropertyShape._propertiesFromRdf(parameters);
1176
+ ShaclCorePropertyShapeStatic.$propertiesFromRdf = $propertiesFromRdf;
1177
+ function $toRdf(_shaclCorePropertyShape, options) {
1178
+ const ignoreRdfType = !!options?.ignoreRdfType;
1179
+ const mutateGraph = options?.mutateGraph;
1180
+ const resourceSet = options?.resourceSet ??
1181
+ new rdfjsResource.MutableResourceSet({
1182
+ dataFactory,
1183
+ dataset: datasetFactory.dataset(),
1184
+ });
1185
+ const resource = BaseShaclCoreShapeStatic.$toRdf(_shaclCorePropertyShape, {
1186
+ ignoreRdfType: true,
1187
+ mutateGraph,
1188
+ resourceSet,
1189
+ });
1190
+ if (!ignoreRdfType) {
1191
+ resource.add($RdfVocabularies.rdf.type, resource.dataFactory.namedNode("http://purl.org/shaclmate/ontology#ShaclCorePropertyShape"));
1192
+ resource.add($RdfVocabularies.rdf.type, resource.dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyShape"));
1193
+ }
1194
+ resource.add(ShaclCorePropertyShapeStatic.$properties.defaultValue["identifier"], _shaclCorePropertyShape.defaultValue);
1195
+ resource.add(ShaclCorePropertyShapeStatic.$properties.descriptions["identifier"], _shaclCorePropertyShape.descriptions.map((item) => item));
1196
+ resource.add(ShaclCorePropertyShapeStatic.$properties.groups["identifier"], _shaclCorePropertyShape.groups.map((item) => item));
1197
+ resource.add(ShaclCorePropertyShapeStatic.$properties.names["identifier"], _shaclCorePropertyShape.names.map((item) => item));
1198
+ resource.add(ShaclCorePropertyShapeStatic.$properties.order["identifier"], _shaclCorePropertyShape.order);
1199
+ resource.add(ShaclCorePropertyShapeStatic.$properties.path["identifier"], PropertyPath.$toRdf(_shaclCorePropertyShape.path, {
1200
+ mutateGraph: mutateGraph,
1201
+ resourceSet: resourceSet,
1202
+ }));
1203
+ resource.add(ShaclCorePropertyShapeStatic.$properties.uniqueLang["identifier"], _shaclCorePropertyShape.uniqueLang);
1204
+ return resource;
626
1205
  }
627
- ShaclCorePropertyShape.fromRdf = fromRdf;
628
- ShaclCorePropertyShape.fromRdfType = dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyShape");
629
- })(ShaclCorePropertyShape || (ShaclCorePropertyShape = {}));
1206
+ ShaclCorePropertyShapeStatic.$toRdf = $toRdf;
1207
+ ShaclCorePropertyShapeStatic.$properties = {
1208
+ ...BaseShaclCoreShapeStatic.$properties,
1209
+ defaultValue: {
1210
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#defaultValue"),
1211
+ },
1212
+ descriptions: {
1213
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#description"),
1214
+ },
1215
+ groups: {
1216
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#group"),
1217
+ },
1218
+ names: {
1219
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#name"),
1220
+ },
1221
+ order: {
1222
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#order"),
1223
+ },
1224
+ path: {
1225
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#path"),
1226
+ },
1227
+ uniqueLang: {
1228
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#uniqueLang"),
1229
+ },
1230
+ };
1231
+ })(ShaclCorePropertyShapeStatic || (ShaclCorePropertyShapeStatic = {}));
630
1232
  export var ShaclmatePropertyShape;
631
1233
  (function (ShaclmatePropertyShape) {
632
- function _propertiesFromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource,
1234
+ ShaclmatePropertyShape.$fromRdfType = dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyShape");
1235
+ ShaclmatePropertyShape.$Identifier = ShaclCorePropertyShapeStatic.$Identifier;
1236
+ function $fromRdf(resource, options) {
1237
+ let { ignoreRdfType = false, languageIn, objectSet, ...context } = options ?? {};
1238
+ if (!objectSet) {
1239
+ objectSet = new $RdfjsDatasetObjectSet({ dataset: resource.dataset });
1240
+ }
1241
+ return ShaclmatePropertyShape.$propertiesFromRdf({
1242
+ ...context,
1243
+ ignoreRdfType,
1244
+ languageIn,
1245
+ objectSet,
1246
+ resource,
1247
+ });
1248
+ }
1249
+ ShaclmatePropertyShape.$fromRdf = $fromRdf;
1250
+ function $propertiesFromRdf({ ignoreRdfType: $ignoreRdfType, languageIn: $languageIn, objectSet: $objectSet, resource: $resource,
633
1251
  // @ts-ignore
634
- ..._context }) {
635
- const _super0Either = ShaclCorePropertyShape._propertiesFromRdf({
636
- ..._context,
1252
+ ...$context }) {
1253
+ const $super0Either = ShaclCorePropertyShapeStatic.$propertiesFromRdf({
1254
+ ...$context,
637
1255
  ignoreRdfType: true,
638
- languageIn: _languageIn,
639
- resource: _resource,
1256
+ languageIn: $languageIn,
1257
+ objectSet: $objectSet,
1258
+ resource: $resource,
640
1259
  });
641
- if (_super0Either.isLeft()) {
642
- return _super0Either;
643
- }
644
- const _super0 = _super0Either.unsafeCoerce();
645
- if (!_ignoreRdfType &&
646
- !_resource.isInstanceOf(dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyShape"))) {
647
- return purify.Left(new rdfjsResource.Resource.ValueError({
648
- focusResource: _resource,
649
- message: `${rdfjsResource.Resource.Identifier.toString(_resource.identifier)} has unexpected RDF type`,
650
- predicate: dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyShape"),
651
- }));
652
- }
653
- const identifier = _resource.identifier;
654
- const type = "ShaclmatePropertyShape";
655
- const _externEither = purify.Either.of(_resource
656
- .values(dataFactory.namedNode("http://purl.org/shaclmate/ontology#extern"), { unique: true })
657
- .head()
658
- .chain((_value) => _value.toBoolean())
659
- .toMaybe());
660
- if (_externEither.isLeft()) {
661
- return _externEither;
662
- }
663
- const extern = _externEither.unsafeCoerce();
664
- const _mutableEither = purify.Either.of(_resource
665
- .values(dataFactory.namedNode("http://purl.org/shaclmate/ontology#mutable"), { unique: true })
666
- .head()
667
- .chain((_value) => _value.toBoolean())
668
- .toMaybe());
1260
+ if ($super0Either.isLeft()) {
1261
+ return $super0Either;
1262
+ }
1263
+ const $super0 = $super0Either.unsafeCoerce();
1264
+ if (!$ignoreRdfType && !$resource.isInstanceOf(ShaclmatePropertyShape.$fromRdfType)) {
1265
+ return $resource
1266
+ .value($RdfVocabularies.rdf.type)
1267
+ .chain((actualRdfType) => actualRdfType.toIri())
1268
+ .chain((actualRdfType) => purify.Left(new Error(`${rdfjsResource.Resource.Identifier.toString($resource.identifier)} has unexpected RDF type (actual: ${actualRdfType.value}, expected: http://www.w3.org/ns/shacl#PropertyShape)`)));
1269
+ }
1270
+ const $identifier = $resource.identifier;
1271
+ const $type = "ShaclmatePropertyShape";
1272
+ const _lazyEither = purify.Either.of($resource.values(ShaclmatePropertyShape.$properties.lazy["identifier"], { unique: true }))
1273
+ .chain((values) => values.chainMap((value) => value.toBoolean()))
1274
+ .map((values) => values.length > 0
1275
+ ? values.map((value) => purify.Maybe.of(value))
1276
+ : rdfjsResource.Resource.Values.fromValue({
1277
+ object: purify.Maybe.empty(),
1278
+ predicate: ShaclmatePropertyShape.$properties.lazy["identifier"],
1279
+ subject: $resource,
1280
+ }))
1281
+ .chain((values) => values.head());
1282
+ if (_lazyEither.isLeft()) {
1283
+ return _lazyEither;
1284
+ }
1285
+ const lazy = _lazyEither.unsafeCoerce();
1286
+ const _mutableEither = purify.Either.of($resource.values(ShaclmatePropertyShape.$properties.mutable["identifier"], { unique: true }))
1287
+ .chain((values) => values.chainMap((value) => value.toBoolean()))
1288
+ .map((values) => values.length > 0
1289
+ ? values.map((value) => purify.Maybe.of(value))
1290
+ : rdfjsResource.Resource.Values.fromValue({
1291
+ object: purify.Maybe.empty(),
1292
+ predicate: ShaclmateNodeShape.$properties.mutable["identifier"],
1293
+ subject: $resource,
1294
+ }))
1295
+ .chain((values) => values.head());
669
1296
  if (_mutableEither.isLeft()) {
670
1297
  return _mutableEither;
671
1298
  }
672
1299
  const mutable = _mutableEither.unsafeCoerce();
673
- const _nameEither = purify.Either.of(_resource
674
- .values(dataFactory.namedNode("http://purl.org/shaclmate/ontology#name"), { unique: true })
675
- .head()
676
- .chain((_value) => _value.toString())
677
- .toMaybe());
1300
+ const _nameEither = purify.Either.of($resource.values(ShaclmatePropertyShape.$properties.name["identifier"], { unique: true }))
1301
+ .chain((values) => values.chainMap((value) => value.toString()))
1302
+ .map((values) => values.length > 0
1303
+ ? values.map((value) => purify.Maybe.of(value))
1304
+ : rdfjsResource.Resource.Values.fromValue({
1305
+ object: purify.Maybe.empty(),
1306
+ predicate: ShaclmateNodeShape.$properties.name["identifier"],
1307
+ subject: $resource,
1308
+ }))
1309
+ .chain((values) => values.head());
678
1310
  if (_nameEither.isLeft()) {
679
1311
  return _nameEither;
680
1312
  }
681
1313
  const name = _nameEither.unsafeCoerce();
682
- const _visibilityEither = purify.Either.of(_resource
683
- .values(dataFactory.namedNode("http://purl.org/shaclmate/ontology#visibility"), { unique: true })
684
- .head()
685
- .chain((_value) => _value.toIri().chain((iri) => {
1314
+ const _stubEither = purify.Either.of($resource.values(ShaclmatePropertyShape.$properties.stub["identifier"], { unique: true }))
1315
+ .chain((values) => values.chainMap((value) => value.toIdentifier()))
1316
+ .map((values) => values.length > 0
1317
+ ? values.map((value) => purify.Maybe.of(value))
1318
+ : rdfjsResource.Resource.Values.fromValue({
1319
+ object: purify.Maybe.empty(),
1320
+ predicate: ShaclmatePropertyShape.$properties.stub["identifier"],
1321
+ subject: $resource,
1322
+ }))
1323
+ .chain((values) => values.head());
1324
+ if (_stubEither.isLeft()) {
1325
+ return _stubEither;
1326
+ }
1327
+ const stub = _stubEither.unsafeCoerce();
1328
+ const _visibilityEither = purify.Either.of($resource.values(ShaclmatePropertyShape.$properties.visibility["identifier"], { unique: true }))
1329
+ .chain((values) => values.chainMap((value) => value.toIri().chain((iri) => {
686
1330
  switch (iri.value) {
687
1331
  case "http://purl.org/shaclmate/ontology#_Visibility_Private":
688
1332
  return purify.Either.of(iri);
@@ -694,238 +1338,360 @@ export var ShaclmatePropertyShape;
694
1338
  return purify.Left(new rdfjsResource.Resource.MistypedValueError({
695
1339
  actualValue: iri,
696
1340
  expectedValueType: 'rdfjs.NamedNode<"http://purl.org/shaclmate/ontology#_Visibility_Private" | "http://purl.org/shaclmate/ontology#_Visibility_Protected" | "http://purl.org/shaclmate/ontology#_Visibility_Public">',
697
- focusResource: _resource,
698
- predicate: dataFactory.namedNode("http://purl.org/shaclmate/ontology#visibility"),
1341
+ focusResource: $resource,
1342
+ predicate: ShaclmatePropertyShape.$properties.visibility["identifier"],
699
1343
  }));
700
1344
  }
701
- }))
702
- .toMaybe());
1345
+ })))
1346
+ .map((values) => values.length > 0
1347
+ ? values.map((value) => purify.Maybe.of(value))
1348
+ : rdfjsResource.Resource.Values.fromValue({
1349
+ object: purify.Maybe.empty(),
1350
+ predicate: ShaclmatePropertyShape.$properties.visibility["identifier"],
1351
+ subject: $resource,
1352
+ }))
1353
+ .chain((values) => values.head());
703
1354
  if (_visibilityEither.isLeft()) {
704
1355
  return _visibilityEither;
705
1356
  }
706
1357
  const visibility = _visibilityEither.unsafeCoerce();
1358
+ const _widenEither = purify.Either.of($resource.values(ShaclmatePropertyShape.$properties.widen["identifier"], { unique: true }))
1359
+ .chain((values) => values.chainMap((value) => value.toBoolean()))
1360
+ .map((values) => values.length > 0
1361
+ ? values.map((value) => purify.Maybe.of(value))
1362
+ : rdfjsResource.Resource.Values.fromValue({
1363
+ object: purify.Maybe.empty(),
1364
+ predicate: ShaclmatePropertyShape.$properties.widen["identifier"],
1365
+ subject: $resource,
1366
+ }))
1367
+ .chain((values) => values.head());
1368
+ if (_widenEither.isLeft()) {
1369
+ return _widenEither;
1370
+ }
1371
+ const widen = _widenEither.unsafeCoerce();
707
1372
  return purify.Either.of({
708
- ..._super0,
709
- identifier,
710
- type,
711
- extern,
1373
+ ...$super0,
1374
+ $identifier,
1375
+ $type,
1376
+ lazy,
712
1377
  mutable,
713
1378
  name,
1379
+ stub,
714
1380
  visibility,
1381
+ widen,
715
1382
  });
716
1383
  }
717
- ShaclmatePropertyShape._propertiesFromRdf = _propertiesFromRdf;
718
- function fromRdf(parameters) {
719
- return ShaclmatePropertyShape._propertiesFromRdf(parameters);
1384
+ ShaclmatePropertyShape.$propertiesFromRdf = $propertiesFromRdf;
1385
+ function $toRdf(_shaclmatePropertyShape, options) {
1386
+ const ignoreRdfType = !!options?.ignoreRdfType;
1387
+ const mutateGraph = options?.mutateGraph;
1388
+ const resourceSet = options?.resourceSet ??
1389
+ new rdfjsResource.MutableResourceSet({
1390
+ dataFactory,
1391
+ dataset: datasetFactory.dataset(),
1392
+ });
1393
+ const resource = ShaclCorePropertyShapeStatic.$toRdf(_shaclmatePropertyShape, { ignoreRdfType: true, mutateGraph, resourceSet });
1394
+ if (!ignoreRdfType) {
1395
+ resource.add($RdfVocabularies.rdf.type, resource.dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyShape"));
1396
+ }
1397
+ resource.add(ShaclmatePropertyShape.$properties.lazy["identifier"], _shaclmatePropertyShape.lazy);
1398
+ resource.add(ShaclmateNodeShape.$properties.mutable["identifier"], _shaclmatePropertyShape.mutable);
1399
+ resource.add(ShaclmateNodeShape.$properties.name["identifier"], _shaclmatePropertyShape.name);
1400
+ resource.add(ShaclmatePropertyShape.$properties.stub["identifier"], _shaclmatePropertyShape.stub);
1401
+ resource.add(ShaclmatePropertyShape.$properties.visibility["identifier"], _shaclmatePropertyShape.visibility);
1402
+ resource.add(ShaclmatePropertyShape.$properties.widen["identifier"], _shaclmatePropertyShape.widen);
1403
+ return resource;
720
1404
  }
721
- ShaclmatePropertyShape.fromRdf = fromRdf;
722
- ShaclmatePropertyShape.fromRdfType = dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyShape");
1405
+ ShaclmatePropertyShape.$toRdf = $toRdf;
1406
+ ShaclmatePropertyShape.$properties = {
1407
+ ...ShaclCorePropertyShapeStatic.$properties,
1408
+ lazy: {
1409
+ identifier: dataFactory.namedNode("http://purl.org/shaclmate/ontology#lazy"),
1410
+ },
1411
+ mutable: {
1412
+ identifier: dataFactory.namedNode("http://purl.org/shaclmate/ontology#mutable"),
1413
+ },
1414
+ name: {
1415
+ identifier: dataFactory.namedNode("http://purl.org/shaclmate/ontology#name"),
1416
+ },
1417
+ stub: {
1418
+ identifier: dataFactory.namedNode("http://purl.org/shaclmate/ontology#stub"),
1419
+ },
1420
+ visibility: {
1421
+ identifier: dataFactory.namedNode("http://purl.org/shaclmate/ontology#visibility"),
1422
+ },
1423
+ widen: {
1424
+ identifier: dataFactory.namedNode("http://purl.org/shaclmate/ontology#widen"),
1425
+ },
1426
+ };
723
1427
  })(ShaclmatePropertyShape || (ShaclmatePropertyShape = {}));
724
- export var OwlOntology;
725
- (function (OwlOntology) {
726
- function _propertiesFromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource,
727
- // @ts-ignore
728
- ..._context }) {
729
- if (!_ignoreRdfType &&
730
- !_resource.isInstanceOf(dataFactory.namedNode("http://www.w3.org/2002/07/owl#Ontology"))) {
731
- return purify.Left(new rdfjsResource.Resource.ValueError({
732
- focusResource: _resource,
733
- message: `${rdfjsResource.Resource.Identifier.toString(_resource.identifier)} has unexpected RDF type`,
734
- predicate: dataFactory.namedNode("http://www.w3.org/2002/07/owl#Ontology"),
1428
+ export var OwlOntologyStatic;
1429
+ (function (OwlOntologyStatic) {
1430
+ OwlOntologyStatic.$fromRdfType = dataFactory.namedNode("http://www.w3.org/2002/07/owl#Ontology");
1431
+ let $Identifier;
1432
+ (function ($Identifier) {
1433
+ function fromString(identifier) {
1434
+ return purify.Either.encase(() => rdfjsResource.Resource.Identifier.fromString({
1435
+ dataFactory,
1436
+ identifier,
735
1437
  }));
736
1438
  }
737
- const identifier = _resource.identifier;
738
- const type = "OwlOntology";
739
- const _labelsEither = purify.Either.of([
740
- ..._resource
741
- .values(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#label"), { unique: true })
742
- .flatMap((_item) => _item
743
- .toValues()
744
- .filter((_value) => {
745
- const _languageInOrDefault = _languageIn ?? [];
746
- if (_languageInOrDefault.length === 0) {
747
- return true;
1439
+ $Identifier.fromString = fromString;
1440
+ $Identifier.toString = rdfjsResource.Resource.Identifier.toString;
1441
+ })($Identifier = OwlOntologyStatic.$Identifier || (OwlOntologyStatic.$Identifier = {}));
1442
+ function $fromRdf(resource, options) {
1443
+ let { ignoreRdfType = false, languageIn, objectSet, ...context } = options ?? {};
1444
+ if (!objectSet) {
1445
+ objectSet = new $RdfjsDatasetObjectSet({ dataset: resource.dataset });
1446
+ }
1447
+ return ShaclmateOntology.$fromRdf(resource, {
1448
+ ...context,
1449
+ ignoreRdfType: false,
1450
+ objectSet,
1451
+ }).altLazy(() => OwlOntologyStatic.$propertiesFromRdf({
1452
+ ...context,
1453
+ ignoreRdfType,
1454
+ languageIn,
1455
+ objectSet,
1456
+ resource,
1457
+ }));
1458
+ }
1459
+ OwlOntologyStatic.$fromRdf = $fromRdf;
1460
+ function $propertiesFromRdf({ ignoreRdfType: $ignoreRdfType, languageIn: $languageIn, objectSet: $objectSet, resource: $resource,
1461
+ // @ts-ignore
1462
+ ...$context }) {
1463
+ if (!$ignoreRdfType && !$resource.isInstanceOf(OwlOntologyStatic.$fromRdfType)) {
1464
+ return $resource
1465
+ .value($RdfVocabularies.rdf.type)
1466
+ .chain((actualRdfType) => actualRdfType.toIri())
1467
+ .chain((actualRdfType) => purify.Left(new Error(`${rdfjsResource.Resource.Identifier.toString($resource.identifier)} has unexpected RDF type (actual: ${actualRdfType.value}, expected: http://www.w3.org/2002/07/owl#Ontology)`)));
1468
+ }
1469
+ const $identifier = $resource.identifier;
1470
+ const $type = "OwlOntology";
1471
+ const _labelsEither = purify.Either.of($resource.values(OwlOntologyStatic.$properties.labels["identifier"], { unique: true }))
1472
+ .chain((values) => {
1473
+ const literalValuesEither = values.chainMap((value) => value.toLiteral());
1474
+ if (literalValuesEither.isLeft()) {
1475
+ return literalValuesEither;
1476
+ }
1477
+ const literalValues = literalValuesEither.unsafeCoerce();
1478
+ const nonUniqueLanguageIn = $languageIn ?? [];
1479
+ if (nonUniqueLanguageIn.length === 0) {
1480
+ return purify.Either.of(literalValues);
1481
+ }
1482
+ let uniqueLanguageIn;
1483
+ if (nonUniqueLanguageIn.length === 1) {
1484
+ uniqueLanguageIn = [nonUniqueLanguageIn[0]];
1485
+ }
1486
+ else {
1487
+ uniqueLanguageIn = [];
1488
+ for (const languageIn of nonUniqueLanguageIn) {
1489
+ if (uniqueLanguageIn.indexOf(languageIn) === -1) {
1490
+ uniqueLanguageIn.push(languageIn);
1491
+ }
748
1492
  }
749
- const _valueLiteral = _value.toLiteral().toMaybe().extract();
750
- if (typeof _valueLiteral === "undefined") {
751
- return false;
1493
+ }
1494
+ // Return all literals for the first languageIn, then all literals for the second languageIn, etc.
1495
+ // Within a languageIn the literals may be in any order.
1496
+ let filteredLiteralValues;
1497
+ for (const languageIn of uniqueLanguageIn) {
1498
+ if (!filteredLiteralValues) {
1499
+ filteredLiteralValues = literalValues.filter((value) => value.language === languageIn);
1500
+ }
1501
+ else {
1502
+ filteredLiteralValues = filteredLiteralValues.concat(...literalValues
1503
+ .filter((value) => value.language === languageIn)
1504
+ .toArray());
752
1505
  }
753
- return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
754
- })
755
- .head()
756
- .chain((_value) => _value.toLiteral())
757
- .toMaybe()
758
- .toList()),
759
- ]);
1506
+ }
1507
+ return purify.Either.of(filteredLiteralValues);
1508
+ })
1509
+ .map((values) => values.toArray())
1510
+ .map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
1511
+ object: valuesArray,
1512
+ predicate: OwlOntologyStatic.$properties.labels["identifier"],
1513
+ subject: $resource,
1514
+ }))
1515
+ .chain((values) => values.head());
760
1516
  if (_labelsEither.isLeft()) {
761
1517
  return _labelsEither;
762
1518
  }
763
1519
  const labels = _labelsEither.unsafeCoerce();
764
- return purify.Either.of({ identifier, type, labels });
1520
+ return purify.Either.of({ $identifier, $type, labels });
765
1521
  }
766
- OwlOntology._propertiesFromRdf = _propertiesFromRdf;
767
- function fromRdf(parameters) {
768
- return OwlOntology._propertiesFromRdf(parameters);
1522
+ OwlOntologyStatic.$propertiesFromRdf = $propertiesFromRdf;
1523
+ function $toRdf(_owlOntology, options) {
1524
+ const ignoreRdfType = !!options?.ignoreRdfType;
1525
+ const mutateGraph = options?.mutateGraph;
1526
+ const resourceSet = options?.resourceSet ??
1527
+ new rdfjsResource.MutableResourceSet({
1528
+ dataFactory,
1529
+ dataset: datasetFactory.dataset(),
1530
+ });
1531
+ const resource = resourceSet.mutableResource(_owlOntology.$identifier, {
1532
+ mutateGraph,
1533
+ });
1534
+ if (!ignoreRdfType) {
1535
+ resource.add($RdfVocabularies.rdf.type, resource.dataFactory.namedNode("http://purl.org/shaclmate/ontology#OwlOntology"));
1536
+ resource.add($RdfVocabularies.rdf.type, resource.dataFactory.namedNode("http://www.w3.org/2002/07/owl#Ontology"));
1537
+ }
1538
+ resource.add(OwlOntologyStatic.$properties.labels["identifier"], _owlOntology.labels.map((item) => item));
1539
+ return resource;
769
1540
  }
770
- OwlOntology.fromRdf = fromRdf;
771
- OwlOntology.fromRdfType = dataFactory.namedNode("http://www.w3.org/2002/07/owl#Ontology");
772
- })(OwlOntology || (OwlOntology = {}));
1541
+ OwlOntologyStatic.$toRdf = $toRdf;
1542
+ OwlOntologyStatic.$properties = {
1543
+ labels: {
1544
+ identifier: dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#label"),
1545
+ },
1546
+ };
1547
+ })(OwlOntologyStatic || (OwlOntologyStatic = {}));
773
1548
  export var ShaclmateOntology;
774
1549
  (function (ShaclmateOntology) {
775
- function _propertiesFromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource,
1550
+ ShaclmateOntology.$fromRdfType = dataFactory.namedNode("http://www.w3.org/2002/07/owl#Ontology");
1551
+ ShaclmateOntology.$Identifier = OwlOntologyStatic.$Identifier;
1552
+ function $fromRdf(resource, options) {
1553
+ let { ignoreRdfType = false, languageIn, objectSet, ...context } = options ?? {};
1554
+ if (!objectSet) {
1555
+ objectSet = new $RdfjsDatasetObjectSet({ dataset: resource.dataset });
1556
+ }
1557
+ return ShaclmateOntology.$propertiesFromRdf({
1558
+ ...context,
1559
+ ignoreRdfType,
1560
+ languageIn,
1561
+ objectSet,
1562
+ resource,
1563
+ });
1564
+ }
1565
+ ShaclmateOntology.$fromRdf = $fromRdf;
1566
+ function $propertiesFromRdf({ ignoreRdfType: $ignoreRdfType, languageIn: $languageIn, objectSet: $objectSet, resource: $resource,
776
1567
  // @ts-ignore
777
- ..._context }) {
778
- const _super0Either = OwlOntology._propertiesFromRdf({
779
- ..._context,
1568
+ ...$context }) {
1569
+ const $super0Either = OwlOntologyStatic.$propertiesFromRdf({
1570
+ ...$context,
780
1571
  ignoreRdfType: true,
781
- languageIn: _languageIn,
782
- resource: _resource,
1572
+ languageIn: $languageIn,
1573
+ objectSet: $objectSet,
1574
+ resource: $resource,
783
1575
  });
784
- if (_super0Either.isLeft()) {
785
- return _super0Either;
786
- }
787
- const _super0 = _super0Either.unsafeCoerce();
788
- if (!_ignoreRdfType &&
789
- !_resource.isInstanceOf(dataFactory.namedNode("http://www.w3.org/2002/07/owl#Ontology"))) {
790
- return purify.Left(new rdfjsResource.Resource.ValueError({
791
- focusResource: _resource,
792
- message: `${rdfjsResource.Resource.Identifier.toString(_resource.identifier)} has unexpected RDF type`,
793
- predicate: dataFactory.namedNode("http://www.w3.org/2002/07/owl#Ontology"),
794
- }));
795
- }
796
- const identifier = _resource.identifier;
797
- const type = "ShaclmateOntology";
798
- const _tsDataFactoryVariableEither = purify.Either.of(_resource
799
- .values(dataFactory.namedNode("http://purl.org/shaclmate/ontology#tsDataFactoryVariable"), { unique: true })
800
- .head()
801
- .chain((_value) => _value.toString())
802
- .toMaybe());
803
- if (_tsDataFactoryVariableEither.isLeft()) {
804
- return _tsDataFactoryVariableEither;
805
- }
806
- const tsDataFactoryVariable = _tsDataFactoryVariableEither.unsafeCoerce();
807
- const _tsFeatureExcludesEither = purify.Either.of([
808
- ..._resource
809
- .values(dataFactory.namedNode("http://purl.org/shaclmate/ontology#tsFeatureExclude"), { unique: true })
810
- .flatMap((_item) => _item
811
- .toValues()
812
- .head()
813
- .chain((_value) => _value.toIri().chain((iri) => {
814
- switch (iri.value) {
815
- case "http://purl.org/shaclmate/ontology#_TsFeature_All":
816
- return purify.Either.of(iri);
817
- case "http://purl.org/shaclmate/ontology#_TsFeature_Create":
818
- return purify.Either.of(iri);
819
- case "http://purl.org/shaclmate/ontology#_TsFeature_Equals":
820
- return purify.Either.of(iri);
821
- case "http://purl.org/shaclmate/ontology#_TsFeature_FromJson":
822
- return purify.Either.of(iri);
823
- case "http://purl.org/shaclmate/ontology#_TsFeature_FromRdf":
824
- return purify.Either.of(iri);
825
- case "http://purl.org/shaclmate/ontology#_TsFeature_Hash":
826
- return purify.Either.of(iri);
827
- case "http://purl.org/shaclmate/ontology#_TsFeature_Json":
828
- return purify.Either.of(iri);
829
- case "http://purl.org/shaclmate/ontology#_TsFeature_JsonSchema":
830
- return purify.Either.of(iri);
831
- case "http://purl.org/shaclmate/ontology#_TsFeature_JsonUiSchema":
832
- return purify.Either.of(iri);
833
- case "http://purl.org/shaclmate/ontology#_TsFeature_None":
834
- return purify.Either.of(iri);
835
- case "http://purl.org/shaclmate/ontology#_TsFeature_Rdf":
836
- return purify.Either.of(iri);
837
- case "http://purl.org/shaclmate/ontology#_TsFeature_Sparql":
838
- return purify.Either.of(iri);
839
- case "http://purl.org/shaclmate/ontology#_TsFeature_ToJson":
840
- return purify.Either.of(iri);
841
- case "http://purl.org/shaclmate/ontology#_TsFeature_ToRdf":
842
- return purify.Either.of(iri);
843
- default:
844
- return purify.Left(new rdfjsResource.Resource.MistypedValueError({
845
- actualValue: iri,
846
- expectedValueType: 'rdfjs.NamedNode<"http://purl.org/shaclmate/ontology#_TsFeature_All" | "http://purl.org/shaclmate/ontology#_TsFeature_Create" | "http://purl.org/shaclmate/ontology#_TsFeature_Equals" | "http://purl.org/shaclmate/ontology#_TsFeature_FromJson" | "http://purl.org/shaclmate/ontology#_TsFeature_FromRdf" | "http://purl.org/shaclmate/ontology#_TsFeature_Hash" | "http://purl.org/shaclmate/ontology#_TsFeature_Json" | "http://purl.org/shaclmate/ontology#_TsFeature_JsonSchema" | "http://purl.org/shaclmate/ontology#_TsFeature_JsonUiSchema" | "http://purl.org/shaclmate/ontology#_TsFeature_None" | "http://purl.org/shaclmate/ontology#_TsFeature_Rdf" | "http://purl.org/shaclmate/ontology#_TsFeature_Sparql" | "http://purl.org/shaclmate/ontology#_TsFeature_ToJson" | "http://purl.org/shaclmate/ontology#_TsFeature_ToRdf">',
847
- focusResource: _resource,
848
- predicate: dataFactory.namedNode("http://purl.org/shaclmate/ontology#tsFeatureExclude"),
849
- }));
850
- }
851
- }))
852
- .toMaybe()
853
- .toList()),
854
- ]);
1576
+ if ($super0Either.isLeft()) {
1577
+ return $super0Either;
1578
+ }
1579
+ const $super0 = $super0Either.unsafeCoerce();
1580
+ if (!$ignoreRdfType && !$resource.isInstanceOf(ShaclmateOntology.$fromRdfType)) {
1581
+ return $resource
1582
+ .value($RdfVocabularies.rdf.type)
1583
+ .chain((actualRdfType) => actualRdfType.toIri())
1584
+ .chain((actualRdfType) => purify.Left(new Error(`${rdfjsResource.Resource.Identifier.toString($resource.identifier)} has unexpected RDF type (actual: ${actualRdfType.value}, expected: http://www.w3.org/2002/07/owl#Ontology)`)));
1585
+ }
1586
+ const $identifier = $resource.identifier;
1587
+ const $type = "ShaclmateOntology";
1588
+ const _tsFeatureExcludesEither = purify.Either.of($resource.values(ShaclmateOntology.$properties.tsFeatureExcludes["identifier"], {
1589
+ unique: true,
1590
+ }))
1591
+ .chain((values) => values.chainMap((value) => value.toIri().chain((iri) => {
1592
+ switch (iri.value) {
1593
+ case "http://purl.org/shaclmate/ontology#_TsFeatures_All":
1594
+ return purify.Either.of(iri);
1595
+ case "http://purl.org/shaclmate/ontology#_TsFeature_Create":
1596
+ return purify.Either.of(iri);
1597
+ case "http://purl.org/shaclmate/ontology#_TsFeatures_Default":
1598
+ return purify.Either.of(iri);
1599
+ case "http://purl.org/shaclmate/ontology#_TsFeature_Equals":
1600
+ return purify.Either.of(iri);
1601
+ case "http://purl.org/shaclmate/ontology#_TsFeature_Graphql":
1602
+ return purify.Either.of(iri);
1603
+ case "http://purl.org/shaclmate/ontology#_TsFeature_Hash":
1604
+ return purify.Either.of(iri);
1605
+ case "http://purl.org/shaclmate/ontology#_TsFeature_Json":
1606
+ return purify.Either.of(iri);
1607
+ case "http://purl.org/shaclmate/ontology#_TsFeatures_None":
1608
+ return purify.Either.of(iri);
1609
+ case "http://purl.org/shaclmate/ontology#_TsFeature_Rdf":
1610
+ return purify.Either.of(iri);
1611
+ case "http://purl.org/shaclmate/ontology#_TsFeature_Sparql":
1612
+ return purify.Either.of(iri);
1613
+ default:
1614
+ return purify.Left(new rdfjsResource.Resource.MistypedValueError({
1615
+ actualValue: iri,
1616
+ expectedValueType: 'rdfjs.NamedNode<"http://purl.org/shaclmate/ontology#_TsFeatures_All" | "http://purl.org/shaclmate/ontology#_TsFeature_Create" | "http://purl.org/shaclmate/ontology#_TsFeatures_Default" | "http://purl.org/shaclmate/ontology#_TsFeature_Equals" | "http://purl.org/shaclmate/ontology#_TsFeature_Graphql" | "http://purl.org/shaclmate/ontology#_TsFeature_Hash" | "http://purl.org/shaclmate/ontology#_TsFeature_Json" | "http://purl.org/shaclmate/ontology#_TsFeatures_None" | "http://purl.org/shaclmate/ontology#_TsFeature_Rdf" | "http://purl.org/shaclmate/ontology#_TsFeature_Sparql">',
1617
+ focusResource: $resource,
1618
+ predicate: ShaclmateNodeShape.$properties.tsFeatureExcludes["identifier"],
1619
+ }));
1620
+ }
1621
+ })))
1622
+ .map((values) => values.toArray())
1623
+ .map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
1624
+ object: valuesArray,
1625
+ predicate: ShaclmateNodeShape.$properties.tsFeatureExcludes["identifier"],
1626
+ subject: $resource,
1627
+ }))
1628
+ .chain((values) => values.head());
855
1629
  if (_tsFeatureExcludesEither.isLeft()) {
856
1630
  return _tsFeatureExcludesEither;
857
1631
  }
858
1632
  const tsFeatureExcludes = _tsFeatureExcludesEither.unsafeCoerce();
859
- const _tsFeatureIncludesEither = purify.Either.of([
860
- ..._resource
861
- .values(dataFactory.namedNode("http://purl.org/shaclmate/ontology#tsFeatureInclude"), { unique: true })
862
- .flatMap((_item) => _item
863
- .toValues()
864
- .head()
865
- .chain((_value) => _value.toIri().chain((iri) => {
866
- switch (iri.value) {
867
- case "http://purl.org/shaclmate/ontology#_TsFeature_All":
868
- return purify.Either.of(iri);
869
- case "http://purl.org/shaclmate/ontology#_TsFeature_Create":
870
- return purify.Either.of(iri);
871
- case "http://purl.org/shaclmate/ontology#_TsFeature_Equals":
872
- return purify.Either.of(iri);
873
- case "http://purl.org/shaclmate/ontology#_TsFeature_FromJson":
874
- return purify.Either.of(iri);
875
- case "http://purl.org/shaclmate/ontology#_TsFeature_FromRdf":
876
- return purify.Either.of(iri);
877
- case "http://purl.org/shaclmate/ontology#_TsFeature_Hash":
878
- return purify.Either.of(iri);
879
- case "http://purl.org/shaclmate/ontology#_TsFeature_Json":
880
- return purify.Either.of(iri);
881
- case "http://purl.org/shaclmate/ontology#_TsFeature_JsonSchema":
882
- return purify.Either.of(iri);
883
- case "http://purl.org/shaclmate/ontology#_TsFeature_JsonUiSchema":
884
- return purify.Either.of(iri);
885
- case "http://purl.org/shaclmate/ontology#_TsFeature_None":
886
- return purify.Either.of(iri);
887
- case "http://purl.org/shaclmate/ontology#_TsFeature_Rdf":
888
- return purify.Either.of(iri);
889
- case "http://purl.org/shaclmate/ontology#_TsFeature_Sparql":
890
- return purify.Either.of(iri);
891
- case "http://purl.org/shaclmate/ontology#_TsFeature_ToJson":
892
- return purify.Either.of(iri);
893
- case "http://purl.org/shaclmate/ontology#_TsFeature_ToRdf":
894
- return purify.Either.of(iri);
895
- default:
896
- return purify.Left(new rdfjsResource.Resource.MistypedValueError({
897
- actualValue: iri,
898
- expectedValueType: 'rdfjs.NamedNode<"http://purl.org/shaclmate/ontology#_TsFeature_All" | "http://purl.org/shaclmate/ontology#_TsFeature_Create" | "http://purl.org/shaclmate/ontology#_TsFeature_Equals" | "http://purl.org/shaclmate/ontology#_TsFeature_FromJson" | "http://purl.org/shaclmate/ontology#_TsFeature_FromRdf" | "http://purl.org/shaclmate/ontology#_TsFeature_Hash" | "http://purl.org/shaclmate/ontology#_TsFeature_Json" | "http://purl.org/shaclmate/ontology#_TsFeature_JsonSchema" | "http://purl.org/shaclmate/ontology#_TsFeature_JsonUiSchema" | "http://purl.org/shaclmate/ontology#_TsFeature_None" | "http://purl.org/shaclmate/ontology#_TsFeature_Rdf" | "http://purl.org/shaclmate/ontology#_TsFeature_Sparql" | "http://purl.org/shaclmate/ontology#_TsFeature_ToJson" | "http://purl.org/shaclmate/ontology#_TsFeature_ToRdf">',
899
- focusResource: _resource,
900
- predicate: dataFactory.namedNode("http://purl.org/shaclmate/ontology#tsFeatureInclude"),
901
- }));
902
- }
903
- }))
904
- .toMaybe()
905
- .toList()),
906
- ]);
1633
+ const _tsFeatureIncludesEither = purify.Either.of($resource.values(ShaclmateOntology.$properties.tsFeatureIncludes["identifier"], {
1634
+ unique: true,
1635
+ }))
1636
+ .chain((values) => values.chainMap((value) => value.toIri().chain((iri) => {
1637
+ switch (iri.value) {
1638
+ case "http://purl.org/shaclmate/ontology#_TsFeatures_All":
1639
+ return purify.Either.of(iri);
1640
+ case "http://purl.org/shaclmate/ontology#_TsFeature_Create":
1641
+ return purify.Either.of(iri);
1642
+ case "http://purl.org/shaclmate/ontology#_TsFeatures_Default":
1643
+ return purify.Either.of(iri);
1644
+ case "http://purl.org/shaclmate/ontology#_TsFeature_Equals":
1645
+ return purify.Either.of(iri);
1646
+ case "http://purl.org/shaclmate/ontology#_TsFeature_Graphql":
1647
+ return purify.Either.of(iri);
1648
+ case "http://purl.org/shaclmate/ontology#_TsFeature_Hash":
1649
+ return purify.Either.of(iri);
1650
+ case "http://purl.org/shaclmate/ontology#_TsFeature_Json":
1651
+ return purify.Either.of(iri);
1652
+ case "http://purl.org/shaclmate/ontology#_TsFeatures_None":
1653
+ return purify.Either.of(iri);
1654
+ case "http://purl.org/shaclmate/ontology#_TsFeature_Rdf":
1655
+ return purify.Either.of(iri);
1656
+ case "http://purl.org/shaclmate/ontology#_TsFeature_Sparql":
1657
+ return purify.Either.of(iri);
1658
+ default:
1659
+ return purify.Left(new rdfjsResource.Resource.MistypedValueError({
1660
+ actualValue: iri,
1661
+ expectedValueType: 'rdfjs.NamedNode<"http://purl.org/shaclmate/ontology#_TsFeatures_All" | "http://purl.org/shaclmate/ontology#_TsFeature_Create" | "http://purl.org/shaclmate/ontology#_TsFeatures_Default" | "http://purl.org/shaclmate/ontology#_TsFeature_Equals" | "http://purl.org/shaclmate/ontology#_TsFeature_Graphql" | "http://purl.org/shaclmate/ontology#_TsFeature_Hash" | "http://purl.org/shaclmate/ontology#_TsFeature_Json" | "http://purl.org/shaclmate/ontology#_TsFeatures_None" | "http://purl.org/shaclmate/ontology#_TsFeature_Rdf" | "http://purl.org/shaclmate/ontology#_TsFeature_Sparql">',
1662
+ focusResource: $resource,
1663
+ predicate: ShaclmateNodeShape.$properties.tsFeatureIncludes["identifier"],
1664
+ }));
1665
+ }
1666
+ })))
1667
+ .map((values) => values.toArray())
1668
+ .map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
1669
+ object: valuesArray,
1670
+ predicate: ShaclmateNodeShape.$properties.tsFeatureIncludes["identifier"],
1671
+ subject: $resource,
1672
+ }))
1673
+ .chain((values) => values.head());
907
1674
  if (_tsFeatureIncludesEither.isLeft()) {
908
1675
  return _tsFeatureIncludesEither;
909
1676
  }
910
1677
  const tsFeatureIncludes = _tsFeatureIncludesEither.unsafeCoerce();
911
- const _tsImportsEither = purify.Either.of([
912
- ..._resource
913
- .values(dataFactory.namedNode("http://purl.org/shaclmate/ontology#tsImport"), { unique: true })
914
- .flatMap((_item) => _item
915
- .toValues()
916
- .head()
917
- .chain((_value) => _value.toString())
918
- .toMaybe()
919
- .toList()),
920
- ]);
1678
+ const _tsImportsEither = purify.Either.of($resource.values(ShaclmateOntology.$properties.tsImports["identifier"], { unique: true }))
1679
+ .chain((values) => values.chainMap((value) => value.toString()))
1680
+ .map((values) => values.toArray())
1681
+ .map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
1682
+ object: valuesArray,
1683
+ predicate: ShaclmateNodeShape.$properties.tsImports["identifier"],
1684
+ subject: $resource,
1685
+ }))
1686
+ .chain((values) => values.head());
921
1687
  if (_tsImportsEither.isLeft()) {
922
1688
  return _tsImportsEither;
923
1689
  }
924
1690
  const tsImports = _tsImportsEither.unsafeCoerce();
925
- const _tsObjectDeclarationTypeEither = purify.Either.of(_resource
926
- .values(dataFactory.namedNode("http://purl.org/shaclmate/ontology#tsObjectDeclarationType"), { unique: true })
927
- .head()
928
- .chain((_value) => _value.toIri().chain((iri) => {
1691
+ const _tsObjectDeclarationTypeEither = purify.Either.of($resource.values(ShaclmateOntology.$properties.tsObjectDeclarationType["identifier"], {
1692
+ unique: true,
1693
+ }))
1694
+ .chain((values) => values.chainMap((value) => value.toIri().chain((iri) => {
929
1695
  switch (iri.value) {
930
1696
  case "http://purl.org/shaclmate/ontology#_TsObjectDeclarationType_Class":
931
1697
  return purify.Either.of(iri);
@@ -935,212 +1701,331 @@ export var ShaclmateOntology;
935
1701
  return purify.Left(new rdfjsResource.Resource.MistypedValueError({
936
1702
  actualValue: iri,
937
1703
  expectedValueType: 'rdfjs.NamedNode<"http://purl.org/shaclmate/ontology#_TsObjectDeclarationType_Class" | "http://purl.org/shaclmate/ontology#_TsObjectDeclarationType_Interface">',
938
- focusResource: _resource,
939
- predicate: dataFactory.namedNode("http://purl.org/shaclmate/ontology#tsObjectDeclarationType"),
1704
+ focusResource: $resource,
1705
+ predicate: ShaclmateNodeShape.$properties.tsObjectDeclarationType["identifier"],
940
1706
  }));
941
1707
  }
942
- }))
943
- .toMaybe());
1708
+ })))
1709
+ .map((values) => values.length > 0
1710
+ ? values.map((value) => purify.Maybe.of(value))
1711
+ : rdfjsResource.Resource.Values.fromValue({
1712
+ object: purify.Maybe.empty(),
1713
+ predicate: ShaclmateNodeShape.$properties.tsObjectDeclarationType["identifier"],
1714
+ subject: $resource,
1715
+ }))
1716
+ .chain((values) => values.head());
944
1717
  if (_tsObjectDeclarationTypeEither.isLeft()) {
945
1718
  return _tsObjectDeclarationTypeEither;
946
1719
  }
947
1720
  const tsObjectDeclarationType = _tsObjectDeclarationTypeEither.unsafeCoerce();
948
- const _tsObjectIdentifierPrefixPropertyNameEither = purify.Either.of(_resource
949
- .values(dataFactory.namedNode("http://purl.org/shaclmate/ontology#tsObjectIdentifierPrefixPropertyName"), { unique: true })
950
- .head()
951
- .chain((_value) => _value.toString())
952
- .toMaybe());
953
- if (_tsObjectIdentifierPrefixPropertyNameEither.isLeft()) {
954
- return _tsObjectIdentifierPrefixPropertyNameEither;
955
- }
956
- const tsObjectIdentifierPrefixPropertyName = _tsObjectIdentifierPrefixPropertyNameEither.unsafeCoerce();
957
- const _tsObjectIdentifierPropertyNameEither = purify.Either.of(_resource
958
- .values(dataFactory.namedNode("http://purl.org/shaclmate/ontology#tsObjectIdentifierPropertyName"), { unique: true })
959
- .head()
960
- .chain((_value) => _value.toString())
961
- .toMaybe());
962
- if (_tsObjectIdentifierPropertyNameEither.isLeft()) {
963
- return _tsObjectIdentifierPropertyNameEither;
964
- }
965
- const tsObjectIdentifierPropertyName = _tsObjectIdentifierPropertyNameEither.unsafeCoerce();
966
- const _tsObjectTypeDiscriminatorPropertyNameEither = purify.Either.of(_resource
967
- .values(dataFactory.namedNode("http://purl.org/shaclmate/ontology#tsObjectTypeDiscriminatorPropertyName"), { unique: true })
968
- .head()
969
- .chain((_value) => _value.toString())
970
- .toMaybe());
971
- if (_tsObjectTypeDiscriminatorPropertyNameEither.isLeft()) {
972
- return _tsObjectTypeDiscriminatorPropertyNameEither;
973
- }
974
- const tsObjectTypeDiscriminatorPropertyName = _tsObjectTypeDiscriminatorPropertyNameEither.unsafeCoerce();
975
1721
  return purify.Either.of({
976
- ..._super0,
977
- identifier,
978
- type,
979
- tsDataFactoryVariable,
1722
+ ...$super0,
1723
+ $identifier,
1724
+ $type,
980
1725
  tsFeatureExcludes,
981
1726
  tsFeatureIncludes,
982
1727
  tsImports,
983
1728
  tsObjectDeclarationType,
984
- tsObjectIdentifierPrefixPropertyName,
985
- tsObjectIdentifierPropertyName,
986
- tsObjectTypeDiscriminatorPropertyName,
987
1729
  });
988
1730
  }
989
- ShaclmateOntology._propertiesFromRdf = _propertiesFromRdf;
990
- function fromRdf(parameters) {
991
- return ShaclmateOntology._propertiesFromRdf(parameters);
1731
+ ShaclmateOntology.$propertiesFromRdf = $propertiesFromRdf;
1732
+ function $toRdf(_shaclmateOntology, options) {
1733
+ const ignoreRdfType = !!options?.ignoreRdfType;
1734
+ const mutateGraph = options?.mutateGraph;
1735
+ const resourceSet = options?.resourceSet ??
1736
+ new rdfjsResource.MutableResourceSet({
1737
+ dataFactory,
1738
+ dataset: datasetFactory.dataset(),
1739
+ });
1740
+ const resource = OwlOntologyStatic.$toRdf(_shaclmateOntology, {
1741
+ ignoreRdfType: true,
1742
+ mutateGraph,
1743
+ resourceSet,
1744
+ });
1745
+ if (!ignoreRdfType) {
1746
+ resource.add($RdfVocabularies.rdf.type, resource.dataFactory.namedNode("http://www.w3.org/2002/07/owl#Ontology"));
1747
+ }
1748
+ resource.add(ShaclmateNodeShape.$properties.tsFeatureExcludes["identifier"], _shaclmateOntology.tsFeatureExcludes.map((item) => item));
1749
+ resource.add(ShaclmateNodeShape.$properties.tsFeatureIncludes["identifier"], _shaclmateOntology.tsFeatureIncludes.map((item) => item));
1750
+ resource.add(ShaclmateNodeShape.$properties.tsImports["identifier"], _shaclmateOntology.tsImports.map((item) => item));
1751
+ resource.add(ShaclmateNodeShape.$properties.tsObjectDeclarationType["identifier"], _shaclmateOntology.tsObjectDeclarationType);
1752
+ return resource;
992
1753
  }
993
- ShaclmateOntology.fromRdf = fromRdf;
994
- ShaclmateOntology.fromRdfType = dataFactory.namedNode("http://www.w3.org/2002/07/owl#Ontology");
1754
+ ShaclmateOntology.$toRdf = $toRdf;
1755
+ ShaclmateOntology.$properties = {
1756
+ ...OwlOntologyStatic.$properties,
1757
+ tsFeatureExcludes: {
1758
+ identifier: dataFactory.namedNode("http://purl.org/shaclmate/ontology#tsFeatureExclude"),
1759
+ },
1760
+ tsFeatureIncludes: {
1761
+ identifier: dataFactory.namedNode("http://purl.org/shaclmate/ontology#tsFeatureInclude"),
1762
+ },
1763
+ tsImports: {
1764
+ identifier: dataFactory.namedNode("http://purl.org/shaclmate/ontology#tsImport"),
1765
+ },
1766
+ tsObjectDeclarationType: {
1767
+ identifier: dataFactory.namedNode("http://purl.org/shaclmate/ontology#tsObjectDeclarationType"),
1768
+ },
1769
+ };
995
1770
  })(ShaclmateOntology || (ShaclmateOntology = {}));
996
- export var ShaclCoreNodeShape;
997
- (function (ShaclCoreNodeShape) {
998
- function _propertiesFromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource,
1771
+ export var ShaclCoreNodeShapeStatic;
1772
+ (function (ShaclCoreNodeShapeStatic) {
1773
+ ShaclCoreNodeShapeStatic.$fromRdfType = dataFactory.namedNode("http://www.w3.org/ns/shacl#NodeShape");
1774
+ ShaclCoreNodeShapeStatic.$Identifier = BaseShaclCoreShapeStatic.$Identifier;
1775
+ function $fromRdf(resource, options) {
1776
+ let { ignoreRdfType = false, languageIn, objectSet, ...context } = options ?? {};
1777
+ if (!objectSet) {
1778
+ objectSet = new $RdfjsDatasetObjectSet({ dataset: resource.dataset });
1779
+ }
1780
+ return ShaclmateNodeShape.$fromRdf(resource, {
1781
+ ...context,
1782
+ ignoreRdfType: false,
1783
+ objectSet,
1784
+ }).altLazy(() => ShaclCoreNodeShapeStatic.$propertiesFromRdf({
1785
+ ...context,
1786
+ ignoreRdfType,
1787
+ languageIn,
1788
+ objectSet,
1789
+ resource,
1790
+ }));
1791
+ }
1792
+ ShaclCoreNodeShapeStatic.$fromRdf = $fromRdf;
1793
+ function $propertiesFromRdf({ ignoreRdfType: $ignoreRdfType, languageIn: $languageIn, objectSet: $objectSet, resource: $resource,
999
1794
  // @ts-ignore
1000
- ..._context }) {
1001
- const _super0Either = BaseShaclCoreShape._propertiesFromRdf({
1002
- ..._context,
1795
+ ...$context }) {
1796
+ const $super0Either = BaseShaclCoreShapeStatic.$propertiesFromRdf({
1797
+ ...$context,
1003
1798
  ignoreRdfType: true,
1004
- languageIn: _languageIn,
1005
- resource: _resource,
1799
+ languageIn: $languageIn,
1800
+ objectSet: $objectSet,
1801
+ resource: $resource,
1006
1802
  });
1007
- if (_super0Either.isLeft()) {
1008
- return _super0Either;
1009
- }
1010
- const _super0 = _super0Either.unsafeCoerce();
1011
- if (!_ignoreRdfType &&
1012
- !_resource.isInstanceOf(dataFactory.namedNode("http://www.w3.org/ns/shacl#NodeShape"))) {
1013
- return purify.Left(new rdfjsResource.Resource.ValueError({
1014
- focusResource: _resource,
1015
- message: `${rdfjsResource.Resource.Identifier.toString(_resource.identifier)} has unexpected RDF type`,
1016
- predicate: dataFactory.namedNode("http://www.w3.org/ns/shacl#NodeShape"),
1017
- }));
1018
- }
1019
- const identifier = _resource.identifier;
1020
- const type = "ShaclCoreNodeShape";
1021
- const _closedEither = purify.Either.of(_resource
1022
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#closed"), {
1023
- unique: true,
1024
- })
1025
- .head()
1026
- .chain((_value) => _value.toBoolean())
1027
- .toMaybe());
1803
+ if ($super0Either.isLeft()) {
1804
+ return $super0Either;
1805
+ }
1806
+ const $super0 = $super0Either.unsafeCoerce();
1807
+ if (!$ignoreRdfType && !$resource.isInstanceOf(ShaclCoreNodeShapeStatic.$fromRdfType)) {
1808
+ return $resource
1809
+ .value($RdfVocabularies.rdf.type)
1810
+ .chain((actualRdfType) => actualRdfType.toIri())
1811
+ .chain((actualRdfType) => purify.Left(new Error(`${rdfjsResource.Resource.Identifier.toString($resource.identifier)} has unexpected RDF type (actual: ${actualRdfType.value}, expected: http://www.w3.org/ns/shacl#NodeShape)`)));
1812
+ }
1813
+ const $identifier = $resource.identifier;
1814
+ const $type = "ShaclCoreNodeShape";
1815
+ const _closedEither = purify.Either.of($resource.values(ShaclCoreNodeShapeStatic.$properties.closed["identifier"], { unique: true }))
1816
+ .chain((values) => values.chainMap((value) => value.toBoolean()))
1817
+ .map((values) => values.length > 0
1818
+ ? values.map((value) => purify.Maybe.of(value))
1819
+ : rdfjsResource.Resource.Values.fromValue({
1820
+ object: purify.Maybe.empty(),
1821
+ predicate: ShaclCoreNodeShapeStatic.$properties.closed["identifier"],
1822
+ subject: $resource,
1823
+ }))
1824
+ .chain((values) => values.head());
1028
1825
  if (_closedEither.isLeft()) {
1029
1826
  return _closedEither;
1030
1827
  }
1031
1828
  const closed = _closedEither.unsafeCoerce();
1032
- const _ignoredPropertiesEither = purify.Either.of(_resource
1033
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#ignoredProperties"), { unique: true })
1034
- .head()
1035
- .chain((value) => value.toList())
1036
- .map((values) => values.flatMap((_value) => _value
1037
- .toValues()
1038
- .head()
1039
- .chain((_value) => _value.toIri())
1040
- .toMaybe()
1041
- .toList()))
1042
- .toMaybe());
1829
+ const _ignoredPropertiesEither = purify.Either.of($resource.values(ShaclCoreNodeShapeStatic.$properties.ignoredProperties["identifier"], {
1830
+ unique: true,
1831
+ }))
1832
+ .chain((values) => values.chainMap((value) => value.toList()))
1833
+ .chain((valueLists) => valueLists.chainMap((valueList) => purify.Either.of(rdfjsResource.Resource.Values.fromArray({
1834
+ objects: valueList,
1835
+ predicate: ShaclCoreNodeShapeStatic.$properties.ignoredProperties["identifier"],
1836
+ subject: $resource,
1837
+ })).chain((values) => values.chainMap((value) => value.toIri()))))
1838
+ .map((valueLists) => valueLists.map((valueList) => valueList.toArray()))
1839
+ .map((values) => values.length > 0
1840
+ ? values.map((value) => purify.Maybe.of(value))
1841
+ : rdfjsResource.Resource.Values.fromValue({
1842
+ object: purify.Maybe.empty(),
1843
+ predicate: ShaclCoreNodeShapeStatic.$properties.ignoredProperties["identifier"],
1844
+ subject: $resource,
1845
+ }))
1846
+ .chain((values) => values.head());
1043
1847
  if (_ignoredPropertiesEither.isLeft()) {
1044
1848
  return _ignoredPropertiesEither;
1045
1849
  }
1046
1850
  const ignoredProperties = _ignoredPropertiesEither.unsafeCoerce();
1047
- const _propertiesEither = purify.Either.of([
1048
- ..._resource
1049
- .values(dataFactory.namedNode("http://www.w3.org/ns/shacl#property"), {
1050
- unique: true,
1051
- })
1052
- .flatMap((_item) => _item
1053
- .toValues()
1054
- .head()
1055
- .chain((_value) => _value.toIdentifier())
1056
- .toMaybe()
1057
- .toList()),
1058
- ]);
1851
+ const _propertiesEither = purify.Either.of($resource.values(ShaclCoreNodeShapeStatic.$properties.properties["identifier"], { unique: true }))
1852
+ .chain((values) => values.chainMap((value) => value.toIdentifier()))
1853
+ .map((values) => values.toArray())
1854
+ .map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
1855
+ object: valuesArray,
1856
+ predicate: ShaclCoreNodeShapeStatic.$properties.properties["identifier"],
1857
+ subject: $resource,
1858
+ }))
1859
+ .chain((values) => values.head());
1059
1860
  if (_propertiesEither.isLeft()) {
1060
1861
  return _propertiesEither;
1061
1862
  }
1062
1863
  const properties = _propertiesEither.unsafeCoerce();
1063
1864
  return purify.Either.of({
1064
- ..._super0,
1065
- identifier,
1066
- type,
1865
+ ...$super0,
1866
+ $identifier,
1867
+ $type,
1067
1868
  closed,
1068
1869
  ignoredProperties,
1069
1870
  properties,
1070
1871
  });
1071
1872
  }
1072
- ShaclCoreNodeShape._propertiesFromRdf = _propertiesFromRdf;
1073
- function fromRdf(parameters) {
1074
- return ShaclCoreNodeShape._propertiesFromRdf(parameters);
1873
+ ShaclCoreNodeShapeStatic.$propertiesFromRdf = $propertiesFromRdf;
1874
+ function $toRdf(_shaclCoreNodeShape, options) {
1875
+ const ignoreRdfType = !!options?.ignoreRdfType;
1876
+ const mutateGraph = options?.mutateGraph;
1877
+ const resourceSet = options?.resourceSet ??
1878
+ new rdfjsResource.MutableResourceSet({
1879
+ dataFactory,
1880
+ dataset: datasetFactory.dataset(),
1881
+ });
1882
+ const resource = BaseShaclCoreShapeStatic.$toRdf(_shaclCoreNodeShape, {
1883
+ ignoreRdfType: true,
1884
+ mutateGraph,
1885
+ resourceSet,
1886
+ });
1887
+ if (!ignoreRdfType) {
1888
+ resource.add($RdfVocabularies.rdf.type, resource.dataFactory.namedNode("http://purl.org/shaclmate/ontology#ShaclCoreNodeShape"));
1889
+ resource.add($RdfVocabularies.rdf.type, resource.dataFactory.namedNode("http://www.w3.org/ns/shacl#NodeShape"));
1890
+ }
1891
+ resource.add(ShaclCoreNodeShapeStatic.$properties.closed["identifier"], _shaclCoreNodeShape.closed);
1892
+ resource.add(ShaclCoreNodeShapeStatic.$properties.ignoredProperties["identifier"], _shaclCoreNodeShape.ignoredProperties.map((value) => value.length > 0
1893
+ ? value.reduce(({ currentSubListResource, listResource }, item, itemIndex, list) => {
1894
+ if (itemIndex === 0) {
1895
+ currentSubListResource = listResource;
1896
+ }
1897
+ else {
1898
+ const newSubListResource = resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph });
1899
+ currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier);
1900
+ currentSubListResource = newSubListResource;
1901
+ }
1902
+ currentSubListResource.add($RdfVocabularies.rdf.first, item);
1903
+ if (itemIndex + 1 === list.length) {
1904
+ currentSubListResource.add($RdfVocabularies.rdf.rest, $RdfVocabularies.rdf.nil);
1905
+ }
1906
+ return { currentSubListResource, listResource };
1907
+ }, {
1908
+ currentSubListResource: null,
1909
+ listResource: resourceSet.mutableResource(dataFactory.blankNode(), { mutateGraph }),
1910
+ }).listResource.identifier
1911
+ : $RdfVocabularies.rdf.nil));
1912
+ resource.add(ShaclCoreNodeShapeStatic.$properties.properties["identifier"], _shaclCoreNodeShape.properties.map((item) => item));
1913
+ return resource;
1075
1914
  }
1076
- ShaclCoreNodeShape.fromRdf = fromRdf;
1077
- ShaclCoreNodeShape.fromRdfType = dataFactory.namedNode("http://www.w3.org/ns/shacl#NodeShape");
1078
- })(ShaclCoreNodeShape || (ShaclCoreNodeShape = {}));
1915
+ ShaclCoreNodeShapeStatic.$toRdf = $toRdf;
1916
+ ShaclCoreNodeShapeStatic.$properties = {
1917
+ ...BaseShaclCoreShapeStatic.$properties,
1918
+ closed: {
1919
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#closed"),
1920
+ },
1921
+ ignoredProperties: {
1922
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#ignoredProperties"),
1923
+ },
1924
+ properties: {
1925
+ identifier: dataFactory.namedNode("http://www.w3.org/ns/shacl#property"),
1926
+ },
1927
+ };
1928
+ })(ShaclCoreNodeShapeStatic || (ShaclCoreNodeShapeStatic = {}));
1079
1929
  export var ShaclmateNodeShape;
1080
1930
  (function (ShaclmateNodeShape) {
1081
- function _propertiesFromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource,
1931
+ ShaclmateNodeShape.$fromRdfType = dataFactory.namedNode("http://www.w3.org/ns/shacl#NodeShape");
1932
+ ShaclmateNodeShape.$Identifier = ShaclCoreNodeShapeStatic.$Identifier;
1933
+ function $fromRdf(resource, options) {
1934
+ let { ignoreRdfType = false, languageIn, objectSet, ...context } = options ?? {};
1935
+ if (!objectSet) {
1936
+ objectSet = new $RdfjsDatasetObjectSet({ dataset: resource.dataset });
1937
+ }
1938
+ return ShaclmateNodeShape.$propertiesFromRdf({
1939
+ ...context,
1940
+ ignoreRdfType,
1941
+ languageIn,
1942
+ objectSet,
1943
+ resource,
1944
+ });
1945
+ }
1946
+ ShaclmateNodeShape.$fromRdf = $fromRdf;
1947
+ function $propertiesFromRdf({ ignoreRdfType: $ignoreRdfType, languageIn: $languageIn, objectSet: $objectSet, resource: $resource,
1082
1948
  // @ts-ignore
1083
- ..._context }) {
1084
- const _super0Either = ShaclCoreNodeShape._propertiesFromRdf({
1085
- ..._context,
1949
+ ...$context }) {
1950
+ const $super0Either = ShaclCoreNodeShapeStatic.$propertiesFromRdf({
1951
+ ...$context,
1086
1952
  ignoreRdfType: true,
1087
- languageIn: _languageIn,
1088
- resource: _resource,
1953
+ languageIn: $languageIn,
1954
+ objectSet: $objectSet,
1955
+ resource: $resource,
1089
1956
  });
1090
- if (_super0Either.isLeft()) {
1091
- return _super0Either;
1092
- }
1093
- const _super0 = _super0Either.unsafeCoerce();
1094
- if (!_ignoreRdfType &&
1095
- !_resource.isInstanceOf(dataFactory.namedNode("http://www.w3.org/ns/shacl#NodeShape"))) {
1096
- return purify.Left(new rdfjsResource.Resource.ValueError({
1097
- focusResource: _resource,
1098
- message: `${rdfjsResource.Resource.Identifier.toString(_resource.identifier)} has unexpected RDF type`,
1099
- predicate: dataFactory.namedNode("http://www.w3.org/ns/shacl#NodeShape"),
1100
- }));
1101
- }
1102
- const identifier = _resource.identifier;
1103
- const type = "ShaclmateNodeShape";
1104
- const _abstractEither = purify.Either.of(_resource
1105
- .values(dataFactory.namedNode("http://purl.org/shaclmate/ontology#abstract"), { unique: true })
1106
- .head()
1107
- .chain((_value) => _value.toBoolean())
1108
- .toMaybe());
1957
+ if ($super0Either.isLeft()) {
1958
+ return $super0Either;
1959
+ }
1960
+ const $super0 = $super0Either.unsafeCoerce();
1961
+ if (!$ignoreRdfType && !$resource.isInstanceOf(ShaclmateNodeShape.$fromRdfType)) {
1962
+ return $resource
1963
+ .value($RdfVocabularies.rdf.type)
1964
+ .chain((actualRdfType) => actualRdfType.toIri())
1965
+ .chain((actualRdfType) => purify.Left(new Error(`${rdfjsResource.Resource.Identifier.toString($resource.identifier)} has unexpected RDF type (actual: ${actualRdfType.value}, expected: http://www.w3.org/ns/shacl#NodeShape)`)));
1966
+ }
1967
+ const $identifier = $resource.identifier;
1968
+ const $type = "ShaclmateNodeShape";
1969
+ const _abstractEither = purify.Either.of($resource.values(ShaclmateNodeShape.$properties.abstract["identifier"], { unique: true }))
1970
+ .chain((values) => values.chainMap((value) => value.toBoolean()))
1971
+ .map((values) => values.length > 0
1972
+ ? values.map((value) => purify.Maybe.of(value))
1973
+ : rdfjsResource.Resource.Values.fromValue({
1974
+ object: purify.Maybe.empty(),
1975
+ predicate: ShaclmateNodeShape.$properties.abstract["identifier"],
1976
+ subject: $resource,
1977
+ }))
1978
+ .chain((values) => values.head());
1109
1979
  if (_abstractEither.isLeft()) {
1110
1980
  return _abstractEither;
1111
1981
  }
1112
1982
  const abstract = _abstractEither.unsafeCoerce();
1113
- const _export_Either = purify.Either.of(_resource
1114
- .values(dataFactory.namedNode("http://purl.org/shaclmate/ontology#export"), { unique: true })
1115
- .head()
1116
- .chain((_value) => _value.toBoolean())
1117
- .toMaybe());
1983
+ const _export_Either = purify.Either.of($resource.values(ShaclmateNodeShape.$properties.export_["identifier"], { unique: true }))
1984
+ .chain((values) => values.chainMap((value) => value.toBoolean()))
1985
+ .map((values) => values.length > 0
1986
+ ? values.map((value) => purify.Maybe.of(value))
1987
+ : rdfjsResource.Resource.Values.fromValue({
1988
+ object: purify.Maybe.empty(),
1989
+ predicate: ShaclmateNodeShape.$properties.export_["identifier"],
1990
+ subject: $resource,
1991
+ }))
1992
+ .chain((values) => values.head());
1118
1993
  if (_export_Either.isLeft()) {
1119
1994
  return _export_Either;
1120
1995
  }
1121
1996
  const export_ = _export_Either.unsafeCoerce();
1122
- const _externEither = purify.Either.of(_resource
1123
- .values(dataFactory.namedNode("http://purl.org/shaclmate/ontology#extern"), { unique: true })
1124
- .head()
1125
- .chain((_value) => _value.toBoolean())
1126
- .toMaybe());
1997
+ const _externEither = purify.Either.of($resource.values(ShaclmateNodeShape.$properties.extern["identifier"], { unique: true }))
1998
+ .chain((values) => values.chainMap((value) => value.toBoolean()))
1999
+ .map((values) => values.length > 0
2000
+ ? values.map((value) => purify.Maybe.of(value))
2001
+ : rdfjsResource.Resource.Values.fromValue({
2002
+ object: purify.Maybe.empty(),
2003
+ predicate: ShaclmateNodeShape.$properties.extern["identifier"],
2004
+ subject: $resource,
2005
+ }))
2006
+ .chain((values) => values.head());
1127
2007
  if (_externEither.isLeft()) {
1128
2008
  return _externEither;
1129
2009
  }
1130
2010
  const extern = _externEither.unsafeCoerce();
1131
- const _fromRdfTypeEither = purify.Either.of(_resource
1132
- .values(dataFactory.namedNode("http://purl.org/shaclmate/ontology#fromRdfType"), { unique: true })
1133
- .head()
1134
- .chain((_value) => _value.toIri())
1135
- .toMaybe());
2011
+ const _fromRdfTypeEither = purify.Either.of($resource.values(ShaclmateNodeShape.$properties.fromRdfType["identifier"], { unique: true }))
2012
+ .chain((values) => values.chainMap((value) => value.toIri()))
2013
+ .map((values) => values.length > 0
2014
+ ? values.map((value) => purify.Maybe.of(value))
2015
+ : rdfjsResource.Resource.Values.fromValue({
2016
+ object: purify.Maybe.empty(),
2017
+ predicate: ShaclmateNodeShape.$properties.fromRdfType["identifier"],
2018
+ subject: $resource,
2019
+ }))
2020
+ .chain((values) => values.head());
1136
2021
  if (_fromRdfTypeEither.isLeft()) {
1137
2022
  return _fromRdfTypeEither;
1138
2023
  }
1139
2024
  const fromRdfType = _fromRdfTypeEither.unsafeCoerce();
1140
- const _identifierMintingStrategyEither = purify.Either.of(_resource
1141
- .values(dataFactory.namedNode("http://purl.org/shaclmate/ontology#identifierMintingStrategy"), { unique: true })
1142
- .head()
1143
- .chain((_value) => _value.toIri().chain((iri) => {
2025
+ const _identifierMintingStrategyEither = purify.Either.of($resource.values(ShaclmateNodeShape.$properties.identifierMintingStrategy["identifier"], {
2026
+ unique: true,
2027
+ }))
2028
+ .chain((values) => values.chainMap((value) => value.toIri().chain((iri) => {
1144
2029
  switch (iri.value) {
1145
2030
  case "http://purl.org/shaclmate/ontology#_IdentifierMintingStrategy_BlankNode":
1146
2031
  return purify.Either.of(iri);
@@ -1152,170 +2037,187 @@ export var ShaclmateNodeShape;
1152
2037
  return purify.Left(new rdfjsResource.Resource.MistypedValueError({
1153
2038
  actualValue: iri,
1154
2039
  expectedValueType: 'rdfjs.NamedNode<"http://purl.org/shaclmate/ontology#_IdentifierMintingStrategy_BlankNode" | "http://purl.org/shaclmate/ontology#_IdentifierMintingStrategy_SHA256" | "http://purl.org/shaclmate/ontology#_IdentifierMintingStrategy_UUIDv4">',
1155
- focusResource: _resource,
1156
- predicate: dataFactory.namedNode("http://purl.org/shaclmate/ontology#identifierMintingStrategy"),
2040
+ focusResource: $resource,
2041
+ predicate: ShaclmateNodeShape.$properties.identifierMintingStrategy["identifier"],
1157
2042
  }));
1158
2043
  }
1159
- }))
1160
- .toMaybe());
2044
+ })))
2045
+ .map((values) => values.length > 0
2046
+ ? values.map((value) => purify.Maybe.of(value))
2047
+ : rdfjsResource.Resource.Values.fromValue({
2048
+ object: purify.Maybe.empty(),
2049
+ predicate: ShaclmateNodeShape.$properties.identifierMintingStrategy["identifier"],
2050
+ subject: $resource,
2051
+ }))
2052
+ .chain((values) => values.head());
1161
2053
  if (_identifierMintingStrategyEither.isLeft()) {
1162
2054
  return _identifierMintingStrategyEither;
1163
2055
  }
1164
2056
  const identifierMintingStrategy = _identifierMintingStrategyEither.unsafeCoerce();
1165
- const _mutableEither = purify.Either.of(_resource
1166
- .values(dataFactory.namedNode("http://purl.org/shaclmate/ontology#mutable"), { unique: true })
1167
- .head()
1168
- .chain((_value) => _value.toBoolean())
1169
- .toMaybe());
2057
+ const _mutableEither = purify.Either.of($resource.values(ShaclmateNodeShape.$properties.mutable["identifier"], { unique: true }))
2058
+ .chain((values) => values.chainMap((value) => value.toBoolean()))
2059
+ .map((values) => values.length > 0
2060
+ ? values.map((value) => purify.Maybe.of(value))
2061
+ : rdfjsResource.Resource.Values.fromValue({
2062
+ object: purify.Maybe.empty(),
2063
+ predicate: ShaclmateNodeShape.$properties.mutable["identifier"],
2064
+ subject: $resource,
2065
+ }))
2066
+ .chain((values) => values.head());
1170
2067
  if (_mutableEither.isLeft()) {
1171
2068
  return _mutableEither;
1172
2069
  }
1173
2070
  const mutable = _mutableEither.unsafeCoerce();
1174
- const _nameEither = purify.Either.of(_resource
1175
- .values(dataFactory.namedNode("http://purl.org/shaclmate/ontology#name"), { unique: true })
1176
- .head()
1177
- .chain((_value) => _value.toString())
1178
- .toMaybe());
2071
+ const _nameEither = purify.Either.of($resource.values(ShaclmateNodeShape.$properties.name["identifier"], { unique: true }))
2072
+ .chain((values) => values.chainMap((value) => value.toString()))
2073
+ .map((values) => values.length > 0
2074
+ ? values.map((value) => purify.Maybe.of(value))
2075
+ : rdfjsResource.Resource.Values.fromValue({
2076
+ object: purify.Maybe.empty(),
2077
+ predicate: ShaclmateNodeShape.$properties.name["identifier"],
2078
+ subject: $resource,
2079
+ }))
2080
+ .chain((values) => values.head());
1179
2081
  if (_nameEither.isLeft()) {
1180
2082
  return _nameEither;
1181
2083
  }
1182
2084
  const name = _nameEither.unsafeCoerce();
1183
- const _toRdfTypesEither = purify.Either.of([
1184
- ..._resource
1185
- .values(dataFactory.namedNode("http://purl.org/shaclmate/ontology#toRdfType"), { unique: true })
1186
- .flatMap((_item) => _item
1187
- .toValues()
1188
- .head()
1189
- .chain((_value) => _value.toIri())
1190
- .toMaybe()
1191
- .toList()),
1192
- ]);
2085
+ const _rdfTypeEither = purify.Either.of($resource.values(ShaclmateNodeShape.$properties.rdfType["identifier"], { unique: true }))
2086
+ .chain((values) => values.chainMap((value) => value.toIri()))
2087
+ .map((values) => values.length > 0
2088
+ ? values.map((value) => purify.Maybe.of(value))
2089
+ : rdfjsResource.Resource.Values.fromValue({
2090
+ object: purify.Maybe.empty(),
2091
+ predicate: ShaclmateNodeShape.$properties.rdfType["identifier"],
2092
+ subject: $resource,
2093
+ }))
2094
+ .chain((values) => values.head());
2095
+ if (_rdfTypeEither.isLeft()) {
2096
+ return _rdfTypeEither;
2097
+ }
2098
+ const rdfType = _rdfTypeEither.unsafeCoerce();
2099
+ const _toRdfTypesEither = purify.Either.of($resource.values(ShaclmateNodeShape.$properties.toRdfTypes["identifier"], {
2100
+ unique: true,
2101
+ }))
2102
+ .chain((values) => values.chainMap((value) => value.toIri()))
2103
+ .map((values) => values.toArray())
2104
+ .map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
2105
+ object: valuesArray,
2106
+ predicate: ShaclmateNodeShape.$properties.toRdfTypes["identifier"],
2107
+ subject: $resource,
2108
+ }))
2109
+ .chain((values) => values.head());
1193
2110
  if (_toRdfTypesEither.isLeft()) {
1194
2111
  return _toRdfTypesEither;
1195
2112
  }
1196
2113
  const toRdfTypes = _toRdfTypesEither.unsafeCoerce();
1197
- const _tsFeatureExcludesEither = purify.Either.of([
1198
- ..._resource
1199
- .values(dataFactory.namedNode("http://purl.org/shaclmate/ontology#tsFeatureExclude"), { unique: true })
1200
- .flatMap((_item) => _item
1201
- .toValues()
1202
- .head()
1203
- .chain((_value) => _value.toIri().chain((iri) => {
1204
- switch (iri.value) {
1205
- case "http://purl.org/shaclmate/ontology#_TsFeature_All":
1206
- return purify.Either.of(iri);
1207
- case "http://purl.org/shaclmate/ontology#_TsFeature_Create":
1208
- return purify.Either.of(iri);
1209
- case "http://purl.org/shaclmate/ontology#_TsFeature_Equals":
1210
- return purify.Either.of(iri);
1211
- case "http://purl.org/shaclmate/ontology#_TsFeature_FromJson":
1212
- return purify.Either.of(iri);
1213
- case "http://purl.org/shaclmate/ontology#_TsFeature_FromRdf":
1214
- return purify.Either.of(iri);
1215
- case "http://purl.org/shaclmate/ontology#_TsFeature_Hash":
1216
- return purify.Either.of(iri);
1217
- case "http://purl.org/shaclmate/ontology#_TsFeature_Json":
1218
- return purify.Either.of(iri);
1219
- case "http://purl.org/shaclmate/ontology#_TsFeature_JsonSchema":
1220
- return purify.Either.of(iri);
1221
- case "http://purl.org/shaclmate/ontology#_TsFeature_JsonUiSchema":
1222
- return purify.Either.of(iri);
1223
- case "http://purl.org/shaclmate/ontology#_TsFeature_None":
1224
- return purify.Either.of(iri);
1225
- case "http://purl.org/shaclmate/ontology#_TsFeature_Rdf":
1226
- return purify.Either.of(iri);
1227
- case "http://purl.org/shaclmate/ontology#_TsFeature_Sparql":
1228
- return purify.Either.of(iri);
1229
- case "http://purl.org/shaclmate/ontology#_TsFeature_ToJson":
1230
- return purify.Either.of(iri);
1231
- case "http://purl.org/shaclmate/ontology#_TsFeature_ToRdf":
1232
- return purify.Either.of(iri);
1233
- default:
1234
- return purify.Left(new rdfjsResource.Resource.MistypedValueError({
1235
- actualValue: iri,
1236
- expectedValueType: 'rdfjs.NamedNode<"http://purl.org/shaclmate/ontology#_TsFeature_All" | "http://purl.org/shaclmate/ontology#_TsFeature_Create" | "http://purl.org/shaclmate/ontology#_TsFeature_Equals" | "http://purl.org/shaclmate/ontology#_TsFeature_FromJson" | "http://purl.org/shaclmate/ontology#_TsFeature_FromRdf" | "http://purl.org/shaclmate/ontology#_TsFeature_Hash" | "http://purl.org/shaclmate/ontology#_TsFeature_Json" | "http://purl.org/shaclmate/ontology#_TsFeature_JsonSchema" | "http://purl.org/shaclmate/ontology#_TsFeature_JsonUiSchema" | "http://purl.org/shaclmate/ontology#_TsFeature_None" | "http://purl.org/shaclmate/ontology#_TsFeature_Rdf" | "http://purl.org/shaclmate/ontology#_TsFeature_Sparql" | "http://purl.org/shaclmate/ontology#_TsFeature_ToJson" | "http://purl.org/shaclmate/ontology#_TsFeature_ToRdf">',
1237
- focusResource: _resource,
1238
- predicate: dataFactory.namedNode("http://purl.org/shaclmate/ontology#tsFeatureExclude"),
1239
- }));
1240
- }
1241
- }))
1242
- .toMaybe()
1243
- .toList()),
1244
- ]);
2114
+ const _tsFeatureExcludesEither = purify.Either.of($resource.values(ShaclmateNodeShape.$properties.tsFeatureExcludes["identifier"], {
2115
+ unique: true,
2116
+ }))
2117
+ .chain((values) => values.chainMap((value) => value.toIri().chain((iri) => {
2118
+ switch (iri.value) {
2119
+ case "http://purl.org/shaclmate/ontology#_TsFeatures_All":
2120
+ return purify.Either.of(iri);
2121
+ case "http://purl.org/shaclmate/ontology#_TsFeature_Create":
2122
+ return purify.Either.of(iri);
2123
+ case "http://purl.org/shaclmate/ontology#_TsFeatures_Default":
2124
+ return purify.Either.of(iri);
2125
+ case "http://purl.org/shaclmate/ontology#_TsFeature_Equals":
2126
+ return purify.Either.of(iri);
2127
+ case "http://purl.org/shaclmate/ontology#_TsFeature_Graphql":
2128
+ return purify.Either.of(iri);
2129
+ case "http://purl.org/shaclmate/ontology#_TsFeature_Hash":
2130
+ return purify.Either.of(iri);
2131
+ case "http://purl.org/shaclmate/ontology#_TsFeature_Json":
2132
+ return purify.Either.of(iri);
2133
+ case "http://purl.org/shaclmate/ontology#_TsFeatures_None":
2134
+ return purify.Either.of(iri);
2135
+ case "http://purl.org/shaclmate/ontology#_TsFeature_Rdf":
2136
+ return purify.Either.of(iri);
2137
+ case "http://purl.org/shaclmate/ontology#_TsFeature_Sparql":
2138
+ return purify.Either.of(iri);
2139
+ default:
2140
+ return purify.Left(new rdfjsResource.Resource.MistypedValueError({
2141
+ actualValue: iri,
2142
+ expectedValueType: 'rdfjs.NamedNode<"http://purl.org/shaclmate/ontology#_TsFeatures_All" | "http://purl.org/shaclmate/ontology#_TsFeature_Create" | "http://purl.org/shaclmate/ontology#_TsFeatures_Default" | "http://purl.org/shaclmate/ontology#_TsFeature_Equals" | "http://purl.org/shaclmate/ontology#_TsFeature_Graphql" | "http://purl.org/shaclmate/ontology#_TsFeature_Hash" | "http://purl.org/shaclmate/ontology#_TsFeature_Json" | "http://purl.org/shaclmate/ontology#_TsFeatures_None" | "http://purl.org/shaclmate/ontology#_TsFeature_Rdf" | "http://purl.org/shaclmate/ontology#_TsFeature_Sparql">',
2143
+ focusResource: $resource,
2144
+ predicate: ShaclmateNodeShape.$properties.tsFeatureExcludes["identifier"],
2145
+ }));
2146
+ }
2147
+ })))
2148
+ .map((values) => values.toArray())
2149
+ .map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
2150
+ object: valuesArray,
2151
+ predicate: ShaclmateNodeShape.$properties.tsFeatureExcludes["identifier"],
2152
+ subject: $resource,
2153
+ }))
2154
+ .chain((values) => values.head());
1245
2155
  if (_tsFeatureExcludesEither.isLeft()) {
1246
2156
  return _tsFeatureExcludesEither;
1247
2157
  }
1248
2158
  const tsFeatureExcludes = _tsFeatureExcludesEither.unsafeCoerce();
1249
- const _tsFeatureIncludesEither = purify.Either.of([
1250
- ..._resource
1251
- .values(dataFactory.namedNode("http://purl.org/shaclmate/ontology#tsFeatureInclude"), { unique: true })
1252
- .flatMap((_item) => _item
1253
- .toValues()
1254
- .head()
1255
- .chain((_value) => _value.toIri().chain((iri) => {
1256
- switch (iri.value) {
1257
- case "http://purl.org/shaclmate/ontology#_TsFeature_All":
1258
- return purify.Either.of(iri);
1259
- case "http://purl.org/shaclmate/ontology#_TsFeature_Create":
1260
- return purify.Either.of(iri);
1261
- case "http://purl.org/shaclmate/ontology#_TsFeature_Equals":
1262
- return purify.Either.of(iri);
1263
- case "http://purl.org/shaclmate/ontology#_TsFeature_FromJson":
1264
- return purify.Either.of(iri);
1265
- case "http://purl.org/shaclmate/ontology#_TsFeature_FromRdf":
1266
- return purify.Either.of(iri);
1267
- case "http://purl.org/shaclmate/ontology#_TsFeature_Hash":
1268
- return purify.Either.of(iri);
1269
- case "http://purl.org/shaclmate/ontology#_TsFeature_Json":
1270
- return purify.Either.of(iri);
1271
- case "http://purl.org/shaclmate/ontology#_TsFeature_JsonSchema":
1272
- return purify.Either.of(iri);
1273
- case "http://purl.org/shaclmate/ontology#_TsFeature_JsonUiSchema":
1274
- return purify.Either.of(iri);
1275
- case "http://purl.org/shaclmate/ontology#_TsFeature_None":
1276
- return purify.Either.of(iri);
1277
- case "http://purl.org/shaclmate/ontology#_TsFeature_Rdf":
1278
- return purify.Either.of(iri);
1279
- case "http://purl.org/shaclmate/ontology#_TsFeature_Sparql":
1280
- return purify.Either.of(iri);
1281
- case "http://purl.org/shaclmate/ontology#_TsFeature_ToJson":
1282
- return purify.Either.of(iri);
1283
- case "http://purl.org/shaclmate/ontology#_TsFeature_ToRdf":
1284
- return purify.Either.of(iri);
1285
- default:
1286
- return purify.Left(new rdfjsResource.Resource.MistypedValueError({
1287
- actualValue: iri,
1288
- expectedValueType: 'rdfjs.NamedNode<"http://purl.org/shaclmate/ontology#_TsFeature_All" | "http://purl.org/shaclmate/ontology#_TsFeature_Create" | "http://purl.org/shaclmate/ontology#_TsFeature_Equals" | "http://purl.org/shaclmate/ontology#_TsFeature_FromJson" | "http://purl.org/shaclmate/ontology#_TsFeature_FromRdf" | "http://purl.org/shaclmate/ontology#_TsFeature_Hash" | "http://purl.org/shaclmate/ontology#_TsFeature_Json" | "http://purl.org/shaclmate/ontology#_TsFeature_JsonSchema" | "http://purl.org/shaclmate/ontology#_TsFeature_JsonUiSchema" | "http://purl.org/shaclmate/ontology#_TsFeature_None" | "http://purl.org/shaclmate/ontology#_TsFeature_Rdf" | "http://purl.org/shaclmate/ontology#_TsFeature_Sparql" | "http://purl.org/shaclmate/ontology#_TsFeature_ToJson" | "http://purl.org/shaclmate/ontology#_TsFeature_ToRdf">',
1289
- focusResource: _resource,
1290
- predicate: dataFactory.namedNode("http://purl.org/shaclmate/ontology#tsFeatureInclude"),
1291
- }));
1292
- }
1293
- }))
1294
- .toMaybe()
1295
- .toList()),
1296
- ]);
2159
+ const _tsFeatureIncludesEither = purify.Either.of($resource.values(ShaclmateNodeShape.$properties.tsFeatureIncludes["identifier"], {
2160
+ unique: true,
2161
+ }))
2162
+ .chain((values) => values.chainMap((value) => value.toIri().chain((iri) => {
2163
+ switch (iri.value) {
2164
+ case "http://purl.org/shaclmate/ontology#_TsFeatures_All":
2165
+ return purify.Either.of(iri);
2166
+ case "http://purl.org/shaclmate/ontology#_TsFeature_Create":
2167
+ return purify.Either.of(iri);
2168
+ case "http://purl.org/shaclmate/ontology#_TsFeatures_Default":
2169
+ return purify.Either.of(iri);
2170
+ case "http://purl.org/shaclmate/ontology#_TsFeature_Equals":
2171
+ return purify.Either.of(iri);
2172
+ case "http://purl.org/shaclmate/ontology#_TsFeature_Graphql":
2173
+ return purify.Either.of(iri);
2174
+ case "http://purl.org/shaclmate/ontology#_TsFeature_Hash":
2175
+ return purify.Either.of(iri);
2176
+ case "http://purl.org/shaclmate/ontology#_TsFeature_Json":
2177
+ return purify.Either.of(iri);
2178
+ case "http://purl.org/shaclmate/ontology#_TsFeatures_None":
2179
+ return purify.Either.of(iri);
2180
+ case "http://purl.org/shaclmate/ontology#_TsFeature_Rdf":
2181
+ return purify.Either.of(iri);
2182
+ case "http://purl.org/shaclmate/ontology#_TsFeature_Sparql":
2183
+ return purify.Either.of(iri);
2184
+ default:
2185
+ return purify.Left(new rdfjsResource.Resource.MistypedValueError({
2186
+ actualValue: iri,
2187
+ expectedValueType: 'rdfjs.NamedNode<"http://purl.org/shaclmate/ontology#_TsFeatures_All" | "http://purl.org/shaclmate/ontology#_TsFeature_Create" | "http://purl.org/shaclmate/ontology#_TsFeatures_Default" | "http://purl.org/shaclmate/ontology#_TsFeature_Equals" | "http://purl.org/shaclmate/ontology#_TsFeature_Graphql" | "http://purl.org/shaclmate/ontology#_TsFeature_Hash" | "http://purl.org/shaclmate/ontology#_TsFeature_Json" | "http://purl.org/shaclmate/ontology#_TsFeatures_None" | "http://purl.org/shaclmate/ontology#_TsFeature_Rdf" | "http://purl.org/shaclmate/ontology#_TsFeature_Sparql">',
2188
+ focusResource: $resource,
2189
+ predicate: ShaclmateNodeShape.$properties.tsFeatureIncludes["identifier"],
2190
+ }));
2191
+ }
2192
+ })))
2193
+ .map((values) => values.toArray())
2194
+ .map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
2195
+ object: valuesArray,
2196
+ predicate: ShaclmateNodeShape.$properties.tsFeatureIncludes["identifier"],
2197
+ subject: $resource,
2198
+ }))
2199
+ .chain((values) => values.head());
1297
2200
  if (_tsFeatureIncludesEither.isLeft()) {
1298
2201
  return _tsFeatureIncludesEither;
1299
2202
  }
1300
2203
  const tsFeatureIncludes = _tsFeatureIncludesEither.unsafeCoerce();
1301
- const _tsImportsEither = purify.Either.of([
1302
- ..._resource
1303
- .values(dataFactory.namedNode("http://purl.org/shaclmate/ontology#tsImport"), { unique: true })
1304
- .flatMap((_item) => _item
1305
- .toValues()
1306
- .head()
1307
- .chain((_value) => _value.toString())
1308
- .toMaybe()
1309
- .toList()),
1310
- ]);
2204
+ const _tsImportsEither = purify.Either.of($resource.values(ShaclmateNodeShape.$properties.tsImports["identifier"], { unique: true }))
2205
+ .chain((values) => values.chainMap((value) => value.toString()))
2206
+ .map((values) => values.toArray())
2207
+ .map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
2208
+ object: valuesArray,
2209
+ predicate: ShaclmateNodeShape.$properties.tsImports["identifier"],
2210
+ subject: $resource,
2211
+ }))
2212
+ .chain((values) => values.head());
1311
2213
  if (_tsImportsEither.isLeft()) {
1312
2214
  return _tsImportsEither;
1313
2215
  }
1314
2216
  const tsImports = _tsImportsEither.unsafeCoerce();
1315
- const _tsObjectDeclarationTypeEither = purify.Either.of(_resource
1316
- .values(dataFactory.namedNode("http://purl.org/shaclmate/ontology#tsObjectDeclarationType"), { unique: true })
1317
- .head()
1318
- .chain((_value) => _value.toIri().chain((iri) => {
2217
+ const _tsObjectDeclarationTypeEither = purify.Either.of($resource.values(ShaclmateNodeShape.$properties.tsObjectDeclarationType["identifier"], {
2218
+ unique: true,
2219
+ }))
2220
+ .chain((values) => values.chainMap((value) => value.toIri().chain((iri) => {
1319
2221
  switch (iri.value) {
1320
2222
  case "http://purl.org/shaclmate/ontology#_TsObjectDeclarationType_Class":
1321
2223
  return purify.Either.of(iri);
@@ -1325,47 +2227,27 @@ export var ShaclmateNodeShape;
1325
2227
  return purify.Left(new rdfjsResource.Resource.MistypedValueError({
1326
2228
  actualValue: iri,
1327
2229
  expectedValueType: 'rdfjs.NamedNode<"http://purl.org/shaclmate/ontology#_TsObjectDeclarationType_Class" | "http://purl.org/shaclmate/ontology#_TsObjectDeclarationType_Interface">',
1328
- focusResource: _resource,
1329
- predicate: dataFactory.namedNode("http://purl.org/shaclmate/ontology#tsObjectDeclarationType"),
2230
+ focusResource: $resource,
2231
+ predicate: ShaclmateNodeShape.$properties.tsObjectDeclarationType["identifier"],
1330
2232
  }));
1331
2233
  }
1332
- }))
1333
- .toMaybe());
2234
+ })))
2235
+ .map((values) => values.length > 0
2236
+ ? values.map((value) => purify.Maybe.of(value))
2237
+ : rdfjsResource.Resource.Values.fromValue({
2238
+ object: purify.Maybe.empty(),
2239
+ predicate: ShaclmateNodeShape.$properties.tsObjectDeclarationType["identifier"],
2240
+ subject: $resource,
2241
+ }))
2242
+ .chain((values) => values.head());
1334
2243
  if (_tsObjectDeclarationTypeEither.isLeft()) {
1335
2244
  return _tsObjectDeclarationTypeEither;
1336
2245
  }
1337
2246
  const tsObjectDeclarationType = _tsObjectDeclarationTypeEither.unsafeCoerce();
1338
- const _tsObjectIdentifierPrefixPropertyNameEither = purify.Either.of(_resource
1339
- .values(dataFactory.namedNode("http://purl.org/shaclmate/ontology#tsObjectIdentifierPrefixPropertyName"), { unique: true })
1340
- .head()
1341
- .chain((_value) => _value.toString())
1342
- .toMaybe());
1343
- if (_tsObjectIdentifierPrefixPropertyNameEither.isLeft()) {
1344
- return _tsObjectIdentifierPrefixPropertyNameEither;
1345
- }
1346
- const tsObjectIdentifierPrefixPropertyName = _tsObjectIdentifierPrefixPropertyNameEither.unsafeCoerce();
1347
- const _tsObjectIdentifierPropertyNameEither = purify.Either.of(_resource
1348
- .values(dataFactory.namedNode("http://purl.org/shaclmate/ontology#tsObjectIdentifierPropertyName"), { unique: true })
1349
- .head()
1350
- .chain((_value) => _value.toString())
1351
- .toMaybe());
1352
- if (_tsObjectIdentifierPropertyNameEither.isLeft()) {
1353
- return _tsObjectIdentifierPropertyNameEither;
1354
- }
1355
- const tsObjectIdentifierPropertyName = _tsObjectIdentifierPropertyNameEither.unsafeCoerce();
1356
- const _tsObjectTypeDiscriminatorPropertyNameEither = purify.Either.of(_resource
1357
- .values(dataFactory.namedNode("http://purl.org/shaclmate/ontology#tsObjectTypeDiscriminatorPropertyName"), { unique: true })
1358
- .head()
1359
- .chain((_value) => _value.toString())
1360
- .toMaybe());
1361
- if (_tsObjectTypeDiscriminatorPropertyNameEither.isLeft()) {
1362
- return _tsObjectTypeDiscriminatorPropertyNameEither;
1363
- }
1364
- const tsObjectTypeDiscriminatorPropertyName = _tsObjectTypeDiscriminatorPropertyNameEither.unsafeCoerce();
1365
2247
  return purify.Either.of({
1366
- ..._super0,
1367
- identifier,
1368
- type,
2248
+ ...$super0,
2249
+ $identifier,
2250
+ $type,
1369
2251
  abstract,
1370
2252
  export_,
1371
2253
  extern,
@@ -1373,115 +2255,735 @@ export var ShaclmateNodeShape;
1373
2255
  identifierMintingStrategy,
1374
2256
  mutable,
1375
2257
  name,
2258
+ rdfType,
1376
2259
  toRdfTypes,
1377
2260
  tsFeatureExcludes,
1378
2261
  tsFeatureIncludes,
1379
2262
  tsImports,
1380
2263
  tsObjectDeclarationType,
1381
- tsObjectIdentifierPrefixPropertyName,
1382
- tsObjectIdentifierPropertyName,
1383
- tsObjectTypeDiscriminatorPropertyName,
1384
2264
  });
1385
2265
  }
1386
- ShaclmateNodeShape._propertiesFromRdf = _propertiesFromRdf;
1387
- function fromRdf(parameters) {
1388
- return ShaclmateNodeShape._propertiesFromRdf(parameters);
2266
+ ShaclmateNodeShape.$propertiesFromRdf = $propertiesFromRdf;
2267
+ function $toRdf(_shaclmateNodeShape, options) {
2268
+ const ignoreRdfType = !!options?.ignoreRdfType;
2269
+ const mutateGraph = options?.mutateGraph;
2270
+ const resourceSet = options?.resourceSet ??
2271
+ new rdfjsResource.MutableResourceSet({
2272
+ dataFactory,
2273
+ dataset: datasetFactory.dataset(),
2274
+ });
2275
+ const resource = ShaclCoreNodeShapeStatic.$toRdf(_shaclmateNodeShape, {
2276
+ ignoreRdfType: true,
2277
+ mutateGraph,
2278
+ resourceSet,
2279
+ });
2280
+ if (!ignoreRdfType) {
2281
+ resource.add($RdfVocabularies.rdf.type, resource.dataFactory.namedNode("http://www.w3.org/ns/shacl#NodeShape"));
2282
+ }
2283
+ resource.add(ShaclmateNodeShape.$properties.abstract["identifier"], _shaclmateNodeShape.abstract);
2284
+ resource.add(ShaclmateNodeShape.$properties.export_["identifier"], _shaclmateNodeShape.export_);
2285
+ resource.add(ShaclmateNodeShape.$properties.extern["identifier"], _shaclmateNodeShape.extern);
2286
+ resource.add(ShaclmateNodeShape.$properties.fromRdfType["identifier"], _shaclmateNodeShape.fromRdfType);
2287
+ resource.add(ShaclmateNodeShape.$properties.identifierMintingStrategy["identifier"], _shaclmateNodeShape.identifierMintingStrategy);
2288
+ resource.add(ShaclmateNodeShape.$properties.mutable["identifier"], _shaclmateNodeShape.mutable);
2289
+ resource.add(ShaclmateNodeShape.$properties.name["identifier"], _shaclmateNodeShape.name);
2290
+ resource.add(ShaclmateNodeShape.$properties.rdfType["identifier"], _shaclmateNodeShape.rdfType);
2291
+ resource.add(ShaclmateNodeShape.$properties.toRdfTypes["identifier"], _shaclmateNodeShape.toRdfTypes.map((item) => item));
2292
+ resource.add(ShaclmateNodeShape.$properties.tsFeatureExcludes["identifier"], _shaclmateNodeShape.tsFeatureExcludes.map((item) => item));
2293
+ resource.add(ShaclmateNodeShape.$properties.tsFeatureIncludes["identifier"], _shaclmateNodeShape.tsFeatureIncludes.map((item) => item));
2294
+ resource.add(ShaclmateNodeShape.$properties.tsImports["identifier"], _shaclmateNodeShape.tsImports.map((item) => item));
2295
+ resource.add(ShaclmateNodeShape.$properties.tsObjectDeclarationType["identifier"], _shaclmateNodeShape.tsObjectDeclarationType);
2296
+ return resource;
1389
2297
  }
1390
- ShaclmateNodeShape.fromRdf = fromRdf;
1391
- ShaclmateNodeShape.fromRdfType = dataFactory.namedNode("http://www.w3.org/ns/shacl#NodeShape");
2298
+ ShaclmateNodeShape.$toRdf = $toRdf;
2299
+ ShaclmateNodeShape.$properties = {
2300
+ ...ShaclCoreNodeShapeStatic.$properties,
2301
+ abstract: {
2302
+ identifier: dataFactory.namedNode("http://purl.org/shaclmate/ontology#abstract"),
2303
+ },
2304
+ export_: {
2305
+ identifier: dataFactory.namedNode("http://purl.org/shaclmate/ontology#export"),
2306
+ },
2307
+ extern: {
2308
+ identifier: dataFactory.namedNode("http://purl.org/shaclmate/ontology#extern"),
2309
+ },
2310
+ fromRdfType: {
2311
+ identifier: dataFactory.namedNode("http://purl.org/shaclmate/ontology#fromRdfType"),
2312
+ },
2313
+ identifierMintingStrategy: {
2314
+ identifier: dataFactory.namedNode("http://purl.org/shaclmate/ontology#identifierMintingStrategy"),
2315
+ },
2316
+ mutable: {
2317
+ identifier: dataFactory.namedNode("http://purl.org/shaclmate/ontology#mutable"),
2318
+ },
2319
+ name: {
2320
+ identifier: dataFactory.namedNode("http://purl.org/shaclmate/ontology#name"),
2321
+ },
2322
+ rdfType: {
2323
+ identifier: dataFactory.namedNode("http://purl.org/shaclmate/ontology#rdfType"),
2324
+ },
2325
+ toRdfTypes: {
2326
+ identifier: dataFactory.namedNode("http://purl.org/shaclmate/ontology#toRdfType"),
2327
+ },
2328
+ tsFeatureExcludes: {
2329
+ identifier: dataFactory.namedNode("http://purl.org/shaclmate/ontology#tsFeatureExclude"),
2330
+ },
2331
+ tsFeatureIncludes: {
2332
+ identifier: dataFactory.namedNode("http://purl.org/shaclmate/ontology#tsFeatureInclude"),
2333
+ },
2334
+ tsImports: {
2335
+ identifier: dataFactory.namedNode("http://purl.org/shaclmate/ontology#tsImport"),
2336
+ },
2337
+ tsObjectDeclarationType: {
2338
+ identifier: dataFactory.namedNode("http://purl.org/shaclmate/ontology#tsObjectDeclarationType"),
2339
+ },
2340
+ };
1392
2341
  })(ShaclmateNodeShape || (ShaclmateNodeShape = {}));
1393
2342
  export var ShaclCorePropertyGroup;
1394
2343
  (function (ShaclCorePropertyGroup) {
1395
- function _propertiesFromRdf({ ignoreRdfType: _ignoreRdfType, languageIn: _languageIn, resource: _resource,
1396
- // @ts-ignore
1397
- ..._context }) {
1398
- if (!_ignoreRdfType &&
1399
- !_resource.isInstanceOf(dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyGroup"))) {
1400
- return purify.Left(new rdfjsResource.Resource.ValueError({
1401
- focusResource: _resource,
1402
- message: `${rdfjsResource.Resource.Identifier.toString(_resource.identifier)} has unexpected RDF type`,
1403
- predicate: dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyGroup"),
2344
+ ShaclCorePropertyGroup.$fromRdfType = dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyGroup");
2345
+ let $Identifier;
2346
+ (function ($Identifier) {
2347
+ function fromString(identifier) {
2348
+ return purify.Either.encase(() => rdfjsResource.Resource.Identifier.fromString({
2349
+ dataFactory,
2350
+ identifier,
1404
2351
  }));
1405
2352
  }
1406
- const identifier = _resource.identifier;
1407
- const type = "ShaclCorePropertyGroup";
1408
- const _commentsEither = purify.Either.of([
1409
- ..._resource
1410
- .values(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#comment"), { unique: true })
1411
- .flatMap((_item) => _item
1412
- .toValues()
1413
- .filter((_value) => {
1414
- const _languageInOrDefault = _languageIn ?? [];
1415
- if (_languageInOrDefault.length === 0) {
1416
- return true;
2353
+ $Identifier.fromString = fromString;
2354
+ $Identifier.toString = rdfjsResource.Resource.Identifier.toString;
2355
+ })($Identifier = ShaclCorePropertyGroup.$Identifier || (ShaclCorePropertyGroup.$Identifier = {}));
2356
+ function $fromRdf(resource, options) {
2357
+ let { ignoreRdfType = false, languageIn, objectSet, ...context } = options ?? {};
2358
+ if (!objectSet) {
2359
+ objectSet = new $RdfjsDatasetObjectSet({ dataset: resource.dataset });
2360
+ }
2361
+ return ShaclCorePropertyGroup.$propertiesFromRdf({
2362
+ ...context,
2363
+ ignoreRdfType,
2364
+ languageIn,
2365
+ objectSet,
2366
+ resource,
2367
+ });
2368
+ }
2369
+ ShaclCorePropertyGroup.$fromRdf = $fromRdf;
2370
+ function $propertiesFromRdf({ ignoreRdfType: $ignoreRdfType, languageIn: $languageIn, objectSet: $objectSet, resource: $resource,
2371
+ // @ts-ignore
2372
+ ...$context }) {
2373
+ if (!$ignoreRdfType && !$resource.isInstanceOf(ShaclCorePropertyGroup.$fromRdfType)) {
2374
+ return $resource
2375
+ .value($RdfVocabularies.rdf.type)
2376
+ .chain((actualRdfType) => actualRdfType.toIri())
2377
+ .chain((actualRdfType) => purify.Left(new Error(`${rdfjsResource.Resource.Identifier.toString($resource.identifier)} has unexpected RDF type (actual: ${actualRdfType.value}, expected: http://www.w3.org/ns/shacl#PropertyGroup)`)));
2378
+ }
2379
+ const $identifier = $resource.identifier;
2380
+ const $type = "ShaclCorePropertyGroup";
2381
+ const _commentsEither = purify.Either.of($resource.values(ShaclCorePropertyGroup.$properties.comments["identifier"], { unique: true }))
2382
+ .chain((values) => {
2383
+ const literalValuesEither = values.chainMap((value) => value.toLiteral());
2384
+ if (literalValuesEither.isLeft()) {
2385
+ return literalValuesEither;
2386
+ }
2387
+ const literalValues = literalValuesEither.unsafeCoerce();
2388
+ const nonUniqueLanguageIn = $languageIn ?? [];
2389
+ if (nonUniqueLanguageIn.length === 0) {
2390
+ return purify.Either.of(literalValues);
2391
+ }
2392
+ let uniqueLanguageIn;
2393
+ if (nonUniqueLanguageIn.length === 1) {
2394
+ uniqueLanguageIn = [nonUniqueLanguageIn[0]];
2395
+ }
2396
+ else {
2397
+ uniqueLanguageIn = [];
2398
+ for (const languageIn of nonUniqueLanguageIn) {
2399
+ if (uniqueLanguageIn.indexOf(languageIn) === -1) {
2400
+ uniqueLanguageIn.push(languageIn);
2401
+ }
1417
2402
  }
1418
- const _valueLiteral = _value.toLiteral().toMaybe().extract();
1419
- if (typeof _valueLiteral === "undefined") {
1420
- return false;
2403
+ }
2404
+ // Return all literals for the first languageIn, then all literals for the second languageIn, etc.
2405
+ // Within a languageIn the literals may be in any order.
2406
+ let filteredLiteralValues;
2407
+ for (const languageIn of uniqueLanguageIn) {
2408
+ if (!filteredLiteralValues) {
2409
+ filteredLiteralValues = literalValues.filter((value) => value.language === languageIn);
1421
2410
  }
1422
- return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
1423
- })
1424
- .head()
1425
- .chain((_value) => _value.toLiteral())
1426
- .toMaybe()
1427
- .toList()),
1428
- ]);
2411
+ else {
2412
+ filteredLiteralValues = filteredLiteralValues.concat(...literalValues
2413
+ .filter((value) => value.language === languageIn)
2414
+ .toArray());
2415
+ }
2416
+ }
2417
+ return purify.Either.of(filteredLiteralValues);
2418
+ })
2419
+ .map((values) => values.toArray())
2420
+ .map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
2421
+ object: valuesArray,
2422
+ predicate: ShaclCorePropertyGroup.$properties.comments["identifier"],
2423
+ subject: $resource,
2424
+ }))
2425
+ .chain((values) => values.head());
1429
2426
  if (_commentsEither.isLeft()) {
1430
2427
  return _commentsEither;
1431
2428
  }
1432
2429
  const comments = _commentsEither.unsafeCoerce();
1433
- const _labelsEither = purify.Either.of([
1434
- ..._resource
1435
- .values(dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#label"), { unique: true })
1436
- .flatMap((_item) => _item
1437
- .toValues()
1438
- .filter((_value) => {
1439
- const _languageInOrDefault = _languageIn ?? [];
1440
- if (_languageInOrDefault.length === 0) {
1441
- return true;
2430
+ const _labelsEither = purify.Either.of($resource.values(ShaclCorePropertyGroup.$properties.labels["identifier"], { unique: true }))
2431
+ .chain((values) => {
2432
+ const literalValuesEither = values.chainMap((value) => value.toLiteral());
2433
+ if (literalValuesEither.isLeft()) {
2434
+ return literalValuesEither;
2435
+ }
2436
+ const literalValues = literalValuesEither.unsafeCoerce();
2437
+ const nonUniqueLanguageIn = $languageIn ?? [];
2438
+ if (nonUniqueLanguageIn.length === 0) {
2439
+ return purify.Either.of(literalValues);
2440
+ }
2441
+ let uniqueLanguageIn;
2442
+ if (nonUniqueLanguageIn.length === 1) {
2443
+ uniqueLanguageIn = [nonUniqueLanguageIn[0]];
2444
+ }
2445
+ else {
2446
+ uniqueLanguageIn = [];
2447
+ for (const languageIn of nonUniqueLanguageIn) {
2448
+ if (uniqueLanguageIn.indexOf(languageIn) === -1) {
2449
+ uniqueLanguageIn.push(languageIn);
2450
+ }
1442
2451
  }
1443
- const _valueLiteral = _value.toLiteral().toMaybe().extract();
1444
- if (typeof _valueLiteral === "undefined") {
1445
- return false;
2452
+ }
2453
+ // Return all literals for the first languageIn, then all literals for the second languageIn, etc.
2454
+ // Within a languageIn the literals may be in any order.
2455
+ let filteredLiteralValues;
2456
+ for (const languageIn of uniqueLanguageIn) {
2457
+ if (!filteredLiteralValues) {
2458
+ filteredLiteralValues = literalValues.filter((value) => value.language === languageIn);
2459
+ }
2460
+ else {
2461
+ filteredLiteralValues = filteredLiteralValues.concat(...literalValues
2462
+ .filter((value) => value.language === languageIn)
2463
+ .toArray());
1446
2464
  }
1447
- return _languageInOrDefault.some((_languageIn) => _languageIn === _valueLiteral.language);
1448
- })
1449
- .head()
1450
- .chain((_value) => _value.toLiteral())
1451
- .toMaybe()
1452
- .toList()),
1453
- ]);
2465
+ }
2466
+ return purify.Either.of(filteredLiteralValues);
2467
+ })
2468
+ .map((values) => values.toArray())
2469
+ .map((valuesArray) => rdfjsResource.Resource.Values.fromValue({
2470
+ object: valuesArray,
2471
+ predicate: ShaclCorePropertyGroup.$properties.labels["identifier"],
2472
+ subject: $resource,
2473
+ }))
2474
+ .chain((values) => values.head());
1454
2475
  if (_labelsEither.isLeft()) {
1455
2476
  return _labelsEither;
1456
2477
  }
1457
2478
  const labels = _labelsEither.unsafeCoerce();
1458
- return purify.Either.of({ identifier, type, comments, labels });
2479
+ return purify.Either.of({ $identifier, $type, comments, labels });
1459
2480
  }
1460
- ShaclCorePropertyGroup._propertiesFromRdf = _propertiesFromRdf;
1461
- function fromRdf(parameters) {
1462
- return ShaclCorePropertyGroup._propertiesFromRdf(parameters);
2481
+ ShaclCorePropertyGroup.$propertiesFromRdf = $propertiesFromRdf;
2482
+ function $toRdf(_shaclCorePropertyGroup, options) {
2483
+ const ignoreRdfType = !!options?.ignoreRdfType;
2484
+ const mutateGraph = options?.mutateGraph;
2485
+ const resourceSet = options?.resourceSet ??
2486
+ new rdfjsResource.MutableResourceSet({
2487
+ dataFactory,
2488
+ dataset: datasetFactory.dataset(),
2489
+ });
2490
+ const resource = resourceSet.mutableResource(_shaclCorePropertyGroup.$identifier, { mutateGraph });
2491
+ if (!ignoreRdfType) {
2492
+ resource.add($RdfVocabularies.rdf.type, resource.dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyGroup"));
2493
+ }
2494
+ resource.add(ShaclCorePropertyGroup.$properties.comments["identifier"], _shaclCorePropertyGroup.comments.map((item) => item));
2495
+ resource.add(ShaclCorePropertyGroup.$properties.labels["identifier"], _shaclCorePropertyGroup.labels.map((item) => item));
2496
+ return resource;
1463
2497
  }
1464
- ShaclCorePropertyGroup.fromRdf = fromRdf;
1465
- ShaclCorePropertyGroup.fromRdfType = dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyGroup");
2498
+ ShaclCorePropertyGroup.$toRdf = $toRdf;
2499
+ ShaclCorePropertyGroup.$properties = {
2500
+ comments: {
2501
+ identifier: dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#comment"),
2502
+ },
2503
+ labels: {
2504
+ identifier: dataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#label"),
2505
+ },
2506
+ };
1466
2507
  })(ShaclCorePropertyGroup || (ShaclCorePropertyGroup = {}));
1467
2508
  export var ShaclCoreShape;
1468
2509
  (function (ShaclCoreShape) {
1469
- function fromRdf({ ignoreRdfType, resource, ...context }) {
1470
- return ShaclCoreNodeShape.fromRdf({ ...context, resource }).altLazy(() => ShaclCorePropertyShape.fromRdf({
1471
- ...context,
1472
- resource,
2510
+ function $fromRdf(resource, options) {
2511
+ return ShaclCoreNodeShapeStatic.$fromRdf(resource, {
2512
+ ...options,
2513
+ ignoreRdfType: false,
2514
+ }).altLazy(() => ShaclCorePropertyShapeStatic.$fromRdf(resource, {
2515
+ ...options,
2516
+ ignoreRdfType: false,
1473
2517
  }));
1474
2518
  }
1475
- ShaclCoreShape.fromRdf = fromRdf;
2519
+ ShaclCoreShape.$fromRdf = $fromRdf;
2520
+ let $Identifier;
2521
+ (function ($Identifier) {
2522
+ function fromString(identifier) {
2523
+ return purify.Either.encase(() => rdfjsResource.Resource.Identifier.fromString({
2524
+ dataFactory,
2525
+ identifier,
2526
+ }));
2527
+ }
2528
+ $Identifier.fromString = fromString;
2529
+ $Identifier.toString = rdfjsResource.Resource.Identifier.toString;
2530
+ })($Identifier = ShaclCoreShape.$Identifier || (ShaclCoreShape.$Identifier = {}));
2531
+ function $toRdf(_shaclCoreShape, _parameters) {
2532
+ switch (_shaclCoreShape.$type) {
2533
+ case "ShaclCoreNodeShape":
2534
+ case "ShaclmateNodeShape":
2535
+ return ShaclCoreNodeShapeStatic.$toRdf(_shaclCoreShape, _parameters);
2536
+ case "ShaclCorePropertyShape":
2537
+ case "ShaclmatePropertyShape":
2538
+ return ShaclCorePropertyShapeStatic.$toRdf(_shaclCoreShape, _parameters);
2539
+ default:
2540
+ _shaclCoreShape;
2541
+ throw new Error("unrecognized type");
2542
+ }
2543
+ }
2544
+ ShaclCoreShape.$toRdf = $toRdf;
1476
2545
  })(ShaclCoreShape || (ShaclCoreShape = {}));
1477
2546
  export var ShaclmateShape;
1478
2547
  (function (ShaclmateShape) {
1479
- function fromRdf({ ignoreRdfType, resource, ...context }) {
1480
- return ShaclmateNodeShape.fromRdf({ ...context, resource }).altLazy(() => ShaclCorePropertyShape.fromRdf({
1481
- ...context,
1482
- resource,
2548
+ function $fromRdf(resource, options) {
2549
+ return ShaclmateNodeShape.$fromRdf(resource, {
2550
+ ...options,
2551
+ ignoreRdfType: false,
2552
+ }).altLazy(() => ShaclCorePropertyShapeStatic.$fromRdf(resource, {
2553
+ ...options,
2554
+ ignoreRdfType: false,
1483
2555
  }));
1484
2556
  }
1485
- ShaclmateShape.fromRdf = fromRdf;
2557
+ ShaclmateShape.$fromRdf = $fromRdf;
2558
+ let $Identifier;
2559
+ (function ($Identifier) {
2560
+ function fromString(identifier) {
2561
+ return purify.Either.encase(() => rdfjsResource.Resource.Identifier.fromString({
2562
+ dataFactory,
2563
+ identifier,
2564
+ }));
2565
+ }
2566
+ $Identifier.fromString = fromString;
2567
+ $Identifier.toString = rdfjsResource.Resource.Identifier.toString;
2568
+ })($Identifier = ShaclmateShape.$Identifier || (ShaclmateShape.$Identifier = {}));
2569
+ function $toRdf(_shaclmateShape, _parameters) {
2570
+ switch (_shaclmateShape.$type) {
2571
+ case "ShaclmateNodeShape":
2572
+ return ShaclmateNodeShape.$toRdf(_shaclmateShape, _parameters);
2573
+ case "ShaclCorePropertyShape":
2574
+ case "ShaclmatePropertyShape":
2575
+ return ShaclCorePropertyShapeStatic.$toRdf(_shaclmateShape, _parameters);
2576
+ default:
2577
+ _shaclmateShape;
2578
+ throw new Error("unrecognized type");
2579
+ }
2580
+ }
2581
+ ShaclmateShape.$toRdf = $toRdf;
1486
2582
  })(ShaclmateShape || (ShaclmateShape = {}));
2583
+ export class $RdfjsDatasetObjectSet {
2584
+ resourceSet;
2585
+ constructor({ dataset }) {
2586
+ this.resourceSet = new rdfjsResource.ResourceSet({ dataset });
2587
+ }
2588
+ async owlOntology(identifier) {
2589
+ return this.owlOntologySync(identifier);
2590
+ }
2591
+ owlOntologySync(identifier) {
2592
+ return this.owlOntologiesSync({
2593
+ where: { identifiers: [identifier], type: "identifiers" },
2594
+ }).map((objects) => objects[0]);
2595
+ }
2596
+ async owlOntologyIdentifiers(query) {
2597
+ return this.owlOntologyIdentifiersSync(query);
2598
+ }
2599
+ owlOntologyIdentifiersSync(query) {
2600
+ return this.$objectIdentifiersSync(OwlOntologyStatic, query);
2601
+ }
2602
+ async owlOntologies(query) {
2603
+ return this.owlOntologiesSync(query);
2604
+ }
2605
+ owlOntologiesSync(query) {
2606
+ return this.$objectsSync(OwlOntologyStatic, query);
2607
+ }
2608
+ async owlOntologiesCount(query) {
2609
+ return this.owlOntologiesCountSync(query);
2610
+ }
2611
+ owlOntologiesCountSync(query) {
2612
+ return this.$objectsCountSync(OwlOntologyStatic, query);
2613
+ }
2614
+ async shaclCoreNodeShape(identifier) {
2615
+ return this.shaclCoreNodeShapeSync(identifier);
2616
+ }
2617
+ shaclCoreNodeShapeSync(identifier) {
2618
+ return this.shaclCoreNodeShapesSync({
2619
+ where: { identifiers: [identifier], type: "identifiers" },
2620
+ }).map((objects) => objects[0]);
2621
+ }
2622
+ async shaclCoreNodeShapeIdentifiers(query) {
2623
+ return this.shaclCoreNodeShapeIdentifiersSync(query);
2624
+ }
2625
+ shaclCoreNodeShapeIdentifiersSync(query) {
2626
+ return this.$objectIdentifiersSync(ShaclCoreNodeShapeStatic, query);
2627
+ }
2628
+ async shaclCoreNodeShapes(query) {
2629
+ return this.shaclCoreNodeShapesSync(query);
2630
+ }
2631
+ shaclCoreNodeShapesSync(query) {
2632
+ return this.$objectsSync(ShaclCoreNodeShapeStatic, query);
2633
+ }
2634
+ async shaclCoreNodeShapesCount(query) {
2635
+ return this.shaclCoreNodeShapesCountSync(query);
2636
+ }
2637
+ shaclCoreNodeShapesCountSync(query) {
2638
+ return this.$objectsCountSync(ShaclCoreNodeShapeStatic, query);
2639
+ }
2640
+ async shaclCorePropertyGroup(identifier) {
2641
+ return this.shaclCorePropertyGroupSync(identifier);
2642
+ }
2643
+ shaclCorePropertyGroupSync(identifier) {
2644
+ return this.shaclCorePropertyGroupsSync({
2645
+ where: { identifiers: [identifier], type: "identifiers" },
2646
+ }).map((objects) => objects[0]);
2647
+ }
2648
+ async shaclCorePropertyGroupIdentifiers(query) {
2649
+ return this.shaclCorePropertyGroupIdentifiersSync(query);
2650
+ }
2651
+ shaclCorePropertyGroupIdentifiersSync(query) {
2652
+ return this.$objectIdentifiersSync(ShaclCorePropertyGroup, query);
2653
+ }
2654
+ async shaclCorePropertyGroups(query) {
2655
+ return this.shaclCorePropertyGroupsSync(query);
2656
+ }
2657
+ shaclCorePropertyGroupsSync(query) {
2658
+ return this.$objectsSync(ShaclCorePropertyGroup, query);
2659
+ }
2660
+ async shaclCorePropertyGroupsCount(query) {
2661
+ return this.shaclCorePropertyGroupsCountSync(query);
2662
+ }
2663
+ shaclCorePropertyGroupsCountSync(query) {
2664
+ return this.$objectsCountSync(ShaclCorePropertyGroup, query);
2665
+ }
2666
+ async shaclCorePropertyShape(identifier) {
2667
+ return this.shaclCorePropertyShapeSync(identifier);
2668
+ }
2669
+ shaclCorePropertyShapeSync(identifier) {
2670
+ return this.shaclCorePropertyShapesSync({
2671
+ where: { identifiers: [identifier], type: "identifiers" },
2672
+ }).map((objects) => objects[0]);
2673
+ }
2674
+ async shaclCorePropertyShapeIdentifiers(query) {
2675
+ return this.shaclCorePropertyShapeIdentifiersSync(query);
2676
+ }
2677
+ shaclCorePropertyShapeIdentifiersSync(query) {
2678
+ return this.$objectIdentifiersSync(ShaclCorePropertyShapeStatic, query);
2679
+ }
2680
+ async shaclCorePropertyShapes(query) {
2681
+ return this.shaclCorePropertyShapesSync(query);
2682
+ }
2683
+ shaclCorePropertyShapesSync(query) {
2684
+ return this.$objectsSync(ShaclCorePropertyShapeStatic, query);
2685
+ }
2686
+ async shaclCorePropertyShapesCount(query) {
2687
+ return this.shaclCorePropertyShapesCountSync(query);
2688
+ }
2689
+ shaclCorePropertyShapesCountSync(query) {
2690
+ return this.$objectsCountSync(ShaclCorePropertyShapeStatic, query);
2691
+ }
2692
+ async shaclmateNodeShape(identifier) {
2693
+ return this.shaclmateNodeShapeSync(identifier);
2694
+ }
2695
+ shaclmateNodeShapeSync(identifier) {
2696
+ return this.shaclmateNodeShapesSync({
2697
+ where: { identifiers: [identifier], type: "identifiers" },
2698
+ }).map((objects) => objects[0]);
2699
+ }
2700
+ async shaclmateNodeShapeIdentifiers(query) {
2701
+ return this.shaclmateNodeShapeIdentifiersSync(query);
2702
+ }
2703
+ shaclmateNodeShapeIdentifiersSync(query) {
2704
+ return this.$objectIdentifiersSync(ShaclmateNodeShape, query);
2705
+ }
2706
+ async shaclmateNodeShapes(query) {
2707
+ return this.shaclmateNodeShapesSync(query);
2708
+ }
2709
+ shaclmateNodeShapesSync(query) {
2710
+ return this.$objectsSync(ShaclmateNodeShape, query);
2711
+ }
2712
+ async shaclmateNodeShapesCount(query) {
2713
+ return this.shaclmateNodeShapesCountSync(query);
2714
+ }
2715
+ shaclmateNodeShapesCountSync(query) {
2716
+ return this.$objectsCountSync(ShaclmateNodeShape, query);
2717
+ }
2718
+ async shaclmateOntology(identifier) {
2719
+ return this.shaclmateOntologySync(identifier);
2720
+ }
2721
+ shaclmateOntologySync(identifier) {
2722
+ return this.shaclmateOntologiesSync({
2723
+ where: { identifiers: [identifier], type: "identifiers" },
2724
+ }).map((objects) => objects[0]);
2725
+ }
2726
+ async shaclmateOntologyIdentifiers(query) {
2727
+ return this.shaclmateOntologyIdentifiersSync(query);
2728
+ }
2729
+ shaclmateOntologyIdentifiersSync(query) {
2730
+ return this.$objectIdentifiersSync(ShaclmateOntology, query);
2731
+ }
2732
+ async shaclmateOntologies(query) {
2733
+ return this.shaclmateOntologiesSync(query);
2734
+ }
2735
+ shaclmateOntologiesSync(query) {
2736
+ return this.$objectsSync(ShaclmateOntology, query);
2737
+ }
2738
+ async shaclmateOntologiesCount(query) {
2739
+ return this.shaclmateOntologiesCountSync(query);
2740
+ }
2741
+ shaclmateOntologiesCountSync(query) {
2742
+ return this.$objectsCountSync(ShaclmateOntology, query);
2743
+ }
2744
+ async shaclmatePropertyShape(identifier) {
2745
+ return this.shaclmatePropertyShapeSync(identifier);
2746
+ }
2747
+ shaclmatePropertyShapeSync(identifier) {
2748
+ return this.shaclmatePropertyShapesSync({
2749
+ where: { identifiers: [identifier], type: "identifiers" },
2750
+ }).map((objects) => objects[0]);
2751
+ }
2752
+ async shaclmatePropertyShapeIdentifiers(query) {
2753
+ return this.shaclmatePropertyShapeIdentifiersSync(query);
2754
+ }
2755
+ shaclmatePropertyShapeIdentifiersSync(query) {
2756
+ return this.$objectIdentifiersSync(ShaclmatePropertyShape, query);
2757
+ }
2758
+ async shaclmatePropertyShapes(query) {
2759
+ return this.shaclmatePropertyShapesSync(query);
2760
+ }
2761
+ shaclmatePropertyShapesSync(query) {
2762
+ return this.$objectsSync(ShaclmatePropertyShape, query);
2763
+ }
2764
+ async shaclmatePropertyShapesCount(query) {
2765
+ return this.shaclmatePropertyShapesCountSync(query);
2766
+ }
2767
+ shaclmatePropertyShapesCountSync(query) {
2768
+ return this.$objectsCountSync(ShaclmatePropertyShape, query);
2769
+ }
2770
+ async shaclCoreShape(identifier) {
2771
+ return this.shaclCoreShapeSync(identifier);
2772
+ }
2773
+ shaclCoreShapeSync(identifier) {
2774
+ return this.shaclCoreShapesSync({
2775
+ where: { identifiers: [identifier], type: "identifiers" },
2776
+ }).map((objects) => objects[0]);
2777
+ }
2778
+ async shaclCoreShapeIdentifiers(query) {
2779
+ return this.shaclCoreShapeIdentifiersSync(query);
2780
+ }
2781
+ shaclCoreShapeIdentifiersSync(query) {
2782
+ return this.$objectUnionIdentifiersSync([ShaclCoreNodeShapeStatic, ShaclCorePropertyShapeStatic], query);
2783
+ }
2784
+ async shaclCoreShapes(query) {
2785
+ return this.shaclCoreShapesSync(query);
2786
+ }
2787
+ shaclCoreShapesSync(query) {
2788
+ return this.$objectUnionsSync([ShaclCoreNodeShapeStatic, ShaclCorePropertyShapeStatic], query);
2789
+ }
2790
+ async shaclCoreShapesCount(query) {
2791
+ return this.shaclCoreShapesCountSync(query);
2792
+ }
2793
+ shaclCoreShapesCountSync(query) {
2794
+ return this.$objectUnionsCountSync([ShaclCoreNodeShapeStatic, ShaclCorePropertyShapeStatic], query);
2795
+ }
2796
+ async shaclmateShape(identifier) {
2797
+ return this.shaclmateShapeSync(identifier);
2798
+ }
2799
+ shaclmateShapeSync(identifier) {
2800
+ return this.shaclmateShapesSync({
2801
+ where: { identifiers: [identifier], type: "identifiers" },
2802
+ }).map((objects) => objects[0]);
2803
+ }
2804
+ async shaclmateShapeIdentifiers(query) {
2805
+ return this.shaclmateShapeIdentifiersSync(query);
2806
+ }
2807
+ shaclmateShapeIdentifiersSync(query) {
2808
+ return this.$objectUnionIdentifiersSync([ShaclmateNodeShape, ShaclCorePropertyShapeStatic], query);
2809
+ }
2810
+ async shaclmateShapes(query) {
2811
+ return this.shaclmateShapesSync(query);
2812
+ }
2813
+ shaclmateShapesSync(query) {
2814
+ return this.$objectUnionsSync([ShaclmateNodeShape, ShaclCorePropertyShapeStatic], query);
2815
+ }
2816
+ async shaclmateShapesCount(query) {
2817
+ return this.shaclmateShapesCountSync(query);
2818
+ }
2819
+ shaclmateShapesCountSync(query) {
2820
+ return this.$objectUnionsCountSync([ShaclmateNodeShape, ShaclCorePropertyShapeStatic], query);
2821
+ }
2822
+ $objectIdentifiersSync(objectType, query) {
2823
+ return this.$objectsSync(objectType, query).map((objects) => objects.map((object) => object.$identifier));
2824
+ }
2825
+ $objectsSync(objectType, query) {
2826
+ const limit = query?.limit ?? Number.MAX_SAFE_INTEGER;
2827
+ if (limit <= 0) {
2828
+ return purify.Either.of([]);
2829
+ }
2830
+ let offset = query?.offset ?? 0;
2831
+ if (offset < 0) {
2832
+ offset = 0;
2833
+ }
2834
+ if (query?.where) {
2835
+ // Assign identifiers in each case block so the compiler will catch missing cases.
2836
+ let identifiers;
2837
+ switch (query.where.type) {
2838
+ case "identifiers": {
2839
+ identifiers = query.where.identifiers.slice(offset, offset + limit);
2840
+ break;
2841
+ }
2842
+ case "triple-objects": {
2843
+ let identifierI = 0;
2844
+ identifiers = [];
2845
+ for (const quad of this.resourceSet.dataset.match(query.where.subject, query.where.predicate, null)) {
2846
+ if (quad.object.termType === "BlankNode" ||
2847
+ quad.object.termType === "NamedNode") {
2848
+ if (++identifierI >= offset) {
2849
+ identifiers.push(quad.object);
2850
+ if (identifiers.length === limit) {
2851
+ break;
2852
+ }
2853
+ }
2854
+ }
2855
+ else {
2856
+ return purify.Left(new Error(`subject=${query.where.subject.value} predicate=${query.where.predicate.value} pattern matches non-identifier (${quad.object.termType}) triple`));
2857
+ }
2858
+ }
2859
+ break;
2860
+ }
2861
+ }
2862
+ const objects = [];
2863
+ for (const identifier of identifiers) {
2864
+ const either = objectType.$fromRdf(this.resourceSet.resource(identifier), { objectSet: this });
2865
+ if (either.isLeft()) {
2866
+ return either;
2867
+ }
2868
+ objects.push(either.unsafeCoerce());
2869
+ }
2870
+ return purify.Either.of(objects);
2871
+ }
2872
+ if (!objectType.$fromRdfType) {
2873
+ return purify.Either.of([]);
2874
+ }
2875
+ const resources = [
2876
+ ...this.resourceSet.instancesOf(objectType.$fromRdfType),
2877
+ ];
2878
+ // Sort resources by identifier so limit and offset are deterministic
2879
+ resources.sort((left, right) => left.identifier.value.localeCompare(right.identifier.value));
2880
+ const objects = [];
2881
+ let objectI = 0;
2882
+ for (const resource of resources) {
2883
+ const either = objectType.$fromRdf(resource, { objectSet: this });
2884
+ if (either.isLeft()) {
2885
+ return either;
2886
+ }
2887
+ if (objectI++ >= offset) {
2888
+ objects.push(either.unsafeCoerce());
2889
+ if (objects.length === limit) {
2890
+ return purify.Either.of(objects);
2891
+ }
2892
+ }
2893
+ }
2894
+ return purify.Either.of(objects);
2895
+ }
2896
+ $objectsCountSync(objectType, query) {
2897
+ return this.$objectsSync(objectType, query).map((objects) => objects.length);
2898
+ }
2899
+ $objectUnionIdentifiersSync(objectTypes, query) {
2900
+ return this.$objectUnionsSync(objectTypes, query).map((objects) => objects.map((object) => object.$identifier));
2901
+ }
2902
+ $objectUnionsSync(objectTypes, query) {
2903
+ const limit = query?.limit ?? Number.MAX_SAFE_INTEGER;
2904
+ if (limit <= 0) {
2905
+ return purify.Either.of([]);
2906
+ }
2907
+ let offset = query?.offset ?? 0;
2908
+ if (offset < 0) {
2909
+ offset = 0;
2910
+ }
2911
+ if (query?.where) {
2912
+ // Assign identifiers in each case block so the compiler will catch missing cases.
2913
+ let identifiers;
2914
+ switch (query.where.type) {
2915
+ case "identifiers": {
2916
+ identifiers = query.where.identifiers.slice(offset, offset + limit);
2917
+ break;
2918
+ }
2919
+ case "triple-objects": {
2920
+ let identifierI = 0;
2921
+ identifiers = [];
2922
+ for (const quad of this.resourceSet.dataset.match(query.where.subject, query.where.predicate, null)) {
2923
+ if (quad.object.termType === "BlankNode" ||
2924
+ quad.object.termType === "NamedNode") {
2925
+ if (++identifierI >= offset) {
2926
+ identifiers.push(quad.object);
2927
+ if (identifiers.length === limit) {
2928
+ break;
2929
+ }
2930
+ }
2931
+ }
2932
+ else {
2933
+ return purify.Left(new Error(`subject=${query.where.subject.value} predicate=${query.where.predicate.value} pattern matches non-identifier (${quad.object.termType}) triple`));
2934
+ }
2935
+ }
2936
+ break;
2937
+ }
2938
+ }
2939
+ const objects = [];
2940
+ for (const identifier of identifiers) {
2941
+ const resource = this.resourceSet.resource(identifier);
2942
+ const lefts = [];
2943
+ for (const objectType of objectTypes) {
2944
+ const either = objectType.$fromRdf(resource, { objectSet: this });
2945
+ if (either.isRight()) {
2946
+ objects.push(either.unsafeCoerce());
2947
+ break;
2948
+ }
2949
+ lefts.push(either);
2950
+ }
2951
+ // Doesn't appear to belong to any of the known object types, just assume the first
2952
+ if (lefts.length === objectTypes.length) {
2953
+ return lefts[0];
2954
+ }
2955
+ }
2956
+ return purify.Either.of(objects);
2957
+ }
2958
+ const resources = [];
2959
+ for (const objectType of objectTypes) {
2960
+ if (!objectType.$fromRdfType) {
2961
+ continue;
2962
+ }
2963
+ for (const resource of this.resourceSet.instancesOf(objectType.$fromRdfType)) {
2964
+ resources.push({ objectType, resource });
2965
+ }
2966
+ }
2967
+ // Sort resources by identifier so limit and offset are deterministic
2968
+ resources.sort((left, right) => left.resource.identifier.value.localeCompare(right.resource.identifier.value));
2969
+ let objectI = 0;
2970
+ const objects = [];
2971
+ for (const { objectType, resource } of resources) {
2972
+ const either = objectType.$fromRdf(resource, { objectSet: this });
2973
+ if (either.isLeft()) {
2974
+ return either;
2975
+ }
2976
+ if (objectI++ >= offset) {
2977
+ objects.push(either.unsafeCoerce());
2978
+ if (objects.length === limit) {
2979
+ return purify.Either.of(objects);
2980
+ }
2981
+ }
2982
+ }
2983
+ return purify.Either.of(objects);
2984
+ }
2985
+ $objectUnionsCountSync(objectTypes, query) {
2986
+ return this.$objectUnionIdentifiersSync(objectTypes, query).map((objects) => objects.length);
2987
+ }
2988
+ }
1487
2989
  //# sourceMappingURL=generated.js.map