@shaclmate/compiler 2.0.20 → 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,3 +1,4 @@
1
+ import type { TsFeature } from "enums/TsFeature.js";
1
2
  import type { Maybe } from "purify-ts";
2
3
  import type { CompositeType } from "./CompositeType.js";
3
4
  import type { Name } from "./Name.js";
@@ -10,6 +11,12 @@ export interface ObjectCompositeType extends CompositeType<ObjectType> {
10
11
  * Documentation comment from rdfs:comment.
11
12
  */
12
13
  readonly comment: Maybe<string>;
14
+ /**
15
+ * Should generated code derived from this type be visible outside its module?
16
+ *
17
+ * Defaults to true.
18
+ */
19
+ readonly export: boolean;
13
20
  /**
14
21
  * Human-readable label from rdfs:label.
15
22
  */
@@ -18,5 +25,9 @@ export interface ObjectCompositeType extends CompositeType<ObjectType> {
18
25
  * Name of this type, usually derived from sh:name or shaclmate:name.
19
26
  */
20
27
  readonly name: Name;
28
+ /**
29
+ * TypeScript features to generate.
30
+ */
31
+ readonly tsFeatures: Set<TsFeature>;
21
32
  }
22
33
  //# sourceMappingURL=ObjectCompositeType.d.ts.map
@@ -3,6 +3,9 @@ import type { NodeKind, PredicatePath } from "@shaclmate/shacl-ast";
3
3
  import type { Maybe } from "purify-ts";
4
4
  import type { IdentifierMintingStrategy, PropertyVisibility, TsFeature, TsObjectDeclarationType } from "../enums/index.js";
5
5
  import type { Name } from "./Name.js";
6
+ import type { ObjectUnionType } from "./ObjectUnionType.js";
7
+ import type { OptionType } from "./OptionType.js";
8
+ import type { SetType } from "./SetType.js";
6
9
  import type { Type } from "./Type.js";
7
10
  export interface ObjectType {
8
11
  /**
@@ -63,7 +66,7 @@ export interface ObjectType {
63
66
  *
64
67
  * Used to associate instances with an RDF identifier.
65
68
  */
66
- readonly identifierKinds: Set<Exclude<NodeKind, "Literal">>;
69
+ readonly identifierNodeKinds: Set<Exclude<NodeKind, "Literal">>;
67
70
  /**
68
71
  * Strategy for minting new object identifiers.
69
72
  */
@@ -92,6 +95,10 @@ export interface ObjectType {
92
95
  * Mutable to support cycle-handling logic in the compiler.
93
96
  */
94
97
  readonly properties: ObjectType.Property[];
98
+ /**
99
+ * Was this type synthesized or did it come from SHACL?
100
+ */
101
+ readonly synthetic: boolean;
95
102
  /**
96
103
  * rdf:type's that will be added to this object when it's serialized toRdf.
97
104
  *
@@ -103,14 +110,6 @@ export interface ObjectType {
103
110
  * TypeScript features to generate.
104
111
  */
105
112
  readonly tsFeatures: Set<TsFeature>;
106
- /**
107
- * Name of the identifier prefix property in TypeScript-generated classes/interfaces.
108
- */
109
- readonly tsIdentifierPrefixPropertyName: string;
110
- /**
111
- * Name of the identifier property in TypeScript-generated classes/interfaces.
112
- */
113
- readonly tsIdentifierPropertyName: string;
114
113
  /**
115
114
  * TypeScript imports to add to generated code.
116
115
  *
@@ -124,10 +123,6 @@ export interface ObjectType {
124
123
  * Whether to generate a TypeScript class or interface for this type.
125
124
  */
126
125
  readonly tsObjectDeclarationType: TsObjectDeclarationType;
127
- /**
128
- * Name of the type discriminator property in TypeScript-generated classes/interfaces.
129
- */
130
- readonly tsTypeDiscriminatorPropertyName: string;
131
126
  }
132
127
  export declare namespace ObjectType {
133
128
  interface Property {
@@ -160,6 +155,16 @@ export declare namespace ObjectType {
160
155
  * SHACL property path (https://www.w3.org/TR/shacl/#property-paths)
161
156
  */
162
157
  readonly path: PredicatePath;
158
+ /**
159
+ * Does the property directly or indirectly reference the ObjectType itself?
160
+ */
161
+ readonly recursive?: boolean;
162
+ /**
163
+ * The property will be resolved lazily, with this type serving as a stub before resolution of the actual type (type).
164
+ *
165
+ * This type will mirror type: if type is an OptionType<ObjectType>, this will also be an OptionType<ObjectType>.
166
+ */
167
+ readonly stubType: Maybe<ObjectType | ObjectUnionType | OptionType<ObjectType | ObjectUnionType> | SetType<ObjectType | ObjectUnionType>>;
163
168
  /**
164
169
  * Type of this property.
165
170
  */
@@ -1,19 +1,8 @@
1
- import type { TsFeature } from "../enums/index.js";
2
1
  import type { ObjectCompositeType } from "./ObjectCompositeType.js";
3
2
  /**
4
3
  * A disjunction/union of object types, corresponding to an sh:xone on a node shape.
5
4
  */
6
5
  export interface ObjectUnionType extends ObjectCompositeType {
7
- /**
8
- * Should generated code derived from this ObjectType be visible outside its module?
9
- *
10
- * Defaults to true.
11
- */
12
- readonly export: boolean;
13
6
  readonly kind: "ObjectUnionType";
14
- /**
15
- * TypeScript features to generate.
16
- */
17
- readonly tsFeatures: Set<TsFeature>;
18
7
  }
19
8
  //# sourceMappingURL=ObjectUnionType.d.ts.map
@@ -4,8 +4,8 @@ import type { Type } from "./Type.js";
4
4
  *
5
5
  * This is a property with sh:minCount 0 and sh:maxCount 1.
6
6
  */
7
- export interface OptionType {
8
- readonly itemType: Type;
7
+ export interface OptionType<ItemTypeT extends Type = Type> {
8
+ readonly itemType: ItemTypeT;
9
9
  readonly kind: "OptionType";
10
10
  }
11
11
  //# sourceMappingURL=OptionType.d.ts.map
@@ -5,11 +5,11 @@ import type { Type } from "./Type.js";
5
5
  *
6
6
  * This is a property with sh:maxCount != 1.
7
7
  */
8
- export interface SetType {
8
+ export interface SetType<ItemTypeT extends Type = Type> {
9
9
  /**
10
10
  * Set item type.
11
11
  */
12
- readonly itemType: Type;
12
+ readonly itemType: ItemTypeT;
13
13
  readonly kind: "SetType";
14
14
  /**
15
15
  * Minimum number of items in the set.
@@ -1,10 +1,18 @@
1
1
  import type { BlankNode, Literal, NamedNode } from "@rdfjs/types";
2
2
  import type { NodeKind } from "@shaclmate/shacl-ast";
3
3
  import type { Maybe } from "purify-ts";
4
- export interface TermType<TermT extends BlankNode | Literal | NamedNode> {
5
- readonly defaultValue: Maybe<TermT>;
6
- readonly hasValues: readonly TermT[];
7
- readonly in_: readonly TermT[];
4
+ /**
5
+ * Parent interface of term types in the ASTs (e.g., identifiers, identifiers).
6
+ *
7
+ * ConstantTermT is the type of sh:defaultValue, sh:hasValue, and sh:in.
8
+ * RuntimeTermT is the type of values at runtime.
9
+ *
10
+ * The two are differentiated because identifiers can have BlankNode or NamedNode values at runtime but only NamedNode values for sh:defaultValue et al.
11
+ */
12
+ export interface TermType<ConstantTermT extends Literal | NamedNode = Literal | NamedNode, _RuntimeTermT extends BlankNode | Literal | NamedNode = BlankNode | Literal | NamedNode> {
13
+ readonly defaultValue: Maybe<ConstantTermT>;
14
+ readonly hasValues: readonly ConstantTermT[];
15
+ readonly in_: readonly ConstantTermT[];
8
16
  readonly kind: "IdentifierType" | "LiteralType" | "TermType";
9
17
  readonly nodeKinds: Set<NodeKind>;
10
18
  }
@@ -11,7 +11,7 @@ import type { PlaceholderType } from "./PlaceholderType.js";
11
11
  import type { SetType } from "./SetType.js";
12
12
  import type { TermType } from "./TermType.js";
13
13
  import type { UnionType } from "./UnionType.js";
14
- export type Type = IdentifierType | IntersectionType | ListType | LiteralType | ObjectIntersectionType | ObjectType | ObjectUnionType | OptionType | PlaceholderType | SetType | (Omit<TermType<BlankNode | Literal | NamedNode>, "kind"> & {
14
+ export type Type = IdentifierType | IntersectionType | ListType | LiteralType | ObjectIntersectionType | ObjectType | ObjectUnionType | OptionType | PlaceholderType | SetType | (Omit<TermType<Literal | NamedNode, BlankNode | Literal | NamedNode>, "kind"> & {
15
15
  readonly kind: "TermType";
16
16
  }) | UnionType;
17
17
  //# sourceMappingURL=Type.d.ts.map
@@ -1,5 +1,2 @@
1
- export type TsFeature = "create" | "equals" | "fromJson" | "fromRdf" | "hash" | "jsonSchema" | "jsonUiSchema" | "sparql" | "toJson" | "toRdf";
2
- export declare namespace TsFeature {
3
- const MEMBERS: readonly TsFeature[];
4
- }
1
+ export type TsFeature = "create" | "equals" | "graphql" | "hash" | "json" | "rdf" | "sparql";
5
2
  //# sourceMappingURL=TsFeature.d.ts.map
@@ -1,16 +1,2 @@
1
- export var TsFeature;
2
- (function (TsFeature) {
3
- TsFeature.MEMBERS = [
4
- "create",
5
- "equals",
6
- "fromJson",
7
- "fromRdf",
8
- "hash",
9
- "jsonSchema",
10
- "jsonUiSchema",
11
- "sparql",
12
- "toJson",
13
- "toRdf",
14
- ];
15
- })(TsFeature || (TsFeature = {}));
1
+ export {};
16
2
  //# sourceMappingURL=TsFeature.js.map
@@ -1,7 +1,22 @@
1
1
  function nameToJson(name) {
2
2
  return {
3
- curie: name.curie.extract(),
4
- identifier: termToJson(name.identifier),
3
+ identifier: {
4
+ curie: name.identifier.termType === "NamedNode"
5
+ ? name.identifier.curie.map((curie) => curie.toString()).extract()
6
+ : undefined,
7
+ termType: name.identifier.termType,
8
+ uniqueLocalPart: name.identifier.termType === "NamedNode"
9
+ ? name.identifier.uniqueLocalPart().extract()
10
+ : undefined,
11
+ value: name.identifier.value,
12
+ },
13
+ label: name.label.extract(),
14
+ propertyPath: name.propertyPath.map((propertyPath) => ({
15
+ curie: propertyPath.curie.map((curie) => curie.toString()).extract(),
16
+ uniqueLocalPart: propertyPath.uniqueLocalPart().extract(),
17
+ termType: propertyPath.termType,
18
+ value: propertyPath.value,
19
+ })),
5
20
  shName: name.shName.extract(),
6
21
  shaclmateName: name.shaclmateName.extract(),
7
22
  };
@@ -73,7 +88,7 @@ function typeToJson(type) {
73
88
  identifierIn: type.identifierIn.length > 0
74
89
  ? type.identifierIn.map(termToJson)
75
90
  : undefined,
76
- identifierKinds: [...type.identifierKinds],
91
+ identifierNodeKinds: [...type.identifierNodeKinds],
77
92
  identifierMintingStrategy: type.identifierMintingStrategy.extract(),
78
93
  toRdfTypes: type.toRdfTypes.length > 0
79
94
  ? type.toRdfTypes.map(termToJson)
@@ -107,6 +122,7 @@ export class AstJsonGenerator {
107
122
  name: nameToJson(property.name),
108
123
  mutable: property.mutable.extract(),
109
124
  path: property.path.iri.value,
125
+ recursive: property.recursive ? true : undefined,
110
126
  type: typeToJson(property.type),
111
127
  })),
112
128
  })),
@@ -1,8 +1,10 @@
1
1
  import { PrimitiveType } from "./PrimitiveType.js";
2
- import type { Type } from "./Type.js";
2
+ import { Type } from "./Type.js";
3
3
  export declare class BooleanType extends PrimitiveType<boolean> {
4
4
  readonly kind = "BooleanType";
5
+ readonly typeof = "boolean";
5
6
  get conversions(): readonly Type.Conversion[];
7
+ get graphqlName(): Type.GraphqlName;
6
8
  get name(): string;
7
9
  jsonZodSchema({ variables, }: Parameters<Type["jsonZodSchema"]>[0]): ReturnType<Type["jsonZodSchema"]>;
8
10
  propertyFromRdfResourceValueExpression({ variables, }: Parameters<PrimitiveType<boolean>["propertyFromRdfResourceValueExpression"]>[0]): string;
@@ -6,9 +6,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  };
7
7
  import { Memoize } from "typescript-memoize";
8
8
  import { PrimitiveType } from "./PrimitiveType.js";
9
+ import { Type } from "./Type.js";
9
10
  import { objectInitializer } from "./objectInitializer.js";
10
11
  export class BooleanType extends PrimitiveType {
11
12
  kind = "BooleanType";
13
+ typeof = "boolean";
12
14
  get conversions() {
13
15
  const conversions = [
14
16
  {
@@ -26,11 +28,14 @@ export class BooleanType extends PrimitiveType {
26
28
  });
27
29
  return conversions;
28
30
  }
31
+ get graphqlName() {
32
+ return new Type.GraphqlName("graphql.GraphQLBoolean");
33
+ }
29
34
  get name() {
30
35
  if (this.primitiveIn.length > 0) {
31
36
  return this.primitiveIn.map((value) => value.toString()).join(" | ");
32
37
  }
33
- return "boolean";
38
+ return this.typeof;
34
39
  }
35
40
  jsonZodSchema({ variables, }) {
36
41
  if (this.primitiveIn.length === 1) {
@@ -41,7 +46,8 @@ export class BooleanType extends PrimitiveType {
41
46
  propertyFromRdfResourceValueExpression({ variables, }) {
42
47
  let expression = `${variables.resourceValue}.toBoolean()`;
43
48
  if (this.primitiveIn.length === 1) {
44
- expression = `${expression}.chain(value => value === ${this.primitiveIn[0]} ? purify.Either.of(value) : purify.Left(new rdfjsResource.Resource.MistypedValueError(${objectInitializer({ actualValue: "rdfLiteral.toRdf(value)", expectedValueType: JSON.stringify(this.name), focusResource: variables.resource, predicate: variables.predicate })})))`;
49
+ const eitherTypeParameters = `<Error, ${this.name}>`;
50
+ expression = `${expression}.chain(value => value === ${this.primitiveIn[0]} ? purify.Either.of${eitherTypeParameters}(value) : purify.Left${eitherTypeParameters}(new rdfjsResource.Resource.MistypedValueError(${objectInitializer({ actualValue: "rdfLiteral.toRdf(value)", expectedValueType: JSON.stringify(this.name), focusResource: variables.resource, predicate: variables.predicate })})))`;
45
51
  }
46
52
  return expression;
47
53
  }
@@ -58,6 +64,9 @@ export class BooleanType extends PrimitiveType {
58
64
  .orDefault(variables.value);
59
65
  }
60
66
  }
67
+ __decorate([
68
+ Memoize()
69
+ ], BooleanType.prototype, "conversions", null);
61
70
  __decorate([
62
71
  Memoize()
63
72
  ], BooleanType.prototype, "name", null);
@@ -1,21 +1,22 @@
1
1
  import type { NamedNode } from "@rdfjs/types";
2
- import type { TsFeature } from "../../enums/index.js";
3
2
  import { PrimitiveType } from "./PrimitiveType.js";
4
- import type { Type } from "./Type.js";
3
+ import { Type } from "./Type.js";
5
4
  export declare class DateTimeType extends PrimitiveType<Date> {
6
- readonly equalsFunction = "dateEquals";
7
- readonly kind: "DateTimeType" | "DateType";
8
- readonly mutable = true;
9
5
  protected readonly xsdDatatype: NamedNode;
10
6
  protected readonly zodDatatype: string;
7
+ readonly equalsFunction = "$dateEquals";
8
+ readonly kind: "DateTimeType" | "DateType";
9
+ readonly mutable = true;
10
+ readonly typeof = "object";
11
11
  get conversions(): readonly Type.Conversion[];
12
- get jsonName(): string;
12
+ get graphqlName(): Type.GraphqlName;
13
+ get jsonName(): Type.JsonName;
13
14
  get name(): string;
14
15
  fromJsonExpression({ variables, }: Parameters<Type["fromJsonExpression"]>[0]): string;
15
16
  hashStatements({ variables, }: Parameters<Type["hashStatements"]>[0]): readonly string[];
16
17
  jsonZodSchema({ variables, }: Parameters<Type["jsonZodSchema"]>[0]): ReturnType<Type["jsonZodSchema"]>;
17
18
  propertyFromRdfResourceValueExpression({ variables, }: Parameters<PrimitiveType<number>["propertyFromRdfResourceValueExpression"]>[0]): string;
18
- snippetDeclarations(features: Set<TsFeature>): readonly string[];
19
+ snippetDeclarations({ features, }: Parameters<PrimitiveType<Date>["snippetDeclarations"]>[0]): readonly string[];
19
20
  toJsonExpression({ variables, }: Parameters<PrimitiveType<Date>["toJsonExpression"]>[0]): string;
20
21
  toRdfExpression({ variables, }: Parameters<PrimitiveType<Date>["toRdfExpression"]>[0]): string;
21
22
  }
@@ -1,13 +1,24 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
1
7
  import { xsd } from "@tpluscode/rdf-ns-builders";
8
+ import { Memoize } from "typescript-memoize";
2
9
  import { PrimitiveType } from "./PrimitiveType.js";
3
10
  import { SnippetDeclarations } from "./SnippetDeclarations.js";
11
+ import { Type } from "./Type.js";
4
12
  import { objectInitializer } from "./objectInitializer.js";
13
+ import { rdfjsTermExpression } from "./rdfjsTermExpression.js";
14
+ import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
5
15
  export class DateTimeType extends PrimitiveType {
6
- equalsFunction = "dateEquals";
7
- kind = "DateTimeType";
8
- mutable = true;
9
16
  xsdDatatype = xsd.dateTime;
10
17
  zodDatatype = "datetime";
18
+ equalsFunction = `${syntheticNamePrefix}dateEquals`;
19
+ kind = "DateTimeType";
20
+ mutable = true;
21
+ typeof = "object";
11
22
  get conversions() {
12
23
  const conversions = [
13
24
  {
@@ -25,8 +36,11 @@ export class DateTimeType extends PrimitiveType {
25
36
  });
26
37
  return conversions;
27
38
  }
39
+ get graphqlName() {
40
+ return new Type.GraphqlName("graphqlScalars.DateTime");
41
+ }
28
42
  get jsonName() {
29
- return "string";
43
+ return new Type.JsonName("string");
30
44
  }
31
45
  get name() {
32
46
  return "Date";
@@ -43,11 +57,12 @@ export class DateTimeType extends PrimitiveType {
43
57
  propertyFromRdfResourceValueExpression({ variables, }) {
44
58
  let expression = `${variables.resourceValue}.toDate()`;
45
59
  if (this.primitiveIn.length > 0) {
46
- expression = `${expression}.chain(value => { ${this.primitiveIn.map((value) => `if (value.getTime() === ${value.getTime()}) { return purify.Either.of(value); }`).join(" ")} return purify.Left(new rdfjsResource.Resource.MistypedValueError(${objectInitializer({ actualValue: `rdfLiteral.toRdf(value, ${objectInitializer({ dataFactory: this.dataFactoryVariable, datatype: this.rdfjsTermExpression(this.xsdDatatype) })})`, expectedValueType: JSON.stringify(this.name), focusResource: variables.resource, predicate: variables.predicate })})); })`;
60
+ const eitherTypeParameters = `<Error, ${this.name}>`;
61
+ expression = `${expression}.chain(value => { ${this.primitiveIn.map((value) => `if (value.getTime() === ${value.getTime()}) { return purify.Either.of${eitherTypeParameters}(value); }`).join(" ")} return purify.Left${eitherTypeParameters}(new rdfjsResource.Resource.MistypedValueError(${objectInitializer({ actualValue: `rdfLiteral.toRdf(value, ${objectInitializer({ dataFactory: "dataFactory", datatype: rdfjsTermExpression(this.xsdDatatype) })})`, expectedValueType: JSON.stringify(this.name), focusResource: variables.resource, predicate: variables.predicate })})); })`;
47
62
  }
48
63
  return expression;
49
64
  }
50
- snippetDeclarations(features) {
65
+ snippetDeclarations({ features, }) {
51
66
  const snippetDeclarations = [];
52
67
  if (features.has("equals")) {
53
68
  snippetDeclarations.push(SnippetDeclarations.dateEquals);
@@ -58,10 +73,19 @@ export class DateTimeType extends PrimitiveType {
58
73
  return `${variables.value}.toISOString()`;
59
74
  }
60
75
  toRdfExpression({ variables, }) {
61
- const valueToRdf = `rdfLiteral.toRdf(${variables.value}, ${objectInitializer({ dataFactory: this.dataFactoryVariable, datatype: this.rdfjsTermExpression(this.xsdDatatype) })})`;
76
+ const valueToRdf = `rdfLiteral.toRdf(${variables.value}, ${objectInitializer({ dataFactory: "dataFactory", datatype: rdfjsTermExpression(this.xsdDatatype) })})`;
62
77
  return this.primitiveDefaultValue
63
78
  .map((defaultValue) => `${variables.value}.getTime() !== ${defaultValue.getTime()} ? ${valueToRdf} : undefined`)
64
79
  .orDefault(valueToRdf);
65
80
  }
66
81
  }
82
+ __decorate([
83
+ Memoize()
84
+ ], DateTimeType.prototype, "conversions", null);
85
+ __decorate([
86
+ Memoize()
87
+ ], DateTimeType.prototype, "graphqlName", null);
88
+ __decorate([
89
+ Memoize()
90
+ ], DateTimeType.prototype, "jsonName", null);
67
91
  //# sourceMappingURL=DateTimeType.js.map
@@ -1,9 +1,12 @@
1
+ import type { NamedNode } from "@rdfjs/types";
1
2
  import { DateTimeType } from "./DateTimeType.js";
2
3
  import type { PrimitiveType } from "./PrimitiveType.js";
4
+ import { Type } from "./Type.js";
3
5
  export declare class DateType extends DateTimeType {
4
- readonly kind = "DateType";
5
- protected readonly xsdDatatype: import("@rdfjs/types").NamedNode<string> & import("@rdfjs/types").NamedNode<"http://www.w3.org/2001/XMLSchema#date">;
6
+ protected readonly xsdDatatype: NamedNode;
6
7
  protected readonly zodDatatype = "date";
8
+ readonly kind = "DateType";
9
+ get graphqlName(): Type.GraphqlName;
7
10
  toJsonExpression({ variables, }: Parameters<PrimitiveType<Date>["toJsonExpression"]>[0]): string;
8
11
  }
9
12
  //# sourceMappingURL=DateType.d.ts.map
@@ -1,11 +1,25 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
1
7
  import { xsd } from "@tpluscode/rdf-ns-builders";
8
+ import { Memoize } from "typescript-memoize";
2
9
  import { DateTimeType } from "./DateTimeType.js";
10
+ import { Type } from "./Type.js";
3
11
  export class DateType extends DateTimeType {
4
- kind = "DateType";
5
12
  xsdDatatype = xsd.date;
6
13
  zodDatatype = "date";
14
+ kind = "DateType";
15
+ get graphqlName() {
16
+ return new Type.GraphqlName("graphqlScalars.Date");
17
+ }
7
18
  toJsonExpression({ variables, }) {
8
19
  return `${variables.value}.toISOString().replace(/T.*$/, '')`;
9
20
  }
10
21
  }
22
+ __decorate([
23
+ Memoize()
24
+ ], DateType.prototype, "graphqlName", null);
11
25
  //# sourceMappingURL=DateType.js.map
@@ -8,10 +8,10 @@ export declare abstract class DeclaredType extends Type {
8
8
  readonly export: boolean;
9
9
  readonly features: Set<TsFeature>;
10
10
  readonly name: string;
11
- constructor({ export_, features, name, ...superParameters }: {
11
+ constructor({ export_, features, name, }: {
12
12
  export_: boolean;
13
13
  features: Set<TsFeature>;
14
14
  name: string;
15
- } & ConstructorParameters<typeof Type>[0]);
15
+ });
16
16
  }
17
17
  //# sourceMappingURL=DeclaredType.d.ts.map
@@ -3,8 +3,8 @@ export class DeclaredType extends Type {
3
3
  export;
4
4
  features;
5
5
  name;
6
- constructor({ export_, features, name, ...superParameters }) {
7
- super(superParameters);
6
+ constructor({ export_, features, name, }) {
7
+ super();
8
8
  this.export = export_;
9
9
  this.features = features;
10
10
  this.name = name;
@@ -0,0 +1,6 @@
1
+ import { NumberType } from "./NumberType.js";
2
+ import { Type } from "./Type.js";
3
+ export declare class FloatType extends NumberType {
4
+ get graphqlName(): Type.GraphqlName;
5
+ }
6
+ //# sourceMappingURL=FloatType.d.ts.map
@@ -0,0 +1,18 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { Memoize } from "typescript-memoize";
8
+ import { NumberType } from "./NumberType.js";
9
+ import { Type } from "./Type.js";
10
+ export class FloatType extends NumberType {
11
+ get graphqlName() {
12
+ return new Type.GraphqlName("graphql.GraphQLFloat");
13
+ }
14
+ }
15
+ __decorate([
16
+ Memoize()
17
+ ], FloatType.prototype, "graphqlName", null);
18
+ //# sourceMappingURL=FloatType.js.map
@@ -1,15 +1,20 @@
1
1
  import type { BlankNode, NamedNode } from "@rdfjs/types";
2
+ import { type FunctionDeclarationStructure, type VariableStatementStructure } from "ts-morph";
2
3
  import { TermType } from "./TermType.js";
3
- import type { Type } from "./Type.js";
4
- export declare class IdentifierType extends TermType<BlankNode | NamedNode> {
4
+ import { Type } from "./Type.js";
5
+ export declare class IdentifierType extends TermType<NamedNode, BlankNode | NamedNode> {
5
6
  readonly kind = "IdentifierType";
6
7
  get conversions(): readonly Type.Conversion[];
8
+ get fromStringFunctionDeclaration(): FunctionDeclarationStructure;
9
+ get graphqlName(): Type.GraphqlName;
7
10
  get isNamedNodeKind(): boolean;
8
- get jsonName(): string;
11
+ get jsonName(): Type.JsonName;
9
12
  get name(): string;
10
- fromJsonExpression({ variables, }: Parameters<TermType<BlankNode | NamedNode>["fromJsonExpression"]>[0]): string;
11
- jsonZodSchema({ variables, }: Parameters<TermType<BlankNode | NamedNode>["jsonZodSchema"]>[0]): ReturnType<TermType<BlankNode | NamedNode>["jsonZodSchema"]>;
12
- toJsonExpression({ variables, }: Parameters<TermType<BlankNode | NamedNode>["toJsonExpression"]>[0]): string;
13
- protected propertyFromRdfResourceValueExpression({ variables, }: Parameters<TermType<BlankNode | NamedNode>["propertyFromRdfResourceValueExpression"]>[0]): string;
13
+ get toStringFunctionDeclaration(): VariableStatementStructure;
14
+ fromJsonExpression({ variables, }: Parameters<TermType<NamedNode, BlankNode | NamedNode>["fromJsonExpression"]>[0]): string;
15
+ graphqlResolveExpression({ variables: { value }, }: Parameters<Type["graphqlResolveExpression"]>[0]): string;
16
+ jsonZodSchema({ variables, }: Parameters<TermType<NamedNode, BlankNode | NamedNode>["jsonZodSchema"]>[0]): ReturnType<TermType<NamedNode, BlankNode | NamedNode>["jsonZodSchema"]>;
17
+ toJsonExpression({ variables, }: Parameters<TermType<NamedNode, BlankNode | NamedNode>["toJsonExpression"]>[0]): string;
18
+ protected propertyFromRdfResourceValueExpression({ variables, }: Parameters<TermType<NamedNode, BlankNode | NamedNode>["propertyFromRdfResourceValueExpression"]>[0]): string;
14
19
  }
15
20
  //# sourceMappingURL=IdentifierType.d.ts.map