@shaclmate/compiler 4.0.29 → 4.0.31

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 (353) hide show
  1. package/dist/_ShapesGraphToAstTransformer/shapeAstTypeName.js +0 -4
  2. package/dist/generators/ts/AbstractCollectionType.js +13 -15
  3. package/dist/generators/ts/AbstractDateType.js +6 -8
  4. package/dist/generators/ts/AbstractIdentifierType.d.ts +1 -1
  5. package/dist/generators/ts/AbstractIdentifierType.js +9 -5
  6. package/dist/generators/ts/AbstractLazyObjectType.d.ts +2 -3
  7. package/dist/generators/ts/AbstractLazyObjectType.js +2 -5
  8. package/dist/generators/ts/AbstractLiteralType.js +2 -3
  9. package/dist/generators/ts/AbstractNamedUnionType.js +39 -41
  10. package/dist/generators/ts/AbstractNumericType.js +8 -11
  11. package/dist/generators/ts/AbstractPrimitiveType.js +1 -2
  12. package/dist/generators/ts/AbstractTermType.js +12 -14
  13. package/dist/generators/ts/AbstractType.d.ts +9 -2
  14. package/dist/generators/ts/AbstractType.js +15 -5
  15. package/dist/generators/ts/AbstractUnionType.d.ts +3 -0
  16. package/dist/generators/ts/AbstractUnionType.js +37 -28
  17. package/dist/generators/ts/BigDecimalType.d.ts +3 -3
  18. package/dist/generators/ts/BigDecimalType.js +24 -21
  19. package/dist/generators/ts/BigIntType.d.ts +1 -1
  20. package/dist/generators/ts/BigIntType.js +9 -5
  21. package/dist/generators/ts/BlankNodeType.js +9 -11
  22. package/dist/generators/ts/BooleanType.d.ts +1 -1
  23. package/dist/generators/ts/BooleanType.js +13 -11
  24. package/dist/generators/ts/DateTimeType.d.ts +1 -1
  25. package/dist/generators/ts/DateTimeType.js +14 -3
  26. package/dist/generators/ts/DateType.d.ts +1 -1
  27. package/dist/generators/ts/DateType.js +14 -3
  28. package/dist/generators/ts/DefaultValueType.js +5 -8
  29. package/dist/generators/ts/FloatType.d.ts +1 -1
  30. package/dist/generators/ts/FloatType.js +13 -2
  31. package/dist/generators/ts/IdentifierType.js +9 -11
  32. package/dist/generators/ts/{imports.d.ts → Imports.d.ts} +3 -3
  33. package/dist/generators/ts/Imports.js +41 -0
  34. package/dist/generators/ts/IntType.d.ts +1 -1
  35. package/dist/generators/ts/IntType.js +13 -2
  36. package/dist/generators/ts/IriType.js +15 -20
  37. package/dist/generators/ts/LazyObjectOptionType.d.ts +8 -8
  38. package/dist/generators/ts/LazyObjectOptionType.js +21 -26
  39. package/dist/generators/ts/LazyObjectSetType.d.ts +5 -1
  40. package/dist/generators/ts/LazyObjectSetType.js +12 -20
  41. package/dist/generators/ts/LazyObjectType.d.ts +5 -1
  42. package/dist/generators/ts/LazyObjectType.js +20 -18
  43. package/dist/generators/ts/ListType.js +12 -15
  44. package/dist/generators/ts/LiteralType.js +8 -10
  45. package/dist/generators/ts/NamedObjectType.d.ts +1 -3
  46. package/dist/generators/ts/NamedObjectType.js +33 -32
  47. package/dist/generators/ts/NamedObjectUnionType.js +37 -29
  48. package/dist/generators/ts/OptionType.js +13 -15
  49. package/dist/generators/ts/Reusables.d.ts +11 -0
  50. package/dist/generators/ts/Reusables.js +14 -0
  51. package/dist/generators/ts/SetType.js +4 -6
  52. package/dist/generators/ts/Snippet.d.ts +3 -0
  53. package/dist/generators/ts/Snippet.js +2 -0
  54. package/dist/generators/ts/SnippetFactory.d.ts +14 -0
  55. package/dist/generators/ts/SnippetFactory.js +2 -0
  56. package/dist/generators/ts/Snippets.d.ts +126 -0
  57. package/dist/generators/ts/Snippets.js +825 -0
  58. package/dist/generators/ts/StringType.d.ts +2 -2
  59. package/dist/generators/ts/StringType.js +14 -12
  60. package/dist/generators/ts/TermType.js +14 -17
  61. package/dist/generators/ts/TsGenerator.d.ts +7 -1
  62. package/dist/generators/ts/TsGenerator.js +90 -14
  63. package/dist/generators/ts/TypeFactory.d.ts +4 -1
  64. package/dist/generators/ts/TypeFactory.js +29 -3
  65. package/dist/generators/ts/ZodGenerator.d.ts +1 -0
  66. package/dist/generators/ts/ZodGenerator.js +10 -8
  67. package/dist/generators/ts/_NamedObjectType/AbstractProperty.d.ts +9 -4
  68. package/dist/generators/ts/_NamedObjectType/AbstractProperty.js +10 -1
  69. package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.d.ts +2 -2
  70. package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.js +17 -24
  71. package/dist/generators/ts/_NamedObjectType/IdentifierProperty.d.ts +1 -1
  72. package/dist/generators/ts/_NamedObjectType/IdentifierProperty.js +10 -14
  73. package/dist/generators/ts/_NamedObjectType/NamedObjectType_createFunctionDeclaration.js +3 -4
  74. package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.js +2 -4
  75. package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterFunctionDeclaration.js +1 -2
  76. package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterTypeDeclaration.js +2 -3
  77. package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.js +7 -11
  78. package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.js +11 -15
  79. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.js +21 -3
  80. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js +83 -8
  81. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.js +2 -4
  82. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.js +1 -4
  83. package/dist/generators/ts/_NamedObjectType/NamedObjectType_graphqlTypeVariableStatement.js +1 -2
  84. package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.js +4 -6
  85. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.js +3 -5
  86. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js +1 -3
  87. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.js +1 -2
  88. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.js +1 -2
  89. package/dist/generators/ts/_NamedObjectType/NamedObjectType_schemaVariableStatement.js +2 -3
  90. package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.d.ts +2 -0
  91. package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.js +4 -7
  92. package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts +2 -0
  93. package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js +2 -4
  94. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.js +2 -3
  95. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionDeclaration.js +14 -23
  96. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.js +4 -5
  97. package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.js +2 -4
  98. package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.js +3 -5
  99. package/dist/generators/ts/_NamedObjectType/ShaclProperty.d.ts +1 -1
  100. package/dist/generators/ts/_NamedObjectType/ShaclProperty.js +12 -15
  101. package/dist/generators/ts/_NamedObjectType/identifierTypeDeclarations.js +4 -5
  102. package/dist/generators/ts/_snippets/snippets_BlankNodeFilter.d.ts +2 -1
  103. package/dist/generators/ts/_snippets/snippets_BlankNodeFilter.js +1 -2
  104. package/dist/generators/ts/_snippets/snippets_BlankNodeSchema.d.ts +2 -1
  105. package/dist/generators/ts/_snippets/snippets_BlankNodeSchema.js +1 -2
  106. package/dist/generators/ts/_snippets/snippets_BooleanFilter.d.ts +2 -1
  107. package/dist/generators/ts/_snippets/snippets_BooleanFilter.js +1 -2
  108. package/dist/generators/ts/_snippets/snippets_BooleanSchema.d.ts +2 -1
  109. package/dist/generators/ts/_snippets/snippets_BooleanSchema.js +1 -2
  110. package/dist/generators/ts/_snippets/snippets_CollectionFilter.d.ts +2 -1
  111. package/dist/generators/ts/_snippets/snippets_CollectionFilter.js +1 -2
  112. package/dist/generators/ts/_snippets/snippets_CollectionSchema.d.ts +2 -1
  113. package/dist/generators/ts/_snippets/snippets_CollectionSchema.js +1 -2
  114. package/dist/generators/ts/_snippets/snippets_DateFilter.d.ts +2 -1
  115. package/dist/generators/ts/_snippets/snippets_DateFilter.js +1 -2
  116. package/dist/generators/ts/_snippets/snippets_DateSchema.d.ts +2 -1
  117. package/dist/generators/ts/_snippets/snippets_DateSchema.js +1 -2
  118. package/dist/generators/ts/_snippets/snippets_DefaultValueSchema.d.ts +2 -1
  119. package/dist/generators/ts/_snippets/snippets_DefaultValueSchema.js +1 -3
  120. package/dist/generators/ts/_snippets/snippets_EqualsResult.d.ts +2 -1
  121. package/dist/generators/ts/_snippets/snippets_EqualsResult.js +1 -3
  122. package/dist/generators/ts/_snippets/snippets_FocusSparqlConstructTriplesFunction.d.ts +2 -1
  123. package/dist/generators/ts/_snippets/snippets_FocusSparqlConstructTriplesFunction.js +1 -3
  124. package/dist/generators/ts/_snippets/snippets_FocusSparqlWherePatternsFunction.d.ts +2 -1
  125. package/dist/generators/ts/_snippets/snippets_FocusSparqlWherePatternsFunction.js +2 -5
  126. package/dist/generators/ts/_snippets/snippets_FromRdfResourceFunction.d.ts +2 -1
  127. package/dist/generators/ts/_snippets/snippets_FromRdfResourceFunction.js +1 -3
  128. package/dist/generators/ts/_snippets/snippets_FromRdfResourceValuesFunction.d.ts +2 -1
  129. package/dist/generators/ts/_snippets/snippets_FromRdfResourceValuesFunction.js +1 -3
  130. package/dist/generators/ts/_snippets/snippets_Hasher.d.ts +2 -1
  131. package/dist/generators/ts/_snippets/snippets_Hasher.js +1 -2
  132. package/dist/generators/ts/_snippets/snippets_IdentifierFilter.d.ts +2 -1
  133. package/dist/generators/ts/_snippets/snippets_IdentifierFilter.js +1 -3
  134. package/dist/generators/ts/_snippets/snippets_IdentifierSchema.d.ts +2 -1
  135. package/dist/generators/ts/_snippets/snippets_IdentifierSchema.js +1 -2
  136. package/dist/generators/ts/_snippets/snippets_IdentifierSet.d.ts +2 -1
  137. package/dist/generators/ts/_snippets/snippets_IdentifierSet.js +1 -3
  138. package/dist/generators/ts/_snippets/snippets_IriFilter.d.ts +2 -1
  139. package/dist/generators/ts/_snippets/snippets_IriFilter.js +1 -3
  140. package/dist/generators/ts/_snippets/snippets_IriSchema.d.ts +2 -1
  141. package/dist/generators/ts/_snippets/snippets_IriSchema.js +1 -3
  142. package/dist/generators/ts/_snippets/snippets_LazyObject.d.ts +2 -1
  143. package/dist/generators/ts/_snippets/snippets_LazyObject.js +1 -3
  144. package/dist/generators/ts/_snippets/snippets_LazyObjectOption.d.ts +2 -1
  145. package/dist/generators/ts/_snippets/snippets_LazyObjectOption.js +1 -3
  146. package/dist/generators/ts/_snippets/snippets_LazyObjectSet.d.ts +2 -1
  147. package/dist/generators/ts/_snippets/snippets_LazyObjectSet.js +1 -3
  148. package/dist/generators/ts/_snippets/snippets_LiteralFilter.d.ts +2 -1
  149. package/dist/generators/ts/_snippets/snippets_LiteralFilter.js +2 -5
  150. package/dist/generators/ts/_snippets/snippets_LiteralSchema.d.ts +2 -1
  151. package/dist/generators/ts/_snippets/snippets_LiteralSchema.js +1 -3
  152. package/dist/generators/ts/_snippets/snippets_MaybeFilter.d.ts +2 -1
  153. package/dist/generators/ts/_snippets/snippets_MaybeFilter.js +1 -2
  154. package/dist/generators/ts/_snippets/snippets_MaybeSchema.d.ts +2 -1
  155. package/dist/generators/ts/_snippets/snippets_MaybeSchema.js +1 -2
  156. package/dist/generators/ts/_snippets/snippets_NumericFilter.d.ts +2 -1
  157. package/dist/generators/ts/_snippets/snippets_NumericFilter.js +1 -2
  158. package/dist/generators/ts/_snippets/snippets_NumericSchema.d.ts +2 -1
  159. package/dist/generators/ts/_snippets/snippets_NumericSchema.js +1 -2
  160. package/dist/generators/ts/_snippets/snippets_PropertyPath.d.ts +2 -1
  161. package/dist/generators/ts/_snippets/snippets_PropertyPath.js +8 -13
  162. package/dist/generators/ts/_snippets/snippets_RdfVocabularies.d.ts +2 -1
  163. package/dist/generators/ts/_snippets/snippets_RdfVocabularies.js +1 -3
  164. package/dist/generators/ts/_snippets/snippets_ShaclPropertySchema.d.ts +2 -1
  165. package/dist/generators/ts/_snippets/snippets_ShaclPropertySchema.js +2 -4
  166. package/dist/generators/ts/_snippets/snippets_SparqlFilterPattern.d.ts +2 -1
  167. package/dist/generators/ts/_snippets/snippets_SparqlFilterPattern.js +1 -3
  168. package/dist/generators/ts/_snippets/snippets_SparqlPattern.d.ts +2 -1
  169. package/dist/generators/ts/_snippets/snippets_SparqlPattern.js +1 -4
  170. package/dist/generators/ts/_snippets/snippets_SparqlPattern_isSolutionGenerating.d.ts +2 -1
  171. package/dist/generators/ts/_snippets/snippets_SparqlPattern_isSolutionGenerating.js +2 -4
  172. package/dist/generators/ts/_snippets/snippets_StringFilter.d.ts +2 -1
  173. package/dist/generators/ts/_snippets/snippets_StringFilter.js +1 -2
  174. package/dist/generators/ts/_snippets/snippets_StringSchema.d.ts +2 -1
  175. package/dist/generators/ts/_snippets/snippets_StringSchema.js +1 -2
  176. package/dist/generators/ts/_snippets/snippets_TermFilter.d.ts +2 -1
  177. package/dist/generators/ts/_snippets/snippets_TermFilter.js +1 -3
  178. package/dist/generators/ts/_snippets/snippets_TermSchema.d.ts +2 -1
  179. package/dist/generators/ts/_snippets/snippets_TermSchema.js +1 -3
  180. package/dist/generators/ts/_snippets/snippets_ToRdfResourceFunction.d.ts +2 -1
  181. package/dist/generators/ts/_snippets/snippets_ToRdfResourceFunction.js +9 -5
  182. package/dist/generators/ts/_snippets/snippets_ToRdfResourceValuesFunction.d.ts +2 -1
  183. package/dist/generators/ts/_snippets/snippets_ToRdfResourceValuesFunction.js +5 -6
  184. package/dist/generators/ts/_snippets/snippets_UnwrapR.d.ts +2 -1
  185. package/dist/generators/ts/_snippets/snippets_UnwrapR.js +1 -3
  186. package/dist/generators/ts/_snippets/snippets_ValueSparqlConstructTriplesFunction.d.ts +2 -1
  187. package/dist/generators/ts/_snippets/snippets_ValueSparqlConstructTriplesFunction.js +1 -3
  188. package/dist/generators/ts/_snippets/snippets_ValueSparqlWherePatternsFunction.d.ts +2 -1
  189. package/dist/generators/ts/_snippets/snippets_ValueSparqlWherePatternsFunction.js +3 -6
  190. package/dist/generators/ts/_snippets/snippets__FromRdfResourceFunction.d.ts +3 -0
  191. package/dist/generators/ts/_snippets/snippets__FromRdfResourceFunction.js +13 -0
  192. package/dist/generators/ts/_snippets/snippets__ToRdfResourceFunction.d.ts +3 -0
  193. package/dist/generators/ts/_snippets/snippets__ToRdfResourceFunction.js +12 -0
  194. package/dist/generators/ts/_snippets/snippets_arrayEquals.d.ts +2 -1
  195. package/dist/generators/ts/_snippets/snippets_arrayEquals.js +7 -10
  196. package/dist/generators/ts/_snippets/snippets_arrayIntersection.d.ts +2 -1
  197. package/dist/generators/ts/_snippets/snippets_arrayIntersection.js +1 -2
  198. package/dist/generators/ts/_snippets/snippets_bigDecimalLiteral.d.ts +2 -1
  199. package/dist/generators/ts/_snippets/snippets_bigDecimalLiteral.js +2 -5
  200. package/dist/generators/ts/_snippets/snippets_bigDecimalSparqlWherePatterns.d.ts +2 -1
  201. package/dist/generators/ts/_snippets/snippets_bigDecimalSparqlWherePatterns.js +11 -19
  202. package/dist/generators/ts/_snippets/snippets_blankNodeSparqlWherePatterns.d.ts +2 -1
  203. package/dist/generators/ts/_snippets/snippets_blankNodeSparqlWherePatterns.js +2 -6
  204. package/dist/generators/ts/_snippets/snippets_booleanEquals.d.ts +2 -1
  205. package/dist/generators/ts/_snippets/snippets_booleanEquals.js +4 -6
  206. package/dist/generators/ts/_snippets/snippets_booleanSparqlWherePatterns.d.ts +2 -1
  207. package/dist/generators/ts/_snippets/snippets_booleanSparqlWherePatterns.js +5 -12
  208. package/dist/generators/ts/_snippets/snippets_compactRecord.d.ts +2 -1
  209. package/dist/generators/ts/_snippets/snippets_compactRecord.js +1 -2
  210. package/dist/generators/ts/_snippets/snippets_dateEquals.d.ts +2 -1
  211. package/dist/generators/ts/_snippets/snippets_dateEquals.js +4 -6
  212. package/dist/generators/ts/_snippets/snippets_dateSparqlWherePatterns.d.ts +2 -1
  213. package/dist/generators/ts/_snippets/snippets_dateSparqlWherePatterns.js +9 -17
  214. package/dist/generators/ts/_snippets/snippets_decodeBigDecimalLiteral.d.ts +2 -1
  215. package/dist/generators/ts/_snippets/snippets_decodeBigDecimalLiteral.js +1 -3
  216. package/dist/generators/ts/_snippets/snippets_deduplicateSparqlPatterns.d.ts +2 -1
  217. package/dist/generators/ts/_snippets/snippets_deduplicateSparqlPatterns.js +3 -5
  218. package/dist/generators/ts/_snippets/snippets_defaultValueSparqlWherePatterns.d.ts +2 -1
  219. package/dist/generators/ts/_snippets/snippets_defaultValueSparqlWherePatterns.js +3 -7
  220. package/dist/generators/ts/_snippets/snippets_filterArray.d.ts +2 -1
  221. package/dist/generators/ts/_snippets/snippets_filterArray.js +2 -4
  222. package/dist/generators/ts/_snippets/snippets_filterBigDecimal.d.ts +2 -1
  223. package/dist/generators/ts/_snippets/snippets_filterBigDecimal.js +2 -5
  224. package/dist/generators/ts/_snippets/snippets_filterBlankNode.d.ts +2 -1
  225. package/dist/generators/ts/_snippets/snippets_filterBlankNode.js +2 -5
  226. package/dist/generators/ts/_snippets/snippets_filterBoolean.d.ts +2 -1
  227. package/dist/generators/ts/_snippets/snippets_filterBoolean.js +2 -4
  228. package/dist/generators/ts/_snippets/snippets_filterDate.d.ts +2 -1
  229. package/dist/generators/ts/_snippets/snippets_filterDate.js +2 -4
  230. package/dist/generators/ts/_snippets/snippets_filterIdentifier.d.ts +2 -1
  231. package/dist/generators/ts/_snippets/snippets_filterIdentifier.js +2 -5
  232. package/dist/generators/ts/_snippets/snippets_filterIri.d.ts +2 -1
  233. package/dist/generators/ts/_snippets/snippets_filterIri.js +2 -5
  234. package/dist/generators/ts/_snippets/snippets_filterLiteral.d.ts +2 -1
  235. package/dist/generators/ts/_snippets/snippets_filterLiteral.js +3 -7
  236. package/dist/generators/ts/_snippets/snippets_filterMaybe.d.ts +2 -1
  237. package/dist/generators/ts/_snippets/snippets_filterMaybe.js +2 -5
  238. package/dist/generators/ts/_snippets/snippets_filterNumeric.d.ts +2 -1
  239. package/dist/generators/ts/_snippets/snippets_filterNumeric.js +2 -4
  240. package/dist/generators/ts/_snippets/snippets_filterString.d.ts +2 -1
  241. package/dist/generators/ts/_snippets/snippets_filterString.js +2 -4
  242. package/dist/generators/ts/_snippets/snippets_filterTerm.d.ts +2 -1
  243. package/dist/generators/ts/_snippets/snippets_filterTerm.js +2 -5
  244. package/dist/generators/ts/_snippets/snippets_fromRdfLanguageIn.d.ts +2 -1
  245. package/dist/generators/ts/_snippets/snippets_fromRdfLanguageIn.js +1 -3
  246. package/dist/generators/ts/_snippets/snippets_fromRdfPreferredLanguages.d.ts +2 -1
  247. package/dist/generators/ts/_snippets/snippets_fromRdfPreferredLanguages.js +1 -3
  248. package/dist/generators/ts/_snippets/snippets_identifierSparqlWherePatterns.d.ts +2 -1
  249. package/dist/generators/ts/_snippets/snippets_identifierSparqlWherePatterns.js +4 -10
  250. package/dist/generators/ts/_snippets/snippets_iriSparqlWherePatterns.d.ts +2 -1
  251. package/dist/generators/ts/_snippets/snippets_iriSparqlWherePatterns.js +5 -12
  252. package/dist/generators/ts/_snippets/snippets_isReadonlyBigIntArray.d.ts +2 -1
  253. package/dist/generators/ts/_snippets/snippets_isReadonlyBigIntArray.js +1 -2
  254. package/dist/generators/ts/_snippets/snippets_isReadonlyBooleanArray.d.ts +2 -1
  255. package/dist/generators/ts/_snippets/snippets_isReadonlyBooleanArray.js +1 -2
  256. package/dist/generators/ts/_snippets/snippets_isReadonlyNumberArray.d.ts +2 -1
  257. package/dist/generators/ts/_snippets/snippets_isReadonlyNumberArray.js +1 -2
  258. package/dist/generators/ts/_snippets/snippets_isReadonlyObjectArray.d.ts +2 -1
  259. package/dist/generators/ts/_snippets/snippets_isReadonlyObjectArray.js +1 -2
  260. package/dist/generators/ts/_snippets/snippets_isReadonlyStringArray.d.ts +2 -1
  261. package/dist/generators/ts/_snippets/snippets_isReadonlyStringArray.js +1 -2
  262. package/dist/generators/ts/_snippets/snippets_liftSparqlPatterns.d.ts +2 -1
  263. package/dist/generators/ts/_snippets/snippets_liftSparqlPatterns.js +4 -7
  264. package/dist/generators/ts/_snippets/snippets_listSparqlConstructTriples.d.ts +2 -1
  265. package/dist/generators/ts/_snippets/snippets_listSparqlConstructTriples.js +6 -12
  266. package/dist/generators/ts/_snippets/snippets_listSparqlWherePatterns.d.ts +2 -1
  267. package/dist/generators/ts/_snippets/snippets_listSparqlWherePatterns.js +9 -18
  268. package/dist/generators/ts/_snippets/snippets_literalFactory.d.ts +2 -1
  269. package/dist/generators/ts/_snippets/snippets_literalFactory.js +1 -3
  270. package/dist/generators/ts/_snippets/snippets_literalSchemaSparqlPatterns.d.ts +2 -1
  271. package/dist/generators/ts/_snippets/snippets_literalSchemaSparqlPatterns.js +7 -13
  272. package/dist/generators/ts/_snippets/snippets_literalSparqlWherePatterns.d.ts +2 -1
  273. package/dist/generators/ts/_snippets/snippets_literalSparqlWherePatterns.js +3 -8
  274. package/dist/generators/ts/_snippets/snippets_maybeEquals.d.ts +2 -1
  275. package/dist/generators/ts/_snippets/snippets_maybeEquals.js +5 -8
  276. package/dist/generators/ts/_snippets/snippets_maybeSparqlConstructTriples.d.ts +2 -1
  277. package/dist/generators/ts/_snippets/snippets_maybeSparqlConstructTriples.js +2 -6
  278. package/dist/generators/ts/_snippets/snippets_maybeSparqlWherePatterns.d.ts +2 -1
  279. package/dist/generators/ts/_snippets/snippets_maybeSparqlWherePatterns.js +4 -9
  280. package/dist/generators/ts/_snippets/snippets_normalizeSparqlWherePatterns.d.ts +2 -1
  281. package/dist/generators/ts/_snippets/snippets_normalizeSparqlWherePatterns.js +9 -14
  282. package/dist/generators/ts/_snippets/snippets_numericSparqlWherePatterns.d.ts +2 -1
  283. package/dist/generators/ts/_snippets/snippets_numericSparqlWherePatterns.js +9 -17
  284. package/dist/generators/ts/_snippets/snippets_parseBlankNode.d.ts +2 -1
  285. package/dist/generators/ts/_snippets/snippets_parseBlankNode.js +2 -5
  286. package/dist/generators/ts/_snippets/snippets_parseIdentifier.d.ts +2 -1
  287. package/dist/generators/ts/_snippets/snippets_parseIdentifier.js +1 -3
  288. package/dist/generators/ts/_snippets/snippets_parseIri.d.ts +2 -1
  289. package/dist/generators/ts/_snippets/snippets_parseIri.js +2 -5
  290. package/dist/generators/ts/_snippets/snippets_setSparqlConstructTriples.d.ts +2 -1
  291. package/dist/generators/ts/_snippets/snippets_setSparqlConstructTriples.js +2 -6
  292. package/dist/generators/ts/_snippets/snippets_setSparqlWherePatterns.d.ts +2 -1
  293. package/dist/generators/ts/_snippets/snippets_setSparqlWherePatterns.js +3 -8
  294. package/dist/generators/ts/_snippets/snippets_shaclPropertyFromRdf.d.ts +2 -1
  295. package/dist/generators/ts/_snippets/snippets_shaclPropertyFromRdf.js +2 -5
  296. package/dist/generators/ts/_snippets/snippets_shaclPropertySparqlConstructTriples.d.ts +2 -1
  297. package/dist/generators/ts/_snippets/snippets_shaclPropertySparqlConstructTriples.js +4 -9
  298. package/dist/generators/ts/_snippets/snippets_shaclPropertySparqlWherePatterns.d.ts +2 -1
  299. package/dist/generators/ts/_snippets/snippets_shaclPropertySparqlWherePatterns.js +8 -15
  300. package/dist/generators/ts/_snippets/snippets_sortSparqlPatterns.d.ts +2 -1
  301. package/dist/generators/ts/_snippets/snippets_sortSparqlPatterns.js +5 -7
  302. package/dist/generators/ts/_snippets/snippets_sparqlInstancesOfPattern.d.ts +2 -1
  303. package/dist/generators/ts/_snippets/snippets_sparqlInstancesOfPattern.js +3 -6
  304. package/dist/generators/ts/_snippets/snippets_sparqlPropertyPath.d.ts +2 -1
  305. package/dist/generators/ts/_snippets/snippets_sparqlPropertyPath.js +3 -6
  306. package/dist/generators/ts/_snippets/snippets_sparqlValueInPattern.d.ts +2 -1
  307. package/dist/generators/ts/_snippets/snippets_sparqlValueInPattern.js +3 -7
  308. package/dist/generators/ts/_snippets/snippets_strictEquals.d.ts +2 -1
  309. package/dist/generators/ts/_snippets/snippets_strictEquals.js +4 -6
  310. package/dist/generators/ts/_snippets/snippets_stringSparqlWherePatterns.d.ts +2 -1
  311. package/dist/generators/ts/_snippets/snippets_stringSparqlWherePatterns.js +7 -15
  312. package/dist/generators/ts/_snippets/snippets_termFilterSparqlPatterns.d.ts +2 -1
  313. package/dist/generators/ts/_snippets/snippets_termFilterSparqlPatterns.js +4 -9
  314. package/dist/generators/ts/_snippets/snippets_termSchemaSparqlPatterns.d.ts +2 -1
  315. package/dist/generators/ts/_snippets/snippets_termSchemaSparqlPatterns.js +6 -11
  316. package/dist/generators/ts/_snippets/snippets_termSparqlWherePatterns.d.ts +2 -1
  317. package/dist/generators/ts/_snippets/snippets_termSparqlWherePatterns.js +3 -9
  318. package/dist/generators/ts/_snippets/snippets_wrap_FromRdfResourceFunction.d.ts +3 -0
  319. package/dist/generators/ts/_snippets/snippets_wrap_FromRdfResourceFunction.js +10 -0
  320. package/dist/generators/ts/_snippets/snippets_wrap_ToRdfResourceFunction.d.ts +3 -0
  321. package/dist/generators/ts/_snippets/snippets_wrap_ToRdfResourceFunction.js +14 -0
  322. package/dist/generators/ts/graphqlSchemaVariableStatement.d.ts +2 -1
  323. package/dist/generators/ts/graphqlSchemaVariableStatement.js +13 -14
  324. package/dist/generators/ts/objectSetDeclarations.d.ts +2 -1
  325. package/dist/generators/ts/objectSetDeclarations.js +3 -3
  326. package/dist/generators/ts/objectSetInterfaceDeclaration.d.ts +2 -1
  327. package/dist/generators/ts/objectSetInterfaceDeclaration.js +4 -5
  328. package/dist/generators/ts/objectSetMethodSignatures.d.ts +2 -1
  329. package/dist/generators/ts/objectSetMethodSignatures.js +4 -5
  330. package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.d.ts +2 -1
  331. package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.js +49 -51
  332. package/dist/generators/ts/rdfjsTermExpression.d.ts +6 -2
  333. package/dist/generators/ts/rdfjsTermExpression.js +13 -15
  334. package/dist/generators/ts/sparqlObjectSetClassDeclaration.d.ts +2 -1
  335. package/dist/generators/ts/sparqlObjectSetClassDeclaration.js +43 -45
  336. package/dist/generators/ts/unsupportedObjectSetMethodDeclarations.d.ts +2 -1
  337. package/dist/generators/ts/unsupportedObjectSetMethodDeclarations.js +6 -7
  338. package/dist/input/ShapesGraph.d.ts +4 -4
  339. package/dist/input/ShapesGraph.js +4 -4
  340. package/dist/input/generated.d.ts +184 -267
  341. package/dist/input/generated.js +721 -779
  342. package/package.json +2 -2
  343. package/dist/generators/ts/_NamedObjectType/NamedObjectType_propertiesFromJsonFunctionDeclaration.d.ts +0 -5
  344. package/dist/generators/ts/_NamedObjectType/NamedObjectType_propertiesFromJsonFunctionDeclaration.js +0 -38
  345. package/dist/generators/ts/_NamedObjectType/NamedObjectType_propertiesFromRdfResourceFunctionDeclaration.d.ts +0 -5
  346. package/dist/generators/ts/_NamedObjectType/NamedObjectType_propertiesFromRdfResourceFunctionDeclaration.js +0 -101
  347. package/dist/generators/ts/_snippets/snippets_PropertiesFromRdfResourceFunction.d.ts +0 -2
  348. package/dist/generators/ts/_snippets/snippets_PropertiesFromRdfResourceFunction.js +0 -15
  349. package/dist/generators/ts/imports.js +0 -41
  350. package/dist/generators/ts/snippets.d.ts +0 -110
  351. package/dist/generators/ts/snippets.js +0 -217
  352. package/dist/generators/ts/synthesizeUberObjectUnionType.d.ts +0 -11
  353. package/dist/generators/ts/synthesizeUberObjectUnionType.js +0 -68
@@ -12,10 +12,6 @@ export function shapeAstTypeName(shape) {
12
12
  if (shape.shaclmateName.isJust()) {
13
13
  return shape.shaclmateName;
14
14
  }
15
- // Explicit rdfs:label
16
- if (shape.label.isJust()) {
17
- return shape.label;
18
- }
19
15
  // CURIE shape identifier
20
16
  if (shapeIdentifier instanceof Curie) {
21
17
  if (shapeIdentifier.hasUniqueReference) {
@@ -9,8 +9,6 @@ import { invariant } from "ts-invariant";
9
9
  import { Memoize } from "typescript-memoize";
10
10
  import { AbstractContainerType } from "./AbstractContainerType.js";
11
11
  import { codeEquals } from "./codeEquals.js";
12
- import { imports } from "./imports.js";
13
- import { snippets } from "./snippets.js";
14
12
  import { code, joinCode } from "./ts-poet-wrapper.js";
15
13
  /**
16
14
  * Abstract base class for ListType and SetType.
@@ -83,15 +81,15 @@ export class AbstractCollectionType extends AbstractContainerType {
83
81
  sourceTypeCheckExpression: (value) => {
84
82
  switch (itemTypeof) {
85
83
  case "bigint":
86
- return code `${snippets.isReadonlyBigIntArray}(${value})`;
84
+ return code `${this.reusables.snippets.isReadonlyBigIntArray}(${value})`;
87
85
  case "boolean":
88
- return code `${snippets.isReadonlyBooleanArray}(${value})`;
86
+ return code `${this.reusables.snippets.isReadonlyBooleanArray}(${value})`;
89
87
  case "number":
90
- return code `${snippets.isReadonlyNumberArray}(${value})`;
88
+ return code `${this.reusables.snippets.isReadonlyNumberArray}(${value})`;
91
89
  case "object":
92
- return code `${snippets.isReadonlyObjectArray}(${value})`;
90
+ return code `${this.reusables.snippets.isReadonlyObjectArray}(${value})`;
93
91
  case "string":
94
- return code `${snippets.isReadonlyStringArray}(${value})`;
92
+ return code `${this.reusables.snippets.isReadonlyStringArray}(${value})`;
95
93
  case "function":
96
94
  case "symbol":
97
95
  case "undefined":
@@ -109,7 +107,7 @@ export class AbstractCollectionType extends AbstractContainerType {
109
107
  // Don't try to do any item type conversions here (yet).
110
108
  conversions.push({
111
109
  conversionExpression: (value) => value,
112
- sourceTypeCheckExpression: (value) => code `${imports.NonEmptyList}.isNonEmpty(${value})`,
110
+ sourceTypeCheckExpression: (value) => code `${this.reusables.imports.NonEmptyList}.isNonEmpty(${value})`,
113
111
  sourceTypeName: this.name,
114
112
  sourceTypeof: "object",
115
113
  });
@@ -117,16 +115,16 @@ export class AbstractCollectionType extends AbstractContainerType {
117
115
  return conversions;
118
116
  }
119
117
  get equalsFunction() {
120
- return code `((left, right) => ${snippets.arrayEquals}(left, right, ${this.itemType.equalsFunction}))`;
118
+ return code `((left, right) => ${this.reusables.snippets.arrayEquals}(left, right, ${this.itemType.equalsFunction}))`;
121
119
  }
122
120
  get filterFunction() {
123
- return code `${snippets.filterArray}<${this.itemType.name}, ${this.itemType.filterType}>(${this.itemType.filterFunction})`;
121
+ return code `${this.reusables.snippets.filterArray}<${this.itemType.name}, ${this.itemType.filterType}>(${this.itemType.filterFunction})`;
124
122
  }
125
123
  get filterType() {
126
- return code `${snippets.CollectionFilter}<${this.itemType.filterType}>`;
124
+ return code `${this.reusables.snippets.CollectionFilter}<${this.itemType.filterType}>`;
127
125
  }
128
126
  get graphqlType() {
129
- return new AbstractContainerType.GraphqlType(code `new ${imports.GraphQLList}(${this.itemType.graphqlType.name})`);
127
+ return new AbstractContainerType.GraphqlType(code `new ${this.reusables.imports.GraphQLList}(${this.itemType.graphqlType.name})`, this.reusables);
130
128
  }
131
129
  get mutable() {
132
130
  return this._mutable || this.itemType.mutable;
@@ -138,10 +136,10 @@ export class AbstractCollectionType extends AbstractContainerType {
138
136
  if (this.minCount === 0n) {
139
137
  return code `readonly (${this.itemType.name})[]`;
140
138
  }
141
- return code `${imports.NonEmptyList}<${this.itemType.name}>`;
139
+ return code `${this.reusables.imports.NonEmptyList}<${this.itemType.name}>`;
142
140
  }
143
141
  get schemaType() {
144
- return code `${snippets.CollectionSchema}<${this.itemType.schemaType}>`;
142
+ return code `${this.reusables.snippets.CollectionSchema}<${this.itemType.schemaType}>`;
145
143
  }
146
144
  get schemaObject() {
147
145
  return {
@@ -152,7 +150,7 @@ export class AbstractCollectionType extends AbstractContainerType {
152
150
  fromJsonExpression({ variables, }) {
153
151
  let expression = variables.value;
154
152
  if (!this._mutable && this.minCount > 0n) {
155
- expression = code `${imports.NonEmptyList}.fromArray(${expression}).unsafeCoerce()`;
153
+ expression = code `${this.reusables.imports.NonEmptyList}.fromArray(${expression}).unsafeCoerce()`;
156
154
  }
157
155
  if (this.minCount === 0n) {
158
156
  expression = code `(${expression} ?? [])`;
@@ -7,17 +7,15 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  import { NonEmptyList } from "purify-ts";
8
8
  import { Memoize } from "typescript-memoize";
9
9
  import { AbstractPrimitiveType } from "./AbstractPrimitiveType.js";
10
- import { rdfjsTermExpression } from "./rdfjsTermExpression.js";
11
- import { snippets } from "./snippets.js";
12
10
  import { code, literalOf } from "./ts-poet-wrapper.js";
13
11
  export class AbstractDateType extends AbstractPrimitiveType {
14
- equalsFunction = code `${snippets.dateEquals}`;
15
- filterFunction = code `${snippets.filterDate}`;
16
- filterType = code `${snippets.DateFilter}`;
12
+ equalsFunction = code `${this.reusables.snippets.dateEquals}`;
13
+ filterFunction = code `${this.reusables.snippets.filterDate}`;
14
+ filterType = code `${this.reusables.snippets.DateFilter}`;
17
15
  mutable = false;
18
16
  name = "Date";
19
- schemaType = code `${snippets.DateSchema}`;
20
- valueSparqlWherePatternsFunction = code `${snippets.dateSparqlWherePatterns}`;
17
+ schemaType = code `${this.reusables.snippets.DateSchema}`;
18
+ valueSparqlWherePatternsFunction = code `${this.reusables.snippets.dateSparqlWherePatterns}`;
21
19
  typeofs = NonEmptyList(["object"]);
22
20
  get conversions() {
23
21
  return [
@@ -49,7 +47,7 @@ export class AbstractDateType extends AbstractPrimitiveType {
49
47
  return new AbstractPrimitiveType.JsonType(code `string`);
50
48
  }
51
49
  toRdfResourceValuesExpression({ variables, }) {
52
- return code `[${snippets.literalFactory}.date(${variables.value}, ${rdfjsTermExpression(this.datatype, { logger: this.logger })})]`;
50
+ return code `[${this.reusables.snippets.literalFactory}.date(${variables.value}, ${this.rdfjsTermExpression(this.datatype)})]`;
53
51
  }
54
52
  fromRdfExpressionChain({ variables, }) {
55
53
  return {
@@ -3,12 +3,12 @@ import type { IdentifierNodeKind } from "@shaclmate/shacl-ast";
3
3
  import { AbstractTermType } from "./AbstractTermType.js";
4
4
  import { type Code } from "./ts-poet-wrapper.js";
5
5
  export declare abstract class AbstractIdentifierType<IdentifierT extends BlankNode | NamedNode> extends AbstractTermType<NamedNode, IdentifierT> {
6
- readonly graphqlType: import("./AbstractType.js").AbstractType.GraphqlType;
7
6
  abstract readonly kind: "BlankNodeType" | "IdentifierType" | "IriType";
8
7
  abstract readonly nodeKinds: ReadonlySet<IdentifierNodeKind>;
9
8
  abstract readonly parseFunction: Code;
10
9
  readonly stringifyFunction: Code;
11
10
  get conversions(): readonly AbstractTermType.Conversion[];
11
+ get graphqlType(): import("./AbstractType.js").AbstractType.GraphqlType;
12
12
  graphqlResolveExpression({ variables: { value }, }: Parameters<AbstractTermType["graphqlResolveExpression"]>[0]): Code;
13
13
  }
14
14
  //# sourceMappingURL=AbstractIdentifierType.d.ts.map
@@ -6,16 +6,14 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  };
7
7
  import { Memoize } from "typescript-memoize";
8
8
  import { AbstractTermType } from "./AbstractTermType.js";
9
- import { imports } from "./imports.js";
10
9
  import { code } from "./ts-poet-wrapper.js";
11
10
  export class AbstractIdentifierType extends AbstractTermType {
12
- graphqlType = new AbstractTermType.GraphqlType(code `${imports.GraphQLString}`);
13
- stringifyFunction = code `${imports.NTriplesTerm}.stringify`;
11
+ stringifyFunction = code `${this.reusables.imports.NTriplesTerm}.stringify`;
14
12
  get conversions() {
15
13
  const conversions = super.conversions.concat();
16
14
  if (this.nodeKinds.has("IRI")) {
17
15
  conversions.push({
18
- conversionExpression: (value) => code `${imports.dataFactory}.namedNode(${value})`,
16
+ conversionExpression: (value) => code `${this.reusables.imports.dataFactory}.namedNode(${value})`,
19
17
  sourceTypeCheckExpression: (value) => code `typeof ${value} === "string"`,
20
18
  sourceTypeName: this.in_.length > 0
21
19
  ? code `${this.in_.map((iri) => `"${iri.value}"`).join(" | ")}`
@@ -25,11 +23,17 @@ export class AbstractIdentifierType extends AbstractTermType {
25
23
  }
26
24
  return conversions;
27
25
  }
26
+ get graphqlType() {
27
+ return new AbstractTermType.GraphqlType(code `${this.reusables.imports.GraphQLString}`, this.reusables);
28
+ }
28
29
  graphqlResolveExpression({ variables: { value }, }) {
29
- return code `${imports.NTriplesTerm}.stringify(${value})`;
30
+ return code `${this.reusables.imports.NTriplesTerm}.stringify(${value})`;
30
31
  }
31
32
  }
32
33
  __decorate([
33
34
  Memoize()
34
35
  ], AbstractIdentifierType.prototype, "conversions", null);
36
+ __decorate([
37
+ Memoize()
38
+ ], AbstractIdentifierType.prototype, "graphqlType", null);
35
39
  //# sourceMappingURL=AbstractIdentifierType.js.map
@@ -8,7 +8,7 @@ import { type Code } from "./ts-poet-wrapper.js";
8
8
  export declare abstract class AbstractLazyObjectType<PartialTypeT extends AbstractLazyObjectType.PartialTypeConstraint, ResolveTypeT extends AbstractLazyObjectType.ResolveTypeConstraint> extends AbstractType {
9
9
  protected readonly partialType: PartialTypeT;
10
10
  protected readonly resolveType: ResolveTypeT;
11
- protected readonly runtimeClass: {
11
+ protected abstract readonly runtimeClass: {
12
12
  readonly name: Code;
13
13
  readonly partialPropertyName: string;
14
14
  readonly rawName: Code;
@@ -17,10 +17,9 @@ export declare abstract class AbstractLazyObjectType<PartialTypeT extends Abstra
17
17
  readonly discriminantProperty: AbstractType["discriminantProperty"];
18
18
  readonly mutable = false;
19
19
  readonly typeofs: NonEmptyList<"object">;
20
- constructor({ partialType, resolveType, runtimeClass, ...superParameters }: {
20
+ constructor({ partialType, resolveType, ...superParameters }: {
21
21
  partialType: PartialTypeT;
22
22
  resolveType: ResolveTypeT;
23
- runtimeClass: AbstractLazyObjectType<ResolveTypeT, PartialTypeT>["runtimeClass"];
24
23
  } & ConstructorParameters<typeof AbstractType>[0]);
25
24
  get conversions(): readonly AbstractType.Conversion[];
26
25
  get equalsFunction(): Code;
@@ -9,21 +9,18 @@ import { invariant } from "ts-invariant";
9
9
  import { Memoize } from "typescript-memoize";
10
10
  import { AbstractType } from "./AbstractType.js";
11
11
  import { removeUndefined } from "./removeUndefined.js";
12
- import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
13
12
  import { code, joinCode } from "./ts-poet-wrapper.js";
14
13
  export class AbstractLazyObjectType extends AbstractType {
15
14
  partialType;
16
15
  resolveType;
17
- runtimeClass;
18
16
  declaration = Maybe.empty();
19
17
  discriminantProperty = Maybe.empty();
20
18
  mutable = false;
21
19
  typeofs = NonEmptyList(["object"]);
22
- constructor({ partialType, resolveType, runtimeClass, ...superParameters }) {
20
+ constructor({ partialType, resolveType, ...superParameters }) {
23
21
  super(superParameters);
24
22
  this.partialType = partialType;
25
23
  this.resolveType = resolveType;
26
- this.runtimeClass = runtimeClass;
27
24
  }
28
25
  get conversions() {
29
26
  return [
@@ -124,7 +121,7 @@ export class AbstractLazyObjectType extends AbstractType {
124
121
  invariant(resolvedNamedObjectUnionType.members.length ===
125
122
  partialNamedObjectUnionType.members.length);
126
123
  const caseBlocks = resolvedNamedObjectUnionType.members.map(({ discriminantValues }, memberI) => {
127
- return code `${discriminantValues.map((discriminantPropertyValue) => `case "${discriminantPropertyValue}":`).join("\n")} return ${partialNamedObjectUnionType.members[memberI].type.name}.${syntheticNamePrefix}create(${variables.resolvedObjectUnion});`;
124
+ return code `${discriminantValues.map((discriminantPropertyValue) => `case "${discriminantPropertyValue}":`).join("\n")} return ${partialNamedObjectUnionType.members[memberI].type.name}.create(${variables.resolvedObjectUnion});`;
128
125
  });
129
126
  caseBlocks.push(code `default: ${variables.resolvedObjectUnion} satisfies never; throw new Error("unrecognized type");`);
130
127
  return code `switch (${variables.resolvedObjectUnion}.${resolvedNamedObjectUnionType.discriminantProperty.unsafeCoerce().name}) { ${joinCode(caseBlocks)} }`;
@@ -1,5 +1,4 @@
1
1
  import { AbstractTermType } from "./AbstractTermType.js";
2
- import { snippets } from "./snippets.js";
3
2
  import { code, literalOf } from "./ts-poet-wrapper.js";
4
3
  export class AbstractLiteralType extends AbstractTermType {
5
4
  nodeKinds = nodeKinds;
@@ -21,9 +20,9 @@ export class AbstractLiteralType extends AbstractTermType {
21
20
  return {
22
21
  ...super.fromRdfExpressionChain({ variables }),
23
22
  languageIn: this.languageIn.length > 0
24
- ? code `chain(values => ${snippets.fromRdfLanguageIn}(values, ${JSON.stringify(this.languageIn)}))`
23
+ ? code `chain(values => ${this.reusables.snippets.fromRdfLanguageIn}(values, ${JSON.stringify(this.languageIn)}))`
25
24
  : undefined,
26
- preferredLanguages: code `chain(values => ${snippets.fromRdfPreferredLanguages}(values, ${variables.preferredLanguages}))`,
25
+ preferredLanguages: code `chain(values => ${this.reusables.snippets.fromRdfPreferredLanguages}(values, ${variables.preferredLanguages}))`,
27
26
  valueTo: code `chain(values => values.chainMap(value => value.toLiteral()))`,
28
27
  };
29
28
  }
@@ -8,8 +8,6 @@ import { Maybe } from "purify-ts";
8
8
  import { Memoize } from "typescript-memoize";
9
9
  import { AbstractType } from "./AbstractType.js";
10
10
  import { AbstractUnionType } from "./AbstractUnionType.js";
11
- import { imports } from "./imports.js";
12
- import { snippets } from "./snippets.js";
13
11
  import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
14
12
  import { code, def, joinCode } from "./ts-poet-wrapper.js";
15
13
  export class AbstractNamedUnionType extends AbstractUnionType {
@@ -37,15 +35,15 @@ ${joinCode(staticModuleDeclarations
37
35
  }
38
36
  get equalsFunction() {
39
37
  if (this.features.has("equals")) {
40
- return code `${this.name}.${syntheticNamePrefix}equals`;
38
+ return code `${this.name}.equals`;
41
39
  }
42
40
  return this.inlineEqualsFunction;
43
41
  }
44
42
  get filterFunction() {
45
- return code `${this.name}.${syntheticNamePrefix}filter`;
43
+ return code `${this.name}.filter`;
46
44
  }
47
45
  get filterType() {
48
- return code `${this.name}.${syntheticNamePrefix}Filter`;
46
+ return code `${this.name}.Filter`;
49
47
  }
50
48
  get jsonSchemaFunctionDeclaration() {
51
49
  const meta = {
@@ -60,66 +58,66 @@ ${joinCode(staticModuleDeclarations
60
58
  return code `export const schema = () => ${this.inlineJsonSchema}.meta(${meta});`;
61
59
  }
62
60
  get jsonTypeAliasDeclaration() {
63
- return code `export type ${syntheticNamePrefix}Json = ${this.inlineJsonType.name}`;
61
+ return code `export type Json = ${this.inlineJsonType.name}`;
64
62
  }
65
63
  get name() {
66
64
  return this._name;
67
65
  }
68
66
  get valueSparqlConstructTriplesFunction() {
69
67
  if (this.features.has("sparql")) {
70
- return code `${this.name}.${syntheticNamePrefix}valueSparqlConstructTriples`;
68
+ return code `${this.name}.valueSparqlConstructTriples`;
71
69
  }
72
70
  return this.inlineValueSparqlConstructTriplesFunction;
73
71
  }
74
72
  get valueSparqlWherePatternsFunction() {
75
73
  if (this.features.has("sparql")) {
76
- return code `${this.name}.${syntheticNamePrefix}valueSparqlWherePatterns`;
74
+ return code `${this.name}.valueSparqlWherePatterns`;
77
75
  }
78
76
  return this.inlineValueSparqlWherePatternsFunction;
79
77
  }
80
78
  get staticModuleDeclarations() {
81
79
  const staticModuleDeclarations = {};
82
80
  if (this.features.has("equals")) {
83
- staticModuleDeclarations[`${syntheticNamePrefix}equals`] =
84
- code `export const ${syntheticNamePrefix}equals = ${this.inlineEqualsFunction};`;
81
+ staticModuleDeclarations[`equals`] =
82
+ code `export const equals = ${this.inlineEqualsFunction};`;
85
83
  }
86
- staticModuleDeclarations[`${syntheticNamePrefix}Filter`] =
87
- code `export type ${syntheticNamePrefix}Filter = ${this.inlineFilterType};`;
88
- staticModuleDeclarations[`${syntheticNamePrefix}filter`] =
89
- code `export const ${syntheticNamePrefix}filter = ${this.inlineFilterFunction};`;
84
+ staticModuleDeclarations[`Filter`] =
85
+ code `export type Filter = ${this.inlineFilterType};`;
86
+ staticModuleDeclarations[`filter`] =
87
+ code `export const filter = ${this.inlineFilterFunction};`;
90
88
  if (this.features.has("hash")) {
91
- staticModuleDeclarations[`${syntheticNamePrefix}hash`] =
92
- code `export function ${syntheticNamePrefix}hash<HasherT extends ${snippets.Hasher}>(value: ${this._name}, hasher: HasherT): HasherT { ${this.inlineHashStatements({ depth: 0, variables: { hasher: code `hasher`, value: code `value` } })} return hasher; }`;
89
+ staticModuleDeclarations[`hash`] =
90
+ code `export function hash<HasherT extends ${this.reusables.snippets.Hasher}>(value: ${this._name}, hasher: HasherT): HasherT { ${this.inlineHashStatements({ depth: 0, variables: { hasher: code `hasher`, value: code `value` } })} return hasher; }`;
93
91
  }
94
92
  if (this.features.has("json")) {
95
- staticModuleDeclarations[`${syntheticNamePrefix}Json`] = code `\
93
+ staticModuleDeclarations[`Json`] = code `\
96
94
  ${this.jsonTypeAliasDeclaration}
97
95
 
98
- export namespace ${syntheticNamePrefix}Json {
96
+ export namespace Json {
99
97
  ${this.jsonSchemaFunctionDeclaration}
100
98
 
101
- export function parse(json: unknown): ${imports.Either}<Error, ${syntheticNamePrefix}Json> {
99
+ export function parse(json: unknown): ${this.reusables.imports.Either}<Error, Json> {
102
100
  const jsonSafeParseResult = schema().safeParse(json);
103
- if (!jsonSafeParseResult.success) { return ${imports.Left}(jsonSafeParseResult.error); }
104
- return ${imports.Right}(jsonSafeParseResult.data);
101
+ if (!jsonSafeParseResult.success) { return ${this.reusables.imports.Left}(jsonSafeParseResult.error); }
102
+ return ${this.reusables.imports.Right}(jsonSafeParseResult.data);
105
103
  }
106
104
  }`;
107
- staticModuleDeclarations[`${syntheticNamePrefix}fromJson`] =
108
- code `export const ${syntheticNamePrefix}fromJson = ${this.inlineFromJsonFunction};`;
109
- staticModuleDeclarations[`${syntheticNamePrefix}toJson`] =
110
- code `export const ${syntheticNamePrefix}toJson = ${this.inlineToJsonFunction};`;
105
+ staticModuleDeclarations[`fromJson`] =
106
+ code `export const fromJson = ${this.inlineFromJsonFunction};`;
107
+ staticModuleDeclarations[`toJson`] =
108
+ code `export const toJson = ${this.inlineToJsonFunction};`;
111
109
  }
112
110
  if (this.features.has("rdf")) {
113
- staticModuleDeclarations[`${syntheticNamePrefix}fromRdfResourceValues`] =
114
- code `export const ${syntheticNamePrefix}fromRdfResourceValues: ${snippets.FromRdfResourceValuesFunction}<${this.name}> = ${this.inlineFromRdfResourceValuesFunction};`;
115
- staticModuleDeclarations[`${syntheticNamePrefix}toRdfResourceValues`] =
116
- code `export const ${syntheticNamePrefix}toRdfResourceValues = ${this.inlineToRdfResourceValuesFunction};`;
111
+ staticModuleDeclarations[`fromRdfResourceValues`] =
112
+ code `export const fromRdfResourceValues: ${this.reusables.snippets.FromRdfResourceValuesFunction}<${this.name}> = ${this.inlineFromRdfResourceValuesFunction};`;
113
+ staticModuleDeclarations[`toRdfResourceValues`] =
114
+ code `export const toRdfResourceValues = ${this.inlineToRdfResourceValuesFunction};`;
117
115
  }
118
116
  if (this.features.has("sparql")) {
119
- staticModuleDeclarations[`${syntheticNamePrefix}valueSparqlConstructTriples`] =
120
- code `export const ${syntheticNamePrefix}valueSparqlConstructTriples: ${snippets.ValueSparqlConstructTriplesFunction}<${this.filterType}, ${this.schemaType}> = ${this.inlineValueSparqlConstructTriplesFunction};`;
121
- staticModuleDeclarations[`${syntheticNamePrefix}valueSparqlWherePatterns`] =
122
- code `export const ${syntheticNamePrefix}valueSparqlWherePatterns: ${snippets.ValueSparqlWherePatternsFunction}<${this.filterType}, ${this.schemaType}> = ${this.inlineValueSparqlWherePatternsFunction};`;
117
+ staticModuleDeclarations[`valueSparqlConstructTriples`] =
118
+ code `export const valueSparqlConstructTriples: ${this.reusables.snippets.ValueSparqlConstructTriplesFunction}<${this.filterType}, ${this.schemaType}> = ${this.inlineValueSparqlConstructTriplesFunction};`;
119
+ staticModuleDeclarations[`valueSparqlWherePatterns`] =
120
+ code `export const valueSparqlWherePatterns: ${this.reusables.snippets.ValueSparqlWherePatternsFunction}<${this.filterType}, ${this.schemaType}> = ${this.inlineValueSparqlWherePatternsFunction};`;
123
121
  }
124
122
  staticModuleDeclarations[`${syntheticNamePrefix}toString`] =
125
123
  code `export const ${syntheticNamePrefix}toString = ${this.inlineToStringFunction};`;
@@ -127,30 +125,30 @@ export namespace ${syntheticNamePrefix}Json {
127
125
  }
128
126
  fromJsonExpression({ variables, }) {
129
127
  if (this.features.has("json")) {
130
- return code `${this.name}.${syntheticNamePrefix}fromJson(${variables.value})`;
128
+ return code `${this.name}.fromJson(${variables.value})`;
131
129
  }
132
130
  return code `${this.inlineFromJsonFunction}(${variables.value})`;
133
131
  }
134
132
  fromRdfResourceValuesExpression({ variables, }) {
135
133
  const { resourceValues: resourceValuesVariable, ...otherVariables } = variables;
136
134
  if (this.features.has("rdf")) {
137
- return code `${this.name}.${syntheticNamePrefix}fromRdfResourceValues(${resourceValuesVariable}, ${otherVariables})`;
135
+ return code `${this.name}.fromRdfResourceValues(${resourceValuesVariable}, ${otherVariables})`;
138
136
  }
139
137
  return code `${this.inlineFromRdfResourceValuesFunction}(${resourceValuesVariable}, ${otherVariables})`;
140
138
  }
141
139
  hashStatements({ depth, variables, }) {
142
140
  if (this.features.has("hash")) {
143
141
  return [
144
- code `${this.name}.${syntheticNamePrefix}hash(${variables.value}, ${variables.hasher});`,
142
+ code `${this.name}.hash(${variables.value}, ${variables.hasher});`,
145
143
  ];
146
144
  }
147
145
  return this.inlineHashStatements({ depth, variables });
148
146
  }
149
147
  jsonSchema({ context, }) {
150
148
  if (this.features.has("json")) {
151
- const expression = code `${this.name}.${syntheticNamePrefix}Json.schema()`;
149
+ const expression = code `${this.name}.Json.schema()`;
152
150
  if (context === "property" && this.recursive) {
153
- return code `${imports.z}.lazy((): ${imports.z}.ZodType<${this.name}.${syntheticNamePrefix}Json> => ${expression})`;
151
+ return code `${this.reusables.imports.z}.lazy((): ${this.reusables.imports.z}.ZodType<${this.name}.Json> => ${expression})`;
154
152
  }
155
153
  return expression;
156
154
  }
@@ -158,20 +156,20 @@ export namespace ${syntheticNamePrefix}Json {
158
156
  }
159
157
  jsonType() {
160
158
  if (this.features.has("json")) {
161
- return new AbstractType.JsonType(`${this.name}.${syntheticNamePrefix}Json`);
159
+ return new AbstractType.JsonType(`${this.name}.Json`);
162
160
  }
163
161
  return this.inlineJsonType;
164
162
  }
165
163
  toJsonExpression({ variables, }) {
166
164
  if (this.features.has("json")) {
167
- return code `${this.name}.${syntheticNamePrefix}toJson(${variables.value})`;
165
+ return code `${this.name}.toJson(${variables.value})`;
168
166
  }
169
167
  return code `${this.inlineToJsonFunction}(${variables.value})`;
170
168
  }
171
169
  toRdfResourceValuesExpression({ variables, }) {
172
170
  const { value: valueVariable, ...otherVariables } = variables;
173
171
  if (this.features.has("rdf")) {
174
- return code `${this.name}.${syntheticNamePrefix}toRdfResourceValues(${valueVariable}, ${otherVariables})`;
172
+ return code `${this.name}.toRdfResourceValues(${valueVariable}, ${otherVariables})`;
175
173
  }
176
174
  return code `${this.inlineToRdfResourceValuesFunction}(${valueVariable}, ${otherVariables})`;
177
175
  }
@@ -6,19 +6,16 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  };
7
7
  import { Memoize } from "typescript-memoize";
8
8
  import { AbstractPrimitiveType } from "./AbstractPrimitiveType.js";
9
- import { imports } from "./imports.js";
10
- import { rdfjsTermExpression } from "./rdfjsTermExpression.js";
11
- import { snippets } from "./snippets.js";
12
9
  import { code, joinCode } from "./ts-poet-wrapper.js";
13
10
  /**
14
11
  * Abstract base class for TypeScript numeric types (bigint | number).
15
12
  */
16
13
  export class AbstractNumericType extends AbstractPrimitiveType {
17
14
  get filterFunction() {
18
- return code `${snippets.filterNumeric}<${this.typeofs[0]}>`;
15
+ return code `${this.reusables.snippets.filterNumeric}<${this.typeofs[0]}>`;
19
16
  }
20
17
  get filterType() {
21
- return code `${snippets.NumericFilter}<${this.typeofs[0]}>`;
18
+ return code `${this.reusables.snippets.NumericFilter}<${this.typeofs[0]}>`;
22
19
  }
23
20
  get name() {
24
21
  if (this.primitiveIn.length > 0) {
@@ -27,10 +24,10 @@ export class AbstractNumericType extends AbstractPrimitiveType {
27
24
  return this.typeofs[0];
28
25
  }
29
26
  get schemaType() {
30
- return code `${snippets.NumericSchema}<${this.typeofs[0]}>`;
27
+ return code `${this.reusables.snippets.NumericSchema}<${this.typeofs[0]}>`;
31
28
  }
32
29
  get valueSparqlWherePatternsFunction() {
33
- return code `${snippets.numericSparqlWherePatterns}<${this.typeofs[0]}>`;
30
+ return code `${this.reusables.snippets.numericSparqlWherePatterns}<${this.typeofs[0]}>`;
34
31
  }
35
32
  get schemaObject() {
36
33
  return {
@@ -43,15 +40,15 @@ export class AbstractNumericType extends AbstractPrimitiveType {
43
40
  jsonSchema(_parameters) {
44
41
  switch (this.primitiveIn.length) {
45
42
  case 0:
46
- return code `${imports.z}.${this.typeofs[0]}()`;
43
+ return code `${this.reusables.imports.z}.${this.typeofs[0]}()`;
47
44
  case 1:
48
- return code `${imports.z}.literal(${this.literalOf(this.primitiveIn[0])})`;
45
+ return code `${this.reusables.imports.z}.literal(${this.literalOf(this.primitiveIn[0])})`;
49
46
  default:
50
- return code `${imports.z}.union([${joinCode(this.primitiveIn.map((value) => code `${imports.z}.literal(${this.literalOf(value)})`), { on: "," })}])`;
47
+ return code `${this.reusables.imports.z}.union([${joinCode(this.primitiveIn.map((value) => code `${this.reusables.imports.z}.literal(${this.literalOf(value)})`), { on: "," })}])`;
51
48
  }
52
49
  }
53
50
  toRdfResourceValuesExpression({ variables, }) {
54
- return code `[${snippets.literalFactory}.${this.typeofs[0]}(${variables.value}, ${rdfjsTermExpression(this.datatype, { logger: this.logger })})]`;
51
+ return code `[${this.reusables.snippets.literalFactory}.${this.typeofs[0]}(${variables.value}, ${this.rdfjsTermExpression(this.datatype)})]`;
55
52
  }
56
53
  fromRdfExpressionChain({ variables, }) {
57
54
  return {
@@ -7,11 +7,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  import { Maybe } from "purify-ts";
8
8
  import { Memoize } from "typescript-memoize";
9
9
  import { AbstractLiteralType } from "./AbstractLiteralType.js";
10
- import { snippets } from "./snippets.js";
11
10
  import { code } from "./ts-poet-wrapper.js";
12
11
  export class AbstractPrimitiveType extends AbstractLiteralType {
13
12
  datatype;
14
- equalsFunction = code `${snippets.strictEquals}`;
13
+ equalsFunction = code `${this.reusables.snippets.strictEquals}`;
15
14
  primitiveIn;
16
15
  constructor({ datatype, primitiveIn, ...superParameters }) {
17
16
  super(superParameters);
@@ -8,10 +8,7 @@ import { NodeKind } from "@shaclmate/shacl-ast";
8
8
  import { Maybe, NonEmptyList } from "purify-ts";
9
9
  import { Memoize } from "typescript-memoize";
10
10
  import { AbstractType } from "./AbstractType.js";
11
- import { imports } from "./imports.js";
12
- import { rdfjsTermExpression } from "./rdfjsTermExpression.js";
13
11
  import { removeUndefined } from "./removeUndefined.js";
14
- import { snippets } from "./snippets.js";
15
12
  import { code, joinCode } from "./ts-poet-wrapper.js";
16
13
  /**
17
14
  * Abstract base class for IdentifierType and LiteralType.
@@ -23,7 +20,7 @@ import { code, joinCode } from "./ts-poet-wrapper.js";
23
20
  */
24
21
  export class AbstractTermType extends AbstractType {
25
22
  declaration = Maybe.empty();
26
- equalsFunction = code `${snippets.booleanEquals}`;
23
+ equalsFunction = code `${this.reusables.snippets.booleanEquals}`;
27
24
  graphqlArgs = Maybe.empty();
28
25
  hasValues;
29
26
  in_;
@@ -44,27 +41,27 @@ export class AbstractTermType extends AbstractType {
44
41
  const conversions = [];
45
42
  if (this.nodeKinds.has("Literal")) {
46
43
  conversions.push({
47
- conversionExpression: (value) => code `${snippets.literalFactory}.bigint(${value})`,
44
+ conversionExpression: (value) => code `${this.reusables.snippets.literalFactory}.bigint(${value})`,
48
45
  sourceTypeCheckExpression: (value) => code `typeof ${value} === "bigint"`,
49
46
  sourceTypeName: code `bigint`,
50
47
  sourceTypeof: "bigint",
51
48
  }, {
52
- conversionExpression: (value) => code `${snippets.literalFactory}.boolean(${value})`,
49
+ conversionExpression: (value) => code `${this.reusables.snippets.literalFactory}.boolean(${value})`,
53
50
  sourceTypeCheckExpression: (value) => code `typeof ${value} === "boolean"`,
54
51
  sourceTypeName: code `boolean`,
55
52
  sourceTypeof: "boolean",
56
53
  }, {
57
- conversionExpression: (value) => code `${snippets.literalFactory}.date(${value})`,
54
+ conversionExpression: (value) => code `${this.reusables.snippets.literalFactory}.date(${value})`,
58
55
  sourceTypeCheckExpression: (value) => code `typeof ${value} === "object" && ${value} instanceof Date`,
59
56
  sourceTypeName: code `Date`,
60
57
  sourceTypeof: "object",
61
58
  }, {
62
- conversionExpression: (value) => code `${snippets.literalFactory}.number(${value})`,
59
+ conversionExpression: (value) => code `${this.reusables.snippets.literalFactory}.number(${value})`,
63
60
  sourceTypeCheckExpression: (value) => code `typeof ${value} === "number"`,
64
61
  sourceTypeName: code `number`,
65
62
  sourceTypeof: "number",
66
63
  }, {
67
- conversionExpression: (value) => code `${snippets.literalFactory}.string(${value})`,
64
+ conversionExpression: (value) => code `${this.reusables.snippets.literalFactory}.string(${value})`,
68
65
  sourceTypeCheckExpression: (value) => code `typeof ${value} === "string"`,
69
66
  sourceTypeName: code `string`,
70
67
  sourceTypeof: "string",
@@ -80,9 +77,10 @@ export class AbstractTermType extends AbstractType {
80
77
  }
81
78
  get discriminantProperty() {
82
79
  return Maybe.of({
80
+ descendantValues: [],
81
+ jsonName: "termType",
83
82
  name: "termType",
84
83
  ownValues: [...this.nodeKinds].map(NodeKind.toTermType),
85
- descendantValues: [],
86
84
  type: "string",
87
85
  });
88
86
  }
@@ -141,14 +139,14 @@ export class AbstractTermType extends AbstractType {
141
139
  fromRdfExpressionChain({ variables, }) {
142
140
  let valueToExpression;
143
141
  if (this.in_.length > 0) {
144
- valueToExpression = code `value.toTerm([${joinCode(this.in_.map((in_) => rdfjsTermExpression(in_, { logger: this.logger })), { on: ", " })}])`;
142
+ valueToExpression = code `value.toTerm([${joinCode(this.in_.map((in_) => this.rdfjsTermExpression(in_)), { on: ", " })}])`;
145
143
  }
146
144
  else if (this.nodeKinds.size < 3) {
147
145
  const eitherTypeParameters = code `<Error, ${this.name}>`;
148
146
  valueToExpression = code `value.toTerm().chain(term => {
149
147
  switch (term.termType) {
150
- ${[...this.nodeKinds].map((nodeKind) => `case "${NodeKind.toTermType(nodeKind)}":`).join("\n")} return ${imports.Either}.of${eitherTypeParameters}(term);
151
- default: return ${imports.Left}${eitherTypeParameters}(new ${imports.Resource}.MistypedTermValueError(${{ actualValue: code `term`, expectedValueType: code `${this.name}`.toCodeString([]), focusResource: variables.resource, propertyPath: variables.propertyPath }}));
148
+ ${[...this.nodeKinds].map((nodeKind) => `case "${NodeKind.toTermType(nodeKind)}":`).join("\n")} return ${this.reusables.imports.Either}.of${eitherTypeParameters}(term);
149
+ default: return ${this.reusables.imports.Left}${eitherTypeParameters}(new ${this.reusables.imports.Resource}.MistypedTermValueError(${{ actualValue: code `term`, expectedValueType: code `${this.name}`.toCodeString([]), focusResource: variables.resource, propertyPath: variables.propertyPath }}));
152
150
  }})`;
153
151
  }
154
152
  else {
@@ -157,7 +155,7 @@ export class AbstractTermType extends AbstractType {
157
155
  return {
158
156
  hasValues: this.hasValues.length > 0
159
157
  ? code `\
160
- chain(values => ${imports.Either}.sequence([${joinCode(this.hasValues.map((hasValue) => rdfjsTermExpression(hasValue, { logger: this.logger })), { on: ", " })}].map(hasValue => values.find(value => value.term.equals(hasValue)))).map(() => values))`
158
+ chain(values => ${this.reusables.imports.Either}.sequence([${joinCode(this.hasValues.map((hasValue) => this.rdfjsTermExpression(hasValue)), { on: ", " })}].map(hasValue => values.find(value => value.term.equals(hasValue)))).map(() => values))`
161
159
  : undefined,
162
160
  valueTo: code `chain(values => values.chainMap(value => ${valueToExpression}))`,
163
161
  };