@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
@@ -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_jsonSchemaFunctionDeclaration() {
4
- if (!this.features.has("json")) {
4
+ if (!this.configuration.features.has("json")) {
5
5
  return Maybe.empty();
6
6
  }
7
7
  let properties = [];
@@ -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_jsonTypeAliasDeclaration() {
4
- if (!this.features.has("json")) {
4
+ if (!this.configuration.features.has("json")) {
5
5
  return Maybe.empty();
6
6
  }
7
7
  const members = [];
@@ -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_jsonUiSchemaFunctionDeclaration() {
4
- if (!this.features.has("json")) {
4
+ if (!this.configuration.features.has("json")) {
5
5
  return Maybe.empty();
6
6
  }
7
7
  const variables = { scopePrefix: code `scopePrefix` };
@@ -1,4 +1,6 @@
1
+ import type { TsGenerator } from "../TsGenerator.js";
1
2
  export declare function NamedObjectType_objectSetMethodNames(this: {
3
+ readonly configuration: TsGenerator.Configuration;
2
4
  readonly name: string;
3
5
  }): {
4
6
  object: string;
@@ -1,7 +1,7 @@
1
1
  import { camelCase, trainCase } from "change-case";
2
2
  import plur from "plur";
3
- import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
4
3
  export function NamedObjectType_objectSetMethodNames() {
4
+ const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
5
5
  const prefixSingular = camelCase(this.name, {
6
6
  prefixCharacters: syntheticNamePrefix,
7
7
  });
@@ -1,9 +1,9 @@
1
1
  import { Maybe } from "purify-ts";
2
2
  import type { Reusables } from "../Reusables.js";
3
- import type { TsFeature } from "../TsFeature.js";
3
+ import type { TsGenerator } from "../TsGenerator.js";
4
4
  import { type Code } from "../ts-poet-wrapper.js";
5
5
  export declare function NamedObjectType_sparqlConstructQueryFunctionDeclaration(this: {
6
- readonly features: ReadonlySet<TsFeature>;
6
+ readonly configuration: TsGenerator.Configuration;
7
7
  readonly filterType: Code;
8
8
  readonly name: string;
9
9
  readonly reusables: Reusables;
@@ -2,7 +2,7 @@ import { camelCase } from "change-case";
2
2
  import { Maybe } from "purify-ts";
3
3
  import { code } from "../ts-poet-wrapper.js";
4
4
  export function NamedObjectType_sparqlConstructQueryFunctionDeclaration() {
5
- if (!this.features.has("sparql")) {
5
+ if (!this.configuration.features.has("sparql")) {
6
6
  return Maybe.empty();
7
7
  }
8
8
  return Maybe.of(code `\
@@ -1,9 +1,9 @@
1
1
  import { Maybe } from "purify-ts";
2
2
  import type { Reusables } from "../Reusables.js";
3
- import type { TsFeature } from "../TsFeature.js";
3
+ import type { TsGenerator } from "../TsGenerator.js";
4
4
  import { type Code } from "../ts-poet-wrapper.js";
5
5
  export declare function NamedObjectType_sparqlConstructQueryStringFunctionDeclaration(this: {
6
- readonly features: ReadonlySet<TsFeature>;
6
+ readonly configuration: TsGenerator.Configuration;
7
7
  readonly filterType: Code;
8
8
  readonly name: string;
9
9
  readonly reusables: Reusables;
@@ -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_sparqlConstructQueryStringFunctionDeclaration() {
4
- if (!this.features.has("sparql")) {
4
+ if (!this.configuration.features.has("sparql")) {
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, joinCode } from "../ts-poet-wrapper.js";
3
3
  export function NamedObjectType_toJsonFunctionDeclaration() {
4
- if (!this.features.has("json")) {
4
+ if (!this.configuration.features.has("json")) {
5
5
  return Maybe.empty();
6
6
  }
7
7
  const jsonObjectMembers = [];
@@ -10,7 +10,7 @@ export function NamedObjectType_toJsonFunctionDeclaration() {
10
10
  }
11
11
  if (this.properties.length > 0) {
12
12
  jsonObjectMembers.push(...this.properties.flatMap((property) => property
13
- .toJsonObjectMemberExpression({
13
+ .toJsonInitializer({
14
14
  variables: {
15
15
  value: property.accessExpression({
16
16
  variables: { object: this.thisVariable },
@@ -2,7 +2,7 @@ import { rdf } from "@tpluscode/rdf-ns-builders";
2
2
  import { Maybe } from "purify-ts";
3
3
  import { code, joinCode } from "../ts-poet-wrapper.js";
4
4
  export function NamedObjectType_toRdfResourceFunctionDeclaration() {
5
- if (!this.features.has("rdf")) {
5
+ if (!this.configuration.features.has("rdf")) {
6
6
  return Maybe.empty();
7
7
  }
8
8
  const statements = this.parentObjectTypes.map((parentObjectType) => code `${parentObjectType.name}._toRdfResource({ ...parameters, ignoreRdfType: true });`);
@@ -1,27 +1,23 @@
1
- import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
2
- import { code, joinCode, literalOf } from "../ts-poet-wrapper.js";
1
+ import { code, joinCode } from "../ts-poet-wrapper.js";
3
2
  export function NamedObjectType_toStringFunctionDeclarations() {
4
- const propertiesToStringRecordProperties = [];
3
+ let propertiesToStringInitializers = [];
5
4
  if (this.parentObjectTypes.length > 0) {
6
5
  for (const parentObjectType of this.parentObjectTypes) {
7
- propertiesToStringRecordProperties.push(code `...${parentObjectType.name}._propertiesToStrings(${this.thisVariable})`);
6
+ propertiesToStringInitializers.push(code `...${parentObjectType.name}._propertiesToStrings(${this.thisVariable})`);
8
7
  }
9
8
  }
10
- for (const property of this.properties) {
11
- property
12
- .toStringExpression({
13
- variables: {
14
- value: property.accessExpression({
15
- variables: { object: this.thisVariable },
16
- }),
17
- },
18
- })
19
- .ifJust((propertyToStringExpression) => {
20
- propertiesToStringRecordProperties.push(code `${literalOf(property.name)}: ${propertyToStringExpression}`);
21
- });
22
- }
23
- const propertiesToStringsReturnExpression = code `${this.reusables.snippets.compactRecord}({${joinCode(propertiesToStringRecordProperties, { on: "," })}})`;
9
+ propertiesToStringInitializers = propertiesToStringInitializers.concat(this.properties.flatMap((property) => property
10
+ .toStringInitializer({
11
+ variables: {
12
+ value: property.accessExpression({
13
+ variables: { object: this.thisVariable },
14
+ }),
15
+ },
16
+ })
17
+ .toList()));
18
+ const propertiesToStringsReturnExpression = code `${this.reusables.snippets.compactRecord}({${joinCode(propertiesToStringInitializers, { on: "," })}})`;
24
19
  const toStringReturnExpression = (propertiesToStrings) => code `\`${this.name}(\${JSON.stringify(${propertiesToStrings})})\``;
20
+ const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
25
21
  return [
26
22
  // Use overloads to allow the function to be attached to an instance or used freestanding
27
23
  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_valueSparqlConstructTriplesFunctionDeclaration() {
4
- if (!this.features.has("sparql")) {
4
+ if (!this.configuration.features.has("sparql")) {
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_valueSparqlWherePatternsFunctionDeclaration() {
4
- if (!this.features.has("sparql")) {
4
+ if (!this.configuration.features.has("sparql")) {
5
5
  return Maybe.empty();
6
6
  }
7
7
  return Maybe.of(code `\
@@ -21,7 +21,7 @@ export declare class ShaclProperty<TypeT extends Type> extends AbstractProperty<
21
21
  path: PropertyPath;
22
22
  recursive: boolean;
23
23
  } & ConstructorParameters<typeof AbstractProperty<TypeT>>[0]);
24
- get constructorParametersSignature(): Maybe<Code>;
24
+ get constructorParameter(): Maybe<Code>;
25
25
  get declaration(): Code;
26
26
  get filterProperty(): Maybe<{
27
27
  name: string;
@@ -35,16 +35,16 @@ export declare class ShaclProperty<TypeT extends Type> extends AbstractProperty<
35
35
  kind: Code;
36
36
  type: Code;
37
37
  };
38
- constructorStatements({ variables, }: Parameters<AbstractProperty<TypeT>["constructorStatements"]>[0]): readonly Code[];
39
- fromJsonExpression({ variables, }: Parameters<AbstractProperty<TypeT>["fromJsonExpression"]>[0]): Maybe<Code>;
40
- fromRdfResourceValuesExpression({ variables, }: Parameters<AbstractProperty<TypeT>["fromRdfResourceValuesExpression"]>[0]): Maybe<Code>;
41
- hashStatements(parameters: Parameters<AbstractProperty<TypeT>["hashStatements"]>[0]): readonly Code[];
38
+ constructorInitializer({ variables, }: Parameters<AbstractProperty<TypeT>["constructorInitializer"]>[0]): Maybe<Code>;
39
+ fromJsonInitializer({ variables, }: Parameters<AbstractProperty<TypeT>["fromJsonInitializer"]>[0]): Maybe<Code>;
40
+ fromRdfResourceValuesInitializer({ variables, }: Parameters<AbstractProperty<TypeT>["fromRdfResourceValuesInitializer"]>[0]): Maybe<Code>;
41
+ hashStatements({ variables, }: Parameters<AbstractProperty<TypeT>["hashStatements"]>[0]): readonly Code[];
42
42
  jsonUiSchemaElement({ variables, }: Parameters<AbstractProperty<TypeT>["jsonUiSchemaElement"]>[0]): Maybe<Code>;
43
43
  sparqlConstructTriplesExpression({ variables, }: Parameters<AbstractProperty<TypeT>["sparqlConstructTriplesExpression"]>[0]): Maybe<Code>;
44
44
  sparqlWherePatternsExpression({ variables, }: Parameters<AbstractProperty<TypeT>["sparqlWherePatternsExpression"]>[0]): ReturnType<AbstractProperty<TypeT>["sparqlWherePatternsExpression"]>;
45
- toJsonObjectMemberExpression(parameters: Parameters<AbstractProperty<TypeT>["toJsonObjectMemberExpression"]>[0]): Maybe<Code>;
45
+ toJsonInitializer(parameters: Parameters<AbstractProperty<TypeT>["toJsonInitializer"]>[0]): Maybe<Code>;
46
46
  toRdfRdfResourceValuesStatements({ variables, }: Parameters<AbstractProperty<TypeT>["toRdfRdfResourceValuesStatements"]>[0]): readonly Code[];
47
- toStringExpression(parameters: Parameters<AbstractProperty<TypeT>["toStringExpression"]>[0]): Maybe<Code>;
47
+ toStringInitializer(parameters: Parameters<AbstractProperty<TypeT>["toStringInitializer"]>[0]): Maybe<Code>;
48
48
  private propertyPathToCode;
49
49
  }
50
50
  //# sourceMappingURL=ShaclProperty.d.ts.map
@@ -6,7 +6,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  };
7
7
  import { Maybe } from "purify-ts";
8
8
  import { Memoize } from "typescript-memoize";
9
- import { codeEquals } from "../codeEquals.js";
10
9
  import { code, joinCode, literalOf } from "../ts-poet-wrapper.js";
11
10
  import { tsComment } from "../tsComment.js";
12
11
  import { AbstractProperty } from "./AbstractProperty.js";
@@ -29,15 +28,19 @@ export class ShaclProperty extends AbstractProperty {
29
28
  this.path = path;
30
29
  this.recursive = recursive;
31
30
  }
32
- get constructorParametersSignature() {
31
+ get constructorParameter() {
32
+ const conversionFunction = this.type.conversionFunction.extract();
33
+ if (!conversionFunction) {
34
+ return Maybe.of(code `readonly ${this.name}: ${this.type.name};`);
35
+ }
33
36
  let hasQuestionToken = false;
34
37
  const typeNames = [];
35
- for (const conversion of this.type.conversions) {
36
- if (conversion.sourceTypeof === "undefined") {
38
+ for (const type of conversionFunction.sourceTypes) {
39
+ if (type.typeof === "undefined") {
37
40
  hasQuestionToken = true;
38
41
  }
39
- else if (!typeNames.some((typeName) => codeEquals(typeName, conversion.sourceTypeName))) {
40
- typeNames.push(code `${conversion.sourceTypeName}`);
42
+ else {
43
+ typeNames.push(code `${type.name}`);
41
44
  }
42
45
  }
43
46
  return Maybe.of(code `readonly ${this.name}${hasQuestionToken ? "?" : ""}: ${joinCode(typeNames, { on: "|" })};`);
@@ -99,7 +102,7 @@ export class ShaclProperty extends AbstractProperty {
99
102
  ...super.schemaObject,
100
103
  // comment: this.comment.map(JSON.stringify).extract(),
101
104
  // description: this.description.map(JSON.stringify).extract(),
102
- path: this.namedObjectType.features.has("rdf")
105
+ path: this.configuration.features.has("rdf")
103
106
  ? this.propertyPathToCode(this.path)
104
107
  : undefined,
105
108
  // label: this.label.map(JSON.stringify).extract(),
@@ -111,28 +114,35 @@ export class ShaclProperty extends AbstractProperty {
111
114
  // : undefined,
112
115
  };
113
116
  }
114
- constructorStatements({ variables, }) {
115
- const typeConversions = this.type.conversions;
116
- if (typeConversions.length === 1) {
117
- return [code `const ${this.name} = ${variables.parameter};`];
117
+ constructorInitializer({ variables, }) {
118
+ const parameterVariable = code `${variables.parameters}.${this.name}`;
119
+ const conversionFunction = this.type.conversionFunction.extract()?.code;
120
+ const validationFunction = this.type.validationFunction.extract();
121
+ let rhs;
122
+ if (conversionFunction && validationFunction) {
123
+ rhs = code `${conversionFunction}(${parameterVariable}).chain(value => ${validationFunction}(${this.namedObjectType.name}.schema.properties.${this.name}.type(), value))`;
124
+ }
125
+ else if (conversionFunction) {
126
+ rhs = code `${conversionFunction}(${parameterVariable})`;
127
+ }
128
+ else if (validationFunction) {
129
+ rhs = code `${validationFunction}(${this.namedObjectType.name}.schema.properties.${this.name}.type(), ${parameterVariable})`;
130
+ }
131
+ else {
132
+ rhs = code `${this.reusables.imports.Either}.of(${parameterVariable})`;
118
133
  }
119
- const statements = [code `let ${this.name}: ${this.type.name};`];
120
- statements.push(joinCode(typeConversions
121
- .map((conversion) => code `if (${conversion.sourceTypeCheckExpression(variables.parameter)}) { ${this.name} = ${conversion.conversionExpression(variables.parameter)}; }`)
122
- // We shouldn't need this else, since the parameter now has the never type, but have to add it to appease the TypeScript compiler
123
- .concat(code `{ ${this.name} = (${variables.parameter}) satisfies never; }`), { on: " else " }));
124
- return statements;
125
- }
126
- fromJsonExpression({ variables, }) {
127
- return Maybe.of(this.type.fromJsonExpression({
134
+ return Maybe.of(code `${this.name}: ${rhs}`);
135
+ }
136
+ fromJsonInitializer({ variables, }) {
137
+ return Maybe.of(code `${this.name}: ${this.type.fromJsonExpression({
128
138
  variables: { value: code `${variables.jsonObject}["${this.name}"]` },
129
- }));
139
+ })}`);
130
140
  }
131
- fromRdfResourceValuesExpression({ variables, }) {
141
+ fromRdfResourceValuesInitializer({ variables, }) {
132
142
  // Assume the property has the correct range and ignore the object's RDF type.
133
143
  // This also accommodates the case where the object of a property is a dangling identifier that's not the
134
144
  // subject of any statements.
135
- return Maybe.of(code `${this.reusables.snippets.shaclPropertyFromRdf}(${{
145
+ return Maybe.of(code `${this.name}: ${this.reusables.snippets.shaclPropertyFromRdf}(${{
136
146
  graph: variables.graph,
137
147
  resource: variables.resource,
138
148
  propertySchema: code `schema.properties.${this.name}`,
@@ -146,8 +156,10 @@ export class ShaclProperty extends AbstractProperty {
146
156
  })})`,
147
157
  }})`);
148
158
  }
149
- hashStatements(parameters) {
150
- return this.type.hashStatements(parameters);
159
+ hashStatements({ variables, }) {
160
+ return [
161
+ code `${this.type.hashFunction}(${variables.hasher}, ${variables.value});`,
162
+ ];
151
163
  }
152
164
  jsonUiSchemaElement({ variables, }) {
153
165
  const scope = code `\`\${${variables.scopePrefix}}/properties/${this.name}\``;
@@ -184,7 +196,7 @@ export class ShaclProperty extends AbstractProperty {
184
196
  }})`,
185
197
  });
186
198
  }
187
- toJsonObjectMemberExpression(parameters) {
199
+ toJsonInitializer(parameters) {
188
200
  return Maybe.of(code `${this.name}: ${this.type.toJsonExpression(parameters)}`);
189
201
  }
190
202
  toRdfRdfResourceValuesStatements({ variables, }) {
@@ -206,11 +218,11 @@ export class ShaclProperty extends AbstractProperty {
206
218
  })}, ${variables.graph});`,
207
219
  ];
208
220
  }
209
- toStringExpression(parameters) {
221
+ toStringInitializer(parameters) {
210
222
  if (!this.display) {
211
223
  return Maybe.empty();
212
224
  }
213
- return Maybe.of(this.type.toStringExpression(parameters));
225
+ return Maybe.of(code `${literalOf(this.name)}: ${this.type.toStringExpression(parameters)}`);
214
226
  }
215
227
  propertyPathToCode(propertyPath) {
216
228
  switch (propertyPath.termType) {
@@ -229,7 +241,7 @@ export class ShaclProperty extends AbstractProperty {
229
241
  }
230
242
  __decorate([
231
243
  Memoize()
232
- ], ShaclProperty.prototype, "constructorParametersSignature", null);
244
+ ], ShaclProperty.prototype, "constructorParameter", null);
233
245
  __decorate([
234
246
  Memoize()
235
247
  ], ShaclProperty.prototype, "declaration", null);
@@ -0,0 +1,3 @@
1
+ import type { SnippetFactory } from "../SnippetFactory.js";
2
+ export declare const snippets_ConversionFunction: SnippetFactory;
3
+ //# sourceMappingURL=snippets_ConversionFunction.d.ts.map
@@ -0,0 +1,4 @@
1
+ import { code, conditionalOutput } from "../ts-poet-wrapper.js";
2
+ export const snippets_ConversionFunction = ({ imports, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}ConversionFunction`, code `\
3
+ type ${syntheticNamePrefix}ConversionFunction<SourceT, TargetT> = (source: SourceT) => ${imports.Either}<Error, TargetT>;`);
4
+ //# sourceMappingURL=snippets_ConversionFunction.js.map
@@ -1,7 +1,7 @@
1
1
  import { code, conditionalOutput } from "../ts-poet-wrapper.js";
2
- export const snippets_DefaultValueSchema = ({ imports, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}DefaultValueSchema`, code `\
3
- interface ${syntheticNamePrefix}DefaultValueSchema<ItemSchemaT> {
4
- readonly defaultValue: ${imports.Literal} | ${imports.NamedNode};
2
+ export const snippets_DefaultValueSchema = ({ syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}DefaultValueSchema`, code `\
3
+ interface ${syntheticNamePrefix}DefaultValueSchema<DefaultValueT, ItemSchemaT> {
4
+ readonly defaultValue: DefaultValueT;
5
5
  readonly item: () => ItemSchemaT;
6
6
  readonly kind: "DefaultValue";
7
7
  }`);
@@ -0,0 +1,3 @@
1
+ import type { SnippetFactory } from "../SnippetFactory.js";
2
+ export declare const snippets_HashFunction: SnippetFactory;
3
+ //# sourceMappingURL=snippets_HashFunction.d.ts.map
@@ -0,0 +1,4 @@
1
+ import { code, conditionalOutput } from "../ts-poet-wrapper.js";
2
+ export const snippets_HashFunction = ({ snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}HashFunction`, code `\
3
+ export type ${syntheticNamePrefix}HashFunction<HasherT extends ${snippets.Hasher}, ValueT> = (hasher: HasherT, value: ValueT) => HasherT;`);
4
+ //# sourceMappingURL=snippets_HashFunction.js.map
@@ -1,32 +1,42 @@
1
- import { code, conditionalOutput } from "../ts-poet-wrapper.js";
1
+ import { code, conditionalOutput, joinCode, } from "../ts-poet-wrapper.js";
2
2
  /**
3
3
  * Adapter between generated code and the rdfjs-resource PropertyPath.
4
4
  */
5
- export const snippets_PropertyPath = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}PropertyPath`, code `\
5
+ export const snippets_PropertyPath = ({ configuration, imports, snippets, syntheticNamePrefix, }) => {
6
+ const companionDeclarations = [];
7
+ if (configuration.features.has("equals")) {
8
+ companionDeclarations.push(code `\
9
+ export function equals(left: ${syntheticNamePrefix}PropertyPath, right: ${syntheticNamePrefix}PropertyPath): ${snippets.EqualsResult} {
10
+ return ${snippets.EqualsResult}.fromBooleanEqualsResult(left, right, ${imports.RdfxResourcePropertyPath}.equals(left, right));
11
+ }`);
12
+ }
13
+ companionDeclarations.push(code `export type Filter = object`, code `\
14
+ export function filter(_filter: Filter, _value: ${syntheticNamePrefix}PropertyPath): boolean {
15
+ return true;
16
+ }`);
17
+ if (configuration.features.has("rdf")) {
18
+ companionDeclarations.push(code `\
19
+ export const fromRdfResource: ${snippets.FromRdfResourceFunction}<${syntheticNamePrefix}PropertyPath> = ${imports.RdfxResourcePropertyPath}.fromResource;`, code `\
20
+ export const fromRdfResourceValues: ${snippets.FromRdfResourceValuesFunction}<${syntheticNamePrefix}PropertyPath> = (values, options) =>
21
+ values.chain((values) =>
22
+ values.chainMap((value) =>
23
+ value
24
+ .toResource()
25
+ .chain((resource) => fromRdfResource(resource, options)),
26
+ ),
27
+ );`);
28
+ }
29
+ companionDeclarations.push(code `export const schema: Readonly<object> = {}`);
30
+ if (configuration.features.has("rdf")) {
31
+ companionDeclarations.push(code `\
32
+ export const toRdfResource: ${snippets.ToRdfResourceFunction}<${syntheticNamePrefix}PropertyPath> = ${imports.RdfxResourcePropertyPath}.toResource;`);
33
+ }
34
+ companionDeclarations.push(code `export const ${syntheticNamePrefix}toString = ${imports.RdfxResourcePropertyPath}.toString;`);
35
+ return conditionalOutput(`${syntheticNamePrefix}PropertyPath`, code `\
6
36
  export type ${syntheticNamePrefix}PropertyPath = ${imports.RdfxResourcePropertyPath};
7
37
 
8
38
  export namespace ${syntheticNamePrefix}PropertyPath {
9
- export type Filter = object;
10
-
11
- export function filter(_filter: Filter, _value: ${syntheticNamePrefix}PropertyPath): boolean {
12
- return true;
13
- }
14
-
15
- export const fromRdfResource: ${snippets.FromRdfResourceFunction}<${syntheticNamePrefix}PropertyPath> = ${imports.RdfxResourcePropertyPath}.fromResource;
16
-
17
- export const fromRdfResourceValues: ${snippets.FromRdfResourceValuesFunction}<${syntheticNamePrefix}PropertyPath> = (values, options) =>
18
- values.chain((values) =>
19
- values.chainMap((value) =>
20
- value
21
- .toResource()
22
- .chain((resource) => fromRdfResource(resource, options)),
23
- ),
24
- );
25
-
26
- export const schema: Readonly<object> = {};
27
-
28
- export const toRdfResource: ${snippets.ToRdfResourceFunction}<${syntheticNamePrefix}PropertyPath> = ${imports.RdfxResourcePropertyPath}.toResource;
29
-
30
- export const ${syntheticNamePrefix}toString = ${imports.RdfxResourcePropertyPath}.toString;
39
+ ${joinCode(companionDeclarations, { on: "\n\n" })}
31
40
  }`);
41
+ };
32
42
  //# sourceMappingURL=snippets_PropertyPath.js.map
@@ -0,0 +1,3 @@
1
+ import type { SnippetFactory } from "../SnippetFactory.js";
2
+ export declare const snippets_ValidationFunction: SnippetFactory;
3
+ //# sourceMappingURL=snippets_ValidationFunction.d.ts.map
@@ -0,0 +1,4 @@
1
+ import { code, conditionalOutput } from "../ts-poet-wrapper.js";
2
+ export const snippets_ValidationFunction = ({ imports, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}ValidationFunction`, code `\
3
+ type ${syntheticNamePrefix}ValidationFunction<SchemaT, ValueT> = (schema: SchemaT, value: ValueT) => ${imports.Either}<Error, ValueT>;`);
4
+ //# sourceMappingURL=snippets_ValidationFunction.js.map
@@ -0,0 +1,3 @@
1
+ import type { SnippetFactory } from "../SnippetFactory.js";
2
+ export declare const snippets_convertToArray: SnippetFactory;
3
+ //# sourceMappingURL=snippets_convertToArray.d.ts.map
@@ -0,0 +1,8 @@
1
+ import { code, conditionalOutput } from "../ts-poet-wrapper.js";
2
+ export const snippets_convertToArray = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertToArray`, code `\
3
+ function ${syntheticNamePrefix}convertToArray<ItemSourceT, ItemTargetT, Readonly extends boolean>(convertToItem: ${snippets.ConversionFunction}<ItemSourceT, ItemTargetT>, _readonly: Readonly) {
4
+ type EitherR = Readonly extends true ? ReadonlyArray<ItemTargetT> : Array<ItemTargetT>;
5
+ return (value: readonly ItemSourceT[] | undefined): ${imports.Either}<Error, EitherR> =>
6
+ (typeof value === "undefined" ? ${imports.Either}.of([]) : ${imports.Either}.sequence(value.map(convertToItem))) as ${imports.Either}<Error, EitherR>;
7
+ }`);
8
+ //# sourceMappingURL=snippets_convertToArray.js.map
@@ -0,0 +1,3 @@
1
+ import type { SnippetFactory } from "../SnippetFactory.js";
2
+ export declare const snippets_convertToBlankNode: SnippetFactory;
3
+ //# sourceMappingURL=snippets_convertToBlankNode.d.ts.map
@@ -0,0 +1,11 @@
1
+ import { code, conditionalOutput } from "../ts-poet-wrapper.js";
2
+ export const snippets_convertToBlankNode = ({ imports, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertToBlankNode`, code `\
3
+ function ${syntheticNamePrefix}convertToBlankNode(value: ${imports.BlankNode} | undefined): ${imports.Either}<Error, ${imports.BlankNode}> {
4
+ switch (typeof value) {
5
+ case "object":
6
+ return ${imports.Either}.of(value);
7
+ case "undefined":
8
+ return ${imports.Either}.of(${imports.dataFactory}.blankNode());
9
+ }
10
+ }`);
11
+ //# sourceMappingURL=snippets_convertToBlankNode.js.map
@@ -0,0 +1,3 @@
1
+ import type { SnippetFactory } from "../SnippetFactory.js";
2
+ export declare const snippets_convertToBlankNodeIdentifierProperty: SnippetFactory;
3
+ //# sourceMappingURL=snippets_convertToBlankNodeIdentifierProperty.d.ts.map
@@ -0,0 +1,17 @@
1
+ import { code, conditionalOutput } from "../ts-poet-wrapper.js";
2
+ export const snippets_convertToBlankNodeIdentifierProperty = ({ imports, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertToBlankNodeIdentifierProperty`, code `\
3
+ function ${syntheticNamePrefix}convertToBlankNodeIdentifierProperty(identifier: (() => ${imports.BlankNode}) | ${imports.BlankNode} | undefined): ${imports.Either}<Error, (() => ${imports.BlankNode})> {
4
+ switch (typeof identifier) {
5
+ case "function":
6
+ return ${imports.Either}.of(identifier);
7
+ case "object": {
8
+ const captureIdentifier = identifier;
9
+ return ${imports.Either}.of(() => captureIdentifier);
10
+ }
11
+ case "undefined": {
12
+ const captureIdentifier = ${imports.dataFactory}.blankNode();
13
+ return ${imports.Either}.of(() => captureIdentifier);
14
+ }
15
+ }
16
+ }`);
17
+ //# sourceMappingURL=snippets_convertToBlankNodeIdentifierProperty.js.map
@@ -0,0 +1,3 @@
1
+ import type { SnippetFactory } from "../SnippetFactory.js";
2
+ export declare const snippets_convertToIdentifier: SnippetFactory;
3
+ //# sourceMappingURL=snippets_convertToIdentifier.d.ts.map
@@ -0,0 +1,13 @@
1
+ import { code, conditionalOutput } from "../ts-poet-wrapper.js";
2
+ export const snippets_convertToIdentifier = ({ imports, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertToIdentifier`, code `\
3
+ function ${syntheticNamePrefix}convertToIdentifier(value: ${imports.BlankNode} | ${imports.NamedNode} | string | undefined): ${imports.Either}<Error, ${imports.BlankNode} | ${imports.NamedNode}> {
4
+ switch (typeof value) {
5
+ case "object":
6
+ return ${imports.Either}.of(value);
7
+ case "string":
8
+ return ${imports.Either}.of(${imports.dataFactory}.namedNode(value));
9
+ case "undefined":
10
+ return ${imports.Either}.of(${imports.dataFactory}.blankNode());
11
+ }
12
+ }`);
13
+ //# sourceMappingURL=snippets_convertToIdentifier.js.map
@@ -0,0 +1,3 @@
1
+ import type { SnippetFactory } from "../SnippetFactory.js";
2
+ export declare const snippets_convertToIdentifierProperty: SnippetFactory;
3
+ //# sourceMappingURL=snippets_convertToIdentifierProperty.d.ts.map
@@ -0,0 +1,21 @@
1
+ import { code, conditionalOutput } from "../ts-poet-wrapper.js";
2
+ export const snippets_convertToIdentifierProperty = ({ imports, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertToIdentifierProperty`, code `\
3
+ function ${syntheticNamePrefix}convertToIdentifierProperty(identifier: (() => ${imports.BlankNode} | ${imports.NamedNode}) | ${imports.BlankNode} | ${imports.NamedNode} | string | undefined): ${imports.Either}<Error, (() => ${imports.BlankNode} | ${imports.NamedNode})> {
4
+ switch (typeof identifier) {
5
+ case "function":
6
+ return ${imports.Either}.of(identifier);
7
+ case "object": {
8
+ const captureIdentifier = identifier;
9
+ return ${imports.Either}.of(() => captureIdentifier);
10
+ }
11
+ case "string": {
12
+ const captureIdentifier = ${imports.dataFactory}.namedNode(identifier);
13
+ return ${imports.Either}.of(() => captureIdentifier);
14
+ }
15
+ case "undefined": {
16
+ const captureIdentifier = ${imports.dataFactory}.blankNode();
17
+ return ${imports.Either}.of(() => captureIdentifier);
18
+ }
19
+ }
20
+ }`);
21
+ //# sourceMappingURL=snippets_convertToIdentifierProperty.js.map
@@ -0,0 +1,3 @@
1
+ import type { SnippetFactory } from "../SnippetFactory.js";
2
+ export declare const snippets_convertToIri: SnippetFactory;
3
+ //# sourceMappingURL=snippets_convertToIri.d.ts.map
@@ -0,0 +1,11 @@
1
+ import { code, conditionalOutput } from "../ts-poet-wrapper.js";
2
+ export const snippets_convertToIri = ({ imports, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertToIri`, code `\
3
+ function ${syntheticNamePrefix}convertToIri<IriT extends string = string>(value: IriT | ${imports.NamedNode}<IriT>): ${imports.Either}<Error, ${imports.NamedNode}<IriT>> {
4
+ switch (typeof value) {
5
+ case "object":
6
+ return ${imports.Either}.of(value);
7
+ case "string":
8
+ return ${imports.Either}.of(${imports.dataFactory}.namedNode<IriT>(value));
9
+ }
10
+ }`);
11
+ //# sourceMappingURL=snippets_convertToIri.js.map
@@ -0,0 +1,3 @@
1
+ import type { SnippetFactory } from "../SnippetFactory.js";
2
+ export declare const snippets_convertToIriIdentifierProperty: SnippetFactory;
3
+ //# sourceMappingURL=snippets_convertToIriIdentifierProperty.d.ts.map
@@ -0,0 +1,17 @@
1
+ import { code, conditionalOutput } from "../ts-poet-wrapper.js";
2
+ export const snippets_convertToIriIdentifierProperty = ({ imports, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertToIriIdentifierProperty`, code `\
3
+ function ${syntheticNamePrefix}convertToIriIdentifierProperty<IriT extends string = string>(identifier: (() => ${imports.NamedNode}<IriT>) | ${imports.NamedNode}<IriT> | IriT): ${imports.Either}<Error, (() => ${imports.NamedNode}<IriT>)> {
4
+ switch (typeof identifier) {
5
+ case "function":
6
+ return ${imports.Either}.of(identifier);
7
+ case "object": {
8
+ const captureIdentifier = identifier;
9
+ return ${imports.Either}.of(() => captureIdentifier);
10
+ }
11
+ case "string": {
12
+ const captureIdentifier = ${imports.dataFactory}.namedNode<IriT>(identifier);
13
+ return ${imports.Either}.of(() => captureIdentifier);
14
+ }
15
+ }
16
+ }`);
17
+ //# sourceMappingURL=snippets_convertToIriIdentifierProperty.js.map