@shaclmate/compiler 4.0.39 → 4.0.41

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 (211) hide show
  1. package/dist/ShapesGraphToAstTransformer.d.ts +0 -8
  2. package/dist/ShapesGraphToAstTransformer.js +5 -85
  3. package/dist/_ShapesGraphToAstTransformer/shapeNodeKinds.js +128 -160
  4. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.d.ts +1 -1
  5. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.js +0 -16
  6. package/dist/ast/AbstractCompoundType.d.ts +2 -1
  7. package/dist/ast/AbstractCompoundType.js +1 -1
  8. package/dist/ast/AbstractLazyObjectType.d.ts +0 -2
  9. package/dist/ast/Ast.d.ts +1 -3
  10. package/dist/ast/ListType.d.ts +1 -1
  11. package/dist/ast/ListType.js +1 -1
  12. package/dist/ast/ObjectType.d.ts +0 -12
  13. package/dist/ast/ObjectType.js +0 -78
  14. package/dist/generators/AstJsonGenerator.js +7 -3
  15. package/dist/generators/transformAstToLabeledPropertyGraph.js +59 -56
  16. package/dist/generators/ts/AbstractCollectionType.d.ts +5 -12
  17. package/dist/generators/ts/AbstractCollectionType.js +9 -68
  18. package/dist/generators/ts/AbstractContainerType.d.ts +4 -6
  19. package/dist/generators/ts/AbstractContainerType.js +5 -9
  20. package/dist/generators/ts/AbstractDateType.d.ts +6 -3
  21. package/dist/generators/ts/AbstractDateType.js +7 -2
  22. package/dist/generators/ts/AbstractIdentifierType.d.ts +4 -0
  23. package/dist/generators/ts/AbstractIdentifierType.js +3 -0
  24. package/dist/generators/ts/AbstractLazyObjectType.d.ts +9 -9
  25. package/dist/generators/ts/AbstractLazyObjectType.js +30 -19
  26. package/dist/generators/ts/AbstractLiteralType.d.ts +1 -0
  27. package/dist/generators/ts/AbstractNumericType.d.ts +1 -1
  28. package/dist/generators/ts/AbstractNumericType.js +9 -9
  29. package/dist/generators/ts/AbstractObjectSetType.d.ts +10 -9
  30. package/dist/generators/ts/AbstractObjectSetType.js +2 -2
  31. package/dist/generators/ts/AbstractPrimitiveType.d.ts +1 -0
  32. package/dist/generators/ts/AbstractPrimitiveType.js +2 -2
  33. package/dist/generators/ts/AbstractTermType.d.ts +1 -2
  34. package/dist/generators/ts/AbstractTermType.js +3 -5
  35. package/dist/generators/ts/AbstractType.d.ts +61 -26
  36. package/dist/generators/ts/AbstractType.js +37 -17
  37. package/dist/generators/ts/BigDecimalType.d.ts +5 -1
  38. package/dist/generators/ts/BigDecimalType.js +6 -3
  39. package/dist/generators/ts/BigIntType.d.ts +3 -1
  40. package/dist/generators/ts/BigIntType.js +3 -3
  41. package/dist/generators/ts/BlankNodeType.d.ts +3 -3
  42. package/dist/generators/ts/BlankNodeType.js +13 -13
  43. package/dist/generators/ts/BooleanType.d.ts +5 -3
  44. package/dist/generators/ts/BooleanType.js +11 -6
  45. package/dist/generators/ts/DefaultValueType.d.ts +40 -2
  46. package/dist/generators/ts/DefaultValueType.js +14 -12
  47. package/dist/generators/ts/FloatType.d.ts +3 -1
  48. package/dist/generators/ts/FloatType.js +1 -1
  49. package/dist/generators/ts/GraphqlSchema.d.ts +4 -4
  50. package/dist/generators/ts/GraphqlSchema.js +6 -6
  51. package/dist/generators/ts/IdentifierType.d.ts +3 -3
  52. package/dist/generators/ts/IdentifierType.js +19 -17
  53. package/dist/generators/ts/IntType.d.ts +3 -1
  54. package/dist/generators/ts/IntType.js +1 -1
  55. package/dist/generators/ts/IriType.d.ts +2 -2
  56. package/dist/generators/ts/IriType.js +21 -19
  57. package/dist/generators/ts/LazyObjectOptionType.d.ts +2 -0
  58. package/dist/generators/ts/LazyObjectOptionType.js +14 -10
  59. package/dist/generators/ts/LazyObjectSetType.js +14 -8
  60. package/dist/generators/ts/LazyObjectType.js +9 -6
  61. package/dist/generators/ts/ListType.d.ts +13 -5
  62. package/dist/generators/ts/ListType.js +48 -12
  63. package/dist/generators/ts/LiteralType.d.ts +5 -1
  64. package/dist/generators/ts/LiteralType.js +11 -8
  65. package/dist/generators/ts/{NamedObjectType.d.ts → ObjectType.d.ts} +19 -34
  66. package/dist/generators/ts/ObjectType.js +282 -0
  67. package/dist/generators/ts/ObjectUnionType.d.ts +20 -0
  68. package/dist/generators/ts/{NamedObjectUnionType.js → ObjectUnionType.js} +52 -60
  69. package/dist/generators/ts/OptionType.d.ts +6 -2
  70. package/dist/generators/ts/OptionType.js +20 -15
  71. package/dist/generators/ts/RdfjsDatasetObjectSetType.js +8 -11
  72. package/dist/generators/ts/SetType.d.ts +16 -1
  73. package/dist/generators/ts/SetType.js +80 -2
  74. package/dist/generators/ts/Snippets.d.ts +3 -1
  75. package/dist/generators/ts/Snippets.js +18 -4
  76. package/dist/generators/ts/SparqlObjectSetType.js +2 -2
  77. package/dist/generators/ts/StringType.d.ts +5 -3
  78. package/dist/generators/ts/StringType.js +15 -6
  79. package/dist/generators/ts/TermType.d.ts +6 -2
  80. package/dist/generators/ts/TermType.js +15 -12
  81. package/dist/generators/ts/TsGenerator.d.ts +1 -1
  82. package/dist/generators/ts/TsGenerator.js +60 -32
  83. package/dist/generators/ts/Type.d.ts +4 -5
  84. package/dist/generators/ts/TypeFactory.d.ts +7 -8
  85. package/dist/generators/ts/TypeFactory.js +62 -76
  86. package/dist/generators/ts/{AbstractUnionType.d.ts → UnionType.d.ts} +36 -11
  87. package/dist/generators/ts/{AbstractUnionType.js → UnionType.js} +296 -105
  88. package/dist/generators/ts/ZodGenerator.d.ts +1 -1
  89. package/dist/generators/ts/ZodGenerator.js +21 -16
  90. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/AbstractProperty.d.ts +9 -6
  91. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/AbstractProperty.js +3 -3
  92. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/DiscriminantProperty.d.ts +9 -13
  93. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/DiscriminantProperty.js +22 -39
  94. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/IdentifierProperty.d.ts +1 -5
  95. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/IdentifierProperty.js +18 -13
  96. package/dist/generators/ts/_ObjectType/ObjectType_createFunctionDeclaration.d.ts +5 -0
  97. package/dist/generators/ts/_ObjectType/ObjectType_createFunctionDeclaration.js +44 -0
  98. package/dist/generators/ts/_ObjectType/ObjectType_equalsFunctionDeclaration.d.ts +5 -0
  99. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.js → _ObjectType/ObjectType_equalsFunctionDeclaration.js} +3 -7
  100. package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionDeclaration.d.ts +5 -0
  101. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_filterFunctionDeclaration.js → _ObjectType/ObjectType_filterFunctionDeclaration.js} +3 -6
  102. package/dist/generators/ts/_ObjectType/ObjectType_filterTypeDeclaration.d.ts +5 -0
  103. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_filterTypeDeclaration.js → _ObjectType/ObjectType_filterTypeDeclaration.js} +2 -5
  104. package/dist/generators/ts/_ObjectType/ObjectType_focusSparqlConstructTriplesFunctionDeclaration.d.ts +5 -0
  105. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.js → _ObjectType/ObjectType_focusSparqlConstructTriplesFunctionDeclaration.js} +2 -6
  106. package/dist/generators/ts/_ObjectType/ObjectType_focusSparqlWherePatternsFunctionDeclaration.d.ts +5 -0
  107. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.js → _ObjectType/ObjectType_focusSparqlWherePatternsFunctionDeclaration.js} +5 -24
  108. package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclaration.d.ts +5 -0
  109. package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclaration.js +18 -0
  110. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionDeclaration.d.ts +5 -0
  111. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionDeclaration.js +51 -0
  112. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.d.ts +5 -0
  113. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.js +15 -0
  114. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfTypeVariableStatement.d.ts +5 -0
  115. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.js → _ObjectType/ObjectType_fromRdfTypeVariableStatement.js} +2 -2
  116. package/dist/generators/ts/_ObjectType/ObjectType_graphqlTypeVariableStatement.d.ts +5 -0
  117. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_graphqlTypeVariableStatement.js → _ObjectType/ObjectType_graphqlTypeVariableStatement.js} +4 -4
  118. package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionDeclarations.d.ts +4 -0
  119. package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionDeclarations.js +41 -0
  120. package/dist/generators/ts/_ObjectType/ObjectType_interfaceDeclaration.d.ts +4 -0
  121. package/dist/generators/ts/_ObjectType/ObjectType_interfaceDeclaration.js +12 -0
  122. package/dist/generators/ts/_ObjectType/ObjectType_isTypeFunctionDeclaration.d.ts +5 -0
  123. package/dist/generators/ts/_ObjectType/ObjectType_isTypeFunctionDeclaration.js +20 -0
  124. package/dist/generators/ts/_ObjectType/ObjectType_jsonParseFunctionDeclaration.d.ts +5 -0
  125. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.js → _ObjectType/ObjectType_jsonParseFunctionDeclaration.js} +2 -2
  126. package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaFunctionDeclaration.d.ts +5 -0
  127. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js → _ObjectType/ObjectType_jsonSchemaFunctionDeclaration.js} +5 -11
  128. package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeAliasDeclaration.d.ts +5 -0
  129. package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeAliasDeclaration.js +9 -0
  130. package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.d.ts +5 -0
  131. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.js → _ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.js} +4 -6
  132. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_objectSetMethodNames.d.ts → _ObjectType/ObjectType_objectSetMethodNames.d.ts} +3 -3
  133. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_objectSetMethodNames.js → _ObjectType/ObjectType_objectSetMethodNames.js} +4 -4
  134. package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.d.ts +5 -0
  135. package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.js +12 -0
  136. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.d.ts → _ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.d.ts} +3 -3
  137. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.js → _ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.js} +5 -5
  138. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts → _ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts} +3 -3
  139. package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.js +12 -0
  140. package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionDeclaration.d.ts +5 -0
  141. package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionDeclaration.js +20 -0
  142. package/dist/generators/ts/_ObjectType/ObjectType_toRdfResourceFunctionDeclaration.d.ts +5 -0
  143. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_toRdfResourceFunctionDeclaration.js → _ObjectType/ObjectType_toRdfResourceFunctionDeclaration.js} +4 -4
  144. package/dist/generators/ts/_ObjectType/ObjectType_toStringFunctionDeclarations.d.ts +4 -0
  145. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.js → _ObjectType/ObjectType_toStringFunctionDeclarations.js} +7 -14
  146. package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlConstructTriplesFunctionDeclaration.d.ts +5 -0
  147. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.js → _ObjectType/ObjectType_valueSparqlConstructTriplesFunctionDeclaration.js} +3 -3
  148. package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlWherePatternsFunctionDeclaration.d.ts +5 -0
  149. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.js → _ObjectType/ObjectType_valueSparqlWherePatternsFunctionDeclaration.js} +3 -3
  150. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/ShaclProperty.js +12 -12
  151. package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.d.ts +4 -0
  152. package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.js +16 -0
  153. package/dist/generators/ts/_snippets/snippets_convertToArraySet.d.ts +3 -0
  154. package/dist/generators/ts/_snippets/snippets_convertToArraySet.js +8 -0
  155. package/dist/generators/ts/_snippets/snippets_convertToList.d.ts +3 -0
  156. package/dist/generators/ts/_snippets/snippets_convertToList.js +7 -0
  157. package/dist/generators/ts/_snippets/snippets_convertToScalarSet.d.ts +3 -0
  158. package/dist/generators/ts/_snippets/snippets_convertToScalarSet.js +15 -0
  159. package/dist/input/generated.d.ts +758 -117
  160. package/dist/input/generated.js +636 -128
  161. package/package.json +4 -6
  162. package/dist/generators/ts/AbstractNamedUnionType.d.ts +0 -30
  163. package/dist/generators/ts/AbstractNamedUnionType.js +0 -190
  164. package/dist/generators/ts/AnonymousUnionType.d.ts +0 -27
  165. package/dist/generators/ts/AnonymousUnionType.js +0 -59
  166. package/dist/generators/ts/NamedObjectType.js +0 -342
  167. package/dist/generators/ts/NamedObjectUnionType.d.ts +0 -37
  168. package/dist/generators/ts/NamedUnionType.d.ts +0 -11
  169. package/dist/generators/ts/NamedUnionType.js +0 -13
  170. package/dist/generators/ts/_NamedObjectType/NamedObjectType_createFunctionDeclaration.d.ts +0 -5
  171. package/dist/generators/ts/_NamedObjectType/NamedObjectType_createFunctionDeclaration.js +0 -65
  172. package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.d.ts +0 -5
  173. package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterFunctionDeclaration.d.ts +0 -5
  174. package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterTypeDeclaration.d.ts +0 -5
  175. package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.d.ts +0 -5
  176. package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.d.ts +0 -5
  177. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.d.ts +0 -5
  178. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.js +0 -43
  179. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.d.ts +0 -5
  180. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js +0 -80
  181. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.d.ts +0 -5
  182. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.js +0 -15
  183. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.d.ts +0 -5
  184. package/dist/generators/ts/_NamedObjectType/NamedObjectType_graphqlTypeVariableStatement.d.ts +0 -5
  185. package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.d.ts +0 -4
  186. package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.js +0 -45
  187. package/dist/generators/ts/_NamedObjectType/NamedObjectType_interfaceDeclaration.d.ts +0 -4
  188. package/dist/generators/ts/_NamedObjectType/NamedObjectType_interfaceDeclaration.js +0 -16
  189. package/dist/generators/ts/_NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.d.ts +0 -5
  190. package/dist/generators/ts/_NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.js +0 -17
  191. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.d.ts +0 -5
  192. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.d.ts +0 -5
  193. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.d.ts +0 -5
  194. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.js +0 -16
  195. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.d.ts +0 -5
  196. package/dist/generators/ts/_NamedObjectType/NamedObjectType_schemaVariableStatement.d.ts +0 -5
  197. package/dist/generators/ts/_NamedObjectType/NamedObjectType_schemaVariableStatement.js +0 -12
  198. package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js +0 -12
  199. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.d.ts +0 -5
  200. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.js +0 -41
  201. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionDeclaration.d.ts +0 -5
  202. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.d.ts +0 -4
  203. package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.d.ts +0 -5
  204. package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.d.ts +0 -5
  205. package/dist/generators/ts/_NamedObjectType/identifierTypeDeclarations.d.ts +0 -4
  206. package/dist/generators/ts/_NamedObjectType/identifierTypeDeclarations.js +0 -25
  207. package/dist/generators/ts/_snippets/snippets_convertToArray.d.ts +0 -3
  208. package/dist/generators/ts/_snippets/snippets_convertToArray.js +0 -8
  209. /package/dist/generators/ts/{_NamedObjectType → _ObjectType}/Property.d.ts +0 -0
  210. /package/dist/generators/ts/{_NamedObjectType → _ObjectType}/Property.js +0 -0
  211. /package/dist/generators/ts/{_NamedObjectType → _ObjectType}/ShaclProperty.d.ts +0 -0
@@ -1,5 +1,5 @@
1
1
  import type { Logger } from "ts-log";
2
- import * as ast from "../../ast/index.js";
2
+ import type * as ast from "../../ast/index.js";
3
3
  import type { Generator } from "../Generator.js";
4
4
  export declare class ZodGenerator implements Generator {
5
5
  private readonly logger;
@@ -1,7 +1,5 @@
1
- import { invariant } from "ts-invariant";
2
- import * as ast from "../../ast/index.js";
3
- import { NamedObjectType_jsonSchemaFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js";
4
- import { NamedObjectType_jsonTypeAliasDeclaration } from "./_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.js";
1
+ import { ObjectType_jsonSchemaFunctionDeclaration } from "./_ObjectType/ObjectType_jsonSchemaFunctionDeclaration.js";
2
+ import { ObjectType_jsonTypeAliasDeclaration } from "./_ObjectType/ObjectType_jsonTypeAliasDeclaration.js";
5
3
  import { Reusables } from "./Reusables.js";
6
4
  import { TsGenerator } from "./TsGenerator.js";
7
5
  import { TypeFactory } from "./TypeFactory.js";
@@ -20,25 +18,32 @@ export class ZodGenerator {
20
18
  reusables,
21
19
  });
22
20
  const declarations = [];
23
- for (const namedObjectType of ast.ObjectType.toposort(ast_.namedObjectTypes).map((astObjectType) => typeFactory.createNamedObjectType(astObjectType))) {
24
- declarations.push(code `\
25
- export namespace ${namedObjectType.name} {
26
- ${joinCode(NamedObjectType_jsonTypeAliasDeclaration.call(namedObjectType).toList())}
21
+ for (const astNamedType of ast_.namedTypes) {
22
+ switch (astNamedType.kind) {
23
+ case "Object": {
24
+ const tsNamedObjectType = typeFactory.createObjectType(astNamedType);
25
+ declarations.push(code `\
26
+ export namespace ${tsNamedObjectType.alias.unsafeCoerce()} {
27
+ ${joinCode(ObjectType_jsonTypeAliasDeclaration.call(tsNamedObjectType).toList())}
27
28
 
28
29
  export namespace Json {
29
- ${joinCode(NamedObjectType_jsonSchemaFunctionDeclaration.call(namedObjectType).toList())}
30
+ ${joinCode(ObjectType_jsonSchemaFunctionDeclaration.call(tsNamedObjectType).toList())}
30
31
  }
31
32
  }`);
32
- }
33
- for (const astNamedUnionType of ast_.namedUnionTypes.map((astNamedUnionType) => typeFactory.createUnionType(astNamedUnionType))) {
34
- invariant(astNamedUnionType.kind !== "AnonymousUnion");
35
- declarations.push(code `\
36
- export namespace ${astNamedUnionType.name} {
37
- ${astNamedUnionType.jsonTypeAliasDeclaration}
33
+ break;
34
+ }
35
+ case "Union": {
36
+ const tsNamedUnionType = typeFactory.createUnionType(astNamedType);
37
+ declarations.push(code `\
38
+ export namespace ${tsNamedUnionType.alias.unsafeCoerce()} {
39
+ ${tsNamedUnionType.jsonTypeAliasDeclaration}
38
40
  export namespace Json {
39
- ${astNamedUnionType.jsonSchemaFunctionDeclaration}
41
+ ${tsNamedUnionType.jsonSchemaFunctionDeclaration}
40
42
  }
41
43
  }`);
44
+ break;
45
+ }
46
+ }
42
47
  }
43
48
  declarations.splice(0, 0, joinCode(reusables.snippets.ifUsed, { on: "\n\n" }));
44
49
  return joinCode(declarations, { on: "\n\n" }).toString({});
@@ -1,15 +1,16 @@
1
1
  import { Maybe } from "purify-ts";
2
2
  import type { Logger } from "ts-log";
3
- import type { NamedObjectType } from "../NamedObjectType.js";
4
3
  import type { Reusables } from "../Reusables.js";
5
4
  import { rdfjsTermExpression } from "../rdfjsTermExpression.js";
6
5
  import type { TsGenerator } from "../TsGenerator.js";
7
6
  import type { Type } from "../Type.js";
8
7
  import { type Code } from "../ts-poet-wrapper.js";
9
- export declare abstract class AbstractProperty<TypeT extends Pick<Type, "filterFunction" | "mutable" | "name" | "schema">> {
8
+ export declare abstract class AbstractProperty<TypeT extends Pick<Type, "expression" | "filterFunction" | "mutable" | "schema">> {
10
9
  protected readonly configuration: TsGenerator.Configuration;
11
10
  protected readonly logger: Logger;
12
- protected readonly namedObjectType: NamedObjectType;
11
+ protected readonly objectType: {
12
+ readonly alias: Maybe<string>;
13
+ };
13
14
  protected readonly reusables: Reusables;
14
15
  /**
15
16
  * Optional parameter to include in the parameters object of constructor function.
@@ -62,18 +63,20 @@ export declare abstract class AbstractProperty<TypeT extends Pick<Type, "filterF
62
63
  */
63
64
  readonly name: string;
64
65
  /**
65
- * Is the property's type the NamedObjectType or does its type indirectly reference the NamedObjectType?
66
+ * Is the property's type the ObjectType or does its type indirectly reference the ObjectType?
66
67
  */
67
68
  abstract readonly recursive: boolean;
68
69
  /**
69
70
  * Property type
70
71
  . */
71
72
  readonly type: TypeT;
72
- constructor({ configuration, logger, name, namedObjectType, reusables, type, }: {
73
+ constructor({ configuration, logger, name, objectType, reusables, type, }: {
73
74
  configuration: TsGenerator.Configuration;
74
75
  logger: Logger;
75
76
  name: string;
76
- namedObjectType: NamedObjectType;
77
+ objectType: {
78
+ readonly alias: Maybe<string>;
79
+ };
77
80
  reusables: Reusables;
78
81
  type: TypeT;
79
82
  });
@@ -11,7 +11,7 @@ import { code, joinCode, literalOf } from "../ts-poet-wrapper.js";
11
11
  export class AbstractProperty {
12
12
  configuration;
13
13
  logger;
14
- namedObjectType;
14
+ objectType;
15
15
  reusables;
16
16
  /**
17
17
  * TypeScript identifier-safe name of the property.
@@ -21,11 +21,11 @@ export class AbstractProperty {
21
21
  * Property type
22
22
  . */
23
23
  type;
24
- constructor({ configuration, logger, name, namedObjectType, reusables, type, }) {
24
+ constructor({ configuration, logger, name, objectType, reusables, type, }) {
25
25
  this.configuration = configuration;
26
26
  this.logger = logger;
27
27
  this.name = name;
28
- this.namedObjectType = namedObjectType;
28
+ this.objectType = objectType;
29
29
  this.reusables = reusables;
30
30
  this.type = type;
31
31
  this.rdfjsTermExpression = rdfjsTermExpression.bind({
@@ -8,9 +8,10 @@ export declare class DiscriminantProperty extends AbstractProperty<DiscriminantP
8
8
  readonly kind = "Discriminant";
9
9
  readonly mutable = false;
10
10
  readonly recursive = false;
11
- constructor({ type, ...superParameters }: {
12
- type: DiscriminantProperty.Type;
13
- } & ConstructorParameters<typeof AbstractProperty>[0]);
11
+ readonly value: string;
12
+ constructor({ value, ...superParameters }: {
13
+ value: string;
14
+ } & Omit<ConstructorParameters<typeof AbstractProperty>[0], "type">);
14
15
  get declaration(): Code;
15
16
  get jsonName(): string;
16
17
  get jsonSchema(): AbstractProperty<DiscriminantProperty.Type>["jsonSchema"];
@@ -27,21 +28,16 @@ export declare class DiscriminantProperty extends AbstractProperty<DiscriminantP
27
28
  toJsonInitializer({ variables, }: Parameters<AbstractProperty<DiscriminantProperty.Type>["toJsonInitializer"]>[0]): Maybe<Code>;
28
29
  toRdfRdfResourceValuesStatements(): readonly Code[];
29
30
  toStringInitializer(): Maybe<Code>;
31
+ get values(): readonly string[];
30
32
  }
31
33
  export declare namespace DiscriminantProperty {
32
34
  class Type {
35
+ readonly value: string;
33
36
  readonly filterFunction: Code;
34
- readonly mutable: boolean;
35
- readonly descendantValues: readonly string[];
36
- readonly ownValues: readonly string[];
37
- constructor({ descendantValues, mutable, ownValues, }: {
38
- descendantValues: readonly string[];
39
- mutable: boolean;
40
- ownValues: readonly string[];
41
- });
42
- get name(): string;
37
+ readonly mutable = false;
38
+ constructor(value: string);
39
+ get expression(): Code;
43
40
  get schema(): Code;
44
- get values(): string[];
45
41
  }
46
42
  }
47
43
  //# sourceMappingURL=DiscriminantProperty.d.ts.map
@@ -6,7 +6,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  };
7
7
  import { Maybe } from "purify-ts";
8
8
  import { Memoize } from "typescript-memoize";
9
- import { arrayOf, code, literalOf } from "../ts-poet-wrapper.js";
9
+ import { code, literalOf } from "../ts-poet-wrapper.js";
10
10
  import { AbstractProperty } from "./AbstractProperty.js";
11
11
  export class DiscriminantProperty extends AbstractProperty {
12
12
  constructorParameter = Maybe.empty();
@@ -15,11 +15,13 @@ export class DiscriminantProperty extends AbstractProperty {
15
15
  kind = "Discriminant";
16
16
  mutable = false;
17
17
  recursive = false;
18
- constructor({ type, ...superParameters }) {
19
- super({ ...superParameters, type });
18
+ value;
19
+ constructor({ value, ...superParameters }) {
20
+ super({ ...superParameters, type: new DiscriminantProperty.Type(value) });
21
+ this.value = value;
20
22
  }
21
23
  get declaration() {
22
- return code `readonly ${this.name}: ${this.type.name};`;
24
+ return code `readonly ${this.name}: ${this.type.expression};`;
23
25
  }
24
26
  get jsonName() {
25
27
  return "@type";
@@ -27,13 +29,11 @@ export class DiscriminantProperty extends AbstractProperty {
27
29
  get jsonSchema() {
28
30
  return Maybe.of({
29
31
  key: this.jsonName,
30
- schema: this.type.values.length > 1
31
- ? code `${this.reusables.imports.z}.enum(${arrayOf(...this.type.values)})`
32
- : code `${this.reusables.imports.z}.literal(${literalOf(this.type.values[0])})`,
32
+ schema: code `${this.reusables.imports.z}.literal(${literalOf(this.value)})`,
33
33
  });
34
34
  }
35
35
  get jsonSignature() {
36
- return Maybe.of(code `readonly "${this.jsonName}": ${this.type.name}`);
36
+ return Maybe.of(code `readonly "${this.jsonName}": ${this.type.expression}`);
37
37
  }
38
38
  get schema() {
39
39
  return Maybe.empty();
@@ -42,7 +42,7 @@ export class DiscriminantProperty extends AbstractProperty {
42
42
  // return super.schemaInitializers.concat(code`type: ${this.type.schema}`);
43
43
  // }
44
44
  get constValue() {
45
- return code `${literalOf(this.namedObjectType.discriminantValue)} as const`;
45
+ return code `${literalOf(this.value)} as const`;
46
46
  }
47
47
  constructorInitializer() {
48
48
  return Maybe.empty();
@@ -54,15 +54,9 @@ export class DiscriminantProperty extends AbstractProperty {
54
54
  return Maybe.empty();
55
55
  }
56
56
  hashStatements({ variables, }) {
57
- if (this.namedObjectType.parentObjectTypes.length > 0) {
58
- return [];
59
- }
60
57
  return [code `${variables.hasher}.update(${variables.value});`];
61
58
  }
62
59
  jsonUiSchemaElement({ variables, }) {
63
- if (this.namedObjectType.parentObjectTypes.length > 0) {
64
- return Maybe.empty();
65
- }
66
60
  const scope = code `\`\${${variables.scopePrefix}}/properties/${this.jsonName}\``;
67
61
  return Maybe.of(code `{ rule: { condition: { schema: { const: ${this.constValue} }, scope: ${scope} }, effect: "HIDE" }, scope: ${scope}, type: "Control" }`);
68
62
  }
@@ -81,6 +75,9 @@ export class DiscriminantProperty extends AbstractProperty {
81
75
  toStringInitializer() {
82
76
  return Maybe.empty();
83
77
  }
78
+ get values() {
79
+ return [this.value];
80
+ }
84
81
  }
85
82
  __decorate([
86
83
  Memoize()
@@ -91,44 +88,30 @@ __decorate([
91
88
  __decorate([
92
89
  Memoize()
93
90
  ], DiscriminantProperty.prototype, "jsonSignature", null);
91
+ __decorate([
92
+ Memoize()
93
+ ], DiscriminantProperty.prototype, "values", null);
94
94
  (function (DiscriminantProperty) {
95
95
  class Type {
96
+ value;
96
97
  filterFunction = code `nonextant`;
97
- mutable;
98
- descendantValues;
99
- ownValues;
100
- constructor({ descendantValues, mutable, ownValues, }) {
101
- this.descendantValues = descendantValues;
102
- this.mutable = mutable;
103
- this.ownValues = ownValues;
98
+ mutable = false;
99
+ constructor(value) {
100
+ this.value = value;
104
101
  }
105
- get name() {
106
- return `${this.values.map((name) => `"${name}"`).join(" | ")}`;
102
+ get expression() {
103
+ return code `${literalOf(this.value)}`;
107
104
  }
108
105
  get schema() {
109
106
  throw new Error("should never be called");
110
- // const initializers: Record<string, unknown> = {};
111
- // if (this.descendantValues.length > 0) {
112
- // initializers["descendantValues"] = this.descendantValues;
113
- // }
114
- // if (this.ownValues.length > 0) {
115
- // initializers["ownValues"] = this.ownValues;
116
- // }
117
- // return code`${initializers}`;
118
- }
119
- get values() {
120
- return this.ownValues.concat(this.descendantValues);
121
107
  }
122
108
  }
123
109
  __decorate([
124
110
  Memoize()
125
- ], Type.prototype, "name", null);
111
+ ], Type.prototype, "expression", null);
126
112
  __decorate([
127
113
  Memoize()
128
114
  ], Type.prototype, "schema", null);
129
- __decorate([
130
- Memoize()
131
- ], Type.prototype, "values", null);
132
115
  DiscriminantProperty.Type = Type;
133
116
  })(DiscriminantProperty || (DiscriminantProperty = {}));
134
117
  //# sourceMappingURL=DiscriminantProperty.js.map
@@ -5,14 +5,9 @@ import type { IriType } from "../IriType.js";
5
5
  import { type Code } from "../ts-poet-wrapper.js";
6
6
  import { AbstractProperty } from "./AbstractProperty.js";
7
7
  export declare class IdentifierProperty extends AbstractProperty<BlankNodeType | IdentifierType | IriType> {
8
- private readonly typeAlias;
9
8
  readonly kind = "Identifier";
10
9
  readonly mutable = false;
11
10
  readonly recursive = false;
12
- constructor({ typeAlias, ...superParameters }: {
13
- type: BlankNodeType | IdentifierType | IriType;
14
- typeAlias: Code;
15
- } & ConstructorParameters<typeof AbstractProperty>[0]);
16
11
  get constructorParameter(): Maybe<Code>;
17
12
  get declaration(): Code;
18
13
  get filterProperty(): Maybe<{
@@ -23,6 +18,7 @@ export declare class IdentifierProperty extends AbstractProperty<BlankNodeType |
23
18
  get jsonSchema(): AbstractProperty<IdentifierType>["jsonSchema"];
24
19
  get jsonSignature(): Maybe<Code>;
25
20
  protected get schemaInitializers(): readonly Code[];
21
+ private get typeExpression();
26
22
  accessExpression({ variables, }: Parameters<AbstractProperty<BlankNodeType | IdentifierType | IriType>["accessExpression"]>[0]): Code;
27
23
  constructorInitializer({ variables, }: Parameters<AbstractProperty<IdentifierType>["constructorInitializer"]>[0]): Maybe<Code>;
28
24
  fromJsonInitializer({ variables, }: Parameters<AbstractProperty<IdentifierType>["fromJsonInitializer"]>[0]): Maybe<Code>;
@@ -12,30 +12,25 @@ import { Memoize } from "typescript-memoize";
12
12
  import { arrayOf, code, joinCode, literalOf, } from "../ts-poet-wrapper.js";
13
13
  import { AbstractProperty } from "./AbstractProperty.js";
14
14
  export class IdentifierProperty extends AbstractProperty {
15
- typeAlias;
16
15
  kind = "Identifier";
17
16
  mutable = false;
18
17
  recursive = false;
19
- constructor({ typeAlias, ...superParameters }) {
20
- super(superParameters);
21
- this.typeAlias = typeAlias;
22
- }
23
18
  get constructorParameter() {
24
19
  let hasQuestionToken = false;
25
- const typeNames = [code `(() => ${this.typeAlias})`];
20
+ const typeExpressions = [code `(() => ${this.typeExpression})`];
26
21
  for (const type of this.type.conversionFunction.unsafeCoerce()
27
22
  .sourceTypes) {
28
- if (type.typeof === "undefined") {
23
+ if (type.jsType.typeof === "undefined") {
29
24
  hasQuestionToken = true;
30
25
  }
31
26
  else {
32
- typeNames.push(code `${type.name}`);
27
+ typeExpressions.push(code `${type.expression}`);
33
28
  }
34
29
  }
35
- return Maybe.of(code `readonly ${this.name}${hasQuestionToken ? "?" : ""}: ${joinCode(typeNames, { on: "|" })};`);
30
+ return Maybe.of(code `readonly ${this.name}${hasQuestionToken ? "?" : ""}: ${joinCode(typeExpressions, { on: "|" })};`);
36
31
  }
37
32
  get declaration() {
38
- return code `readonly ${this.name}: () => ${this.typeAlias};`;
33
+ return code `readonly ${this.name}: () => ${this.typeExpression};`;
39
34
  }
40
35
  get filterProperty() {
41
36
  return Maybe.of({
@@ -50,8 +45,8 @@ export class IdentifierProperty extends AbstractProperty {
50
45
  args: Maybe.empty(),
51
46
  description: Maybe.empty(),
52
47
  name: `_${this.name.substring(syntheticNamePrefix.length)}`,
53
- resolve: code `(source) => ${this.typeAlias}.stringify(${this.accessExpression({ variables: { object: code `source` } })})`,
54
- type: this.type.graphqlType.name,
48
+ resolve: code `(source) => ${this.typeExpression}.stringify(${this.accessExpression({ variables: { object: code `source` } })})`,
49
+ type: this.type.graphqlType.expression,
55
50
  });
56
51
  }
57
52
  get jsonSchema() {
@@ -78,6 +73,11 @@ export class IdentifierProperty extends AbstractProperty {
78
73
  get schemaInitializers() {
79
74
  return super.schemaInitializers.concat(code `type: ${this.type.schema}`);
80
75
  }
76
+ get typeExpression() {
77
+ return this.objectType.alias
78
+ .map((objectTypeAlias) => code `${objectTypeAlias}.Identifier`)
79
+ .orDefault(this.type.expression);
80
+ }
81
81
  accessExpression({ variables, }) {
82
82
  return code `${variables.object}.${this.name}()`;
83
83
  }
@@ -131,7 +131,9 @@ export class IdentifierProperty extends AbstractProperty {
131
131
  ignoreRdfType: true, // Unused
132
132
  preferredLanguages: variables.preferredLanguages,
133
133
  propertyPatterns: code `[]`,
134
- schema: code `${this.namedObjectType.name}.schema.properties.${this.name}.type`,
134
+ schema: this.objectType.alias
135
+ .map((objectTypeAlias) => code `${objectTypeAlias}.schema.properties.${this.name}.type`)
136
+ .orDefault(this.type.schema),
135
137
  valueVariable: variables.focusIdentifier,
136
138
  variablePrefix: variables.variablePrefix, // Unused
137
139
  }})`,
@@ -180,4 +182,7 @@ __decorate([
180
182
  __decorate([
181
183
  Memoize()
182
184
  ], IdentifierProperty.prototype, "jsonSignature", null);
185
+ __decorate([
186
+ Memoize()
187
+ ], IdentifierProperty.prototype, "typeExpression", null);
183
188
  //# sourceMappingURL=IdentifierProperty.js.map
@@ -0,0 +1,5 @@
1
+ import { Maybe } from "purify-ts";
2
+ import type { ObjectType } from "../ObjectType.js";
3
+ import { type Code } from "../ts-poet-wrapper.js";
4
+ export declare function ObjectType_createFunctionDeclaration(this: ObjectType): Maybe<Code>;
5
+ //# sourceMappingURL=ObjectType_createFunctionDeclaration.d.ts.map
@@ -0,0 +1,44 @@
1
+ import { Maybe } from "purify-ts";
2
+ import { invariant } from "ts-invariant";
3
+ import { code, joinCode, literalOf } from "../ts-poet-wrapper.js";
4
+ export function ObjectType_createFunctionDeclaration() {
5
+ if (!this.configuration.features.has("Object.create")) {
6
+ return Maybe.empty();
7
+ }
8
+ const parametersPropertySignatures = this.properties.flatMap((property) => property.constructorParameter.toList());
9
+ const parametersType = parametersPropertySignatures.length > 0
10
+ ? code `{ ${joinCode(parametersPropertySignatures)} }`
11
+ : code `object`;
12
+ const parametersHasQuestionToken = parametersPropertySignatures.every((propertySignature) => propertySignature.toCodeString([]).indexOf("?:") !== -1);
13
+ const parametersVariable = code `parameters${parametersHasQuestionToken ? "?" : ""}`;
14
+ const parametersSignature = code `parameters${parametersHasQuestionToken ? "?" : ""}: ${parametersType}`;
15
+ const propertyInitializers = this.properties.flatMap((property) => property
16
+ .constructorInitializer({
17
+ variables: { parameters: parametersVariable },
18
+ })
19
+ .toList());
20
+ invariant(propertyInitializers.length > 0);
21
+ let returnExpression = code `${this.reusables.snippets.sequenceRecord}({ ${joinCode(propertyInitializers, { on: "," })} })`;
22
+ this.discriminantProperty.ifJust((discriminantProperty) => {
23
+ returnExpression = code `${returnExpression}.map(properties => ({ ...properties, ${discriminantProperty.name}: ${literalOf(discriminantProperty.value)} as const }))`;
24
+ });
25
+ const monkeyPatchMethods = [];
26
+ if (this.configuration.features.has("Object.toJson")) {
27
+ monkeyPatchMethods.push("toJson");
28
+ }
29
+ if (this.configuration.features.has("Object.toString")) {
30
+ monkeyPatchMethods.push(`${this.configuration.syntheticNamePrefix}toString`);
31
+ }
32
+ if (monkeyPatchMethods.length > 0) {
33
+ returnExpression = code `${returnExpression}.map(object => ${this.reusables.snippets.monkeyPatchObject}(object, { ${monkeyPatchMethods.join(", ")} }))`;
34
+ }
35
+ return Maybe.of(code `\
36
+ export function create(${parametersSignature}): ${this.reusables.imports.Either}<Error, ${this.expression}> {
37
+ return ${returnExpression};
38
+ }
39
+
40
+ export function createUnsafe(${parametersSignature}): ${this.expression} {
41
+ return create(parameters).unsafeCoerce();
42
+ }`);
43
+ }
44
+ //# sourceMappingURL=ObjectType_createFunctionDeclaration.js.map
@@ -0,0 +1,5 @@
1
+ import { Maybe } from "purify-ts";
2
+ import type { ObjectType } from "../ObjectType.js";
3
+ import { type Code } from "../ts-poet-wrapper.js";
4
+ export declare function ObjectType_equalsFunctionDeclaration(this: ObjectType): Maybe<Code>;
5
+ //# sourceMappingURL=ObjectType_equalsFunctionDeclaration.d.ts.map
@@ -1,14 +1,10 @@
1
1
  import { Maybe } from "purify-ts";
2
2
  import { code, joinCode } from "../ts-poet-wrapper.js";
3
- export function NamedObjectType_equalsFunctionDeclaration() {
3
+ export function ObjectType_equalsFunctionDeclaration() {
4
4
  if (!this.configuration.features.has("Object.equals")) {
5
5
  return Maybe.empty();
6
6
  }
7
7
  const chain = [];
8
- // For every parent, find the nearest equals implementation
9
- for (const parentObjectType of this.parentObjectTypes) {
10
- chain.push(code `${parentObjectType.name}.equals(left, right)`);
11
- }
12
8
  for (const property of this.properties) {
13
9
  if (property.kind === "Discriminant") {
14
10
  continue;
@@ -16,8 +12,8 @@ export function NamedObjectType_equalsFunctionDeclaration() {
16
12
  chain.push(code `(${property.type.equalsFunction})(${property.accessExpression({ variables: { object: code `left` } })}, ${property.accessExpression({ variables: { object: code `right` } })}).mapLeft(propertyValuesUnequal => ({ left, right, propertyName: "${property.name}", propertyValuesUnequal, type: "property" as const }))`);
17
13
  }
18
14
  return Maybe.of(code `\
19
- export function equals(left: ${this.name}, right: ${this.name}): ${this.reusables.snippets.EqualsResult} {
15
+ export function equals(left: ${this.expression}, right: ${this.expression}): ${this.reusables.snippets.EqualsResult} {
20
16
  return ${joinCode(chain.map((chainPart, chainPartI) => chainPartI === 0 ? chainPart : code `chain(() => ${chainPart})`), { on: "." })}
21
17
  }`);
22
18
  }
23
- //# sourceMappingURL=NamedObjectType_equalsFunctionDeclaration.js.map
19
+ //# sourceMappingURL=ObjectType_equalsFunctionDeclaration.js.map
@@ -0,0 +1,5 @@
1
+ import { Maybe } from "purify-ts";
2
+ import type { ObjectType } from "../ObjectType.js";
3
+ import { type Code } from "../ts-poet-wrapper.js";
4
+ export declare function ObjectType_filterFunctionDeclaration(this: ObjectType): Maybe<Code>;
5
+ //# sourceMappingURL=ObjectType_filterFunctionDeclaration.d.ts.map
@@ -1,13 +1,10 @@
1
1
  import { Maybe } from "purify-ts";
2
2
  import { code, joinCode } from "../ts-poet-wrapper.js";
3
- export function NamedObjectType_filterFunctionDeclaration() {
3
+ export function ObjectType_filterFunctionDeclaration() {
4
4
  if (!this.configuration.features.has("Object.filter")) {
5
5
  return Maybe.empty();
6
6
  }
7
7
  const statements = [];
8
- for (const parentObjectType of this.parentObjectTypes) {
9
- statements.push(code `if (!${parentObjectType.filterFunction}(filter, value)) { return false; }`);
10
- }
11
8
  if (this.properties.length > 0) {
12
9
  for (const property of this.properties) {
13
10
  property.filterProperty.ifJust(({ name }) => {
@@ -17,8 +14,8 @@ export function NamedObjectType_filterFunctionDeclaration() {
17
14
  }
18
15
  statements.push(code `return true;`);
19
16
  return Maybe.of(code `\
20
- export function filter(filter: ${this.filterType}, value: ${this.name}): boolean {
17
+ export function filter(filter: ${this.filterType}, value: ${this.expression}): boolean {
21
18
  ${joinCode(statements)}
22
19
  }`);
23
20
  }
24
- //# sourceMappingURL=NamedObjectType_filterFunctionDeclaration.js.map
21
+ //# sourceMappingURL=ObjectType_filterFunctionDeclaration.js.map
@@ -0,0 +1,5 @@
1
+ import { Maybe } from "purify-ts";
2
+ import type { ObjectType } from "../ObjectType.js";
3
+ import { type Code } from "../ts-poet-wrapper.js";
4
+ export declare function ObjectType_filterTypeDeclaration(this: ObjectType): Maybe<Code>;
5
+ //# sourceMappingURL=ObjectType_filterTypeDeclaration.d.ts.map
@@ -1,6 +1,6 @@
1
1
  import { Maybe } from "purify-ts";
2
2
  import { code, joinCode } from "../ts-poet-wrapper.js";
3
- export function NamedObjectType_filterTypeDeclaration() {
3
+ export function ObjectType_filterTypeDeclaration() {
4
4
  if (!this.configuration.features.has("Object.filter")) {
5
5
  return Maybe.empty();
6
6
  }
@@ -16,10 +16,7 @@ export function NamedObjectType_filterTypeDeclaration() {
16
16
  members.push(code `{ ${joinCode(Object.entries(filterProperties).map(([name, type]) => code `readonly ${name}?: ${type}`), { on: ";" })} }`);
17
17
  }
18
18
  }
19
- for (const parentObjectType of this.parentObjectTypes) {
20
- members.push(code `${parentObjectType.name}.Filter`);
21
- }
22
19
  return Maybe.of(code `\
23
20
  export type Filter = ${members.length > 0 ? joinCode(members, { on: " & " }) : "object"};`);
24
21
  }
25
- //# sourceMappingURL=NamedObjectType_filterTypeDeclaration.js.map
22
+ //# sourceMappingURL=ObjectType_filterTypeDeclaration.js.map
@@ -0,0 +1,5 @@
1
+ import { Maybe } from "purify-ts";
2
+ import type { ObjectType } from "../ObjectType.js";
3
+ import { type Code } from "../ts-poet-wrapper.js";
4
+ export declare function ObjectType_focusSparqlConstructTriplesFunctionDeclaration(this: ObjectType): Maybe<Code>;
5
+ //# sourceMappingURL=ObjectType_focusSparqlConstructTriplesFunctionDeclaration.d.ts.map
@@ -6,7 +6,7 @@ const variables = {
6
6
  focusIdentifier: code `parameters.focusIdentifier`,
7
7
  variablePrefix: code `parameters.variablePrefix`,
8
8
  };
9
- export function NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration() {
9
+ export function ObjectType_focusSparqlConstructTriplesFunctionDeclaration() {
10
10
  if (!this.configuration.features.has("Object.SPARQL")) {
11
11
  return Maybe.empty();
12
12
  }
@@ -14,10 +14,6 @@ export function NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration()
14
14
  const rdfTypeVariable = code `${this.reusables.imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}RdfType\`)`;
15
15
  let triplesVariableDeclarationKeyword = "const";
16
16
  const statements = [];
17
- for (const parentObjectType of this.parentObjectTypes) {
18
- statements.push(code `triples = triples.concat(${parentObjectType.name}.focusSparqlConstructTriples(${{ filter: variables.filter, focusIdentifier: variables.focusIdentifier, ignoreRdfType: true, variablePrefix: variables.variablePrefix }}));`);
19
- triplesVariableDeclarationKeyword = "let";
20
- }
21
17
  if (this.fromRdfType.isJust()) {
22
18
  statements.push(code `\
23
19
  if (!parameters?.ignoreRdfType) {
@@ -51,4 +47,4 @@ ${statements.length > 0
51
47
  : "return [];"}
52
48
  };`);
53
49
  }
54
- //# sourceMappingURL=NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.js.map
50
+ //# sourceMappingURL=ObjectType_focusSparqlConstructTriplesFunctionDeclaration.js.map
@@ -0,0 +1,5 @@
1
+ import { Maybe } from "purify-ts";
2
+ import type { ObjectType } from "../ObjectType.js";
3
+ import { type Code } from "../ts-poet-wrapper.js";
4
+ export declare function ObjectType_focusSparqlWherePatternsFunctionDeclaration(this: ObjectType): Maybe<Code>;
5
+ //# sourceMappingURL=ObjectType_focusSparqlWherePatternsFunctionDeclaration.d.ts.map