@shaclmate/compiler 2.0.22 → 2.0.23

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 (172) hide show
  1. package/dist/ShapesGraphToAstTransformer.d.ts +1 -0
  2. package/dist/ShapesGraphToAstTransformer.js +56 -12
  3. package/dist/_ShapesGraphToAstTransformer/flattenAstObjectCompositeTypeMemberTypes.d.ts +13 -0
  4. package/dist/_ShapesGraphToAstTransformer/flattenAstObjectCompositeTypeMemberTypes.js +51 -0
  5. package/dist/_ShapesGraphToAstTransformer/shapeAstName.js +53 -12
  6. package/dist/_ShapesGraphToAstTransformer/transformNodeShapeToAstType.d.ts +5 -0
  7. package/dist/_ShapesGraphToAstTransformer/transformNodeShapeToAstType.js +130 -54
  8. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstCompositeType.d.ts +2 -3
  9. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstCompositeType.js +122 -129
  10. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstIdentifierType.d.ts +2 -2
  11. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstLiteralType.d.ts +2 -2
  12. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +127 -5
  13. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstTermType.d.ts +3 -3
  14. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstType.d.ts +2 -3
  15. package/dist/ast/Ast.d.ts +0 -1
  16. package/dist/ast/Curie.d.ts +14 -0
  17. package/dist/ast/Curie.js +21 -0
  18. package/dist/ast/IdentifierType.d.ts +3 -2
  19. package/dist/ast/ListType.d.ts +2 -1
  20. package/dist/ast/LiteralType.d.ts +1 -1
  21. package/dist/ast/Name.d.ts +40 -5
  22. package/dist/ast/ObjectCompositeType.d.ts +11 -0
  23. package/dist/ast/ObjectType.d.ts +18 -13
  24. package/dist/ast/ObjectUnionType.d.ts +0 -11
  25. package/dist/ast/OptionType.d.ts +2 -2
  26. package/dist/ast/SetType.d.ts +2 -2
  27. package/dist/ast/TermType.d.ts +12 -4
  28. package/dist/ast/Type.d.ts +1 -1
  29. package/dist/enums/TsFeature.d.ts +1 -4
  30. package/dist/enums/TsFeature.js +1 -15
  31. package/dist/generators/json/AstJsonGenerator.js +19 -3
  32. package/dist/generators/ts/BooleanType.d.ts +3 -1
  33. package/dist/generators/ts/BooleanType.js +11 -2
  34. package/dist/generators/ts/DateTimeType.d.ts +8 -7
  35. package/dist/generators/ts/DateTimeType.js +31 -7
  36. package/dist/generators/ts/DateType.d.ts +5 -2
  37. package/dist/generators/ts/DateType.js +15 -1
  38. package/dist/generators/ts/DeclaredType.d.ts +2 -2
  39. package/dist/generators/ts/DeclaredType.js +2 -2
  40. package/dist/generators/ts/FloatType.d.ts +6 -0
  41. package/dist/generators/ts/FloatType.js +18 -0
  42. package/dist/generators/ts/IdentifierType.d.ts +12 -7
  43. package/dist/generators/ts/IdentifierType.js +94 -6
  44. package/dist/generators/ts/Import.d.ts +2 -0
  45. package/dist/generators/ts/Import.js +10 -0
  46. package/dist/generators/ts/IntType.d.ts +6 -0
  47. package/dist/generators/ts/IntType.js +18 -0
  48. package/dist/generators/ts/ListType.d.ts +15 -12
  49. package/dist/generators/ts/ListType.js +98 -57
  50. package/dist/generators/ts/LiteralType.d.ts +10 -9
  51. package/dist/generators/ts/LiteralType.js +13 -2
  52. package/dist/generators/ts/NumberType.d.ts +2 -1
  53. package/dist/generators/ts/NumberType.js +7 -2
  54. package/dist/generators/ts/ObjectType.d.ts +66 -43
  55. package/dist/generators/ts/ObjectType.js +144 -123
  56. package/dist/generators/ts/ObjectUnionType.d.ts +49 -8
  57. package/dist/generators/ts/ObjectUnionType.js +290 -97
  58. package/dist/generators/ts/OptionType.d.ts +14 -10
  59. package/dist/generators/ts/OptionType.js +60 -34
  60. package/dist/generators/ts/PrimitiveType.d.ts +4 -4
  61. package/dist/generators/ts/PrimitiveType.js +18 -3
  62. package/dist/generators/ts/SetType.d.ts +16 -12
  63. package/dist/generators/ts/SetType.js +69 -40
  64. package/dist/generators/ts/SnippetDeclarations.d.ts +13 -8
  65. package/dist/generators/ts/SnippetDeclarations.js +215 -101
  66. package/dist/generators/ts/StringType.d.ts +3 -1
  67. package/dist/generators/ts/StringType.js +14 -2
  68. package/dist/generators/ts/TermType.d.ts +22 -14
  69. package/dist/generators/ts/TermType.js +53 -25
  70. package/dist/generators/ts/TsGenerator.d.ts +2 -1
  71. package/dist/generators/ts/TsGenerator.js +23 -12
  72. package/dist/generators/ts/Type.d.ts +89 -31
  73. package/dist/generators/ts/Type.js +57 -54
  74. package/dist/generators/ts/TypeFactory.d.ts +4 -5
  75. package/dist/generators/ts/TypeFactory.js +290 -226
  76. package/dist/generators/ts/UnionType.d.ts +14 -10
  77. package/dist/generators/ts/UnionType.js +319 -142
  78. package/dist/generators/ts/_ObjectType/EagerShaclProperty.d.ts +12 -0
  79. package/dist/generators/ts/_ObjectType/EagerShaclProperty.js +30 -0
  80. package/dist/generators/ts/_ObjectType/IdentifierPrefixProperty.d.ts +13 -12
  81. package/dist/generators/ts/_ObjectType/IdentifierPrefixProperty.js +46 -47
  82. package/dist/generators/ts/_ObjectType/IdentifierProperty.d.ts +20 -13
  83. package/dist/generators/ts/_ObjectType/IdentifierProperty.js +152 -124
  84. package/dist/generators/ts/_ObjectType/LazyShaclProperty.d.ts +87 -0
  85. package/dist/generators/ts/_ObjectType/LazyShaclProperty.js +237 -0
  86. package/dist/generators/ts/_ObjectType/Property.d.ts +39 -44
  87. package/dist/generators/ts/_ObjectType/Property.js +1 -10
  88. package/dist/generators/ts/_ObjectType/ShaclProperty.d.ts +25 -30
  89. package/dist/generators/ts/_ObjectType/ShaclProperty.js +108 -85
  90. package/dist/generators/ts/_ObjectType/TypeDiscriminatorProperty.d.ts +21 -17
  91. package/dist/generators/ts/_ObjectType/TypeDiscriminatorProperty.js +61 -53
  92. package/dist/generators/ts/_ObjectType/classDeclaration.js +6 -5
  93. package/dist/generators/ts/_ObjectType/createFunctionDeclaration.js +5 -4
  94. package/dist/generators/ts/_ObjectType/equalsFunctionOrMethodDeclaration.js +5 -4
  95. package/dist/generators/ts/_ObjectType/fromRdfTypeVariableStatement.d.ts +1 -1
  96. package/dist/generators/ts/_ObjectType/fromRdfTypeVariableStatement.js +8 -5
  97. package/dist/generators/ts/_ObjectType/graphqlTypeVariableStatement.d.ts +5 -0
  98. package/dist/generators/ts/_ObjectType/graphqlTypeVariableStatement.js +37 -0
  99. package/dist/generators/ts/_ObjectType/hashFunctionOrMethodDeclarations.js +7 -8
  100. package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.d.ts +7 -0
  101. package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.js +54 -0
  102. package/dist/generators/ts/_ObjectType/index.d.ts +9 -7
  103. package/dist/generators/ts/_ObjectType/index.js +9 -7
  104. package/dist/generators/ts/_ObjectType/interfaceDeclaration.js +1 -1
  105. package/dist/generators/ts/_ObjectType/jsonFunctionDeclarations.d.ts +4 -0
  106. package/dist/generators/ts/_ObjectType/jsonFunctionDeclarations.js +189 -0
  107. package/dist/generators/ts/_ObjectType/jsonTypeAliasDeclaration.d.ts +5 -0
  108. package/dist/generators/ts/_ObjectType/jsonTypeAliasDeclaration.js +28 -0
  109. package/dist/generators/ts/_ObjectType/objectSetMethodNames.d.ts +9 -0
  110. package/dist/generators/ts/_ObjectType/objectSetMethodNames.js +18 -0
  111. package/dist/generators/ts/_ObjectType/propertiesVariableStatement.d.ts +5 -0
  112. package/dist/generators/ts/_ObjectType/propertiesVariableStatement.js +37 -0
  113. package/dist/generators/ts/_ObjectType/rdfFunctionDeclarations.d.ts +4 -0
  114. package/dist/generators/ts/_ObjectType/rdfFunctionDeclarations.js +152 -0
  115. package/dist/generators/ts/_ObjectType/sparqlConstructQueryFunctionDeclaration.d.ts +1 -1
  116. package/dist/generators/ts/_ObjectType/sparqlConstructQueryFunctionDeclaration.js +4 -3
  117. package/dist/generators/ts/_ObjectType/sparqlConstructQueryStringFunctionDeclaration.d.ts +1 -1
  118. package/dist/generators/ts/_ObjectType/sparqlConstructQueryStringFunctionDeclaration.js +3 -2
  119. package/dist/generators/ts/_ObjectType/sparqlFunctionDeclarations.js +103 -35
  120. package/dist/generators/ts/_ObjectType/toJsonFunctionOrMethodDeclaration.js +6 -6
  121. package/dist/generators/ts/_ObjectType/toRdfFunctionOrMethodDeclaration.js +15 -13
  122. package/dist/generators/ts/graphqlSchemaVariableStatement.d.ts +9 -0
  123. package/dist/generators/ts/graphqlSchemaVariableStatement.js +86 -0
  124. package/dist/generators/ts/objectSetDeclarations.d.ts +8 -0
  125. package/dist/generators/ts/objectSetDeclarations.js +59 -0
  126. package/dist/generators/ts/objectSetInterfaceDeclaration.d.ts +8 -0
  127. package/dist/generators/ts/objectSetInterfaceDeclaration.js +46 -0
  128. package/dist/generators/ts/objectSetMethodSignatures.d.ts +11 -0
  129. package/dist/generators/ts/objectSetMethodSignatures.js +52 -0
  130. package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.d.ts +8 -0
  131. package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.js +393 -0
  132. package/dist/generators/ts/rdfjsTermExpression.d.ts +3 -0
  133. package/dist/generators/ts/rdfjsTermExpression.js +57 -0
  134. package/dist/generators/ts/sparqlObjectSetClassDeclaration.d.ts +8 -0
  135. package/dist/generators/ts/sparqlObjectSetClassDeclaration.js +415 -0
  136. package/dist/generators/ts/syntheticNamePrefix.d.ts +2 -0
  137. package/dist/generators/ts/syntheticNamePrefix.js +2 -0
  138. package/dist/generators/ts/tsName.js +27 -13
  139. package/dist/generators/ts/unsupportedObjectSetMethodDeclarations.d.ts +10 -0
  140. package/dist/generators/ts/unsupportedObjectSetMethodDeclarations.js +19 -0
  141. package/dist/input/NodeShape.d.ts +6 -8
  142. package/dist/input/NodeShape.js +20 -44
  143. package/dist/input/Ontology.d.ts +0 -3
  144. package/dist/input/Ontology.js +0 -9
  145. package/dist/input/PropertyPath.d.ts +6 -5
  146. package/dist/input/PropertyPath.js +14 -22
  147. package/dist/input/PropertyShape.d.ts +3 -1
  148. package/dist/input/PropertyShape.js +8 -2
  149. package/dist/input/ShapesGraph.js +4 -4
  150. package/dist/input/generated.d.ts +923 -105
  151. package/dist/input/generated.js +1865 -969
  152. package/dist/input/tsFeatures.d.ts +3 -2
  153. package/dist/input/tsFeatures.js +44 -27
  154. package/package.json +18 -16
  155. package/dist/generators/ts/_ObjectType/fromJsonFunctionDeclarations.d.ts +0 -4
  156. package/dist/generators/ts/_ObjectType/fromJsonFunctionDeclarations.js +0 -78
  157. package/dist/generators/ts/_ObjectType/fromRdfFunctionDeclarations.d.ts +0 -4
  158. package/dist/generators/ts/_ObjectType/fromRdfFunctionDeclarations.js +0 -91
  159. package/dist/generators/ts/_ObjectType/jsonSchemaFunctionDeclaration.d.ts +0 -5
  160. package/dist/generators/ts/_ObjectType/jsonSchemaFunctionDeclaration.js +0 -19
  161. package/dist/generators/ts/_ObjectType/jsonUiSchemaFunctionDeclaration.d.ts +0 -5
  162. package/dist/generators/ts/_ObjectType/jsonUiSchemaFunctionDeclaration.js +0 -31
  163. package/dist/generators/ts/_ObjectType/jsonZodSchemaFunctionDeclaration.d.ts +0 -5
  164. package/dist/generators/ts/_ObjectType/jsonZodSchemaFunctionDeclaration.js +0 -37
  165. package/dist/generators/ts/_ObjectType/rdfjsTermExpression.d.ts +0 -6
  166. package/dist/generators/ts/_ObjectType/rdfjsTermExpression.js +0 -17
  167. package/dist/generators/ts/_ObjectType/toJsonFunctionDeclaration.d.ts +0 -5
  168. package/dist/generators/ts/_ObjectType/toJsonFunctionDeclaration.js +0 -19
  169. package/dist/generators/ts/_ObjectType/toJsonReturnType.d.ts +0 -3
  170. package/dist/generators/ts/_ObjectType/toJsonReturnType.js +0 -17
  171. package/dist/generators/ts/_ObjectType/toRdfFunctionDeclaration.d.ts +0 -5
  172. package/dist/generators/ts/_ObjectType/toRdfFunctionDeclaration.js +0 -19
@@ -1,6 +1,6 @@
1
1
  import type { NamedNode } from "@rdfjs/types";
2
- import type * as purify from "purify-ts";
3
- import type * as rdfjsResource from "rdfjs-resource";
2
+ import { Either } from "purify-ts";
3
+ import { Resource } from "rdfjs-resource";
4
4
  export interface AlternativePath {
5
5
  readonly kind: "AlternativePath";
6
6
  readonly members: readonly PropertyPath[];
@@ -31,11 +31,12 @@ export interface ZeroOrOnePath {
31
31
  }
32
32
  export type PropertyPath = AlternativePath | InversePath | OneOrMorePath | PredicatePath | SequencePath | ZeroOrMorePath | ZeroOrOnePath;
33
33
  export declare namespace PropertyPath {
34
- function fromRdf({ resource, }: {
34
+ function $fromRdf({ resource, }: {
35
35
  [_index: string]: any;
36
36
  ignoreRdfType?: boolean;
37
37
  languageIn?: readonly string[];
38
- resource: rdfjsResource.Resource;
39
- }): purify.Either<rdfjsResource.Resource.ValueError, PropertyPath>;
38
+ resource: Resource;
39
+ }): Either<Error, PropertyPath>;
40
+ function $toRdf(_propertyPath: PropertyPath, _options?: any): Resource;
40
41
  }
41
42
  //# sourceMappingURL=PropertyPath.d.ts.map
@@ -3,7 +3,7 @@ import { Either, Left } from "purify-ts";
3
3
  import { Resource } from "rdfjs-resource";
4
4
  export var PropertyPath;
5
5
  (function (PropertyPath) {
6
- function fromRdf({ resource, }) {
6
+ function $fromRdf({ resource, }) {
7
7
  // Predicate path
8
8
  // sh:path ex:parent
9
9
  if (resource.identifier.termType === "NamedNode") {
@@ -16,13 +16,9 @@ export var PropertyPath;
16
16
  for (const value of values) {
17
17
  const memberResource = value.toResource().toMaybe();
18
18
  if (memberResource.isNothing()) {
19
- return Left(new Resource.ValueError({
20
- focusResource: resource,
21
- message: "non-identifier in property path list",
22
- predicate: rdf.subject,
23
- }));
19
+ return Left(new Error(`non-identifier in property path list ${Resource.Identifier.toString(listResource.identifier)}`));
24
20
  }
25
- const member = PropertyPath.fromRdf({
21
+ const member = PropertyPath.$fromRdf({
26
22
  resource: memberResource.unsafeCoerce(),
27
23
  });
28
24
  if (member.isLeft()) {
@@ -39,11 +35,7 @@ export var PropertyPath;
39
35
  case "NamedNode":
40
36
  break;
41
37
  default:
42
- return Left(new Resource.ValueError({
43
- focusResource: resource,
44
- message: `non-BlankNode/NamedNode property path object on path ${resource.identifier.value}: ${quad.object.termType} ${quad.object.value}`,
45
- predicate: quad.predicate,
46
- }));
38
+ return Left(new Error(`non-BlankNode/NamedNode property path object on path ${Resource.Identifier.toString(resource.identifier)}: ${quad.object.termType} ${quad.object.value}`));
47
39
  }
48
40
  const objectResource = new Resource({
49
41
  dataset: resource.dataset,
@@ -60,14 +52,14 @@ export var PropertyPath;
60
52
  // Inverse path
61
53
  // sh:path: [ sh:inversePath ex:parent ]
62
54
  if (quad.predicate.equals(sh.inversePath)) {
63
- return PropertyPath.fromRdf({ resource: objectResource }).map((path) => ({
55
+ return PropertyPath.$fromRdf({ resource: objectResource }).map((path) => ({
64
56
  kind: "InversePath",
65
57
  path,
66
58
  }));
67
59
  }
68
60
  // One or more path
69
61
  if (quad.predicate.equals(sh.oneOrMorePath)) {
70
- return PropertyPath.fromRdf({ resource: objectResource }).map((path) => ({
62
+ return PropertyPath.$fromRdf({ resource: objectResource }).map((path) => ({
71
63
  kind: "OneOrMorePath",
72
64
  path,
73
65
  }));
@@ -82,24 +74,24 @@ export var PropertyPath;
82
74
  }
83
75
  // Zero or more path
84
76
  if (quad.predicate.equals(sh.zeroOrMorePath)) {
85
- return PropertyPath.fromRdf({ resource: objectResource }).map((path) => ({
77
+ return PropertyPath.$fromRdf({ resource: objectResource }).map((path) => ({
86
78
  kind: "ZeroOrMorePath",
87
79
  path,
88
80
  }));
89
81
  }
90
82
  if (quad.predicate.equals(sh.zeroOrOnePath)) {
91
- return PropertyPath.fromRdf({ resource: objectResource }).map((path) => ({
83
+ return PropertyPath.$fromRdf({ resource: objectResource }).map((path) => ({
92
84
  kind: "ZeroOrOnePath",
93
85
  path,
94
86
  }));
95
87
  }
96
88
  }
97
- return Left(new Resource.ValueError({
98
- focusResource: resource,
99
- message: `unrecognized or ill-formed SHACL property path ${resource.identifier.value}`,
100
- predicate: rdf.subject,
101
- }));
89
+ return Left(new Error(`unrecognized or ill-formed SHACL property path ${Resource.Identifier.toString(resource.identifier)}`));
102
90
  }
103
- PropertyPath.fromRdf = fromRdf;
91
+ PropertyPath.$fromRdf = $fromRdf;
92
+ function $toRdf(_propertyPath, _options) {
93
+ throw new Error("not implemented");
94
+ }
95
+ PropertyPath.$toRdf = $toRdf;
104
96
  })(PropertyPath || (PropertyPath = {}));
105
97
  //# sourceMappingURL=PropertyPath.js.map
@@ -7,9 +7,11 @@ import type { NodeShape, Ontology, PropertyGroup, ShapesGraph } from "./index.js
7
7
  export declare class PropertyShape extends ShaclCorePropertyShape<NodeShape, Ontology, PropertyGroup, any, Shape> {
8
8
  private readonly generatedShaclmatePropertyShape;
9
9
  constructor(generatedShaclmatePropertyShape: generated.ShaclmatePropertyShape, shapesGraph: ShapesGraph);
10
- get extern(): Maybe<boolean>;
10
+ get lazy(): Maybe<boolean>;
11
11
  get mutable(): Maybe<boolean>;
12
12
  get shaclmateName(): Maybe<string>;
13
+ get stub(): Maybe<NodeShape>;
13
14
  get visibility(): PropertyVisibility;
15
+ get widen(): Maybe<boolean>;
14
16
  }
15
17
  //# sourceMappingURL=PropertyShape.d.ts.map
@@ -6,8 +6,8 @@ export class PropertyShape extends ShaclCorePropertyShape {
6
6
  super({ ...generatedShaclmatePropertyShape, uniqueLang: Maybe.empty() }, shapesGraph);
7
7
  this.generatedShaclmatePropertyShape = generatedShaclmatePropertyShape;
8
8
  }
9
- get extern() {
10
- return this.generatedShaclmatePropertyShape.extern;
9
+ get lazy() {
10
+ return this.generatedShaclmatePropertyShape.lazy;
11
11
  }
12
12
  get mutable() {
13
13
  return this.generatedShaclmatePropertyShape.mutable;
@@ -15,6 +15,9 @@ export class PropertyShape extends ShaclCorePropertyShape {
15
15
  get shaclmateName() {
16
16
  return this.generatedShaclmatePropertyShape.name;
17
17
  }
18
+ get stub() {
19
+ return this.generatedShaclmatePropertyShape.stub.chain((identifier) => this.shapesGraph.nodeShapeByIdentifier(identifier));
20
+ }
18
21
  get visibility() {
19
22
  return this.generatedShaclmatePropertyShape.visibility
20
23
  .map((iri) => {
@@ -31,5 +34,8 @@ export class PropertyShape extends ShaclCorePropertyShape {
31
34
  })
32
35
  .orDefault("public");
33
36
  }
37
+ get widen() {
38
+ return this.generatedShaclmatePropertyShape.widen;
39
+ }
34
40
  }
35
41
  //# sourceMappingURL=PropertyShape.js.map
@@ -10,7 +10,7 @@ export class ShapesGraph extends RdfjsShapesGraph {
10
10
  dataset,
11
11
  factory: {
12
12
  nodeShapeFromRdf({ resource, shapesGraph, }) {
13
- return generated.ShaclmateNodeShape.fromRdf({
13
+ return generated.ShaclmateNodeShape.$fromRdf({
14
14
  ignoreRdfType: true,
15
15
  resource,
16
16
  }).map((generatedShape) => new NodeShape({
@@ -26,19 +26,19 @@ export class ShapesGraph extends RdfjsShapesGraph {
26
26
  }));
27
27
  },
28
28
  ontologyFromRdf({ resource, }) {
29
- return generated.ShaclmateOntology.fromRdf({
29
+ return generated.ShaclmateOntology.$fromRdf({
30
30
  ignoreRdfType: true,
31
31
  resource,
32
32
  }).map((generatedOntology) => new Ontology(generatedOntology));
33
33
  },
34
34
  propertyGroupFromRdf({ resource, }) {
35
- return generated.ShaclCorePropertyGroup.fromRdf({
35
+ return generated.ShaclCorePropertyGroup.$fromRdf({
36
36
  ignoreRdfType: true,
37
37
  resource,
38
38
  }).map((generatedPropertyGroup) => new PropertyGroup(generatedPropertyGroup));
39
39
  },
40
40
  propertyShapeFromRdf({ resource, shapesGraph, }) {
41
- return generated.ShaclmatePropertyShape.fromRdf({
41
+ return generated.ShaclmatePropertyShape.$fromRdf({
42
42
  ignoreRdfType: true,
43
43
  resource,
44
44
  }).map((generatedShape) => new PropertyShape(generatedShape, shapesGraph));