@shaclmate/compiler 4.0.33 → 4.0.35

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 (213) hide show
  1. package/dist/Compiler.d.ts +0 -3
  2. package/dist/Compiler.js +0 -2
  3. package/dist/ShapesGraphToAstTransformer.d.ts +1 -4
  4. package/dist/ShapesGraphToAstTransformer.js +1 -5
  5. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +1 -3
  6. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompoundType.js +4 -7
  7. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.js +0 -1
  8. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.js +1 -3
  9. package/dist/ast/AbstractCompoundType.d.ts +6 -4
  10. package/dist/ast/AbstractCompoundType.js +4 -37
  11. package/dist/ast/ObjectType.d.ts +1 -7
  12. package/dist/ast/ObjectType.js +1 -6
  13. package/dist/generators/ts/AbstractCollectionType.d.ts +9 -8
  14. package/dist/generators/ts/AbstractCollectionType.js +38 -120
  15. package/dist/generators/ts/AbstractContainerType.d.ts +3 -1
  16. package/dist/generators/ts/AbstractContainerType.js +20 -0
  17. package/dist/generators/ts/AbstractDateType.d.ts +5 -10
  18. package/dist/generators/ts/AbstractDateType.js +5 -32
  19. package/dist/generators/ts/AbstractIdentifierType.d.ts +4 -1
  20. package/dist/generators/ts/AbstractIdentifierType.js +0 -17
  21. package/dist/generators/ts/AbstractLazyObjectType.d.ts +9 -5
  22. package/dist/generators/ts/AbstractLazyObjectType.js +22 -21
  23. package/dist/generators/ts/AbstractLiteralType.d.ts +12 -4
  24. package/dist/generators/ts/AbstractLiteralType.js +3 -3
  25. package/dist/generators/ts/AbstractNamedUnionType.d.ts +2 -5
  26. package/dist/generators/ts/AbstractNamedUnionType.js +27 -58
  27. package/dist/generators/ts/AbstractNumericType.d.ts +3 -9
  28. package/dist/generators/ts/AbstractNumericType.js +6 -13
  29. package/dist/generators/ts/AbstractPrimitiveType.d.ts +9 -4
  30. package/dist/generators/ts/AbstractPrimitiveType.js +11 -18
  31. package/dist/generators/ts/AbstractTermType.d.ts +10 -5
  32. package/dist/generators/ts/AbstractTermType.js +14 -53
  33. package/dist/generators/ts/AbstractType.d.ts +39 -24
  34. package/dist/generators/ts/AbstractType.js +4 -2
  35. package/dist/generators/ts/AbstractUnionType.d.ts +3 -2
  36. package/dist/generators/ts/AbstractUnionType.js +29 -39
  37. package/dist/generators/ts/AnonymousUnionType.d.ts +1 -1
  38. package/dist/generators/ts/AnonymousUnionType.js +3 -3
  39. package/dist/generators/ts/BigDecimalType.d.ts +7 -4
  40. package/dist/generators/ts/BigDecimalType.js +11 -45
  41. package/dist/generators/ts/BigIntType.d.ts +3 -4
  42. package/dist/generators/ts/BigIntType.js +6 -17
  43. package/dist/generators/ts/BlankNodeType.d.ts +8 -7
  44. package/dist/generators/ts/BlankNodeType.js +18 -5
  45. package/dist/generators/ts/BooleanType.d.ts +6 -9
  46. package/dist/generators/ts/BooleanType.js +9 -16
  47. package/dist/generators/ts/DateTimeType.d.ts +4 -1
  48. package/dist/generators/ts/DateTimeType.js +6 -13
  49. package/dist/generators/ts/DateType.d.ts +4 -1
  50. package/dist/generators/ts/DateType.js +7 -14
  51. package/dist/generators/ts/DefaultValueType.d.ts +6 -6
  52. package/dist/generators/ts/DefaultValueType.js +30 -63
  53. package/dist/generators/ts/FloatType.d.ts +3 -3
  54. package/dist/generators/ts/FloatType.js +5 -5
  55. package/dist/generators/ts/IdentifierType.d.ts +7 -6
  56. package/dist/generators/ts/IdentifierType.js +26 -5
  57. package/dist/generators/ts/IntType.d.ts +3 -3
  58. package/dist/generators/ts/IntType.js +5 -5
  59. package/dist/generators/ts/IriType.d.ts +9 -12
  60. package/dist/generators/ts/IriType.js +43 -32
  61. package/dist/generators/ts/LazyObjectOptionType.d.ts +2 -1
  62. package/dist/generators/ts/LazyObjectOptionType.js +23 -44
  63. package/dist/generators/ts/LazyObjectSetType.d.ts +2 -1
  64. package/dist/generators/ts/LazyObjectSetType.js +19 -29
  65. package/dist/generators/ts/LazyObjectType.d.ts +2 -1
  66. package/dist/generators/ts/LazyObjectType.js +18 -26
  67. package/dist/generators/ts/LiteralType.d.ts +6 -3
  68. package/dist/generators/ts/LiteralType.js +27 -13
  69. package/dist/generators/ts/NamedObjectType.d.ts +7 -9
  70. package/dist/generators/ts/NamedObjectType.js +24 -32
  71. package/dist/generators/ts/NamedObjectUnionType.d.ts +3 -1
  72. package/dist/generators/ts/NamedObjectUnionType.js +21 -14
  73. package/dist/generators/ts/OptionType.d.ts +6 -5
  74. package/dist/generators/ts/OptionType.js +31 -51
  75. package/dist/generators/ts/Reusables.d.ts +3 -1
  76. package/dist/generators/ts/Reusables.js +2 -1
  77. package/dist/generators/ts/SetType.d.ts +0 -1
  78. package/dist/generators/ts/SetType.js +4 -22
  79. package/dist/generators/ts/SnippetFactory.d.ts +2 -0
  80. package/dist/generators/ts/Snippets.d.ts +36 -8
  81. package/dist/generators/ts/Snippets.js +207 -30
  82. package/dist/generators/ts/StringType.d.ts +6 -10
  83. package/dist/generators/ts/StringType.js +8 -21
  84. package/dist/generators/ts/TermType.d.ts +2 -4
  85. package/dist/generators/ts/TermType.js +6 -10
  86. package/dist/generators/ts/TsGenerator.d.ts +14 -1
  87. package/dist/generators/ts/TsGenerator.js +41 -12
  88. package/dist/generators/ts/TypeFactory.d.ts +8 -4
  89. package/dist/generators/ts/TypeFactory.js +73 -49
  90. package/dist/generators/ts/ZodGenerator.js +6 -3
  91. package/dist/generators/ts/_NamedObjectType/AbstractProperty.d.ts +27 -20
  92. package/dist/generators/ts/_NamedObjectType/AbstractProperty.js +4 -2
  93. package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.d.ts +7 -7
  94. package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.js +9 -9
  95. package/dist/generators/ts/_NamedObjectType/IdentifierProperty.d.ts +6 -6
  96. package/dist/generators/ts/_NamedObjectType/IdentifierProperty.js +36 -39
  97. package/dist/generators/ts/_NamedObjectType/NamedObjectType_createFunctionDeclaration.js +34 -31
  98. package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.js +1 -1
  99. package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.js +1 -1
  100. package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.js +1 -1
  101. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.js +31 -19
  102. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js +30 -36
  103. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.js +1 -1
  104. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.js +1 -1
  105. package/dist/generators/ts/_NamedObjectType/NamedObjectType_graphqlTypeVariableStatement.js +2 -3
  106. package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.js +6 -8
  107. package/dist/generators/ts/_NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.js +1 -2
  108. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.js +1 -1
  109. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js +1 -1
  110. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.js +1 -1
  111. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.js +1 -1
  112. package/dist/generators/ts/_NamedObjectType/NamedObjectType_objectSetMethodNames.d.ts +2 -0
  113. package/dist/generators/ts/_NamedObjectType/NamedObjectType_objectSetMethodNames.js +1 -1
  114. package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.d.ts +2 -2
  115. package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.js +1 -1
  116. package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts +2 -2
  117. package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js +1 -1
  118. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.js +2 -2
  119. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionDeclaration.js +1 -1
  120. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.js +14 -18
  121. package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.js +1 -1
  122. package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.js +1 -1
  123. package/dist/generators/ts/_NamedObjectType/ShaclProperty.d.ts +7 -7
  124. package/dist/generators/ts/_NamedObjectType/ShaclProperty.js +41 -29
  125. package/dist/generators/ts/_snippets/snippets_ConversionFunction.d.ts +3 -0
  126. package/dist/generators/ts/_snippets/snippets_ConversionFunction.js +4 -0
  127. package/dist/generators/ts/_snippets/snippets_DefaultValueSchema.js +3 -3
  128. package/dist/generators/ts/_snippets/snippets_HashFunction.d.ts +3 -0
  129. package/dist/generators/ts/_snippets/snippets_HashFunction.js +4 -0
  130. package/dist/generators/ts/_snippets/snippets_PropertyPath.js +34 -24
  131. package/dist/generators/ts/_snippets/snippets_ValidationFunction.d.ts +3 -0
  132. package/dist/generators/ts/_snippets/snippets_ValidationFunction.js +4 -0
  133. package/dist/generators/ts/_snippets/snippets_convertToArray.d.ts +3 -0
  134. package/dist/generators/ts/_snippets/snippets_convertToArray.js +8 -0
  135. package/dist/generators/ts/_snippets/snippets_convertToBlankNode.d.ts +3 -0
  136. package/dist/generators/ts/_snippets/snippets_convertToBlankNode.js +11 -0
  137. package/dist/generators/ts/_snippets/snippets_convertToBlankNodeIdentifierProperty.d.ts +3 -0
  138. package/dist/generators/ts/_snippets/snippets_convertToBlankNodeIdentifierProperty.js +17 -0
  139. package/dist/generators/ts/_snippets/snippets_convertToIdentifier.d.ts +3 -0
  140. package/dist/generators/ts/_snippets/snippets_convertToIdentifier.js +13 -0
  141. package/dist/generators/ts/_snippets/snippets_convertToIdentifierProperty.d.ts +3 -0
  142. package/dist/generators/ts/_snippets/snippets_convertToIdentifierProperty.js +21 -0
  143. package/dist/generators/ts/_snippets/snippets_convertToIri.d.ts +3 -0
  144. package/dist/generators/ts/_snippets/snippets_convertToIri.js +11 -0
  145. package/dist/generators/ts/_snippets/snippets_convertToIriIdentifierProperty.d.ts +3 -0
  146. package/dist/generators/ts/_snippets/snippets_convertToIriIdentifierProperty.js +17 -0
  147. package/dist/generators/ts/_snippets/snippets_convertToLazyObject.d.ts +3 -0
  148. package/dist/generators/ts/_snippets/snippets_convertToLazyObject.js +15 -0
  149. package/dist/generators/ts/_snippets/snippets_convertToLazyObjectOption.d.ts +3 -0
  150. package/dist/generators/ts/_snippets/snippets_convertToLazyObjectOption.js +31 -0
  151. package/dist/generators/ts/_snippets/snippets_convertToLazyObjectSet.d.ts +3 -0
  152. package/dist/generators/ts/_snippets/snippets_convertToLazyObjectSet.js +25 -0
  153. package/dist/generators/ts/_snippets/snippets_convertToLiteral.d.ts +3 -0
  154. package/dist/generators/ts/_snippets/snippets_convertToLiteral.js +13 -0
  155. package/dist/generators/ts/_snippets/snippets_convertToMaybe.d.ts +3 -0
  156. package/dist/generators/ts/_snippets/snippets_convertToMaybe.js +19 -0
  157. package/dist/generators/ts/_snippets/snippets_convertWithDefaultValue.d.ts +3 -0
  158. package/dist/generators/ts/_snippets/snippets_convertWithDefaultValue.js +11 -0
  159. package/dist/generators/ts/_snippets/snippets_defaultValueSparqlWherePatterns.js +1 -1
  160. package/dist/generators/ts/_snippets/snippets_hashArray.d.ts +3 -0
  161. package/dist/generators/ts/_snippets/snippets_hashArray.js +11 -0
  162. package/dist/generators/ts/_snippets/snippets_hashBigDecimal.d.ts +3 -0
  163. package/dist/generators/ts/_snippets/snippets_hashBigDecimal.js +7 -0
  164. package/dist/generators/ts/_snippets/snippets_hashBoolean.d.ts +3 -0
  165. package/dist/generators/ts/_snippets/snippets_hashBoolean.js +7 -0
  166. package/dist/generators/ts/_snippets/snippets_hashDate.d.ts +3 -0
  167. package/dist/generators/ts/_snippets/snippets_hashDate.js +7 -0
  168. package/dist/generators/ts/_snippets/snippets_hashDateTime.d.ts +3 -0
  169. package/dist/generators/ts/_snippets/snippets_hashDateTime.js +7 -0
  170. package/dist/generators/ts/_snippets/snippets_hashMaybe.d.ts +3 -0
  171. package/dist/generators/ts/_snippets/snippets_hashMaybe.js +11 -0
  172. package/dist/generators/ts/_snippets/snippets_hashNumeric.d.ts +3 -0
  173. package/dist/generators/ts/_snippets/snippets_hashNumeric.js +7 -0
  174. package/dist/generators/ts/_snippets/snippets_hashString.d.ts +3 -0
  175. package/dist/generators/ts/_snippets/snippets_hashString.js +7 -0
  176. package/dist/generators/ts/_snippets/snippets_hashTerm.d.ts +3 -0
  177. package/dist/generators/ts/_snippets/snippets_hashTerm.js +12 -0
  178. package/dist/generators/ts/_snippets/snippets_identityConversionFunction.d.ts +3 -0
  179. package/dist/generators/ts/_snippets/snippets_identityConversionFunction.js +6 -0
  180. package/dist/generators/ts/_snippets/snippets_identityValidationFunction.d.ts +3 -0
  181. package/dist/generators/ts/_snippets/snippets_identityValidationFunction.js +6 -0
  182. package/dist/generators/ts/_snippets/snippets_toIsoDateString.d.ts +3 -0
  183. package/dist/generators/ts/_snippets/snippets_toIsoDateString.js +6 -0
  184. package/dist/generators/ts/_snippets/snippets_validateArray.d.ts +3 -0
  185. package/dist/generators/ts/_snippets/snippets_validateArray.js +13 -0
  186. package/dist/generators/ts/_snippets/snippets_validateMaybe.d.ts +3 -0
  187. package/dist/generators/ts/_snippets/snippets_validateMaybe.js +7 -0
  188. package/dist/generators/ts/graphqlSchemaVariableStatement.d.ts +1 -1
  189. package/dist/generators/ts/graphqlSchemaVariableStatement.js +7 -4
  190. package/dist/generators/ts/objectSetDeclarations.js +4 -34
  191. package/dist/generators/ts/objectSetInterfaceDeclaration.js +1 -1
  192. package/dist/generators/ts/objectSetMethodSignatures.js +2 -2
  193. package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.js +2 -2
  194. package/dist/generators/ts/sparqlObjectSetClassDeclaration.js +2 -2
  195. package/dist/input/ShapesGraph.d.ts +5 -8
  196. package/dist/input/ShapesGraph.js +5 -6
  197. package/dist/input/generated.d.ts +175 -230
  198. package/dist/input/generated.js +226 -1748
  199. package/package.json +2 -2
  200. package/dist/_ShapesGraphToAstTransformer/nodeShapeTsFeatures.d.ts +0 -6
  201. package/dist/_ShapesGraphToAstTransformer/nodeShapeTsFeatures.js +0 -67
  202. package/dist/generators/ts/_snippets/snippets_isReadonlyBigIntArray.d.ts +0 -3
  203. package/dist/generators/ts/_snippets/snippets_isReadonlyBigIntArray.js +0 -6
  204. package/dist/generators/ts/_snippets/snippets_isReadonlyBooleanArray.d.ts +0 -3
  205. package/dist/generators/ts/_snippets/snippets_isReadonlyBooleanArray.js +0 -6
  206. package/dist/generators/ts/_snippets/snippets_isReadonlyNumberArray.d.ts +0 -3
  207. package/dist/generators/ts/_snippets/snippets_isReadonlyNumberArray.js +0 -6
  208. package/dist/generators/ts/_snippets/snippets_isReadonlyObjectArray.d.ts +0 -3
  209. package/dist/generators/ts/_snippets/snippets_isReadonlyObjectArray.js +0 -6
  210. package/dist/generators/ts/_snippets/snippets_isReadonlyStringArray.d.ts +0 -3
  211. package/dist/generators/ts/_snippets/snippets_isReadonlyStringArray.js +0 -6
  212. package/dist/generators/ts/syntheticNamePrefix.d.ts +0 -2
  213. package/dist/generators/ts/syntheticNamePrefix.js +0 -2
@@ -2,7 +2,7 @@ import { Maybe } from "purify-ts";
2
2
  import { type Code } from "../ts-poet-wrapper.js";
3
3
  import { AbstractProperty } from "./AbstractProperty.js";
4
4
  export declare class DiscriminantProperty extends AbstractProperty<DiscriminantProperty.Type> {
5
- readonly constructorParametersSignature: Maybe<Code>;
5
+ readonly constructorParameter: Maybe<Code>;
6
6
  readonly filterProperty: AbstractProperty<DiscriminantProperty.Type>["filterProperty"];
7
7
  readonly graphqlField: AbstractProperty<DiscriminantProperty.Type>["graphqlField"];
8
8
  readonly kind = "DiscriminantProperty";
@@ -15,17 +15,17 @@ export declare class DiscriminantProperty extends AbstractProperty<DiscriminantP
15
15
  get jsonName(): string;
16
16
  get jsonSchema(): AbstractProperty<DiscriminantProperty.Type>["jsonSchema"];
17
17
  get jsonSignature(): Maybe<Code>;
18
- private get initializer();
19
- constructorStatements(): readonly Code[];
20
- fromJsonExpression(): Maybe<Code>;
21
- fromRdfResourceValuesExpression(): Maybe<Code>;
18
+ private get constValue();
19
+ constructorInitializer(): Maybe<Code>;
20
+ fromJsonInitializer(): Maybe<Code>;
21
+ fromRdfResourceValuesInitializer(): Maybe<Code>;
22
22
  hashStatements({ variables, }: Parameters<AbstractProperty<DiscriminantProperty.Type>["hashStatements"]>[0]): readonly Code[];
23
23
  jsonUiSchemaElement({ variables, }: Parameters<AbstractProperty<DiscriminantProperty.Type>["jsonUiSchemaElement"]>[0]): Maybe<Code>;
24
24
  sparqlConstructTriplesExpression(): Maybe<Code>;
25
25
  sparqlWherePatternsExpression(): ReturnType<AbstractProperty<DiscriminantProperty.Type>["sparqlWherePatternsExpression"]>;
26
- toJsonObjectMemberExpression({ variables, }: Parameters<AbstractProperty<DiscriminantProperty.Type>["toJsonObjectMemberExpression"]>[0]): Maybe<Code>;
26
+ toJsonInitializer({ variables, }: Parameters<AbstractProperty<DiscriminantProperty.Type>["toJsonInitializer"]>[0]): Maybe<Code>;
27
27
  toRdfRdfResourceValuesStatements(): readonly Code[];
28
- toStringExpression(): Maybe<Code>;
28
+ toStringInitializer(): Maybe<Code>;
29
29
  }
30
30
  export declare namespace DiscriminantProperty {
31
31
  class Type {
@@ -10,7 +10,7 @@ import { removeUndefined } from "../removeUndefined.js";
10
10
  import { arrayOf, code, literalOf } from "../ts-poet-wrapper.js";
11
11
  import { AbstractProperty } from "./AbstractProperty.js";
12
12
  export class DiscriminantProperty extends AbstractProperty {
13
- constructorParametersSignature = Maybe.empty();
13
+ constructorParameter = Maybe.empty();
14
14
  filterProperty = Maybe.empty();
15
15
  graphqlField = Maybe.empty();
16
16
  kind = "DiscriminantProperty";
@@ -36,16 +36,16 @@ export class DiscriminantProperty extends AbstractProperty {
36
36
  get jsonSignature() {
37
37
  return Maybe.of(code `readonly "${this.jsonName}": ${this.type.name}`);
38
38
  }
39
- get initializer() {
39
+ get constValue() {
40
40
  return code `${literalOf(this.namedObjectType.discriminantValue)} as const`;
41
41
  }
42
- constructorStatements() {
43
- return [code `const ${this.name} = ${this.initializer};`];
42
+ constructorInitializer() {
43
+ return Maybe.empty();
44
44
  }
45
- fromJsonExpression() {
45
+ fromJsonInitializer() {
46
46
  return Maybe.empty();
47
47
  }
48
- fromRdfResourceValuesExpression() {
48
+ fromRdfResourceValuesInitializer() {
49
49
  return Maybe.empty();
50
50
  }
51
51
  hashStatements({ variables, }) {
@@ -59,7 +59,7 @@ export class DiscriminantProperty extends AbstractProperty {
59
59
  return Maybe.empty();
60
60
  }
61
61
  const scope = code `\`\${${variables.scopePrefix}}/properties/${this.jsonName}\``;
62
- return Maybe.of(code `{ rule: { condition: { schema: { const: ${this.initializer} }, scope: ${scope} }, effect: "HIDE" }, scope: ${scope}, type: "Control" }`);
62
+ return Maybe.of(code `{ rule: { condition: { schema: { const: ${this.constValue} }, scope: ${scope} }, effect: "HIDE" }, scope: ${scope}, type: "Control" }`);
63
63
  }
64
64
  sparqlConstructTriplesExpression() {
65
65
  return Maybe.empty();
@@ -67,13 +67,13 @@ export class DiscriminantProperty extends AbstractProperty {
67
67
  sparqlWherePatternsExpression() {
68
68
  return Maybe.empty();
69
69
  }
70
- toJsonObjectMemberExpression({ variables, }) {
70
+ toJsonInitializer({ variables, }) {
71
71
  return Maybe.of(code `"${this.jsonName}": ${variables.value}`);
72
72
  }
73
73
  toRdfRdfResourceValuesStatements() {
74
74
  return [];
75
75
  }
76
- toStringExpression() {
76
+ toStringInitializer() {
77
77
  return Maybe.empty();
78
78
  }
79
79
  }
@@ -13,7 +13,7 @@ export declare class IdentifierProperty extends AbstractProperty<BlankNodeType |
13
13
  type: BlankNodeType | IdentifierType | IriType;
14
14
  typeAlias: Code;
15
15
  } & ConstructorParameters<typeof AbstractProperty>[0]);
16
- get constructorParametersSignature(): Maybe<Code>;
16
+ get constructorParameter(): Maybe<Code>;
17
17
  get declaration(): Code;
18
18
  get filterProperty(): Maybe<{
19
19
  name: string;
@@ -23,9 +23,9 @@ export declare class IdentifierProperty extends AbstractProperty<BlankNodeType |
23
23
  get jsonSchema(): AbstractProperty<IdentifierType>["jsonSchema"];
24
24
  get jsonSignature(): Maybe<Code>;
25
25
  accessExpression({ variables, }: Parameters<AbstractProperty<BlankNodeType | IdentifierType | IriType>["accessExpression"]>[0]): Code;
26
- constructorStatements({ variables, }: Parameters<AbstractProperty<IdentifierType>["constructorStatements"]>[0]): readonly Code[];
27
- fromJsonExpression({ variables, }: Parameters<AbstractProperty<IdentifierType>["fromJsonExpression"]>[0]): Maybe<Code>;
28
- fromRdfResourceValuesExpression({ variables, }: Parameters<AbstractProperty<IdentifierType>["fromRdfResourceValuesExpression"]>[0]): Maybe<Code>;
26
+ constructorInitializer({ variables, }: Parameters<AbstractProperty<IdentifierType>["constructorInitializer"]>[0]): Maybe<Code>;
27
+ fromJsonInitializer({ variables, }: Parameters<AbstractProperty<IdentifierType>["fromJsonInitializer"]>[0]): Maybe<Code>;
28
+ fromRdfResourceValuesInitializer({ variables, }: Parameters<AbstractProperty<IdentifierType>["fromRdfResourceValuesInitializer"]>[0]): Maybe<Code>;
29
29
  hashStatements({ variables, }: Parameters<AbstractProperty<IdentifierType>["hashStatements"]>[0]): readonly Code[];
30
30
  jsonUiSchemaElement({ variables, }: Parameters<AbstractProperty<IdentifierType>["jsonUiSchemaElement"]>[0]): Maybe<Code>;
31
31
  sparqlConstructTriplesExpression(): Maybe<Code>;
@@ -33,8 +33,8 @@ export declare class IdentifierProperty extends AbstractProperty<BlankNodeType |
33
33
  condition: Code;
34
34
  patterns: Code;
35
35
  }>;
36
- toJsonObjectMemberExpression({ variables, }: Parameters<AbstractProperty<IdentifierType>["toJsonObjectMemberExpression"]>[0]): Maybe<Code>;
36
+ toJsonInitializer({ variables, }: Parameters<AbstractProperty<IdentifierType>["toJsonInitializer"]>[0]): Maybe<Code>;
37
37
  toRdfRdfResourceValuesStatements(): readonly Code[];
38
- toStringExpression(parameters: Parameters<AbstractProperty<IdentifierType>["toStringExpression"]>[0]): Maybe<Code>;
38
+ toStringInitializer(parameters: Parameters<AbstractProperty<IdentifierType>["toStringInitializer"]>[0]): Maybe<Code>;
39
39
  }
40
40
  //# sourceMappingURL=IdentifierProperty.d.ts.map
@@ -9,9 +9,7 @@ import { rdf } from "@tpluscode/rdf-ns-builders";
9
9
  import { Maybe } from "purify-ts";
10
10
  import { invariant } from "ts-invariant";
11
11
  import { Memoize } from "typescript-memoize";
12
- import { codeEquals } from "../codeEquals.js";
13
- import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
14
- import { arrayOf, code, joinCode } from "../ts-poet-wrapper.js";
12
+ import { arrayOf, code, joinCode, literalOf, } from "../ts-poet-wrapper.js";
15
13
  import { AbstractProperty } from "./AbstractProperty.js";
16
14
  export class IdentifierProperty extends AbstractProperty {
17
15
  typeAlias;
@@ -22,13 +20,16 @@ export class IdentifierProperty extends AbstractProperty {
22
20
  super(superParameters);
23
21
  this.typeAlias = typeAlias;
24
22
  }
25
- get constructorParametersSignature() {
26
- const hasQuestionToken = this.type.nodeKinds.has("BlankNode");
23
+ get constructorParameter() {
24
+ let hasQuestionToken = false;
27
25
  const typeNames = [code `(() => ${this.typeAlias})`];
28
- for (const conversion of this.type.conversions) {
29
- if (conversion.sourceTypeof !== "undefined" &&
30
- !typeNames.some((typeName) => codeEquals(typeName, conversion.sourceTypeName))) {
31
- typeNames.push(code `${conversion.sourceTypeName}`);
26
+ for (const type of this.type.conversionFunction.unsafeCoerce()
27
+ .sourceTypes) {
28
+ if (type.typeof === "undefined") {
29
+ hasQuestionToken = true;
30
+ }
31
+ else {
32
+ typeNames.push(code `${type.name}`);
32
33
  }
33
34
  }
34
35
  return Maybe.of(code `readonly ${this.name}${hasQuestionToken ? "?" : ""}: ${joinCode(typeNames, { on: "|" })};`);
@@ -43,6 +44,7 @@ export class IdentifierProperty extends AbstractProperty {
43
44
  });
44
45
  }
45
46
  get graphqlField() {
47
+ const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
46
48
  invariant(this.name.startsWith(syntheticNamePrefix));
47
49
  return Maybe.of({
48
50
  args: Maybe.empty(),
@@ -76,37 +78,32 @@ export class IdentifierProperty extends AbstractProperty {
76
78
  accessExpression({ variables, }) {
77
79
  return code `${variables.object}.${this.name}()`;
78
80
  }
79
- constructorStatements({ variables, }) {
80
- const parameterVariable = code `${this.name}Parameter`;
81
- const statements = [
82
- // Pull out the parameter so the function can capture it if necessary.
83
- code `const ${parameterVariable} = ${variables.parameter};`,
84
- code `let ${this.name}: () => ${this.typeAlias};`,
85
- ];
86
- const typeConversions = this.type.conversions;
87
- const conversionBranches = [
88
- code `if (typeof ${parameterVariable} === "function") { ${this.name} = ${parameterVariable}; }`,
89
- ];
90
- for (const conversion of typeConversions) {
91
- invariant(conversion.sourceTypeof !== "function");
92
- invariant(conversion.sourceTypeof !== "undefined");
93
- conversionBranches.push(code `if (${conversion.sourceTypeCheckExpression(parameterVariable)}) { ${this.name} = () => ${conversion.conversionExpression(parameterVariable)}; }`);
81
+ constructorInitializer({ variables, }) {
82
+ const nodeKinds = this.type.nodeKinds;
83
+ let conversionFunction;
84
+ if (nodeKinds.size === 2) {
85
+ conversionFunction = code `${this.reusables.snippets.convertToIdentifierProperty}`;
94
86
  }
95
- if (this.type.nodeKinds.has("BlankNode")) {
96
- conversionBranches.push(code `if (${parameterVariable} === undefined) { const ${syntheticNamePrefix}eagerIdentifier = ${this.reusables.imports.dataFactory}.blankNode(); ${this.name} = () => ${syntheticNamePrefix}eagerIdentifier; }`);
87
+ else {
88
+ invariant(nodeKinds.size === 1);
89
+ if (nodeKinds.has("BlankNode")) {
90
+ conversionFunction = code `${this.reusables.snippets.convertToBlankNodeIdentifierProperty}`;
91
+ }
92
+ else {
93
+ conversionFunction = code `${this.reusables.snippets.convertToIriIdentifierProperty}<${this.type.in_.length > 0
94
+ ? joinCode(this.type.in_.map((in_) => code `${literalOf(in_.value)}`), { on: " | " })
95
+ : "string"}>`;
96
+ }
97
97
  }
98
- // We shouldn't need this else, since the parameter now has the never type, but have to add it to appease the TypeScript compiler
99
- conversionBranches.push(code `{ ${this.name} = (${parameterVariable}) satisfies never;\n }`);
100
- statements.push(joinCode(conversionBranches, { on: " else " }));
101
- return statements;
98
+ return Maybe.of(code `${this.name}: ${conversionFunction}(${variables.parameters}.${this.name})`);
102
99
  }
103
- fromJsonExpression({ variables, }) {
104
- return Maybe.of(this.type.fromJsonExpression({
100
+ fromJsonInitializer({ variables, }) {
101
+ return Maybe.of(code `${this.name}: ${this.type.fromJsonExpression({
105
102
  variables: { value: variables.jsonObject },
106
- }));
103
+ })}`);
107
104
  }
108
- fromRdfResourceValuesExpression({ variables, }) {
109
- return Maybe.of(code `${this.type.fromRdfResourceValuesExpression({
105
+ fromRdfResourceValuesInitializer({ variables, }) {
106
+ return Maybe.of(code `${this.name}: ${this.type.fromRdfResourceValuesExpression({
110
107
  variables: {
111
108
  ...variables,
112
109
  propertyPath: this.rdfjsTermExpression(rdf.subject),
@@ -137,7 +134,7 @@ export class IdentifierProperty extends AbstractProperty {
137
134
  }})`,
138
135
  });
139
136
  }
140
- toJsonObjectMemberExpression({ variables, }) {
137
+ toJsonInitializer({ variables, }) {
141
138
  const nodeKinds = [...this.type.nodeKinds];
142
139
  const valueToNodeKinds = nodeKinds.map((nodeKind) => {
143
140
  switch (nodeKind) {
@@ -158,13 +155,13 @@ export class IdentifierProperty extends AbstractProperty {
158
155
  toRdfRdfResourceValuesStatements() {
159
156
  return [];
160
157
  }
161
- toStringExpression(parameters) {
162
- return Maybe.of(this.type.toStringExpression(parameters));
158
+ toStringInitializer(parameters) {
159
+ return Maybe.of(code `${literalOf(this.name)}: ${this.type.toStringExpression(parameters)}`);
163
160
  }
164
161
  }
165
162
  __decorate([
166
163
  Memoize()
167
- ], IdentifierProperty.prototype, "constructorParametersSignature", null);
164
+ ], IdentifierProperty.prototype, "constructorParameter", null);
168
165
  __decorate([
169
166
  Memoize()
170
167
  ], IdentifierProperty.prototype, "declaration", null);
@@ -1,12 +1,11 @@
1
1
  import { Maybe } from "purify-ts";
2
2
  import { invariant } from "ts-invariant";
3
- import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
4
- import { code, joinCode } from "../ts-poet-wrapper.js";
3
+ import { code, joinCode, literalOf } from "../ts-poet-wrapper.js";
5
4
  export function NamedObjectType_createFunctionDeclaration() {
6
- if (!this.features.has("create")) {
5
+ if (!this.configuration.features.has("create")) {
7
6
  return Maybe.empty();
8
7
  }
9
- const parametersPropertySignatures = this.properties.flatMap((property) => property.constructorParametersSignature.toList());
8
+ const parametersPropertySignatures = this.properties.flatMap((property) => property.constructorParameter.toList());
10
9
  const parametersType = [];
11
10
  if (parametersPropertySignatures.length > 0) {
12
11
  parametersType.push(code `{ ${joinCode(parametersPropertySignatures)} }`);
@@ -17,40 +16,44 @@ export function NamedObjectType_createFunctionDeclaration() {
17
16
  if (parametersType.length === 0) {
18
17
  parametersType.push(code `object`);
19
18
  }
20
- const propertyInitializers = [];
21
- const omitPropertyNames = [];
22
- const propertyStatements = [];
23
- for (const parentObjectType of this.parentObjectTypes) {
24
- propertyInitializers.push(`...${parentObjectType.name}.create(parameters)`);
25
- }
26
19
  const parametersHasQuestionToken = this.parentObjectTypes.length === 0 &&
27
20
  parametersPropertySignatures.every((propertySignature) => propertySignature.toCodeString([]).indexOf("?:") !== -1);
28
21
  const parametersVariable = code `parameters${parametersHasQuestionToken ? "?" : ""}`;
29
- for (const property of this.properties) {
30
- const thisPropertyStatements = property.constructorStatements({
31
- variables: {
32
- parameter: code `${parametersVariable}.${property.name}`,
33
- parameters: parametersVariable,
34
- },
22
+ const parametersSignature = code `parameters${parametersHasQuestionToken ? "?" : ""}: ${joinCode(parametersType, { on: " & " })}`;
23
+ const chains = [];
24
+ this.parentObjectTypes.forEach((parentObjectType, parentObjectTypeI) => {
25
+ chains.push({
26
+ expression: code `${parentObjectType.name}.create(parameters)`,
27
+ variable: `super${parentObjectTypeI}`,
35
28
  });
36
- if (thisPropertyStatements.length > 0) {
37
- propertyInitializers.push(property.name);
38
- propertyStatements.push(...thisPropertyStatements);
39
- }
40
- else {
41
- omitPropertyNames.push(property.name);
42
- }
43
- }
29
+ });
30
+ const propertyInitializers = this.properties.flatMap((property) => property
31
+ .constructorInitializer({
32
+ variables: { parameters: parametersVariable },
33
+ })
34
+ .toList());
44
35
  invariant(propertyInitializers.length > 0);
45
- invariant(propertyStatements.length > 0);
36
+ chains.push({
37
+ expression: code `${this.reusables.snippets.sequenceRecord}({ ${joinCode(propertyInitializers, { on: "," })} })`,
38
+ variable: "properties",
39
+ });
40
+ const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
46
41
  return Maybe.of(code `\
47
- export function create(parameters${parametersHasQuestionToken ? "?" : ""}: ${joinCode(parametersType, { on: " & " })}): ${omitPropertyNames.length === 0 ? this.name : `Omit<${this.name}, ${omitPropertyNames.map((omitPropertyName) => `"${omitPropertyName}"`).join(" | ")}>`} {
48
- ${joinCode(propertyStatements)}
49
- const ${syntheticNamePrefix}object = { ${propertyInitializers.join(", ")} };
50
- if (!globalThis.Object.prototype.hasOwnProperty.call(${syntheticNamePrefix}object, "toString")) {
51
- (${syntheticNamePrefix}object as any).toString = ${syntheticNamePrefix}toString;
42
+ export function create(${parametersSignature}): ${this.reusables.imports.Either}<Error, ${this.name}> {
43
+ return ${chains.toReversed().reduce((acc, { expression, variable }, chainI) => code `(${expression}).${chainI === 0 ? "map" : "chain"}(${variable} => ${acc})`, code `\
44
+ {
45
+ const finalObject = { ${chains
46
+ .map((chain) => `...${chain.variable}`)
47
+ .join(", ")}, ${this._discriminantProperty.name}: ${literalOf(this.discriminantValue)} as const };
48
+ if (!globalThis.Object.prototype.hasOwnProperty.call(finalObject, "toString")) {
49
+ (finalObject as any).toString = ${syntheticNamePrefix}toString;
52
50
  }
53
- return ${syntheticNamePrefix}object;
51
+ return finalObject;
52
+ }`)};
53
+ }
54
+
55
+ export function createUnsafe(${parametersSignature}): ${this.name} {
56
+ return create(parameters).unsafeCoerce();
54
57
  }`);
55
58
  }
56
59
  //# sourceMappingURL=NamedObjectType_createFunctionDeclaration.js.map
@@ -1,7 +1,7 @@
1
1
  import { Maybe } from "purify-ts";
2
2
  import { code, joinCode } from "../ts-poet-wrapper.js";
3
3
  export function NamedObjectType_equalsFunctionDeclaration() {
4
- if (!this.features.has("equals")) {
4
+ if (!this.configuration.features.has("equals")) {
5
5
  return Maybe.empty();
6
6
  }
7
7
  const chain = [];
@@ -7,7 +7,7 @@ const variables = {
7
7
  variablePrefix: code `parameters.variablePrefix`,
8
8
  };
9
9
  export function NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration() {
10
- if (!this.features.has("sparql")) {
10
+ if (!this.configuration.features.has("sparql")) {
11
11
  return Maybe.empty();
12
12
  }
13
13
  const rdfClassVariable = code `${this.reusables.imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}RdfClass\`)`;
@@ -8,7 +8,7 @@ const variables = {
8
8
  variablePrefix: code `parameters.variablePrefix`,
9
9
  };
10
10
  export function NamedObjectType_focusSparqlWherePatternsFunctionDeclaration() {
11
- if (!this.features.has("sparql")) {
11
+ if (!this.configuration.features.has("sparql")) {
12
12
  return Maybe.empty();
13
13
  }
14
14
  const rdfClassVariable = code `${this.reusables.imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}RdfClass\`)`;
@@ -1,31 +1,43 @@
1
1
  import { Maybe } from "purify-ts";
2
- import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
3
2
  import { code, joinCode } from "../ts-poet-wrapper.js";
4
- const variables = {
5
- jsonObject: code `${syntheticNamePrefix}json`,
6
- };
7
3
  export function NamedObjectType_fromJsonFunctionDeclaration() {
8
- if (!this.features.has("json")) {
4
+ if (!this.configuration.features.has("json")) {
9
5
  return Maybe.empty();
10
6
  }
11
- const initializers = [];
12
- const statements = [];
13
- this.parentObjectTypes.forEach((parentObjectType) => {
14
- initializers.push(code `...${parentObjectType.name}.fromJson(${variables.jsonObject})`);
7
+ const variables = {
8
+ jsonObject: code `${this.configuration.syntheticNamePrefix}json`,
9
+ };
10
+ const chains = [];
11
+ this.parentObjectTypes.forEach((parentObjectType, parentObjectTypeI) => {
12
+ chains.push({
13
+ expression: code `${parentObjectType.name}.fromJson(${variables.jsonObject})`,
14
+ variable: `super${parentObjectTypeI}`,
15
+ });
15
16
  });
16
- for (const property of this.properties) {
17
- property
18
- .fromJsonExpression({
19
- variables,
20
- })
21
- .ifJust((propertyFromJsonExpression) => {
22
- initializers.push(code `${property.name}: ${propertyFromJsonExpression}`);
17
+ const propertyInitializers = this.properties.flatMap((property) => property.fromJsonInitializer({ variables }).toList());
18
+ if (propertyInitializers.length > 0) {
19
+ chains.push({
20
+ expression: code `${this.reusables.snippets.sequenceRecord}({ ${joinCode(propertyInitializers, { on: "," })} })`,
21
+ variable: "properties",
23
22
  });
24
23
  }
25
- statements.push(code `return create({ ${joinCode(initializers, { on: ", " })} });`);
24
+ let returnExpression;
25
+ switch (chains.length) {
26
+ case 0:
27
+ returnExpression = code `create({})`;
28
+ break;
29
+ case 1:
30
+ returnExpression = code `(${chains[0].expression}).chain(create)`;
31
+ break;
32
+ default:
33
+ returnExpression = code `${chains
34
+ .reverse()
35
+ .reduce((acc, { expression, variable }) => code `(${expression}).chain(${variable} => ${acc})`, code `(create({ ${chains.map((chain) => `...${chain.variable}`).join(", ")} }))`)}`;
36
+ break;
37
+ }
26
38
  return Maybe.of(code `\
27
- export function fromJson(${variables.jsonObject}: ${this.jsonType().name}): ${this.name} {
28
- ${joinCode(statements, { on: "\n" })}
39
+ export function fromJson(${variables.jsonObject}: ${this.jsonType().name}): ${this.reusables.imports.Either}<Error, ${this.name}> {
40
+ return ${returnExpression};
29
41
  }`);
30
42
  }
31
43
  //# sourceMappingURL=NamedObjectType_fromJsonFunctionDeclaration.js.map
@@ -1,27 +1,27 @@
1
1
  import { rdf } from "@tpluscode/rdf-ns-builders";
2
2
  import { Maybe } from "purify-ts";
3
- import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
4
3
  import { code, joinCode } from "../ts-poet-wrapper.js";
5
- const optionsVariable = `_${syntheticNamePrefix}options`;
6
- const variables = {
7
- context: code `${optionsVariable}.context`,
8
- graph: code `${optionsVariable}.graph`,
9
- ignoreRdfType: code `${optionsVariable}.ignoreRdfType`,
10
- objectSet: code `${optionsVariable}.objectSet`,
11
- preferredLanguages: code `${optionsVariable}.preferredLanguages`,
12
- resource: code `${syntheticNamePrefix}resource`,
13
- };
14
- const propertyFromRdfResourceValuesExpressionVariable = {
15
- context: variables.context,
16
- graph: variables.graph,
17
- objectSet: variables.objectSet,
18
- preferredLanguages: variables.preferredLanguages,
19
- resource: variables.resource,
20
- };
21
4
  export function NamedObjectType_fromRdfResourceFunctionDeclaration() {
22
- if (!this.features.has("rdf")) {
5
+ if (!this.configuration.features.has("rdf")) {
23
6
  return Maybe.empty();
24
7
  }
8
+ const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
9
+ const optionsVariable = `_${syntheticNamePrefix}options`;
10
+ const variables = {
11
+ context: code `${optionsVariable}.context`,
12
+ graph: code `${optionsVariable}.graph`,
13
+ ignoreRdfType: code `${optionsVariable}.ignoreRdfType`,
14
+ objectSet: code `${optionsVariable}.objectSet`,
15
+ preferredLanguages: code `${optionsVariable}.preferredLanguages`,
16
+ resource: code `${syntheticNamePrefix}resource`,
17
+ };
18
+ const propertyFromRdfResourceValuesExpressionVariable = {
19
+ context: variables.context,
20
+ graph: variables.graph,
21
+ objectSet: variables.objectSet,
22
+ preferredLanguages: variables.preferredLanguages,
23
+ resource: variables.resource,
24
+ };
25
25
  const chains = [];
26
26
  const partials = [];
27
27
  this.parentObjectTypes.forEach((parentObjectType, parentObjectTypeI) => {
@@ -60,20 +60,14 @@ export function NamedObjectType_fromRdfResourceFunctionDeclaration() {
60
60
  variable: `_rdfTypeCheck`,
61
61
  });
62
62
  });
63
- const propertyFromRdfResourceValuesExpressions = {};
64
- for (const property of this.properties) {
65
- property
66
- .fromRdfResourceValuesExpression({
67
- variables: propertyFromRdfResourceValuesExpressionVariable,
68
- })
69
- .ifJust((propertyFromRdfResourceValuesExpression) => {
70
- propertyFromRdfResourceValuesExpressions[property.name] =
71
- propertyFromRdfResourceValuesExpression;
72
- });
73
- }
74
- if (Object.keys(propertyFromRdfResourceValuesExpressions).length > 0) {
63
+ const propertyFromRdfResourceValuesInitializers = this.properties.flatMap((property) => property
64
+ .fromRdfResourceValuesInitializer({
65
+ variables: propertyFromRdfResourceValuesExpressionVariable,
66
+ })
67
+ .toList());
68
+ if (Object.keys(propertyFromRdfResourceValuesInitializers).length > 0) {
75
69
  chains.push({
76
- expression: code `${this.reusables.snippets.sequenceRecord}(${propertyFromRdfResourceValuesExpressions})`,
70
+ expression: code `${this.reusables.snippets.sequenceRecord}({ ${joinCode(propertyFromRdfResourceValuesInitializers, { on: ", " })} })`,
77
71
  variable: "properties",
78
72
  });
79
73
  partials.push("properties");
@@ -90,19 +84,19 @@ export function NamedObjectType_fromRdfResourceFunctionDeclaration() {
90
84
  partialsJoined = code `{ ${partials.map((partial) => `...${partial}`).join(", ")} }`;
91
85
  break;
92
86
  }
93
- const statements = [];
87
+ let returnExpression;
94
88
  const resultExpression = code `create(${partialsJoined})`;
95
89
  if (chains.length === 0) {
96
- statements.push(code `return ${this.reusables.imports.Right}(${resultExpression});`);
90
+ returnExpression = code `${this.reusables.imports.Right}(${resultExpression})`;
97
91
  }
98
92
  else {
99
- statements.push(code `return ${chains
93
+ returnExpression = code `${chains
100
94
  .reverse()
101
- .reduce((acc, { expression, variable }, chainI) => code `(${expression}).${chainI === 0 ? "map" : "chain"}(${variable} => ${acc})`, code `(${resultExpression})`)}`);
95
+ .reduce((acc, { expression, variable }) => code `(${expression}).chain(${variable} => ${acc})`, code `(${resultExpression})`)}`;
102
96
  }
103
97
  return Maybe.of(code `\
104
98
  export const _fromRdfResource: ${this.reusables.snippets._FromRdfResourceFunction}<${this.name}> = (${variables.resource}, ${optionsVariable}) => {
105
- ${joinCode(statements)}
99
+ return ${returnExpression};
106
100
  }
107
101
 
108
102
  export const fromRdfResource = ${this.reusables.snippets.wrap_FromRdfResourceFunction}(_fromRdfResource);`);
@@ -1,7 +1,7 @@
1
1
  import { Maybe } from "purify-ts";
2
2
  import { code } from "../ts-poet-wrapper.js";
3
3
  export function NamedObjectType_fromRdfResourceValuesFunctionDeclaration() {
4
- if (!this.features.has("rdf")) {
4
+ if (!this.configuration.features.has("rdf")) {
5
5
  return Maybe.empty();
6
6
  }
7
7
  return Maybe.of(code `\
@@ -1,7 +1,7 @@
1
1
  import { Maybe } from "purify-ts";
2
2
  import { code } from "../ts-poet-wrapper.js";
3
3
  export function NamedObjectType_fromRdfTypeVariableStatement() {
4
- if (!this.features.has("rdf")) {
4
+ if (!this.configuration.features.has("rdf")) {
5
5
  return Maybe.empty();
6
6
  }
7
7
  return this.fromRdfType.map((fromRdfType) => code `\
@@ -1,15 +1,14 @@
1
1
  import { Maybe } from "purify-ts";
2
- import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
3
2
  import { code } from "../ts-poet-wrapper.js";
4
3
  export function NamedObjectType_graphqlTypeVariableStatement() {
5
- if (!this.features.has("graphql")) {
4
+ if (!this.configuration.features.has("graphql")) {
6
5
  return Maybe.empty();
7
6
  }
8
7
  if (this.synthetic) {
9
8
  return Maybe.empty();
10
9
  }
11
10
  return Maybe.of(code `\
12
- export const GraphQL = new ${this.reusables.imports.GraphQLObjectType}<${this.name}, { objectSet: ${syntheticNamePrefix}ObjectSet }>(${{
11
+ export const GraphQL = new ${this.reusables.imports.GraphQLObjectType}<${this.name}, { objectSet: ${this.configuration.syntheticNamePrefix}ObjectSet }>(${{
13
12
  description: this.comment.extract(),
14
13
  fields: code `() => (${this.properties.reduce((fields, property) => {
15
14
  property.graphqlField.ifJust((field) => {
@@ -1,12 +1,11 @@
1
1
  import { code, joinCode } from "../ts-poet-wrapper.js";
2
- const hasherVariable = code `_hasher`;
2
+ const hasherVariable = code `hasher`;
3
3
  export function NamedObjectType_hashFunctionDeclarations() {
4
- if (!this.features.has("hash")) {
4
+ if (!this.configuration.features.has("hash")) {
5
5
  return [];
6
6
  }
7
7
  const hashOwnShaclPropertiesStatements = this.properties.flatMap((property) => property.kind === "ShaclProperty"
8
8
  ? property.hashStatements({
9
- depth: 0,
10
9
  variables: {
11
10
  hasher: hasherVariable,
12
11
  value: property.accessExpression({
@@ -18,15 +17,14 @@ export function NamedObjectType_hashFunctionDeclarations() {
18
17
  const hashShaclPropertiesStatements = [];
19
18
  const hashStatements = [];
20
19
  for (const parentObjectType of this.parentObjectTypes) {
21
- hashShaclPropertiesStatements.push(code `${parentObjectType.name}.hashShaclProperties(${this.thisVariable}, ${hasherVariable});`);
20
+ hashShaclPropertiesStatements.push(code `${parentObjectType.name}.hashShaclProperties(${hasherVariable}, ${this.thisVariable});`);
22
21
  }
23
- hashStatements.push(code `${this.name}.hashShaclProperties(${this.thisVariable}, ${hasherVariable});`);
22
+ hashStatements.push(code `${this.name}.hashShaclProperties(${hasherVariable}, ${this.thisVariable});`);
24
23
  hashShaclPropertiesStatements.push(...hashOwnShaclPropertiesStatements);
25
24
  hashShaclPropertiesStatements.push(code `return ${hasherVariable};`);
26
25
  hashStatements.push(...this.properties
27
26
  .filter((property) => property.kind !== "ShaclProperty")
28
27
  .flatMap((property) => property.hashStatements({
29
- depth: 0,
30
28
  variables: {
31
29
  hasher: hasherVariable,
32
30
  value: code `${property.accessExpression({ variables: { object: this.thisVariable } })}`,
@@ -35,11 +33,11 @@ export function NamedObjectType_hashFunctionDeclarations() {
35
33
  hashStatements.push(code `return ${hasherVariable};`);
36
34
  return [
37
35
  code `\
38
- export function hash<HasherT extends ${this.reusables.snippets.Hasher}>(${this.thisVariable}: ${this.name}, ${hasherVariable}: HasherT): HasherT {
36
+ export function hash<HasherT extends ${this.reusables.snippets.Hasher}>(${hasherVariable}: HasherT, ${this.thisVariable}: ${this.name}): HasherT {
39
37
  ${joinCode(hashStatements)}
40
38
  }`,
41
39
  code `\
42
- export function hashShaclProperties<HasherT extends ${this.reusables.snippets.Hasher}>(${this.thisVariable}: ${this.name}, ${hasherVariable}: HasherT): HasherT {
40
+ export function hashShaclProperties<HasherT extends ${this.reusables.snippets.Hasher}>(${hasherVariable}: HasherT, ${this.thisVariable}: ${this.name}): HasherT {
43
41
  ${joinCode(hashShaclPropertiesStatements)}
44
42
  }`,
45
43
  ];
@@ -1,8 +1,7 @@
1
- import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
2
1
  import { code } from "../ts-poet-wrapper.js";
3
2
  export function NamedObjectType_isTypeFunctionDeclaration() {
4
3
  return code `\
5
- export function is${this.name}(object: ${syntheticNamePrefix}Object): object is ${this.name} {
4
+ export function is${this.name}(object: ${this.configuration.syntheticNamePrefix}Object): object is ${this.name} {
6
5
  switch (object.${this._discriminantProperty.name}) {
7
6
  ${this._discriminantProperty.type.descendantValues
8
7
  .concat(this._discriminantProperty.type.ownValues)
@@ -1,7 +1,7 @@
1
1
  import { Maybe } from "purify-ts";
2
2
  import { code } from "../ts-poet-wrapper.js";
3
3
  export function NamedObjectType_jsonParseFunctionDeclaration() {
4
- if (!this.features.has("json")) {
4
+ if (!this.configuration.features.has("json")) {
5
5
  return Maybe.empty();
6
6
  }
7
7
  return Maybe.of(code `\